From df97c582d7ab9bbb6734a82f5ca123405866c4e0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 23 Mar 2022 16:48:17 +0100 Subject: [PATCH 001/532] possibly important fix for ring buffer write --- src/fsfw/container/SimpleRingBuffer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fsfw/container/SimpleRingBuffer.cpp b/src/fsfw/container/SimpleRingBuffer.cpp index bcf3cf20..0c95fe40 100644 --- a/src/fsfw/container/SimpleRingBuffer.cpp +++ b/src/fsfw/container/SimpleRingBuffer.cpp @@ -48,6 +48,9 @@ void SimpleRingBuffer::confirmBytesWritten(size_t amount) { } ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) { + if(amount > maxSize()) { + return HasReturnvaluesIF::RETURN_FAILED; + } if (availableWriteSpace() >= amount or overwriteOld) { size_t amountTillWrap = writeTillWrap(); if (amountTillWrap >= amount) { From a891769a02949d82a144bc5ea8f0e6522b0ce14e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Mar 2022 11:32:27 +0100 Subject: [PATCH 002/532] ring buffer cfg error warning --- src/fsfw/container/SimpleRingBuffer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/fsfw/container/SimpleRingBuffer.cpp b/src/fsfw/container/SimpleRingBuffer.cpp index 0c95fe40..7e9aac1a 100644 --- a/src/fsfw/container/SimpleRingBuffer.cpp +++ b/src/fsfw/container/SimpleRingBuffer.cpp @@ -1,4 +1,7 @@ #include "fsfw/container/SimpleRingBuffer.h" +#include "fsfw/FSFW.h" + +#include "fsfw/serviceinterface.h" #include @@ -48,7 +51,14 @@ void SimpleRingBuffer::confirmBytesWritten(size_t amount) { } ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) { - if(amount > maxSize()) { + if(amount > getMaxSize()) { +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "SimpleRingBuffer::writeData: Amount of data too large" << std::endl; +#else + sif::printError("SimpleRingBuffer::writeData: Amount of data too large\n"); +#endif +#endif return HasReturnvaluesIF::RETURN_FAILED; } if (availableWriteSpace() >= amount or overwriteOld) { From 8a44c498c5b24aba0da99557c616808f58d1e6a2 Mon Sep 17 00:00:00 2001 From: Cleanroom Laptop L590 Date: Thu, 24 Mar 2022 16:50:59 +0100 Subject: [PATCH 003/532] add two additional tests for ring buffer --- tests/src/fsfw_tests/unit/container/RingBufferTest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp b/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp index a83fa2ac..30ffd598 100644 --- a/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp +++ b/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp @@ -31,6 +31,8 @@ TEST_CASE("Ring Buffer Test", "[RingBufferTest]") { for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } + REQUIRE(ringBuffer.writeData(testData, 1024) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.writeData(nullptr, 5) == retval::CATCH_FAILED); } SECTION("Get Free Element Test") { From 879223f38fef0c6cd3705bb10efa674c701bb792 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Mar 2022 20:57:42 +0100 Subject: [PATCH 004/532] added nullptr check --- src/fsfw/container/SimpleRingBuffer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fsfw/container/SimpleRingBuffer.cpp b/src/fsfw/container/SimpleRingBuffer.cpp index 7e9aac1a..437e72ea 100644 --- a/src/fsfw/container/SimpleRingBuffer.cpp +++ b/src/fsfw/container/SimpleRingBuffer.cpp @@ -51,6 +51,9 @@ void SimpleRingBuffer::confirmBytesWritten(size_t amount) { } ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) { + if(data == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } if(amount > getMaxSize()) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 From 23f8e5cb410c193231b7ee96b00c4732817d5296 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Mar 2022 21:01:21 +0100 Subject: [PATCH 005/532] some more tests fail --- tests/src/fsfw_tests/unit/container/RingBufferTest.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp b/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp index 30ffd598..b365bed0 100644 --- a/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp +++ b/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp @@ -236,9 +236,8 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { SECTION("Overflow") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - // Writing more than the buffer is large, technically thats allowed - // But it is senseless and has undesired impact on read call - REQUIRE(ringBuffer.writeData(testData, 13) == retval::CATCH_OK); + // Writing more than the buffer is large. Will be rejected + REQUIRE(ringBuffer.writeData(testData, 13) == retval::CATCH_FAILED); REQUIRE(ringBuffer.getAvailableReadData() == 3); ringBuffer.clear(); uint8_t *ptr = nullptr; From ad57e6713e2460a997b8cc1a111da9902f10d9d6 Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Fri, 25 Mar 2022 15:20:06 +0100 Subject: [PATCH 006/532] Fixed Unittests --- .../fsfw_tests/unit/container/RingBufferTest.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp b/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp index b365bed0..f9e25451 100644 --- a/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp +++ b/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp @@ -146,12 +146,13 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { SECTION("Overflow") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - // Writing more than the buffer is large, technically thats allowed - // But it is senseless and has undesired impact on read call - REQUIRE(ringBuffer.writeData(testData, 13) == retval::CATCH_OK); - REQUIRE(ringBuffer.getAvailableReadData() == 3); + // We don't allow writing of Data that is larger than the ring buffer in total + REQUIRE(ringBuffer.getMaxSize() == 9); + REQUIRE(ringBuffer.writeData(testData, 13) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.getAvailableReadData() == 0); ringBuffer.clear(); uint8_t *ptr = nullptr; + // With excess Bytes 13 Bytes can be written to this Buffer REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == retval::CATCH_OK); REQUIRE(ptr != nullptr); memcpy(ptr, testData, 13); @@ -236,10 +237,13 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { SECTION("Overflow") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - // Writing more than the buffer is large. Will be rejected + // Writing more than the buffer is large. + // This write will be rejected and is seen as a configuration mistake REQUIRE(ringBuffer.writeData(testData, 13) == retval::CATCH_FAILED); - REQUIRE(ringBuffer.getAvailableReadData() == 3); + REQUIRE(ringBuffer.getAvailableReadData() == 0); ringBuffer.clear(); + // Using FreeElement allows the usage of excessBytes but + // should be used with caution uint8_t *ptr = nullptr; REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == retval::CATCH_OK); REQUIRE(ptr != nullptr); From 70f575396db7beb9bb236e7b5ef007c9347c5bd7 Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Fri, 25 Mar 2022 15:27:22 +0100 Subject: [PATCH 007/532] Added changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7d3b90b..a8e13578 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 - HAL Devicehandlers: Periodic printout is run-time configurable now - `oneShotAction` flag in the `TestTask` class is not static anymore +- `SimpleRingBuffer::writeData` now checks if the amount is larger than the total size of the + Buffer and rejects such writeData calls with `HasReturnvaluesIF::RETURN_FAILED` + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/586 ## Removed From b7a316008a1642188a0e3e8e6b1789ae490d19e1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Mar 2022 15:07:46 +0200 Subject: [PATCH 008/532] increase allowed read bytes --- tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp index 3ad26876..20677298 100644 --- a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp +++ b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp @@ -82,7 +82,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { readBytes = 0; sizesFifo.retrieve(&readBytes); // That's about the size of the reply - bool beTrue = (readBytes > 200) and (readBytes < 300); + bool beTrue = (readBytes > 200) and (readBytes < 400); REQUIRE(beTrue); uint8_t largerReadBuffer[1024] = {}; outputBuffer.readData(largerReadBuffer, readBytes); From adfefdd93f4ecadae162f2f56ce65df731cb5e94 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Apr 2022 14:19:01 +0200 Subject: [PATCH 009/532] printout tweak --- src/fsfw/osal/linux/MessageQueue.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index f876ec6e..3a9b7e1e 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -334,10 +334,9 @@ ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messag */ #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::MessageQueue: Default MQ size " << defaultMqMaxMsg - << " is too small for requested size " << messageDepth << std::endl; + << " is too small for requested message depth " << messageDepth << std::endl; sif::error << "This error can be fixed by setting the maximum " - "allowed message size higher!" - << std::endl; + "allowed message depth higher" << std::endl; #else sif::printError( "MessageQueue::MessageQueue: Default MQ size %d is too small for" From 951c077abce4e88d4c2bf48502de341d751148e1 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 26 Apr 2022 10:03:04 +0200 Subject: [PATCH 010/532] option to use Countdown object to time out replies --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 85 ++++++++++++++----- src/fsfw/devicehandlers/DeviceHandlerBase.h | 27 +++++- 2 files changed, 89 insertions(+), 23 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 0e2802ac..fb9a597c 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -233,17 +233,28 @@ ReturnValue_t DeviceHandlerBase::initialize() { } void DeviceHandlerBase::decrementDeviceReplyMap() { + bool timedOut = false; for (std::pair& replyPair : deviceReplyMap) { - if (replyPair.second.delayCycles != 0) { + if (replyPair.second.countdown != nullptr && replyPair.second.active) { + if (replyPair.second.countdown->hasTimedOut()) { + timedOut = true; + } + } + if (replyPair.second.delayCycles != 0 && replyPair.second.countdown == nullptr) { replyPair.second.delayCycles--; if (replyPair.second.delayCycles == 0) { if (replyPair.second.periodic) { replyPair.second.delayCycles = replyPair.second.maxDelayCycles; } - replyToReply(replyPair.first, replyPair.second, TIMEOUT); - missedReply(replyPair.first); + timedOut = true; } } + if (timedOut) { + replyToReply(replyPair.first, replyPair.second, TIMEOUT); + missedReply(replyPair.first); + timedOut = false; + replyPair.second.active = false; + } } } @@ -359,7 +370,6 @@ void DeviceHandlerBase::doStateMachine() { setMode(MODE_OFF); break; } - if (currentUptime - timeoutStart >= powerSwitcher->getSwitchDelayMs()) { triggerEvent(MODE_TRANSITION_FAILED, PowerSwitchIF::SWITCH_TIMEOUT, 0); setMode(MODE_ERROR_ON); @@ -408,20 +418,22 @@ ReturnValue_t DeviceHandlerBase::isModeCombinationValid(Mode_t mode, Submode_t s ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap( DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, LocalPoolDataSetBase* replyDataSet, - size_t replyLen, bool periodic, bool hasDifferentReplyId, DeviceCommandId_t replyId) { + size_t replyLen, bool periodic, bool hasDifferentReplyId, DeviceCommandId_t replyId, + Countdown* countdown) { // No need to check, as we may try to insert multiple times. insertInCommandMap(deviceCommand, hasDifferentReplyId, replyId); if (hasDifferentReplyId) { - return insertInReplyMap(replyId, maxDelayCycles, replyDataSet, replyLen, periodic); + return insertInReplyMap(replyId, maxDelayCycles, replyDataSet, replyLen, periodic, countdown); } else { - return insertInReplyMap(deviceCommand, maxDelayCycles, replyDataSet, replyLen, periodic); + return insertInReplyMap(deviceCommand, maxDelayCycles, replyDataSet, replyLen, periodic, + countdown); } } ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, uint16_t maxDelayCycles, LocalPoolDataSetBase* dataSet, size_t replyLen, - bool periodic) { + bool periodic, Countdown* countdown) { DeviceReplyInfo info; info.maxDelayCycles = maxDelayCycles; info.periodic = periodic; @@ -429,6 +441,10 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, info.replyLen = replyLen; info.dataSet = dataSet; info.command = deviceCommandMap.end(); + info.countdown = countdown; + if (info.periodic) { + info.active = true; + } auto resultPair = deviceReplyMap.emplace(replyId, info); if (resultPair.second) { return RETURN_OK; @@ -458,16 +474,16 @@ size_t DeviceHandlerBase::getNextReplyLength(DeviceCommandId_t commandId) { DeviceCommandId_t replyId = NO_COMMAND_ID; DeviceCommandMap::iterator command = cookieInfo.pendingCommand; if (command->second.useAlternativeReplyId) { - replyId = command->second.alternativeReplyId; - } - else { - replyId = commandId; + replyId = command->second.alternativeReplyId; + } else { + replyId = commandId; } DeviceReplyIter iter = deviceReplyMap.find(replyId); if (iter != deviceReplyMap.end()) { - if (iter->second.delayCycles != 0) { - return iter->second.replyLen; - } + if ((iter->second.delayCycles != 0 && iter->second.countdown == nullptr) || + (iter->second.active && iter->second.countdown != nullptr)) { + return iter->second.replyLen; + } } return 0; } @@ -809,17 +825,18 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, DeviceCommandId DeviceReplyInfo* info = &(iter->second); - if (info->delayCycles != 0) { + if ((info->delayCycles != 0 && info->countdown == nullptr) || + (info->active && info->countdown != nullptr)) { result = interpretDeviceReply(foundId, receivedData); if (result == IGNORE_REPLY_DATA) { return; } - if (info->periodic) { - info->delayCycles = info->maxDelayCycles; - } else { - info->delayCycles = 0; + if (info->active && info->countdown != nullptr) { + disableTimeoutControlledReply(info); + } else if (info->delayCycles != 0) { + disableDelayCyclesControlledReply(info); } if (result != RETURN_OK) { @@ -838,6 +855,24 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, DeviceCommandId } } +void DeviceHandlerBase::disableTimeoutControlledReply(DeviceReplyInfo* info) { + if (info->periodic) { + info->countdown->resetTimer(); + } else { + info->active = false; + info->countdown->timeOut(); + } +} + +void DeviceHandlerBase::disableDelayCyclesControlledReply(DeviceReplyInfo* info) { + if (info->periodic) { + info->delayCycles = info->maxDelayCycles; + } else { + info->delayCycles = 0; + info->active = false; + } +} + ReturnValue_t DeviceHandlerBase::getStorageData(store_address_t storageAddress, uint8_t** data, size_t* len) { size_t lenTmp; @@ -963,6 +998,10 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(DeviceCommandMap::iterato info->delayCycles = info->maxDelayCycles; info->command = command; command->second.expectedReplies = expectedReplies; + if (info->countdown != nullptr) { + info->countdown->resetTimer(); + } + info->active = true; return RETURN_OK; } else { return NO_REPLY_EXPECTED; @@ -1197,7 +1236,8 @@ void DeviceHandlerBase::setParentQueue(MessageQueueId_t parentQueueId) { bool DeviceHandlerBase::isAwaitingReply() { std::map::iterator iter; for (iter = deviceReplyMap.begin(); iter != deviceReplyMap.end(); ++iter) { - if (iter->second.delayCycles != 0) { + if ((iter->second.delayCycles != 0 && iter->second.countdown == nullptr) || + (iter->second.active && iter->second.countdown != nullptr)) { return true; } } @@ -1353,6 +1393,9 @@ uint8_t DeviceHandlerBase::getReplyDelayCycles(DeviceCommandId_t deviceCommand) if (iter == deviceReplyMap.end()) { return 0; } + else if (iter->second.countdown != nullptr) { + return 0; + } return iter->second.delayCycles; } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 5e974831..4a9a8aa2 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -448,6 +448,9 @@ class DeviceHandlerBase : public DeviceHandlerIF, * by the device repeatedly without request) or not. Default is aperiodic (0). * Please note that periodic replies are disabled by default. You can enable them with * #updatePeriodicReply + * @param countdown Instead of using maxDelayCycles to timeout a device reply it is also possible + * to provide a pointer to a Countdown object which will signal the timeout + * when expired * @return - @c RETURN_OK when the command was successfully inserted, * - @c RETURN_FAILED else. */ @@ -455,7 +458,8 @@ class DeviceHandlerBase : public DeviceHandlerIF, LocalPoolDataSetBase *replyDataSet = nullptr, size_t replyLen = 0, bool periodic = false, bool hasDifferentReplyId = false, - DeviceCommandId_t replyId = 0); + DeviceCommandId_t replyId = 0, + Countdown *countdown = nullptr); /** * @brief This is a helper method to insert replies in the reply map. * @param deviceCommand Identifier of the reply to add. @@ -465,12 +469,15 @@ class DeviceHandlerBase : public DeviceHandlerIF, * by the device repeatedly without request) or not. Default is aperiodic (0). * Please note that periodic replies are disabled by default. You can enable them with * #updatePeriodicReply + * @param countdown Instead of using maxDelayCycles to timeout a device reply it is also possible + * to provide a pointer to a Countdown object which will signal the timeout + * when expired * @return - @c RETURN_OK when the command was successfully inserted, * - @c RETURN_FAILED else. */ ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, LocalPoolDataSetBase *dataSet = nullptr, size_t replyLen = 0, - bool periodic = false); + bool periodic = false, Countdown *countdown = nullptr); /** * @brief A simple command to add a command to the commandList. @@ -783,6 +790,11 @@ class DeviceHandlerBase : public DeviceHandlerIF, LocalPoolDataSetBase *dataSet = nullptr; //! The command that expects this reply. DeviceCommandMap::iterator command; + //! Instead of using delayCycles to specify the maximum time to wait for the device reply, it + //! is also possible specify a countdown + Countdown* countdown = nullptr; + //! will be set to true when reply is enabled + bool active = false; }; using DeviceReplyMap = std::map; @@ -1243,6 +1255,17 @@ class DeviceHandlerBase : public DeviceHandlerIF, */ void doGetRead(void); + /** + * @brief Handles disabling of replies which use a timeout to detect missed replies. + */ + void disableTimeoutControlledReply(DeviceReplyInfo* info); + + /** + * @brief Handles disabling of replies which use a number of maximum delay cycles to detect + * missed replies. + */ + void disableDelayCyclesControlledReply(DeviceReplyInfo* info); + /** * Retrive data from the #IPCStore. * From 0aee86442eafa6d8827435e2c2e22074ba733e34 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 26 Apr 2022 11:48:18 +0200 Subject: [PATCH 011/532] typo in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 99c842af..5112230a 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ You can also use `-DFSFW_OSAL=linux` on Linux systems. Coverage data in HTML format can be generated using the `CodeCoverage` [CMake module](https://github.com/bilke/cmake-modules/tree/master). -To build the unittests, run them and then generare the coverage data in this format, +To build the unittests, run them and then generate the coverage data in this format, the following command can be used inside the build directory after the build system was set up ```sh From 1611a4e1f0c013d9fa632edc858a14cb7509c32f Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 16 May 2022 11:10:35 +0200 Subject: [PATCH 012/532] device handler unittest wip --- scripts/helper.py | 27 +++++-- .../unit/devicehandler/ComIFMock.cpp | 24 +++++++ .../fsfw_tests/unit/devicehandler/ComIFMock.h | 27 +++++++ .../unit/devicehandler/CookieIFMock.cpp | 7 ++ .../unit/devicehandler/CookieIFMock.h | 12 ++++ .../devicehandler/DeviceHandlerCommander.cpp | 70 +++++++++++++++++++ .../devicehandler/DeviceHandlerCommander.h | 49 +++++++++++++ .../unit/devicehandler/DeviceHandlerMock.cpp | 70 +++++++++++++++++++ .../unit/devicehandler/DeviceHandlerMock.h | 36 ++++++++++ .../devicehandler/TestDeviceHandlerBase.cpp | 36 ++++++++++ .../devicehandler/TestDeviceHandlerBase.h | 49 +++++++++++++ .../unit/testcfg/objects/systemObjectList.h | 61 ++++++++-------- 12 files changed, 435 insertions(+), 33 deletions(-) create mode 100644 tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp create mode 100644 tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h create mode 100644 tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp create mode 100644 tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.h create mode 100644 tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp create mode 100644 tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h create mode 100644 tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp create mode 100644 tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h create mode 100644 tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp create mode 100644 tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.h diff --git a/scripts/helper.py b/scripts/helper.py index 4dff908d..56cf352b 100755 --- a/scripts/helper.py +++ b/scripts/helper.py @@ -48,6 +48,20 @@ def main(): action="store_true", help="Run valgrind on generated test binary", ) + parser.add_argument( + "-g", + "--generators", + default = "Ninja", + action="store", + help="CMake generators", + ) + parser.add_argument( + "-w", + "--windows", + default=False, + action="store_true", + help="Run on windows", + ) args = parser.parse_args() if args.all: @@ -115,14 +129,14 @@ def handle_tests_type(args, build_dir_list: list): if args.create: if os.path.exists(UNITTEST_FOLDER_NAME): shutil.rmtree(UNITTEST_FOLDER_NAME) - create_tests_build_cfg() + create_tests_build_cfg(args) build_directory = UNITTEST_FOLDER_NAME elif len(build_dir_list) == 0: print( "No valid CMake tests build directory found. " "Trying to set up test build system" ) - create_tests_build_cfg() + create_tests_build_cfg(args) build_directory = UNITTEST_FOLDER_NAME elif len(build_dir_list) == 1: build_directory = build_dir_list[0] @@ -147,10 +161,15 @@ def handle_tests_type(args, build_dir_list: list): os.chdir("..") -def create_tests_build_cfg(): +def create_tests_build_cfg(args): os.mkdir(UNITTEST_FOLDER_NAME) os.chdir(UNITTEST_FOLDER_NAME) - cmd_runner("cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..") + if args.windows: + cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON \ + -DGCOVR_PATH="py -m gcovr" ..' + else: + cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..' + cmd_runner(cmake_cmd) os.chdir("..") diff --git a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp new file mode 100644 index 00000000..6bcf5e20 --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp @@ -0,0 +1,24 @@ +#include "ComIFMock.h" + +ComIFMock::ComIFMock(obejct_id_t objectId) {} + +ComIFMock::~ComIFMock() {} + +ReturnValue_t ComIFMock::initializeInterface(CookieIF *cookie) { return RETURN_OK; } + +ReturnValue_t ComIFMock::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) { + rememberSentByte = *sendData; + return RETURN_OK; +} + +ReturnValue_t ComIFMock::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } + +ReturnValue_t ComIFMock::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { + return RETURN_OK; +} + +ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { + *size = sizeof(rememberSentByte); + *buffer = &rememberSentByte; + return RETURN_OK; +} diff --git a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h new file mode 100644 index 00000000..fde6be45 --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h @@ -0,0 +1,27 @@ +#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ +#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ + +#include + +/** + * @brief The ComIFMock supports the simulation of various device communication error cases + * like incomplete or wrong replies and can be used to test the DeviceHandlerBase. + */ +class ComIFMock : public DeviceCommunicationIF, public SystemObject { + public: + ComIFMock(obejct_id_t objectId); + virtual ~ComIFMock(); + + virtual ReturnValue_t initializeInterface(CookieIF *cookie) override; + virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, + size_t sendLen) override; + virtual ReturnValue_t getSendSuccess(CookieIF *cookie) override; + virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; + virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, + size_t *size) override; + + private: + uint8_t rememberSentByte = 0; +}; + +#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ */ diff --git a/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp new file mode 100644 index 00000000..f73c1731 --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp @@ -0,0 +1,7 @@ +#include "CookieIFMock.h" + +CookieIFMock::CookieIFMock() { +} + +CookieIFMock::~CookieIFMock() { +} diff --git a/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.h b/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.h new file mode 100644 index 00000000..ad40f55f --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.h @@ -0,0 +1,12 @@ +#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COOKIEIFMOCK_H_ +#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COOKIEIFMOCK_H_ + +#include "fsfw/devicehandlers/CookieIF.h" + +class CookieIFMock { + public: + CookieIFMock(); + virtual ~CookieIFMock(); +}; + +#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COOKIEIFMOCK_H_ */ diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp new file mode 100644 index 00000000..4da5f36c --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp @@ -0,0 +1,70 @@ +#include "DeviceHandlerCommander.h" + +DeviceHandlerCommander::DeviceHandlerCommander(object_id_t objectId) + : SystemObject(objectId), commandActionHelper(this) { + auto mqArgs = MqArgs(this->getObjectId()); + commandQueue = QueueFactory::instance()->createMessageQueue( + QUEUE_SIZE, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); +} + +DeviceHandlerCommander::~DeviceHandlerCommander() {} + +ReturnValue_t DeviceHandlerCommander::performOperation(uint8_t operationCode) { + readCommandQueue(); +} + +ReturnValue_t DeviceHandlerCommander::initialize() { + ReturnValue_t result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return HasReturnvaluesIF::RETURN_OK; +} + +MessageQueueIF* DeviceHandlerCommander::getCommandQueuePtr() { return commandQueue; } + +void DeviceHandlerCommander::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {} + +void DeviceHandlerCommander::stepFailedReceived(ActionId_t actionId, uint8_t step, + ReturnValue_t returnCode) {} + +void DeviceHandlerCommander::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { +} + +void DeviceHandlerCommander::completionSuccessfulReceived(ActionId_t actionId) { + lastReplyReturnCode = RETURN_OK; +} + +void DeviceHandlerCommander::completionFailedReceived(ActionId_t actionId, + ReturnValue_t returnCode) { + lastReplyReturnCode = returnCode; +} + +void DeviceHandlerCommander::readCommandQueue() { + CommandMessage message; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + if (result != HasReturnvaluesIF::RETURN_OK) { + continue; + } + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + } +} + +ReturnValue_t DeviceHandlerCommander::sendCommand(object_id_t target, ActionId_t actionId) { + return commandActionHelper.commandAction(target, actionId, nullptr, 0); +} + +ReturnValue_t DeviceHandlerCommander::getReplyReturnCode() { return lastReplyReturnCode; } + +void DeviceHandlerCommander::resetReplyReturnCode() { + lastReplyReturnCode = RETURN_FAILED; +} diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h new file mode 100644 index 00000000..587932e0 --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h @@ -0,0 +1,49 @@ +#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ +#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ + +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/action/CommandActionHelper.h" +#include "fsfw/action/CommandsActionsIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +class DeviceHandlerCommander : public ExecutableObjectIF, + public SystemObject, + public CommandsActionsIF, + public HasReturnvaluesIF { + public: + DeviceHandlerCommander(object_id_t objectId); + virtual ~DeviceHandlerCommander(); + + ReturnValue_t performOperation(uint8_t operationCode = 0); + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + + /** + * @brief Calling this function will send the command to the device handler object. + * + * @param target Object ID of the device handler + * @param actionId Action ID of the command to send + */ + ReturnValue_t sendCommand(object_id_t target, ActionId_t actionId); + + ReturnValue_t getReplyReturnCode(); + void resetReplyReturnCode(); + + private: + + MessageQueueIF* commandQueue = nullptr; + + CommandActionHelper commandActionHelper; + + ReturnValue_t lastReplyReturnCode = RETURN_FAILED; + + void readCommandQueue(); +}; + +#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ */ diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp new file mode 100644 index 00000000..ccdabc40 --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp @@ -0,0 +1,70 @@ +#include "DeviceHandlerMock.h" + +DeviceHandlerMock::DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication) + : DeviceHandlerBase(objetcId, deviceCommunication, nullptr) {} + +DeviceHandlerMock::~DeviceHandlerMock() { +} + +void DeviceHandlerMock::doStartup() { + setMode(_MODE_TO_ON); +} + +void DeviceHandlerMock::doShutdown() { + setMode(_MODE_POWER_DOWN); +} + +ReturnValue_t DeviceHandlerMock::buildNormalDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t DeviceHandlerMock::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t DeviceHandlerMock::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch(deviceCommand) { + case PERIODIC_REPLY_TEST_COMMAND: { + commandBuffer[0] = periodicReplyTestData; + rawPacket = commandBuffer; + rawPacketLen = sizeof(periodicReplyTestData); + } + default: + WARN("DeviceHandlerMock::buildCommandFromCommand: Invalid device command"); + } + return RETURN_OK; +} + +ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) { + switch(*start) { + case periodicReplyTestData: { + return RETURN_OK; + break; + } + default: + break; + } + return RETURN_FAILED; +} + +ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + switch(id){ + case PERIODIC_REPLY_TEST_COMMAND: + break; + default: + break; + } +} + +void DeviceHandlerMock::fillCommandAndReplyMap() { + insertInCommandAndReplyMap(PERIODIC_REPLY_TEST_COMMAND, 2, nullptr, 0, true, false, 0, + periodicReplyCountdown); +} + +uint32_t DeviceHandlerMock::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 500; +} + diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h new file mode 100644 index 00000000..3e358d65 --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h @@ -0,0 +1,36 @@ +#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ +#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ + +#include + +class DeviceHandlerMock : public DeviceHandlerBase { + public: + + static const DeviceCommandId_t PERIODIC_REPLY_TEST_COMMAND = 1; + + DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication); + virtual ~DeviceHandlerMock(); + +protected: + void doStartUp() override; + void doStartShutdown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + +private: + + uint8_t periodicReplyTestData = 1; + + Countdown periodicReplyCountdown = Countdown(10); + + uint8_t commandBuffer[1]; +}; + +#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ */ diff --git a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp new file mode 100644 index 00000000..b3291782 --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp @@ -0,0 +1,36 @@ +#include "TestDeviceHandlerBase.h" + +#include +#include "ComIFMock.h" + +#include "fsfw_tests/unit/devicehandler/DeviceHandlerMock.h" +#include "fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h" +#include "fsfw_tests/unit/devicehandler/CookieIFMock.h" +#include "fsfw_tests/unit/testcfg/objects/systemObjectList.h" + +TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { + + SECTION("Periodic reply with countdown based timeout success") { + CookieIFMock cookieIFMock; + ComIFperiodicMock comIFperiodic(objects::COM_IF_MOCK); + DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK, + &cookieIFMock); + ReturnValue_t result = deviceHandlerMock.initialize(); + REQUIRE(result == RETURN_OK); + DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER); + result = deviceHandlerCommander.initialize(); + REQUIRE(result == RETURN_OK); + result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, + DeviceHandlerMock::PERIODIC_REPLY_TEST_COMMAND); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + result = deviceHandlerCommander.getReplyReturnCode(); + REQUIRE(result == RETURN_OK); + } +// SECTION("Periodic reply with countdown based timeout failed") { +// +// } +} diff --git a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.h b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.h new file mode 100644 index 00000000..ed35c34a --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.h @@ -0,0 +1,49 @@ +#ifndef UNITTEST_HOSTED_TESTACTIONHELPER_H_ +#define UNITTEST_HOSTED_TESTACTIONHELPER_H_ + +#include +#include + +#include + +#include "fsfw_tests/unit/CatchDefinitions.h" + +class ActionHelperOwnerMockBase : public HasActionsIF { + public: + bool getCommandQueueCalled = false; + bool executeActionCalled = false; + static const size_t MAX_SIZE = 3; + uint8_t buffer[MAX_SIZE] = {0, 0, 0}; + size_t size = 0; + + MessageQueueId_t getCommandQueue() const override { return tconst::testQueueId; } + + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override { + executeActionCalled = true; + if (size > MAX_SIZE) { + return 0xAFFE; + } + this->size = size; + memcpy(buffer, data, size); + return HasReturnvaluesIF::RETURN_OK; + } + + void clearBuffer() { + this->size = 0; + for (size_t i = 0; i < MAX_SIZE; i++) { + buffer[i] = 0; + } + } + + void getBuffer(const uint8_t** ptr, size_t* size) { + if (size != nullptr) { + *size = this->size; + } + if (ptr != nullptr) { + *ptr = buffer; + } + } +}; + +#endif /* UNITTEST_TESTFW_NEWTESTS_TESTACTIONHELPER_H_ */ diff --git a/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h b/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h index 3eba1484..29450309 100644 --- a/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h +++ b/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h @@ -1,29 +1,32 @@ -#ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ - -#include - -#include "fsfw/objectmanager/frameworkObjects.h" - -// The objects will be instantiated in the ID order -namespace objects { -enum sourceObjects : uint32_t { - /* All addresses between start and end are reserved for the FSFW */ - FSFW_CONFIG_RESERVED_START = PUS_SERVICE_1_VERIFICATION, - FSFW_CONFIG_RESERVED_END = TM_STORE, - - UDP_BRIDGE = 15, - UDP_POLLING_TASK = 16, - - TEST_ECHO_COM_IF = 20, - TEST_DEVICE = 21, - - HK_RECEIVER_MOCK = 22, - TEST_LOCAL_POOL_OWNER_BASE = 25, - - SHARED_SET_ID = 26 - -}; -} - -#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ +#ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ +#define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ + +#include + +#include "fsfw/objectmanager/frameworkObjects.h" + +// The objects will be instantiated in the ID order +namespace objects { +enum sourceObjects : uint32_t { + /* All addresses between start and end are reserved for the FSFW */ + FSFW_CONFIG_RESERVED_START = PUS_SERVICE_1_VERIFICATION, + FSFW_CONFIG_RESERVED_END = TM_STORE, + + UDP_BRIDGE = 15, + UDP_POLLING_TASK = 16, + + TEST_ECHO_COM_IF = 20, + TEST_DEVICE = 21, + + HK_RECEIVER_MOCK = 22, + TEST_LOCAL_POOL_OWNER_BASE = 25, + + SHARED_SET_ID = 26, + + DEVICE_HANDLER_MOCK = 27, + COM_IF_MOCK = 28, + DEVICE_HANDLER_COMMANDER = 29, +}; +} + +#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ From bf673c56c69b16a8aeae12b30de1dd90c5588dfc Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 5 Jun 2022 12:52:55 +0200 Subject: [PATCH 013/532] unit test for dhb --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 8 ++- src/fsfw/events/EventManager.cpp | 5 ++ src/fsfw/events/EventManager.h | 2 + src/fsfw/events/EventManagerIF.h | 2 + src/fsfw/fdir/FailureIsolationBase.cpp | 12 +++- src/fsfw/fdir/FaultCounter.cpp | 8 +-- src/fsfw/fdir/FaultCounter.h | 14 +++- src/fsfw/health/HealthHelper.cpp | 4 +- src/fsfw/health/HealthTable.cpp | 9 +++ src/fsfw/health/HealthTable.h | 1 + src/fsfw/health/HealthTableIF.h | 2 + tests/src/fsfw_tests/unit/CMakeLists.txt | 1 + tests/src/fsfw_tests/unit/CatchFactory.cpp | 2 +- .../unit/devicehandler/ComIFMock.cpp | 31 ++++++-- .../fsfw_tests/unit/devicehandler/ComIFMock.h | 15 +++- .../unit/devicehandler/CookieIFMock.h | 2 +- .../devicehandler/DeviceHandlerCommander.cpp | 9 +-- .../devicehandler/DeviceHandlerCommander.h | 2 + .../unit/devicehandler/DeviceHandlerMock.cpp | 71 +++++++++++++------ .../unit/devicehandler/DeviceHandlerMock.h | 48 ++++++++----- .../devicehandler/TestDeviceHandlerBase.cpp | 65 +++++++++++------ .../devicehandler/TestDeviceHandlerBase.h | 49 ------------- 22 files changed, 224 insertions(+), 138 deletions(-) delete mode 100644 tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.h diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index fb9a597c..a874824d 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -65,7 +65,9 @@ void DeviceHandlerBase::setThermalStateRequestPoolIds(lp_id_t thermalStatePoolId } DeviceHandlerBase::~DeviceHandlerBase() { - delete comCookie; + if (comCookie != nullptr) { + delete comCookie; + } if (defaultFDIRUsed) { delete fdirInstance; } @@ -253,7 +255,9 @@ void DeviceHandlerBase::decrementDeviceReplyMap() { replyToReply(replyPair.first, replyPair.second, TIMEOUT); missedReply(replyPair.first); timedOut = false; - replyPair.second.active = false; + if (not replyPair.second.periodic) { + replyPair.second.active = false; + } } } } diff --git a/src/fsfw/events/EventManager.cpp b/src/fsfw/events/EventManager.cpp index aaa7d6c5..47270d2a 100644 --- a/src/fsfw/events/EventManager.cpp +++ b/src/fsfw/events/EventManager.cpp @@ -88,6 +88,11 @@ ReturnValue_t EventManager::subscribeToEventRange(MessageQueueId_t listener, Eve return result; } +ReturnValue_t EventManager::unsubscribeFromAllEvents(MessageQueueId_t listener, + object_id_t object) { + return unsubscribeFromEventRange(listener, 0, 0, true, object); +} + ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener, EventId_t idFrom, EventId_t idTo, bool idInverted, object_id_t reporterFrom, diff --git a/src/fsfw/events/EventManager.h b/src/fsfw/events/EventManager.h index f2d642ff..77d657e8 100644 --- a/src/fsfw/events/EventManager.h +++ b/src/fsfw/events/EventManager.h @@ -37,6 +37,8 @@ class EventManager : public EventManagerIF, public ExecutableObjectIF, public Sy EventId_t idTo = 0, bool idInverted = false, object_id_t reporterFrom = 0, object_id_t reporterTo = 0, bool reporterInverted = false); + ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, + object_id_t object); ReturnValue_t unsubscribeFromEventRange(MessageQueueId_t listener, EventId_t idFrom = 0, EventId_t idTo = 0, bool idInverted = false, object_id_t reporterFrom = 0, object_id_t reporterTo = 0, diff --git a/src/fsfw/events/EventManagerIF.h b/src/fsfw/events/EventManagerIF.h index 98051ba0..893f86f1 100644 --- a/src/fsfw/events/EventManagerIF.h +++ b/src/fsfw/events/EventManagerIF.h @@ -20,6 +20,8 @@ class EventManagerIF { bool forwardAllButSelected = false) = 0; virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event) = 0; virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener, object_id_t object) = 0; + virtual ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, + object_id_t object) = 0; virtual ReturnValue_t subscribeToEventRange(MessageQueueId_t listener, EventId_t idFrom = 0, EventId_t idTo = 0, bool idInverted = false, object_id_t reporterFrom = 0, diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index fedef869..da17d783 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -14,7 +14,17 @@ FailureIsolationBase::FailureIsolationBase(object_id_t owner, object_id_t parent } FailureIsolationBase::~FailureIsolationBase() { - QueueFactory::instance()->deleteMessageQueue(eventQueue); + EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + if (manager == nullptr) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "FailureIsolationBase::~FailureIsolationBase: Event Manager has not" + " been initialized!" + << std::endl; +#endif + return; + } + manager->unsubscribeFromAllEvents(eventQueue->getId(), ownerId); + QueueFactory::instance()->deleteMessageQueue(eventQueue); } ReturnValue_t FailureIsolationBase::initialize() { diff --git a/src/fsfw/fdir/FaultCounter.cpp b/src/fsfw/fdir/FaultCounter.cpp index e87cf613..4515e5b1 100644 --- a/src/fsfw/fdir/FaultCounter.cpp +++ b/src/fsfw/fdir/FaultCounter.cpp @@ -60,14 +60,14 @@ ReturnValue_t FaultCounter::getParameter(uint8_t domainId, uint8_t uniqueId, return INVALID_DOMAIN_ID; } - switch (uniqueId) { - case 0: + switch (static_cast(uniqueId)) { + case ParameterIds::FAILURE_THRESHOLD: parameterWrapper->set(failureThreshold); break; - case 1: + case ParameterIds::FAULT_COUNT: parameterWrapper->set(faultCount); break; - case 2: + case ParameterIds::TIMEOUT: parameterWrapper->set(timer.timeout); break; default: diff --git a/src/fsfw/fdir/FaultCounter.h b/src/fsfw/fdir/FaultCounter.h index 3b59885c..c5630da9 100644 --- a/src/fsfw/fdir/FaultCounter.h +++ b/src/fsfw/fdir/FaultCounter.h @@ -6,6 +6,13 @@ class FaultCounter : public HasParametersIF { public: + + enum class ParameterIds { + FAILURE_THRESHOLD, + FAULT_COUNT, + TIMEOUT + }; + FaultCounter(); FaultCounter(uint32_t failureThreshold, uint32_t decrementAfterMs, uint8_t setParameterDomain = 0); @@ -23,9 +30,10 @@ class FaultCounter : public HasParametersIF { void setFailureThreshold(uint32_t failureThreshold); void setFaultDecrementTimeMs(uint32_t timeMs); - virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, - ParameterWrapper *parameterWrapper, - const ParameterWrapper *newValues, uint16_t startAtIndex); + virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, + ParameterWrapper *parameterWrapper, + const ParameterWrapper *newValues = nullptr, uint16_t startAtIndex = + 0); void setParameterDomain(uint8_t domain); diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index 4bef128c..b9884115 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -5,7 +5,9 @@ HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId) : objectId(objectId), owner(owner) {} -HealthHelper::~HealthHelper() {} +HealthHelper::~HealthHelper() { + healthTable->removeObject(objectId); +} ReturnValue_t HealthHelper::handleHealthCommand(CommandMessage* message) { switch (message->getCommand()) { diff --git a/src/fsfw/health/HealthTable.cpp b/src/fsfw/health/HealthTable.cpp index ab4881f4..ee8fcd94 100644 --- a/src/fsfw/health/HealthTable.cpp +++ b/src/fsfw/health/HealthTable.cpp @@ -27,6 +27,15 @@ ReturnValue_t HealthTable::registerObject(object_id_t object, return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t HealthTable::removeObject(object_id_t object) { + mapIterator = healthMap.find(object); + if (mapIterator == healthMap.end()) { + return HasReturnvaluesIF::RETURN_FAILED; + } + healthMap.erase(mapIterator); + return HasReturnvaluesIF::RETURN_OK; +} + void HealthTable::setHealth(object_id_t object, HasHealthIF::HealthState newState) { MutexGuard(mutex, timeoutType, mutexTimeoutMs); HealthMap::iterator iter = healthMap.find(object); diff --git a/src/fsfw/health/HealthTable.h b/src/fsfw/health/HealthTable.h index 4718abc3..60e00f92 100644 --- a/src/fsfw/health/HealthTable.h +++ b/src/fsfw/health/HealthTable.h @@ -17,6 +17,7 @@ class HealthTable : public HealthTableIF, public SystemObject { /** HealthTableIF overrides */ virtual ReturnValue_t registerObject( object_id_t object, HasHealthIF::HealthState initilialState = HasHealthIF::HEALTHY) override; + ReturnValue_t removeObject(object_id_t object) override; virtual size_t getPrintSize() override; virtual void printAll(uint8_t* pointer, size_t maxSize) override; diff --git a/src/fsfw/health/HealthTableIF.h b/src/fsfw/health/HealthTableIF.h index 50266ac2..aab3f0eb 100644 --- a/src/fsfw/health/HealthTableIF.h +++ b/src/fsfw/health/HealthTableIF.h @@ -14,6 +14,8 @@ class HealthTableIF : public ManagesHealthIF { virtual ReturnValue_t registerObject( object_id_t object, HasHealthIF::HealthState initilialState = HasHealthIF::HEALTHY) = 0; + virtual ReturnValue_t removeObject(object_id_t objectId) = 0; + virtual size_t getPrintSize() = 0; virtual void printAll(uint8_t *pointer, size_t maxSize) = 0; diff --git a/tests/src/fsfw_tests/unit/CMakeLists.txt b/tests/src/fsfw_tests/unit/CMakeLists.txt index a8d31d88..eb57202a 100644 --- a/tests/src/fsfw_tests/unit/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/CMakeLists.txt @@ -23,3 +23,4 @@ add_subdirectory(tmtcpacket) add_subdirectory(cfdp) add_subdirectory(hal) add_subdirectory(internalerror) +add_subdirectory(devicehandler) diff --git a/tests/src/fsfw_tests/unit/CatchFactory.cpp b/tests/src/fsfw_tests/unit/CatchFactory.cpp index 01018dfa..860a9bed 100644 --- a/tests/src/fsfw_tests/unit/CatchFactory.cpp +++ b/tests/src/fsfw_tests/unit/CatchFactory.cpp @@ -65,7 +65,7 @@ void Factory::setStaticFrameworkObjectIds() { VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; - DeviceHandlerBase::rawDataReceiverId = objects::PUS_SERVICE_2_DEVICE_ACCESS; + DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT; LocalDataPoolManager::defaultHkDestination = objects::HK_RECEIVER_MOCK; diff --git a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp index 6bcf5e20..4dd64c1a 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp @@ -1,13 +1,14 @@ #include "ComIFMock.h" +#include "DeviceHandlerMock.h" -ComIFMock::ComIFMock(obejct_id_t objectId) {} +ComIFMock::ComIFMock(object_id_t objectId) : SystemObject(objectId){} ComIFMock::~ComIFMock() {} ReturnValue_t ComIFMock::initializeInterface(CookieIF *cookie) { return RETURN_OK; } ReturnValue_t ComIFMock::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) { - rememberSentByte = *sendData; + data = *sendData; return RETURN_OK; } @@ -18,7 +19,29 @@ ReturnValue_t ComIFMock::requestReceiveMessage(CookieIF *cookie, size_t requestL } ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { - *size = sizeof(rememberSentByte); - *buffer = &rememberSentByte; + switch(testCase) { + case TestCase::MISSED_REPLY: { + *size = 0; + return RETURN_OK; + } + case TestCase::SIMPLE_COMMAND_NOMINAL: { + *size = 1; + data = DeviceHandlerMock::SIMPLE_COMMAND_DATA; + *buffer = &data; + break; + } + case TestCase::PERIODIC_REPLY_NOMINAL: { + *size = 1; + data = DeviceHandlerMock::PERIODIC_REPLY_DATA; + *buffer = &data; + break; + } + default: + break; + } return RETURN_OK; } + +void ComIFMock::setTestCase(TestCase testCase_) { + testCase = testCase_; +} diff --git a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h index fde6be45..7de4937f 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h +++ b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h @@ -2,14 +2,17 @@ #define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ #include +#include /** * @brief The ComIFMock supports the simulation of various device communication error cases - * like incomplete or wrong replies and can be used to test the DeviceHandlerBase. + * like incomplete or wrong replies and can be used to test the DeviceHandlerBase. */ class ComIFMock : public DeviceCommunicationIF, public SystemObject { public: - ComIFMock(obejct_id_t objectId); + enum class TestCase { SIMPLE_COMMAND_NOMINAL, PERIODIC_REPLY_NOMINAL, MISSED_REPLY }; + + ComIFMock(object_id_t objectId); virtual ~ComIFMock(); virtual ReturnValue_t initializeInterface(CookieIF *cookie) override; @@ -19,9 +22,15 @@ class ComIFMock : public DeviceCommunicationIF, public SystemObject { virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) override; + void setTestCase(TestCase testCase_); private: - uint8_t rememberSentByte = 0; + TestCase testCase = TestCase::SIMPLE_COMMAND_NOMINAL; + + static const uint8_t SIMPLE_COMMAND_DATA = 1; + static const uint8_t PERIODIC_REPLY_DATA = 2; + + uint8_t data = 0; }; #endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ */ diff --git a/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.h b/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.h index ad40f55f..5c868932 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.h +++ b/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.h @@ -3,7 +3,7 @@ #include "fsfw/devicehandlers/CookieIF.h" -class CookieIFMock { +class CookieIFMock : public CookieIF { public: CookieIFMock(); virtual ~CookieIFMock(); diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp index 4da5f36c..b3889b2c 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp @@ -1,4 +1,5 @@ #include "DeviceHandlerCommander.h" +#include DeviceHandlerCommander::DeviceHandlerCommander(object_id_t objectId) : SystemObject(objectId), commandActionHelper(this) { @@ -11,6 +12,7 @@ DeviceHandlerCommander::~DeviceHandlerCommander() {} ReturnValue_t DeviceHandlerCommander::performOperation(uint8_t operationCode) { readCommandQueue(); + return RETURN_OK; } ReturnValue_t DeviceHandlerCommander::initialize() { @@ -18,10 +20,6 @@ ReturnValue_t DeviceHandlerCommander::initialize() { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } return HasReturnvaluesIF::RETURN_OK; } @@ -49,9 +47,6 @@ void DeviceHandlerCommander::readCommandQueue() { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; result = commandQueue->receiveMessage(&message)) { - if (result != HasReturnvaluesIF::RETURN_OK) { - continue; - } result = commandActionHelper.handleReply(&message); if (result == HasReturnvaluesIF::RETURN_OK) { continue; diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h index 587932e0..77168043 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h @@ -37,6 +37,8 @@ class DeviceHandlerCommander : public ExecutableObjectIF, private: + static const uint32_t QUEUE_SIZE = 20; + MessageQueueIF* commandQueue = nullptr; CommandActionHelper commandActionHelper; diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp index ccdabc40..ca1dff2f 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp @@ -1,18 +1,18 @@ #include "DeviceHandlerMock.h" -DeviceHandlerMock::DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication) - : DeviceHandlerBase(objetcId, deviceCommunication, nullptr) {} +#include -DeviceHandlerMock::~DeviceHandlerMock() { +DeviceHandlerMock::DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, + CookieIF *comCookie, FailureIsolationBase *fdirInstance) + : DeviceHandlerBase(objectId, deviceCommunication, comCookie, fdirInstance) { + mode = MODE_ON; } -void DeviceHandlerMock::doStartup() { - setMode(_MODE_TO_ON); -} +DeviceHandlerMock::~DeviceHandlerMock() {} -void DeviceHandlerMock::doShutdown() { - setMode(_MODE_POWER_DOWN); -} +void DeviceHandlerMock::doStartUp() { setMode(_MODE_TO_ON); } + +void DeviceHandlerMock::doShutDown() { setMode(_MODE_POWER_DOWN); } ReturnValue_t DeviceHandlerMock::buildNormalDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; @@ -25,22 +25,32 @@ ReturnValue_t DeviceHandlerMock::buildTransitionDeviceCommand(DeviceCommandId_t ReturnValue_t DeviceHandlerMock::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, size_t commandDataLen) { - switch(deviceCommand) { - case PERIODIC_REPLY_TEST_COMMAND: { - commandBuffer[0] = periodicReplyTestData; + switch (deviceCommand) { + case SIMPLE_COMMAND: { + commandBuffer[0] = SIMPLE_COMMAND_DATA; rawPacket = commandBuffer; - rawPacketLen = sizeof(periodicReplyTestData); + rawPacketLen = sizeof(SIMPLE_COMMAND_DATA); + break; } default: WARN("DeviceHandlerMock::buildCommandFromCommand: Invalid device command"); + break; } return RETURN_OK; } -ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, - size_t *foundLen) { - switch(*start) { - case periodicReplyTestData: { +ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) { + switch (*start) { + case SIMPLE_COMMAND_DATA: { + *foundId = SIMPLE_COMMAND; + *foundLen = sizeof(SIMPLE_COMMAND_DATA); + return RETURN_OK; + break; + } + case PERIODIC_REPLY_DATA: { + *foundId = PERIODIC_REPLY; + *foundLen = sizeof(PERIODIC_REPLY_DATA); return RETURN_OK; break; } @@ -51,20 +61,35 @@ ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, } ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { - switch(id){ - case PERIODIC_REPLY_TEST_COMMAND: + switch (id) { + case SIMPLE_COMMAND: + case PERIODIC_REPLY: { + periodicReplyReceived = true; break; + } default: break; } + return RETURN_OK; } void DeviceHandlerMock::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(PERIODIC_REPLY_TEST_COMMAND, 2, nullptr, 0, true, false, 0, - periodicReplyCountdown); + insertInCommandAndReplyMap(SIMPLE_COMMAND, 0, nullptr, 0, false, false, 0, + &simpleCommandReplyTimeout); + insertInCommandAndReplyMap(PERIODIC_REPLY, 0, nullptr, 0, true, false, 0, + &periodicReplyCountdown); } -uint32_t DeviceHandlerMock::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 500; +uint32_t DeviceHandlerMock::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } + +void DeviceHandlerMock::changePeriodicReplyCountdown(uint32_t timeout) { + periodicReplyCountdown.setTimeout(0); } +void DeviceHandlerMock::resetPeriodicReplyState() { + periodicReplyReceived = false; +} + +bool DeviceHandlerMock::getPeriodicReplyReceived() { + return periodicReplyReceived; +} diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h index 3e358d65..ac79d926 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h @@ -3,34 +3,44 @@ #include -class DeviceHandlerMock : public DeviceHandlerBase { - public: +class DeviceHandlerMock: public DeviceHandlerBase { +public: - static const DeviceCommandId_t PERIODIC_REPLY_TEST_COMMAND = 1; + static const DeviceCommandId_t SIMPLE_COMMAND = 1; + static const DeviceCommandId_t PERIODIC_REPLY = 2; - DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication); - virtual ~DeviceHandlerMock(); + static const uint8_t SIMPLE_COMMAND_DATA = 1; + static const uint8_t PERIODIC_REPLY_DATA = 2; + + DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, + CookieIF *comCookie, FailureIsolationBase* fdirInstance); + virtual ~DeviceHandlerMock(); + void changePeriodicReplyCountdown(uint32_t timeout); + void resetPeriodicReplyState(); + bool getPeriodicReplyReceived(); protected: - void doStartUp() override; - void doStartShutdown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, - size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; - void fillCommandAndReplyMap() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, + const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; private: - uint8_t periodicReplyTestData = 1; + Countdown simpleCommandReplyTimeout = Countdown(50); + Countdown periodicReplyCountdown = Countdown(10); - Countdown periodicReplyCountdown = Countdown(10); + uint8_t commandBuffer[1]; - uint8_t commandBuffer[1]; + bool periodicReplyReceived = false; }; #endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ */ diff --git a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp index b3291782..1271eb49 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp @@ -1,36 +1,61 @@ -#include "TestDeviceHandlerBase.h" - #include -#include "ComIFMock.h" -#include "fsfw_tests/unit/devicehandler/DeviceHandlerMock.h" -#include "fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h" +#include "ComIFMock.h" +#include "DeviceFdirMock.h" #include "fsfw_tests/unit/devicehandler/CookieIFMock.h" +#include "fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h" +#include "fsfw_tests/unit/devicehandler/DeviceHandlerMock.h" #include "fsfw_tests/unit/testcfg/objects/systemObjectList.h" TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { - SECTION("Periodic reply with countdown based timeout success") { - CookieIFMock cookieIFMock; - ComIFperiodicMock comIFperiodic(objects::COM_IF_MOCK); - DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK, - &cookieIFMock); - ReturnValue_t result = deviceHandlerMock.initialize(); - REQUIRE(result == RETURN_OK); - DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER); - result = deviceHandlerCommander.initialize(); - REQUIRE(result == RETURN_OK); + // Will be deleted with DHB destructor + CookieIFMock* cookieIFMock = new CookieIFMock; + ComIFMock comIF(objects::COM_IF_MOCK); + DeviceFdirMock deviceFdirMock(objects::DEVICE_HANDLER_MOCK, objects::NO_OBJECT); + DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK, + cookieIFMock, &deviceFdirMock); + ReturnValue_t result = deviceHandlerMock.initialize(); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER); + result = deviceHandlerCommander.initialize(); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + + SECTION("Commanding") { + comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL); result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, - DeviceHandlerMock::PERIODIC_REPLY_TEST_COMMAND); + DeviceHandlerMock::SIMPLE_COMMAND); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + deviceHandlerCommander.performOperation(); result = deviceHandlerCommander.getReplyReturnCode(); - REQUIRE(result == RETURN_OK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + } + + SECTION("Periodic reply") { + comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + REQUIRE(deviceHandlerMock.getPeriodicReplyReceived() == true); + } + + SECTION("Missed periodic reply") { + comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); + // Set the timeout to 0 to immediately timeout the reply + deviceHandlerMock.changePeriodicReplyCountdown(0); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); + REQUIRE(missedReplies == 1); } -// SECTION("Periodic reply with countdown based timeout failed") { -// -// } } diff --git a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.h b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.h deleted file mode 100644 index ed35c34a..00000000 --- a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef UNITTEST_HOSTED_TESTACTIONHELPER_H_ -#define UNITTEST_HOSTED_TESTACTIONHELPER_H_ - -#include -#include - -#include - -#include "fsfw_tests/unit/CatchDefinitions.h" - -class ActionHelperOwnerMockBase : public HasActionsIF { - public: - bool getCommandQueueCalled = false; - bool executeActionCalled = false; - static const size_t MAX_SIZE = 3; - uint8_t buffer[MAX_SIZE] = {0, 0, 0}; - size_t size = 0; - - MessageQueueId_t getCommandQueue() const override { return tconst::testQueueId; } - - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override { - executeActionCalled = true; - if (size > MAX_SIZE) { - return 0xAFFE; - } - this->size = size; - memcpy(buffer, data, size); - return HasReturnvaluesIF::RETURN_OK; - } - - void clearBuffer() { - this->size = 0; - for (size_t i = 0; i < MAX_SIZE; i++) { - buffer[i] = 0; - } - } - - void getBuffer(const uint8_t** ptr, size_t* size) { - if (size != nullptr) { - *size = this->size; - } - if (ptr != nullptr) { - *ptr = buffer; - } - } -}; - -#endif /* UNITTEST_TESTFW_NEWTESTS_TESTACTIONHELPER_H_ */ From 2fa4fd61d0ee5fb626e9fb9d70a98a08109d2438 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 5 Jun 2022 12:54:13 +0200 Subject: [PATCH 014/532] device fdir mock --- .../unit/devicehandler/CMakeLists.txt | 8 ++++++++ .../unit/devicehandler/DeviceFdirMock.cpp | 18 ++++++++++++++++++ .../unit/devicehandler/DeviceFdirMock.h | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 tests/src/fsfw_tests/unit/devicehandler/CMakeLists.txt create mode 100644 tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.cpp create mode 100644 tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.h diff --git a/tests/src/fsfw_tests/unit/devicehandler/CMakeLists.txt b/tests/src/fsfw_tests/unit/devicehandler/CMakeLists.txt new file mode 100644 index 00000000..7ad5d316 --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/CMakeLists.txt @@ -0,0 +1,8 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE + CookieIFMock.cpp + ComIFMock.cpp + DeviceHandlerCommander.cpp + DeviceHandlerMock.cpp + DeviceFdirMock.cpp + TestDeviceHandlerBase.cpp +) diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.cpp new file mode 100644 index 00000000..dfef7cd3 --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.cpp @@ -0,0 +1,18 @@ +#include "DeviceFdirMock.h" + +#include + +DeviceFdirMock::DeviceFdirMock(object_id_t owner, object_id_t parent) + : DeviceHandlerFailureIsolation(owner, parent) {} + +DeviceFdirMock::~DeviceFdirMock() {} + +uint32_t DeviceFdirMock::getMissedReplyCount() { + ParameterWrapper parameterWrapper; + this->getParameter(MISSED_REPLY_DOMAIN_ID, + static_cast(FaultCounter::ParameterIds::FAULT_COUNT), + ¶meterWrapper, nullptr, 0); + uint32_t missedReplyCount = 0; + parameterWrapper.getElement(&missedReplyCount); + return missedReplyCount; +} diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.h b/tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.h new file mode 100644 index 00000000..b314fc98 --- /dev/null +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.h @@ -0,0 +1,18 @@ +#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEFDIRMOCK_H_ +#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEFDIRMOCK_H_ + +#include "fsfw/devicehandlers/DeviceHandlerFailureIsolation.h" + +class DeviceFdirMock : public DeviceHandlerFailureIsolation { + public: + DeviceFdirMock(object_id_t owner, object_id_t parent); + virtual ~DeviceFdirMock(); + + uint32_t getMissedReplyCount(); + + private: + static const uint8_t STRANGE_REPLY_DOMAIN_ID = 0xF0; + static const uint8_t MISSED_REPLY_DOMAIN_ID = 0xF1; +}; + +#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEFDIRMOCK_H_ */ From 4fba2704aa0d834cf96d2db05eee92ca960fdb9f Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 6 Jun 2022 10:53:08 +0200 Subject: [PATCH 015/532] unit test for detection of missed reply when commanded externally --- .../fsfw_tests/unit/devicehandler/ComIFMock.h | 3 ++- .../unit/devicehandler/DeviceHandlerMock.cpp | 6 ++++- .../unit/devicehandler/DeviceHandlerMock.h | 1 + .../devicehandler/TestDeviceHandlerBase.cpp | 25 +++++++++++++++++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h index 7de4937f..1463deb6 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h +++ b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h @@ -6,7 +6,8 @@ /** * @brief The ComIFMock supports the simulation of various device communication error cases - * like incomplete or wrong replies and can be used to test the DeviceHandlerBase. + * like incomplete or wrong replies and can be used to test the + * DeviceHandlerBase. */ class ComIFMock : public DeviceCommunicationIF, public SystemObject { public: diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp index ca1dff2f..88f712db 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp @@ -83,7 +83,11 @@ void DeviceHandlerMock::fillCommandAndReplyMap() { uint32_t DeviceHandlerMock::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } void DeviceHandlerMock::changePeriodicReplyCountdown(uint32_t timeout) { - periodicReplyCountdown.setTimeout(0); + periodicReplyCountdown.setTimeout(timeout); +} + +void DeviceHandlerMock::changeSimpleCommandReplyCountdown(uint32_t timeout) { + simpleCommandReplyTimeout.setTimeout(timeout); } void DeviceHandlerMock::resetPeriodicReplyState() { diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h index ac79d926..4ff0d77d 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h @@ -16,6 +16,7 @@ public: CookieIF *comCookie, FailureIsolationBase* fdirInstance); virtual ~DeviceHandlerMock(); void changePeriodicReplyCountdown(uint32_t timeout); + void changeSimpleCommandReplyCountdown(uint32_t timeout); void resetPeriodicReplyState(); bool getPeriodicReplyReceived(); diff --git a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp index 1271eb49..283a8799 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp @@ -21,7 +21,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { result = deviceHandlerCommander.initialize(); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - SECTION("Commanding") { + SECTION("Commanding nominal") { comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL); result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, DeviceHandlerMock::SIMPLE_COMMAND); @@ -36,7 +36,28 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { REQUIRE(result == HasReturnvaluesIF::RETURN_OK); } - SECTION("Periodic reply") { + SECTION("Commanding missed reply") { + comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); + deviceHandlerCommander.resetReplyReturnCode(); + // Set the timeout to 0 to immediately timeout the reply + deviceHandlerMock.changeSimpleCommandReplyCountdown(0); + result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, + DeviceHandlerMock::SIMPLE_COMMAND); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerCommander.performOperation(); + result = deviceHandlerCommander.getReplyReturnCode(); + REQUIRE(result == DeviceHandlerIF::TIMEOUT); + uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); + REQUIRE(missedReplies == 1); + } + + SECTION("Periodic reply nominal") { comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); From ae2f7219fd9d0f78fb9cb6846cedbbd159db142f Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 6 Jun 2022 11:55:42 +0200 Subject: [PATCH 016/532] run auto-formatter --- README.md | 5 +- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 7 +- src/fsfw/devicehandlers/DeviceHandlerBase.h | 6 +- src/fsfw/events/EventManager.h | 3 +- src/fsfw/events/EventManagerIF.h | 3 +- src/fsfw/fdir/FailureIsolationBase.cpp | 14 ++-- src/fsfw/fdir/FaultCounter.h | 15 ++--- src/fsfw/health/HealthHelper.cpp | 4 +- src/fsfw/health/HealthTable.cpp | 8 +-- .../unit/devicehandler/ComIFMock.cpp | 47 +++++++------ .../unit/devicehandler/CookieIFMock.cpp | 6 +- .../devicehandler/DeviceHandlerCommander.cpp | 5 +- .../devicehandler/DeviceHandlerCommander.h | 7 +- .../unit/devicehandler/DeviceHandlerMock.cpp | 30 ++++----- .../unit/devicehandler/DeviceHandlerMock.h | 63 +++++++++-------- .../devicehandler/TestDeviceHandlerBase.cpp | 67 +++++++++---------- .../unit/testcfg/objects/systemObjectList.h | 2 +- 17 files changed, 136 insertions(+), 156 deletions(-) diff --git a/README.md b/README.md index 5112230a..673b66c6 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,10 @@ and open the documentation conveniently. Try `helper.py -h for more information. The formatting is done by the `clang-format` tool. The configuration is contained within the `.clang-format` file in the repository root. As long as `clang-format` is installed, you -can run the `apply-clang-format.sh` helper script to format all source files consistently. +can run the `auto-format.sh` helper script to format all source files consistently. Furthermore cmake-format is required to format CMake files which can be installed with: +````sh +sudo pip install cmakelang +```` ## Index diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index a874824d..5eb45685 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -66,7 +66,7 @@ void DeviceHandlerBase::setThermalStateRequestPoolIds(lp_id_t thermalStatePoolId DeviceHandlerBase::~DeviceHandlerBase() { if (comCookie != nullptr) { - delete comCookie; + delete comCookie; } if (defaultFDIRUsed) { delete fdirInstance; @@ -256,7 +256,7 @@ void DeviceHandlerBase::decrementDeviceReplyMap() { missedReply(replyPair.first); timedOut = false; if (not replyPair.second.periodic) { - replyPair.second.active = false; + replyPair.second.active = false; } } } @@ -1396,8 +1396,7 @@ uint8_t DeviceHandlerBase::getReplyDelayCycles(DeviceCommandId_t deviceCommand) DeviceReplyMap::iterator iter = deviceReplyMap.find(deviceCommand); if (iter == deviceReplyMap.end()) { return 0; - } - else if (iter->second.countdown != nullptr) { + } else if (iter->second.countdown != nullptr) { return 0; } return iter->second.delayCycles; diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 1e1803e8..1945ac65 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -792,7 +792,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, DeviceCommandMap::iterator command; //! Instead of using delayCycles to specify the maximum time to wait for the device reply, it //! is also possible specify a countdown - Countdown* countdown = nullptr; + Countdown *countdown = nullptr; //! will be set to true when reply is enabled bool active = false; }; @@ -1259,13 +1259,13 @@ class DeviceHandlerBase : public DeviceHandlerIF, /** * @brief Handles disabling of replies which use a timeout to detect missed replies. */ - void disableTimeoutControlledReply(DeviceReplyInfo* info); + void disableTimeoutControlledReply(DeviceReplyInfo *info); /** * @brief Handles disabling of replies which use a number of maximum delay cycles to detect * missed replies. */ - void disableDelayCyclesControlledReply(DeviceReplyInfo* info); + void disableDelayCyclesControlledReply(DeviceReplyInfo *info); /** * Retrive data from the #IPCStore. diff --git a/src/fsfw/events/EventManager.h b/src/fsfw/events/EventManager.h index 77d657e8..70245f5d 100644 --- a/src/fsfw/events/EventManager.h +++ b/src/fsfw/events/EventManager.h @@ -37,8 +37,7 @@ class EventManager : public EventManagerIF, public ExecutableObjectIF, public Sy EventId_t idTo = 0, bool idInverted = false, object_id_t reporterFrom = 0, object_id_t reporterTo = 0, bool reporterInverted = false); - ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, - object_id_t object); + ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, object_id_t object); ReturnValue_t unsubscribeFromEventRange(MessageQueueId_t listener, EventId_t idFrom = 0, EventId_t idTo = 0, bool idInverted = false, object_id_t reporterFrom = 0, object_id_t reporterTo = 0, diff --git a/src/fsfw/events/EventManagerIF.h b/src/fsfw/events/EventManagerIF.h index 893f86f1..adb61f2b 100644 --- a/src/fsfw/events/EventManagerIF.h +++ b/src/fsfw/events/EventManagerIF.h @@ -20,8 +20,7 @@ class EventManagerIF { bool forwardAllButSelected = false) = 0; virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event) = 0; virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener, object_id_t object) = 0; - virtual ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, - object_id_t object) = 0; + virtual ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, object_id_t object) = 0; virtual ReturnValue_t subscribeToEventRange(MessageQueueId_t listener, EventId_t idFrom = 0, EventId_t idTo = 0, bool idInverted = false, object_id_t reporterFrom = 0, diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index da17d783..3e6d5dcf 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -15,16 +15,16 @@ FailureIsolationBase::FailureIsolationBase(object_id_t owner, object_id_t parent FailureIsolationBase::~FailureIsolationBase() { EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); - if (manager == nullptr) { + if (manager == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "FailureIsolationBase::~FailureIsolationBase: Event Manager has not" - " been initialized!" - << std::endl; + sif::error << "FailureIsolationBase::~FailureIsolationBase: Event Manager has not" + " been initialized!" + << std::endl; #endif - return; - } + return; + } manager->unsubscribeFromAllEvents(eventQueue->getId(), ownerId); - QueueFactory::instance()->deleteMessageQueue(eventQueue); + QueueFactory::instance()->deleteMessageQueue(eventQueue); } ReturnValue_t FailureIsolationBase::initialize() { diff --git a/src/fsfw/fdir/FaultCounter.h b/src/fsfw/fdir/FaultCounter.h index c5630da9..cca780d6 100644 --- a/src/fsfw/fdir/FaultCounter.h +++ b/src/fsfw/fdir/FaultCounter.h @@ -6,12 +6,7 @@ class FaultCounter : public HasParametersIF { public: - - enum class ParameterIds { - FAILURE_THRESHOLD, - FAULT_COUNT, - TIMEOUT - }; + enum class ParameterIds { FAILURE_THRESHOLD, FAULT_COUNT, TIMEOUT }; FaultCounter(); FaultCounter(uint32_t failureThreshold, uint32_t decrementAfterMs, @@ -30,10 +25,10 @@ class FaultCounter : public HasParametersIF { void setFailureThreshold(uint32_t failureThreshold); void setFaultDecrementTimeMs(uint32_t timeMs); - virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, - ParameterWrapper *parameterWrapper, - const ParameterWrapper *newValues = nullptr, uint16_t startAtIndex = - 0); + virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, + ParameterWrapper *parameterWrapper, + const ParameterWrapper *newValues = nullptr, + uint16_t startAtIndex = 0); void setParameterDomain(uint8_t domain); diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index b9884115..0f51ddeb 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -5,9 +5,7 @@ HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId) : objectId(objectId), owner(owner) {} -HealthHelper::~HealthHelper() { - healthTable->removeObject(objectId); -} +HealthHelper::~HealthHelper() { healthTable->removeObject(objectId); } ReturnValue_t HealthHelper::handleHealthCommand(CommandMessage* message) { switch (message->getCommand()) { diff --git a/src/fsfw/health/HealthTable.cpp b/src/fsfw/health/HealthTable.cpp index ee8fcd94..f4bda1c3 100644 --- a/src/fsfw/health/HealthTable.cpp +++ b/src/fsfw/health/HealthTable.cpp @@ -28,10 +28,10 @@ ReturnValue_t HealthTable::registerObject(object_id_t object, } ReturnValue_t HealthTable::removeObject(object_id_t object) { - mapIterator = healthMap.find(object); - if (mapIterator == healthMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; - } + mapIterator = healthMap.find(object); + if (mapIterator == healthMap.end()) { + return HasReturnvaluesIF::RETURN_FAILED; + } healthMap.erase(mapIterator); return HasReturnvaluesIF::RETURN_OK; } diff --git a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp index 4dd64c1a..4d985f94 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp @@ -1,7 +1,8 @@ #include "ComIFMock.h" + #include "DeviceHandlerMock.h" -ComIFMock::ComIFMock(object_id_t objectId) : SystemObject(objectId){} +ComIFMock::ComIFMock(object_id_t objectId) : SystemObject(objectId) {} ComIFMock::~ComIFMock() {} @@ -19,29 +20,27 @@ ReturnValue_t ComIFMock::requestReceiveMessage(CookieIF *cookie, size_t requestL } ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { - switch(testCase) { - case TestCase::MISSED_REPLY: { - *size = 0; - return RETURN_OK; - } - case TestCase::SIMPLE_COMMAND_NOMINAL: { - *size = 1; - data = DeviceHandlerMock::SIMPLE_COMMAND_DATA; - *buffer = &data; - break; - } - case TestCase::PERIODIC_REPLY_NOMINAL: { - *size = 1; - data = DeviceHandlerMock::PERIODIC_REPLY_DATA; - *buffer = &data; - break; - } - default: - break; - } + switch (testCase) { + case TestCase::MISSED_REPLY: { + *size = 0; + return RETURN_OK; + } + case TestCase::SIMPLE_COMMAND_NOMINAL: { + *size = 1; + data = DeviceHandlerMock::SIMPLE_COMMAND_DATA; + *buffer = &data; + break; + } + case TestCase::PERIODIC_REPLY_NOMINAL: { + *size = 1; + data = DeviceHandlerMock::PERIODIC_REPLY_DATA; + *buffer = &data; + break; + } + default: + break; + } return RETURN_OK; } -void ComIFMock::setTestCase(TestCase testCase_) { - testCase = testCase_; -} +void ComIFMock::setTestCase(TestCase testCase_) { testCase = testCase_; } diff --git a/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp index f73c1731..e9b03a6c 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp @@ -1,7 +1,5 @@ #include "CookieIFMock.h" -CookieIFMock::CookieIFMock() { -} +CookieIFMock::CookieIFMock() {} -CookieIFMock::~CookieIFMock() { -} +CookieIFMock::~CookieIFMock() {} diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp index b3889b2c..4540a388 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp @@ -1,4 +1,5 @@ #include "DeviceHandlerCommander.h" + #include DeviceHandlerCommander::DeviceHandlerCommander(object_id_t objectId) @@ -60,6 +61,4 @@ ReturnValue_t DeviceHandlerCommander::sendCommand(object_id_t target, ActionId_t ReturnValue_t DeviceHandlerCommander::getReplyReturnCode() { return lastReplyReturnCode; } -void DeviceHandlerCommander::resetReplyReturnCode() { - lastReplyReturnCode = RETURN_FAILED; -} +void DeviceHandlerCommander::resetReplyReturnCode() { lastReplyReturnCode = RETURN_FAILED; } diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h index 77168043..82183baf 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h @@ -1,16 +1,16 @@ #ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ #define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ -#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/CommandsActionsIF.h" -#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" class DeviceHandlerCommander : public ExecutableObjectIF, public SystemObject, public CommandsActionsIF, - public HasReturnvaluesIF { + public HasReturnvaluesIF { public: DeviceHandlerCommander(object_id_t objectId); virtual ~DeviceHandlerCommander(); @@ -36,7 +36,6 @@ class DeviceHandlerCommander : public ExecutableObjectIF, void resetReplyReturnCode(); private: - static const uint32_t QUEUE_SIZE = 20; MessageQueueIF* commandQueue = nullptr; diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp index 88f712db..7350d579 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp @@ -42,13 +42,13 @@ ReturnValue_t DeviceHandlerMock::buildCommandFromCommand(DeviceCommandId_t devic ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, size_t *foundLen) { switch (*start) { - case SIMPLE_COMMAND_DATA: { - *foundId = SIMPLE_COMMAND; - *foundLen = sizeof(SIMPLE_COMMAND_DATA); - return RETURN_OK; - break; - } - case PERIODIC_REPLY_DATA: { + case SIMPLE_COMMAND_DATA: { + *foundId = SIMPLE_COMMAND; + *foundLen = sizeof(SIMPLE_COMMAND_DATA); + return RETURN_OK; + break; + } + case PERIODIC_REPLY_DATA: { *foundId = PERIODIC_REPLY; *foundLen = sizeof(PERIODIC_REPLY_DATA); return RETURN_OK; @@ -64,7 +64,7 @@ ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, cons switch (id) { case SIMPLE_COMMAND: case PERIODIC_REPLY: { - periodicReplyReceived = true; + periodicReplyReceived = true; break; } default: @@ -74,9 +74,9 @@ ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, cons } void DeviceHandlerMock::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(SIMPLE_COMMAND, 0, nullptr, 0, false, false, 0, - &simpleCommandReplyTimeout); - insertInCommandAndReplyMap(PERIODIC_REPLY, 0, nullptr, 0, true, false, 0, + insertInCommandAndReplyMap(SIMPLE_COMMAND, 0, nullptr, 0, false, false, 0, + &simpleCommandReplyTimeout); + insertInCommandAndReplyMap(PERIODIC_REPLY, 0, nullptr, 0, true, false, 0, &periodicReplyCountdown); } @@ -90,10 +90,6 @@ void DeviceHandlerMock::changeSimpleCommandReplyCountdown(uint32_t timeout) { simpleCommandReplyTimeout.setTimeout(timeout); } -void DeviceHandlerMock::resetPeriodicReplyState() { - periodicReplyReceived = false; -} +void DeviceHandlerMock::resetPeriodicReplyState() { periodicReplyReceived = false; } -bool DeviceHandlerMock::getPeriodicReplyReceived() { - return periodicReplyReceived; -} +bool DeviceHandlerMock::getPeriodicReplyReceived() { return periodicReplyReceived; } diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h index 4ff0d77d..95d0fdbb 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h @@ -3,45 +3,42 @@ #include -class DeviceHandlerMock: public DeviceHandlerBase { -public: +class DeviceHandlerMock : public DeviceHandlerBase { + public: + static const DeviceCommandId_t SIMPLE_COMMAND = 1; + static const DeviceCommandId_t PERIODIC_REPLY = 2; - static const DeviceCommandId_t SIMPLE_COMMAND = 1; - static const DeviceCommandId_t PERIODIC_REPLY = 2; + static const uint8_t SIMPLE_COMMAND_DATA = 1; + static const uint8_t PERIODIC_REPLY_DATA = 2; - static const uint8_t SIMPLE_COMMAND_DATA = 1; - static const uint8_t PERIODIC_REPLY_DATA = 2; + DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, + FailureIsolationBase *fdirInstance); + virtual ~DeviceHandlerMock(); + void changePeriodicReplyCountdown(uint32_t timeout); + void changeSimpleCommandReplyCountdown(uint32_t timeout); + void resetPeriodicReplyState(); + bool getPeriodicReplyReceived(); - DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, - CookieIF *comCookie, FailureIsolationBase* fdirInstance); - virtual ~DeviceHandlerMock(); - void changePeriodicReplyCountdown(uint32_t timeout); - void changeSimpleCommandReplyCountdown(uint32_t timeout); - void resetPeriodicReplyState(); - bool getPeriodicReplyReceived(); + protected: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; -protected: - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t len, - DeviceCommandId_t *foundId, size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) override; - void fillCommandAndReplyMap() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + private: + Countdown simpleCommandReplyTimeout = Countdown(50); + Countdown periodicReplyCountdown = Countdown(10); -private: + uint8_t commandBuffer[1]; - Countdown simpleCommandReplyTimeout = Countdown(50); - Countdown periodicReplyCountdown = Countdown(10); - - uint8_t commandBuffer[1]; - - bool periodicReplyReceived = false; + bool periodicReplyReceived = false; }; #endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ */ diff --git a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp index 283a8799..9a20f1a8 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp @@ -8,21 +8,20 @@ #include "fsfw_tests/unit/testcfg/objects/systemObjectList.h" TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { - - // Will be deleted with DHB destructor - CookieIFMock* cookieIFMock = new CookieIFMock; - ComIFMock comIF(objects::COM_IF_MOCK); - DeviceFdirMock deviceFdirMock(objects::DEVICE_HANDLER_MOCK, objects::NO_OBJECT); - DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK, - cookieIFMock, &deviceFdirMock); - ReturnValue_t result = deviceHandlerMock.initialize(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER); - result = deviceHandlerCommander.initialize(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + // Will be deleted with DHB destructor + CookieIFMock* cookieIFMock = new CookieIFMock; + ComIFMock comIF(objects::COM_IF_MOCK); + DeviceFdirMock deviceFdirMock(objects::DEVICE_HANDLER_MOCK, objects::NO_OBJECT); + DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK, + cookieIFMock, &deviceFdirMock); + ReturnValue_t result = deviceHandlerMock.initialize(); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER); + result = deviceHandlerCommander.initialize(); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); SECTION("Commanding nominal") { - comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL); + comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL); result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, DeviceHandlerMock::SIMPLE_COMMAND); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); @@ -37,28 +36,28 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { } SECTION("Commanding missed reply") { - comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); - deviceHandlerCommander.resetReplyReturnCode(); - // Set the timeout to 0 to immediately timeout the reply - deviceHandlerMock.changeSimpleCommandReplyCountdown(0); - result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, - DeviceHandlerMock::SIMPLE_COMMAND); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); - deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); - deviceHandlerCommander.performOperation(); - result = deviceHandlerCommander.getReplyReturnCode(); - REQUIRE(result == DeviceHandlerIF::TIMEOUT); - uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); - REQUIRE(missedReplies == 1); - } + comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); + deviceHandlerCommander.resetReplyReturnCode(); + // Set the timeout to 0 to immediately timeout the reply + deviceHandlerMock.changeSimpleCommandReplyCountdown(0); + result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, + DeviceHandlerMock::SIMPLE_COMMAND); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerCommander.performOperation(); + result = deviceHandlerCommander.getReplyReturnCode(); + REQUIRE(result == DeviceHandlerIF::TIMEOUT); + uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); + REQUIRE(missedReplies == 1); + } SECTION("Periodic reply nominal") { - comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL); + comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); @@ -68,7 +67,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { } SECTION("Missed periodic reply") { - comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); + comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); // Set the timeout to 0 to immediately timeout the reply deviceHandlerMock.changePeriodicReplyCountdown(0); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); diff --git a/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h b/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h index 6f40da3c..17b980e9 100644 --- a/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h +++ b/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h @@ -31,4 +31,4 @@ enum sourceObjects : uint32_t { }; } -#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ +#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ From 103661faccd8cd505b2ca179dc1999b05ec2a933 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 6 Jun 2022 12:26:00 +0200 Subject: [PATCH 017/532] deugging --- .../devicehandler/TestDeviceHandlerBase.cpp | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp index 9a20f1a8..5ced746b 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp @@ -35,26 +35,26 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { REQUIRE(result == HasReturnvaluesIF::RETURN_OK); } - SECTION("Commanding missed reply") { - comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); - deviceHandlerCommander.resetReplyReturnCode(); - // Set the timeout to 0 to immediately timeout the reply - deviceHandlerMock.changeSimpleCommandReplyCountdown(0); - result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, - DeviceHandlerMock::SIMPLE_COMMAND); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); - deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); - deviceHandlerCommander.performOperation(); - result = deviceHandlerCommander.getReplyReturnCode(); - REQUIRE(result == DeviceHandlerIF::TIMEOUT); - uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); - REQUIRE(missedReplies == 1); - } +// SECTION("Commanding missed reply") { +// comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); +// deviceHandlerCommander.resetReplyReturnCode(); +// // Set the timeout to 0 to immediately timeout the reply +// deviceHandlerMock.changeSimpleCommandReplyCountdown(0); +// result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, +// DeviceHandlerMock::SIMPLE_COMMAND); +// REQUIRE(result == HasReturnvaluesIF::RETURN_OK); +// deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); +// deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); +// deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); +// deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); +// deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); +// deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); +// deviceHandlerCommander.performOperation(); +// result = deviceHandlerCommander.getReplyReturnCode(); +// REQUIRE(result == DeviceHandlerIF::TIMEOUT); +// uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); +// REQUIRE(missedReplies == 1); +// } SECTION("Periodic reply nominal") { comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL); From ade36e65c6a1026ad9b2dff838622fc439856a57 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 6 Jun 2022 12:30:27 +0200 Subject: [PATCH 018/532] missed reply check in simple command nominal test case --- .../devicehandler/TestDeviceHandlerBase.cpp | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp index 5ced746b..dd9e9ca5 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp @@ -32,29 +32,31 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); deviceHandlerCommander.performOperation(); result = deviceHandlerCommander.getReplyReturnCode(); + uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); + REQUIRE(missedReplies == 0); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); } -// SECTION("Commanding missed reply") { -// comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); -// deviceHandlerCommander.resetReplyReturnCode(); -// // Set the timeout to 0 to immediately timeout the reply -// deviceHandlerMock.changeSimpleCommandReplyCountdown(0); -// result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, -// DeviceHandlerMock::SIMPLE_COMMAND); -// REQUIRE(result == HasReturnvaluesIF::RETURN_OK); -// deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); -// deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); -// deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); -// deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); -// deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); -// deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); -// deviceHandlerCommander.performOperation(); -// result = deviceHandlerCommander.getReplyReturnCode(); -// REQUIRE(result == DeviceHandlerIF::TIMEOUT); -// uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); -// REQUIRE(missedReplies == 1); -// } + SECTION("Commanding missed reply") { + comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); + deviceHandlerCommander.resetReplyReturnCode(); + // Set the timeout to 0 to immediately timeout the reply + deviceHandlerMock.changeSimpleCommandReplyCountdown(0); + result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, + DeviceHandlerMock::SIMPLE_COMMAND); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerCommander.performOperation(); + result = deviceHandlerCommander.getReplyReturnCode(); + REQUIRE(result == DeviceHandlerIF::TIMEOUT); + uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); + REQUIRE(missedReplies == 1); + } SECTION("Periodic reply nominal") { comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL); From 21eb386f3cae3b0e05a7731382069a3a8d2663fd Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 6 Jun 2022 12:34:57 +0200 Subject: [PATCH 019/532] changed reply timeouts --- tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h index 95d0fdbb..1ab1d90b 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h @@ -33,8 +33,8 @@ class DeviceHandlerMock : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; private: - Countdown simpleCommandReplyTimeout = Countdown(50); - Countdown periodicReplyCountdown = Countdown(10); + Countdown simpleCommandReplyTimeout = Countdown(1000); + Countdown periodicReplyCountdown = Countdown(1000); uint8_t commandBuffer[1]; From 2d2f65bf89d02f8605e3471063bfd4ab5e53c39d Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 23 Jun 2022 11:54:51 +0200 Subject: [PATCH 020/532] moved activation of periodic replies to updatePeriodicReply --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 7 ++++--- .../unit/devicehandler/DeviceHandlerMock.cpp | 8 ++++++++ .../unit/devicehandler/DeviceHandlerMock.h | 2 ++ .../unit/devicehandler/TestDeviceHandlerBase.cpp | 12 ++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 5eb45685..f3cfcee4 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -446,9 +446,6 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, info.dataSet = dataSet; info.command = deviceCommandMap.end(); info.countdown = countdown; - if (info.periodic) { - info.active = true; - } auto resultPair = deviceReplyMap.emplace(replyId, info); if (resultPair.second) { return RETURN_OK; @@ -522,8 +519,10 @@ ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandI } if (enable) { info->delayCycles = info->maxDelayCycles; + info->active = true; } else { info->delayCycles = 0; + info->active = false; } } return HasReturnvaluesIF::RETURN_OK; @@ -999,6 +998,8 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(DeviceCommandMap::iterato } if (iter != deviceReplyMap.end()) { DeviceReplyInfo* info = &(iter->second); + // If a countdown has been set, the delay cycles will be ignored and the reply times out + // as soon as the countdown has expired info->delayCycles = info->maxDelayCycles; info->command = command; command->second.expectedReplies = expectedReplies; diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp index 7350d579..a17da98b 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp @@ -93,3 +93,11 @@ void DeviceHandlerMock::changeSimpleCommandReplyCountdown(uint32_t timeout) { void DeviceHandlerMock::resetPeriodicReplyState() { periodicReplyReceived = false; } bool DeviceHandlerMock::getPeriodicReplyReceived() { return periodicReplyReceived; } + +ReturnValue_t DeviceHandlerMock::enablePeriodicReply(DeviceCommandId_t replyId) { + return updatePeriodicReply(true, replyId); +} + +ReturnValue_t DeviceHandlerMock::disablePeriodicReply(DeviceCommandId_t replyId) { + return updatePeriodicReply(false, replyId); +} diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h index 1ab1d90b..f5fcb4aa 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h @@ -18,6 +18,8 @@ class DeviceHandlerMock : public DeviceHandlerBase { void changeSimpleCommandReplyCountdown(uint32_t timeout); void resetPeriodicReplyState(); bool getPeriodicReplyReceived(); + ReturnValue_t enablePeriodicReply(DeviceCommandId_t replyId); + ReturnValue_t disablePeriodicReply(DeviceCommandId_t replyId); protected: void doStartUp() override; diff --git a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp index dd9e9ca5..99d3816f 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp @@ -60,6 +60,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { SECTION("Periodic reply nominal") { comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL); + deviceHandlerMock.enablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); @@ -72,6 +73,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); // Set the timeout to 0 to immediately timeout the reply deviceHandlerMock.changePeriodicReplyCountdown(0); + deviceHandlerMock.enablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); @@ -79,5 +81,15 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); REQUIRE(missedReplies == 1); + // Test if disabling of periodic reply + deviceHandlerMock.disablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + missedReplies = deviceFdirMock.getMissedReplyCount(); + // Should still be 1 because periodic reply is now disabled + REQUIRE(missedReplies == 1); } } From df97bbc6913a7501f80fab893586e7564abb3678 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 23 Jun 2022 11:56:46 +0200 Subject: [PATCH 021/532] run auto-formatter --- src/fsfw/datapoollocal/LocalDataPoolManager.cpp | 3 ++- src/fsfw/osal/linux/FixedTimeslotTask.cpp | 2 +- .../unit/devicehandler/DeviceHandlerMock.cpp | 4 ++-- .../unit/devicehandler/TestDeviceHandlerBase.cpp | 16 ++++++++-------- .../fsfw_tests/unit/hal/testCommandExecutor.cpp | 2 +- .../unit/storagemanager/TestNewAccessor.cpp | 10 +++++----- .../fsfw_tests/unit/storagemanager/TestPool.cpp | 2 +- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 215d1753..9b7f800f 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -696,7 +696,8 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { if (result != HasReturnvaluesIF::RETURN_OK) { /* Configuration error */ #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalDataPoolManager::performPeriodicHkOperation: HK generation failed." << std::endl; + sif::warning << "LocalDataPoolManager::performPeriodicHkOperation: HK generation failed." + << std::endl; #else sif::printWarning("LocalDataPoolManager::performPeriodicHkOperation: HK generation failed.\n"); #endif diff --git a/src/fsfw/osal/linux/FixedTimeslotTask.cpp b/src/fsfw/osal/linux/FixedTimeslotTask.cpp index 775acea8..156413ea 100644 --- a/src/fsfw/osal/linux/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/linux/FixedTimeslotTask.cpp @@ -54,7 +54,7 @@ ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) { // If the deadline was missed, the deadlineMissedFunc is called. if (!PosixThread::delayUntil(&lastWakeTime, interval)) { // No time left on timer -> we missed the deadline - if(dlmFunc != nullptr){ + if (dlmFunc != nullptr) { dlmFunc(); } } diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp index a17da98b..1e05f8f3 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp @@ -95,9 +95,9 @@ void DeviceHandlerMock::resetPeriodicReplyState() { periodicReplyReceived = fals bool DeviceHandlerMock::getPeriodicReplyReceived() { return periodicReplyReceived; } ReturnValue_t DeviceHandlerMock::enablePeriodicReply(DeviceCommandId_t replyId) { - return updatePeriodicReply(true, replyId); + return updatePeriodicReply(true, replyId); } ReturnValue_t DeviceHandlerMock::disablePeriodicReply(DeviceCommandId_t replyId) { - return updatePeriodicReply(false, replyId); + return updatePeriodicReply(false, replyId); } diff --git a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp index 99d3816f..873329c3 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp +++ b/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp @@ -33,7 +33,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { deviceHandlerCommander.performOperation(); result = deviceHandlerCommander.getReplyReturnCode(); uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); - REQUIRE(missedReplies == 0); + REQUIRE(missedReplies == 0); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); } @@ -84,12 +84,12 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { // Test if disabling of periodic reply deviceHandlerMock.disablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); - missedReplies = deviceFdirMock.getMissedReplyCount(); - // Should still be 1 because periodic reply is now disabled - REQUIRE(missedReplies == 1); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + missedReplies = deviceFdirMock.getMissedReplyCount(); + // Should still be 1 because periodic reply is now disabled + REQUIRE(missedReplies == 1); } } diff --git a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp index 09d31280..d34f67aa 100644 --- a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp +++ b/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp @@ -4,12 +4,12 @@ #include #include -#include "tests/TestsConfig.h" #include "fsfw/container/DynamicFIFO.h" #include "fsfw/container/SimpleRingBuffer.h" #include "fsfw/platform.h" #include "fsfw/serviceinterface.h" #include "fsfw_hal/linux/CommandExecutor.h" +#include "tests/TestsConfig.h" #ifdef PLATFORM_UNIX diff --git a/tests/src/fsfw_tests/unit/storagemanager/TestNewAccessor.cpp b/tests/src/fsfw_tests/unit/storagemanager/TestNewAccessor.cpp index 9631de38..7b90c86e 100644 --- a/tests/src/fsfw_tests/unit/storagemanager/TestNewAccessor.cpp +++ b/tests/src/fsfw_tests/unit/storagemanager/TestNewAccessor.cpp @@ -157,7 +157,7 @@ TEST_CASE("New Accessor", "[NewAccessor]") { } } - SECTION("Operators"){ + SECTION("Operators") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); REQUIRE(result == retval::CATCH_OK); { @@ -173,13 +173,13 @@ TEST_CASE("New Accessor", "[NewAccessor]") { REQUIRE(result == HasReturnvaluesIF::RETURN_OK); CHECK(accessor2.getId() == testStoreId); CHECK(accessor2.size() == 10); - + std::array newData; // Expect data to be invalid so this must return RETURN_FAILED - result = accessor.getDataCopy(newData.data(),newData.size()); + result = accessor.getDataCopy(newData.data(), newData.size()); REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); - // Expect data to be too small - result = accessor2.getDataCopy(data.data(),data.size()); + // Expect data to be too small + result = accessor2.getDataCopy(data.data(), data.size()); REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); } } diff --git a/tests/src/fsfw_tests/unit/storagemanager/TestPool.cpp b/tests/src/fsfw_tests/unit/storagemanager/TestPool.cpp index ce1f8518..51130047 100644 --- a/tests/src/fsfw_tests/unit/storagemanager/TestPool.cpp +++ b/tests/src/fsfw_tests/unit/storagemanager/TestPool.cpp @@ -1,9 +1,9 @@ #include #include +#include #include #include -#include #include "fsfw_tests/unit/CatchDefinitions.h" From 7de56f189b51830c799b5d92ef87bb1c74aff281 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Jul 2022 10:13:48 +0200 Subject: [PATCH 022/532] install etl library in ci/cd --- automation/Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/automation/Dockerfile b/automation/Dockerfile index 0eb98fbb..2ed2a7d9 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -12,3 +12,9 @@ RUN git clone https://github.com/catchorg/Catch2.git && \ git checkout v3.0.0-preview5 && \ cmake -Bbuild -H. -DBUILD_TESTING=OFF && \ cmake --build build/ --target install + +RUN git clone https://github.com/ETLCPP/etl.git && \ + cd etl && \ + git checkout 20.28.0 && \ + cmake -B build . && \ + cmake --install build/ From 5cccd5caba2f1cae3510c350bc9edf8cc021d019 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Jul 2022 10:21:47 +0200 Subject: [PATCH 023/532] bump used container --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 798b6b1a..7101958e 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { BUILDDIR = 'build-tests' } agent { - docker { image 'fsfw-ci:d2'} + docker { image 'fsfw-ci:d3'} } stages { stage('Clean') { From 5a9db72814c7f085f91e40cec76e0831e1cd3e84 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Jul 2022 10:27:14 +0200 Subject: [PATCH 024/532] test public linkage --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8163f3e..e9e3e471 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,7 @@ endif() set(FSFW_SOURCES_DIR "${CMAKE_SOURCE_DIR}/src/fsfw") set(FSFW_ETL_LIB_NAME etl) +set(FSFW_ETL_LINK_TARGET etl::etl) set(FSFW_ETL_LIB_MAJOR_VERSION 20 CACHE STRING "ETL library major version requirement") @@ -447,8 +448,8 @@ target_include_directories( target_compile_options(${LIB_FSFW_NAME} PRIVATE ${FSFW_WARNING_FLAGS} ${COMPILER_FLAGS}) -target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ETL_LINK_TARGET} - ${FSFW_ADDITIONAL_LINK_LIBS}) +target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ADDITIONAL_LINK_LIBS}) +target_link_libraries(${LIB_FSFW_NAME} PUBLIC ${FSFW_ETL_LINK_TARGET}) string( CONCAT From fef6ddceff2185cea943e874d11a15e2dfaab6a3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Jul 2022 11:16:13 +0200 Subject: [PATCH 025/532] delete run configs --- .run/fsfw-tests_coverage.run.xml | 7 ------- .run/fsfw.run.xml | 7 ------- 2 files changed, 14 deletions(-) delete mode 100644 .run/fsfw-tests_coverage.run.xml delete mode 100644 .run/fsfw.run.xml diff --git a/.run/fsfw-tests_coverage.run.xml b/.run/fsfw-tests_coverage.run.xml deleted file mode 100644 index 49d9b135..00000000 --- a/.run/fsfw-tests_coverage.run.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.run/fsfw.run.xml b/.run/fsfw.run.xml deleted file mode 100644 index 72f74939..00000000 --- a/.run/fsfw.run.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file From 3bef73708f9bbee845fe439775af9f56e580658d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Jul 2022 11:44:26 +0200 Subject: [PATCH 026/532] clang-tidy changes for actions module --- src/fsfw/action/ActionHelper.cpp | 4 ++-- src/fsfw/action/ActionHelper.h | 4 ++-- src/fsfw/action/ActionMessage.cpp | 9 ++++----- src/fsfw/action/CommandActionHelper.cpp | 21 +++++++++------------ src/fsfw/action/CommandActionHelper.h | 4 ++-- src/fsfw/action/CommandsActionsIF.h | 6 +++--- src/fsfw/action/HasActionsIF.h | 8 ++++---- src/fsfw/action/SimpleActionHelper.cpp | 4 ++-- src/fsfw/action/SimpleActionHelper.h | 8 ++++---- 9 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/fsfw/action/ActionHelper.cpp b/src/fsfw/action/ActionHelper.cpp index d41c78b4..bee68b40 100644 --- a/src/fsfw/action/ActionHelper.cpp +++ b/src/fsfw/action/ActionHelper.cpp @@ -6,7 +6,7 @@ ActionHelper::ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue) : owner(setOwner), queueToUse(useThisQueue) {} -ActionHelper::~ActionHelper() {} +ActionHelper::~ActionHelper() = default; ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) { if (command->getCommand() == ActionMessage::EXECUTE_ACTION) { @@ -59,7 +59,7 @@ void ActionHelper::setQueueToUse(MessageQueueIF* queue) { queueToUse = queue; } void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId, store_address_t dataAddress) { - const uint8_t* dataPtr = NULL; + const uint8_t* dataPtr = nullptr; size_t size = 0; ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/src/fsfw/action/ActionHelper.h b/src/fsfw/action/ActionHelper.h index d86e87d2..a9910b05 100644 --- a/src/fsfw/action/ActionHelper.h +++ b/src/fsfw/action/ActionHelper.h @@ -1,9 +1,9 @@ #ifndef FSFW_ACTION_ACTIONHELPER_H_ #define FSFW_ACTION_ACTIONHELPER_H_ -#include "../ipc/MessageQueueIF.h" -#include "../serialize/SerializeIF.h" #include "ActionMessage.h" +#include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/serialize/SerializeIF.h" /** * @brief Action Helper is a helper class which handles action messages * diff --git a/src/fsfw/action/ActionMessage.cpp b/src/fsfw/action/ActionMessage.cpp index 40a516b1..7fc68558 100644 --- a/src/fsfw/action/ActionMessage.cpp +++ b/src/fsfw/action/ActionMessage.cpp @@ -2,9 +2,9 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/storagemanager/StorageManagerIF.h" -ActionMessage::ActionMessage() {} +ActionMessage::ActionMessage() = default; -ActionMessage::~ActionMessage() {} +ActionMessage::~ActionMessage() = default; void ActionMessage::setCommand(CommandMessage* message, ActionId_t fid, store_address_t parameters) { @@ -64,9 +64,8 @@ void ActionMessage::clear(CommandMessage* message) { switch (message->getCommand()) { case EXECUTE_ACTION: case DATA_REPLY: { - StorageManagerIF* ipcStore = - ObjectManager::instance()->get(objects::IPC_STORE); - if (ipcStore != NULL) { + auto* ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); + if (ipcStore != nullptr) { ipcStore->deleteData(getStoreId(message)); } break; diff --git a/src/fsfw/action/CommandActionHelper.cpp b/src/fsfw/action/CommandActionHelper.cpp index 19d8e9b8..a06bc44c 100644 --- a/src/fsfw/action/CommandActionHelper.cpp +++ b/src/fsfw/action/CommandActionHelper.cpp @@ -2,14 +2,14 @@ #include "fsfw/objectmanager/ObjectManager.h" CommandActionHelper::CommandActionHelper(CommandsActionsIF *setOwner) - : owner(setOwner), queueToUse(NULL), ipcStore(NULL), commandCount(0), lastTarget(0) {} + : owner(setOwner), queueToUse(nullptr), ipcStore(nullptr), commandCount(0), lastTarget(0) {} -CommandActionHelper::~CommandActionHelper() {} +CommandActionHelper::~CommandActionHelper() = default; ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId_t actionId, SerializeIF *data) { - HasActionsIF *receiver = ObjectManager::instance()->get(commandTo); - if (receiver == NULL) { + auto *receiver = ObjectManager::instance()->get(commandTo); + if (receiver == nullptr) { return CommandsActionsIF::OBJECT_HAS_NO_FUNCTIONS; } store_address_t storeId; @@ -29,11 +29,8 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId_t actionId, const uint8_t *data, uint32_t size) { - // if (commandCount != 0) { - // return CommandsFunctionsIF::ALREADY_COMMANDING; - // } - HasActionsIF *receiver = ObjectManager::instance()->get(commandTo); - if (receiver == NULL) { + auto *receiver = ObjectManager::instance()->get(commandTo); + if (receiver == nullptr) { return CommandsActionsIF::OBJECT_HAS_NO_FUNCTIONS; } store_address_t storeId; @@ -59,12 +56,12 @@ ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId, ActionI ReturnValue_t CommandActionHelper::initialize() { ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); - if (ipcStore == NULL) { + if (ipcStore == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } queueToUse = owner->getCommandQueuePtr(); - if (queueToUse == NULL) { + if (queueToUse == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; @@ -104,7 +101,7 @@ ReturnValue_t CommandActionHelper::handleReply(CommandMessage *reply) { uint8_t CommandActionHelper::getCommandCount() const { return commandCount; } void CommandActionHelper::extractDataForOwner(ActionId_t actionId, store_address_t storeId) { - const uint8_t *data = NULL; + const uint8_t *data = nullptr; size_t size = 0; ReturnValue_t result = ipcStore->getData(storeId, &data, &size); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/src/fsfw/action/CommandActionHelper.h b/src/fsfw/action/CommandActionHelper.h index dd8ad7f1..a6ec0ca7 100644 --- a/src/fsfw/action/CommandActionHelper.h +++ b/src/fsfw/action/CommandActionHelper.h @@ -14,14 +14,14 @@ class CommandActionHelper { friend class CommandsActionsIF; public: - CommandActionHelper(CommandsActionsIF* owner); + explicit CommandActionHelper(CommandsActionsIF* owner); virtual ~CommandActionHelper(); ReturnValue_t commandAction(object_id_t commandTo, ActionId_t actionId, const uint8_t* data, uint32_t size); ReturnValue_t commandAction(object_id_t commandTo, ActionId_t actionId, SerializeIF* data); ReturnValue_t initialize(); ReturnValue_t handleReply(CommandMessage* reply); - uint8_t getCommandCount() const; + [[nodiscard]] uint8_t getCommandCount() const; private: CommandsActionsIF* owner; diff --git a/src/fsfw/action/CommandsActionsIF.h b/src/fsfw/action/CommandsActionsIF.h index 5870a9f2..94d9a7c4 100644 --- a/src/fsfw/action/CommandsActionsIF.h +++ b/src/fsfw/action/CommandsActionsIF.h @@ -1,9 +1,9 @@ #ifndef FSFW_ACTION_COMMANDSACTIONSIF_H_ #define FSFW_ACTION_COMMANDSACTIONSIF_H_ -#include "../ipc/MessageQueueIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" #include "CommandActionHelper.h" +#include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" /** * Interface to separate commanding actions of other objects. @@ -21,7 +21,7 @@ class CommandsActionsIF { static const uint8_t INTERFACE_ID = CLASS_ID::COMMANDS_ACTIONS_IF; static const ReturnValue_t OBJECT_HAS_NO_FUNCTIONS = MAKE_RETURN_CODE(1); static const ReturnValue_t ALREADY_COMMANDING = MAKE_RETURN_CODE(2); - virtual ~CommandsActionsIF() {} + virtual ~CommandsActionsIF() = default; virtual MessageQueueIF* getCommandQueuePtr() = 0; protected: diff --git a/src/fsfw/action/HasActionsIF.h b/src/fsfw/action/HasActionsIF.h index acc502d7..89e58add 100644 --- a/src/fsfw/action/HasActionsIF.h +++ b/src/fsfw/action/HasActionsIF.h @@ -1,11 +1,11 @@ #ifndef FSFW_ACTION_HASACTIONSIF_H_ #define FSFW_ACTION_HASACTIONSIF_H_ -#include "../ipc/MessageQueueIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" #include "ActionHelper.h" #include "ActionMessage.h" #include "SimpleActionHelper.h" +#include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" /** * @brief @@ -40,12 +40,12 @@ class HasActionsIF { static const ReturnValue_t INVALID_PARAMETERS = MAKE_RETURN_CODE(2); static const ReturnValue_t EXECUTION_FINISHED = MAKE_RETURN_CODE(3); static const ReturnValue_t INVALID_ACTION_ID = MAKE_RETURN_CODE(4); - virtual ~HasActionsIF() {} + virtual ~HasActionsIF() = default; /** * Function to get the MessageQueueId_t of the implementing object * @return MessageQueueId_t of the object */ - virtual MessageQueueId_t getCommandQueue() const = 0; + [[nodiscard]] virtual MessageQueueId_t getCommandQueue() const = 0; /** * Execute or initialize the execution of a certain function. * The ActionHelpers will execute this function and behave differently diff --git a/src/fsfw/action/SimpleActionHelper.cpp b/src/fsfw/action/SimpleActionHelper.cpp index 894f0df6..fc7e064e 100644 --- a/src/fsfw/action/SimpleActionHelper.cpp +++ b/src/fsfw/action/SimpleActionHelper.cpp @@ -3,7 +3,7 @@ SimpleActionHelper::SimpleActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue) : ActionHelper(setOwner, useThisQueue), isExecuting(false) {} -SimpleActionHelper::~SimpleActionHelper() {} +SimpleActionHelper::~SimpleActionHelper() = default; void SimpleActionHelper::step(ReturnValue_t result) { // STEP_OFFESET is subtracted to compensate for adding offset in base @@ -38,7 +38,7 @@ void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId ActionMessage::setStepReply(&reply, actionId, 0, HasActionsIF::IS_BUSY); queueToUse->sendMessage(commandedBy, &reply); } - const uint8_t* dataPtr = NULL; + const uint8_t* dataPtr = nullptr; size_t size = 0; ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/src/fsfw/action/SimpleActionHelper.h b/src/fsfw/action/SimpleActionHelper.h index 5cb85fbd..973c7cf2 100644 --- a/src/fsfw/action/SimpleActionHelper.h +++ b/src/fsfw/action/SimpleActionHelper.h @@ -11,15 +11,15 @@ class SimpleActionHelper : public ActionHelper { public: SimpleActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue); - virtual ~SimpleActionHelper(); + ~SimpleActionHelper() override; void step(ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); void finish(ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); ReturnValue_t reportData(SerializeIF* data); protected: void prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId, - store_address_t dataAddress); - virtual void resetHelper(); + store_address_t dataAddress) override; + void resetHelper() override; private: bool isExecuting; @@ -28,4 +28,4 @@ class SimpleActionHelper : public ActionHelper { uint8_t stepCount = 0; }; -#endif /* SIMPLEACTIONHELPER_H_ */ +#endif /* FSFW_ACTION_SIMPLEACTIONHELPER_H_ */ From 14bac9a4187aeeebc40c9c87b7f4a67440052e54 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Jul 2022 11:48:36 +0200 Subject: [PATCH 027/532] clang-tidy changes for controller module --- src/fsfw/controller/ControllerBase.cpp | 20 +++++------ src/fsfw/controller/ControllerBase.h | 28 +++++++-------- .../controller/ExtendedControllerBase.cpp | 4 +-- src/fsfw/controller/ExtendedControllerBase.h | 34 +++++++++---------- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp index 953dacb4..7a8b6bc4 100644 --- a/src/fsfw/controller/ControllerBase.cpp +++ b/src/fsfw/controller/ControllerBase.cpp @@ -26,7 +26,7 @@ ReturnValue_t ControllerBase::initialize() { MessageQueueId_t parentQueue = 0; if (parentId != objects::NO_OBJECT) { - SubsystemBase* parent = ObjectManager::instance()->get(parentId); + auto* parent = ObjectManager::instance()->get(parentId); if (parent == nullptr) { return RETURN_FAILED; } @@ -52,7 +52,7 @@ MessageQueueId_t ControllerBase::getCommandQueue() const { return commandQueue-> void ControllerBase::handleQueue() { CommandMessage command; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result; for (result = commandQueue->receiveMessage(&command); result == RETURN_OK; result = commandQueue->receiveMessage(&command)) { result = modeHelper.handleModeCommand(&command); @@ -73,20 +73,20 @@ void ControllerBase::handleQueue() { } } -void ControllerBase::startTransition(Mode_t mode, Submode_t submode) { +void ControllerBase::startTransition(Mode_t mode_, Submode_t submode_) { changeHK(this->mode, this->submode, false); triggerEvent(CHANGING_MODE, mode, submode); - this->mode = mode; - this->submode = submode; + mode = mode_; + submode = submode_; modeHelper.modeChanged(mode, submode); modeChanged(mode, submode); announceMode(false); changeHK(this->mode, this->submode, true); } -void ControllerBase::getMode(Mode_t* mode, Submode_t* submode) { - *mode = this->mode; - *submode = this->submode; +void ControllerBase::getMode(Mode_t* mode_, Submode_t* submode_) { + *mode_ = this->mode; + *submode_ = this->submode; } void ControllerBase::setToExternalControl() { healthHelper.setHealth(EXTERNAL_CONTROL); } @@ -99,7 +99,7 @@ ReturnValue_t ControllerBase::performOperation(uint8_t opCode) { return RETURN_OK; } -void ControllerBase::modeChanged(Mode_t mode, Submode_t submode) { return; } +void ControllerBase::modeChanged(Mode_t mode_, Submode_t submode_) {} ReturnValue_t ControllerBase::setHealth(HealthState health) { switch (health) { @@ -115,6 +115,6 @@ ReturnValue_t ControllerBase::setHealth(HealthState health) { HasHealthIF::HealthState ControllerBase::getHealth() { return healthHelper.getHealth(); } void ControllerBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; } -void ControllerBase::changeHK(Mode_t mode, Submode_t submode, bool enable) {} +void ControllerBase::changeHK(Mode_t mode_, Submode_t submode_, bool enable) {} ReturnValue_t ControllerBase::initializeAfterTaskCreation() { return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/controller/ControllerBase.h b/src/fsfw/controller/ControllerBase.h index 227b859b..550659b8 100644 --- a/src/fsfw/controller/ControllerBase.h +++ b/src/fsfw/controller/ControllerBase.h @@ -24,21 +24,21 @@ class ControllerBase : public HasModesIF, static const Mode_t MODE_NORMAL = 2; ControllerBase(object_id_t setObjectId, object_id_t parentId, size_t commandQueueDepth = 3); - virtual ~ControllerBase(); + ~ControllerBase() override; /** SystemObject override */ - virtual ReturnValue_t initialize() override; + ReturnValue_t initialize() override; - virtual MessageQueueId_t getCommandQueue() const override; + [[nodiscard]] MessageQueueId_t getCommandQueue() const override; /** HasHealthIF overrides */ - virtual ReturnValue_t setHealth(HealthState health) override; - virtual HasHealthIF::HealthState getHealth() override; + ReturnValue_t setHealth(HealthState health) override; + HasHealthIF::HealthState getHealth() override; /** ExecutableObjectIF overrides */ - virtual ReturnValue_t performOperation(uint8_t opCode) override; - virtual void setTaskIF(PeriodicTaskIF *task) override; - virtual ReturnValue_t initializeAfterTaskCreation() override; + ReturnValue_t performOperation(uint8_t opCode) override; + void setTaskIF(PeriodicTaskIF *task) override; + ReturnValue_t initializeAfterTaskCreation() override; protected: /** @@ -54,8 +54,8 @@ class ControllerBase : public HasModesIF, */ virtual void performControlOperation() = 0; - virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) override = 0; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) override = 0; const object_id_t parentId; @@ -80,10 +80,10 @@ class ControllerBase : public HasModesIF, /** Mode helpers */ virtual void modeChanged(Mode_t mode, Submode_t submode); - virtual void startTransition(Mode_t mode, Submode_t submode) override; - virtual void getMode(Mode_t *mode, Submode_t *submode) override; - virtual void setToExternalControl() override; - virtual void announceMode(bool recursive); + void startTransition(Mode_t mode, Submode_t submode) override; + void getMode(Mode_t *mode, Submode_t *submode) override; + void setToExternalControl() override; + void announceMode(bool recursive) override; /** HK helpers */ virtual void changeHK(Mode_t mode, Submode_t submode, bool enable); }; diff --git a/src/fsfw/controller/ExtendedControllerBase.cpp b/src/fsfw/controller/ExtendedControllerBase.cpp index 0dfd9dc7..64b39a31 100644 --- a/src/fsfw/controller/ExtendedControllerBase.cpp +++ b/src/fsfw/controller/ExtendedControllerBase.cpp @@ -6,7 +6,7 @@ ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, object_id_t poolManager(this, commandQueue), actionHelper(this, commandQueue) {} -ExtendedControllerBase::~ExtendedControllerBase() {} +ExtendedControllerBase::~ExtendedControllerBase() = default; ReturnValue_t ExtendedControllerBase::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, @@ -31,7 +31,7 @@ ReturnValue_t ExtendedControllerBase::handleCommandMessage(CommandMessage *messa void ExtendedControllerBase::handleQueue() { CommandMessage command; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result; for (result = commandQueue->receiveMessage(&command); result == RETURN_OK; result = commandQueue->receiveMessage(&command)) { result = actionHelper.handleActionMessage(&command); diff --git a/src/fsfw/controller/ExtendedControllerBase.h b/src/fsfw/controller/ExtendedControllerBase.h index 0c64f5b9..b5583a88 100644 --- a/src/fsfw/controller/ExtendedControllerBase.h +++ b/src/fsfw/controller/ExtendedControllerBase.h @@ -18,16 +18,16 @@ class ExtendedControllerBase : public ControllerBase, public HasLocalDataPoolIF { public: ExtendedControllerBase(object_id_t objectId, object_id_t parentId, size_t commandQueueDepth = 3); - virtual ~ExtendedControllerBase(); + ~ExtendedControllerBase() override; /* SystemObjectIF overrides */ - virtual ReturnValue_t initialize() override; + ReturnValue_t initialize() override; - virtual MessageQueueId_t getCommandQueue() const override; + [[nodiscard]] MessageQueueId_t getCommandQueue() const override; /* ExecutableObjectIF overrides */ - virtual ReturnValue_t performOperation(uint8_t opCode) override; - virtual ReturnValue_t initializeAfterTaskCreation() override; + ReturnValue_t performOperation(uint8_t opCode) override; + ReturnValue_t initializeAfterTaskCreation() override; protected: LocalDataPoolManager poolManager; @@ -39,32 +39,32 @@ class ExtendedControllerBase : public ControllerBase, * @param message * @return */ - virtual ReturnValue_t handleCommandMessage(CommandMessage* message) = 0; + ReturnValue_t handleCommandMessage(CommandMessage* message) override = 0; /** * Periodic helper from ControllerBase, implemented by child class. */ - virtual void performControlOperation() = 0; + void performControlOperation() override = 0; /* Handle the four messages mentioned above */ void handleQueue() override; /* HasActionsIF overrides */ - virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; /* HasLocalDatapoolIF overrides */ - virtual LocalDataPoolManager* getHkManagerHandle() override; - virtual object_id_t getObjectId() const override; - virtual uint32_t getPeriodicOperationFrequency() const override; + LocalDataPoolManager* getHkManagerHandle() override; + [[nodiscard]] object_id_t getObjectId() const override; + [[nodiscard]] uint32_t getPeriodicOperationFrequency() const override; - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override = 0; - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override = 0; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override = 0; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override = 0; // Mode abstract functions - virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t* msToReachTheMode) override = 0; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) override = 0; }; #endif /* FSFW_CONTROLLER_EXTENDEDCONTROLLERBASE_H_ */ From 0519083894aae3bf39524033d542593df21874b8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 8 Jul 2022 17:48:06 +0200 Subject: [PATCH 028/532] remove duplicate entries --- CHANGELOG.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ba6d754..e4e15eaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,12 +19,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Bump C++ required version to C++17. Every project which uses the FSFW and every modern compiler supports it PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/622 -- HAL Linux SPI: Set the Clock Default State when setting new SPI speed - and mode - PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/573 -- GPIO HAL: `Direction`, `GpioOperation` and `Levels` are enum classes now, which prevents - name clashes with Windows defines. - PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 - New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 - HAL Devicehandlers: Periodic printout is run-time configurable now From 32fea9838ed2052195b12493e974663de97f6861 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 8 Jul 2022 17:56:44 +0200 Subject: [PATCH 029/532] add new pool entry constructor - This constructor allows to simply specify the length. This is also the new default constructor for scalar values which are initially invalid --- src/fsfw/datapool/PoolEntry.cpp | 24 +++++++++++++----------- src/fsfw/datapool/PoolEntry.h | 7 +++++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/fsfw/datapool/PoolEntry.cpp b/src/fsfw/datapool/PoolEntry.cpp index fd110e6c..9138a705 100644 --- a/src/fsfw/datapool/PoolEntry.cpp +++ b/src/fsfw/datapool/PoolEntry.cpp @@ -7,24 +7,26 @@ #include "fsfw/serviceinterface/ServiceInterface.h" template -PoolEntry::PoolEntry(std::initializer_list initValue, bool setValid) - : length(static_cast(initValue.size())), valid(setValid) { - this->address = new T[this->length]; - if (initValue.size() == 0) { - std::memset(this->address, 0, this->getByteSize()); - } else { - std::copy(initValue.begin(), initValue.end(), this->address); +PoolEntry::PoolEntry(uint8_t len, bool setValid) : length(len), valid(setValid) { + this->address = new T[this->length](); + std::memset(this->address, 0, this->getByteSize()); +} + +template +PoolEntry::PoolEntry(std::initializer_list initValues, bool setValid) + : length(static_cast(initValues.size())), valid(setValid) { + this->address = new T[this->length](); + if (initValues.size() > 0) { + std::copy(initValues.begin(), initValues.end(), this->address); } } template -PoolEntry::PoolEntry(T* initValue, uint8_t setLength, bool setValid) +PoolEntry::PoolEntry(const T* initValue, uint8_t setLength, bool setValid) : length(setLength), valid(setValid) { - this->address = new T[this->length]; + this->address = new T[this->length](); if (initValue != nullptr) { std::memcpy(this->address, initValue, this->getByteSize()); - } else { - std::memset(this->address, 0, this->getByteSize()); } } diff --git a/src/fsfw/datapool/PoolEntry.h b/src/fsfw/datapool/PoolEntry.h index d3d80f09..4010f78d 100644 --- a/src/fsfw/datapool/PoolEntry.h +++ b/src/fsfw/datapool/PoolEntry.h @@ -33,6 +33,9 @@ class PoolEntry : public PoolEntryIF { "instead! The ECSS standard defines a boolean as a one bit " "field. Therefore it is preferred to store a boolean as an " "uint8_t"); + + PoolEntry(uint8_t len = 1, bool setValid = false); + /** * @brief In the classe's constructor, space is allocated on the heap and * potential initialization values are copied to that space. @@ -49,7 +52,7 @@ class PoolEntry : public PoolEntryIF { * @param setValid * Sets the initialization flag. It is invalid by default. */ - PoolEntry(std::initializer_list initValue = {0}, bool setValid = false); + PoolEntry(std::initializer_list initValue, bool setValid = false); /** * @brief In the classe's constructor, space is allocated on the heap and @@ -62,7 +65,7 @@ class PoolEntry : public PoolEntryIF { * @param setValid * Sets the initialization flag. It is invalid by default. */ - PoolEntry(T* initValue, uint8_t setLength = 1, bool setValid = false); + PoolEntry(const T* initValue, uint8_t setLength = 1, bool setValid = false); //! Explicitely deleted copy ctor, copying is not allowed. PoolEntry(const PoolEntry&) = delete; From 0e4964030656253d06cc799f6f0ccbdd4ea517c6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 8 Jul 2022 17:59:43 +0200 Subject: [PATCH 030/532] update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ba6d754..02970e84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -120,6 +120,8 @@ https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/593 ## Additions +- New constructor for PoolEntry which allows to simply specify the length of the pool entry. + This is also the new default constructor for scalar value with 0 as an initial value - Added options for CI/CD builds: `FSFW_CICD_BUILD`. This allows the source code to know whether it is running in CI/CD PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/623 From adbf375f38c30dc24af246b3638bbb3bcb5dda64 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Wed, 13 Jul 2022 21:58:07 +0200 Subject: [PATCH 031/532] some small fixes to dhb countdown addition --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index f3cfcee4..a6f9b35d 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -239,25 +239,20 @@ void DeviceHandlerBase::decrementDeviceReplyMap() { for (std::pair& replyPair : deviceReplyMap) { if (replyPair.second.countdown != nullptr && replyPair.second.active) { if (replyPair.second.countdown->hasTimedOut()) { + disableTimeoutControlledReply(&replyPair.second); timedOut = true; } } if (replyPair.second.delayCycles != 0 && replyPair.second.countdown == nullptr) { replyPair.second.delayCycles--; if (replyPair.second.delayCycles == 0) { - if (replyPair.second.periodic) { - replyPair.second.delayCycles = replyPair.second.maxDelayCycles; - } + disableDelayCyclesControlledReply(&replyPair.second); timedOut = true; } } if (timedOut) { replyToReply(replyPair.first, replyPair.second, TIMEOUT); missedReply(replyPair.first); - timedOut = false; - if (not replyPair.second.periodic) { - replyPair.second.active = false; - } } } } @@ -518,11 +513,19 @@ ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandI return COMMAND_NOT_SUPPORTED; } if (enable) { - info->delayCycles = info->maxDelayCycles; info->active = true; + if (info->countdown != nullptr) { + info->delayCycles = info->maxDelayCycles; + } else { + info->countdown->resetTimer(); + } } else { - info->delayCycles = 0; info->active = false; + if (info->countdown != nullptr) { + info->delayCycles = 0; + } else { + info->countdown->timeOut(); + } } } return HasReturnvaluesIF::RETURN_OK; @@ -1398,7 +1401,12 @@ uint8_t DeviceHandlerBase::getReplyDelayCycles(DeviceCommandId_t deviceCommand) if (iter == deviceReplyMap.end()) { return 0; } else if (iter->second.countdown != nullptr) { - return 0; + // fake a useful return value for legacy code + if (iter->second.active) { + return 1; + } else { + return 0; + } } return iter->second.delayCycles; } From 4d34f93cfc32400c09cf5c8d7653e2ac85538d14 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 14 Jul 2022 08:58:23 +0200 Subject: [PATCH 032/532] missing reset of timedOut value in loop of decrementDeviceReplyMap --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index a6f9b35d..ca7701d0 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -253,6 +253,7 @@ void DeviceHandlerBase::decrementDeviceReplyMap() { if (timedOut) { replyToReply(replyPair.first, replyPair.second, TIMEOUT); missedReply(replyPair.first); + timedOut = false; } } } From ecac08814e8dbcf4d47ac0bea111502bcb528dfa Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 14 Jul 2022 09:15:13 +0200 Subject: [PATCH 033/532] better naming for functions which reset states of replies --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 12 ++++++------ src/fsfw/devicehandlers/DeviceHandlerBase.h | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index ca7701d0..cf457a03 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -239,14 +239,14 @@ void DeviceHandlerBase::decrementDeviceReplyMap() { for (std::pair& replyPair : deviceReplyMap) { if (replyPair.second.countdown != nullptr && replyPair.second.active) { if (replyPair.second.countdown->hasTimedOut()) { - disableTimeoutControlledReply(&replyPair.second); + resetTimeoutControlledReply(&replyPair.second); timedOut = true; } } if (replyPair.second.delayCycles != 0 && replyPair.second.countdown == nullptr) { replyPair.second.delayCycles--; if (replyPair.second.delayCycles == 0) { - disableDelayCyclesControlledReply(&replyPair.second); + resetDelayCyclesControlledReply(&replyPair.second); timedOut = true; } } @@ -841,9 +841,9 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, DeviceCommandId } if (info->active && info->countdown != nullptr) { - disableTimeoutControlledReply(info); + resetTimeoutControlledReply(info); } else if (info->delayCycles != 0) { - disableDelayCyclesControlledReply(info); + resetDelayCyclesControlledReply(info); } if (result != RETURN_OK) { @@ -862,7 +862,7 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, DeviceCommandId } } -void DeviceHandlerBase::disableTimeoutControlledReply(DeviceReplyInfo* info) { +void DeviceHandlerBase::resetTimeoutControlledReply(DeviceReplyInfo* info) { if (info->periodic) { info->countdown->resetTimer(); } else { @@ -871,7 +871,7 @@ void DeviceHandlerBase::disableTimeoutControlledReply(DeviceReplyInfo* info) { } } -void DeviceHandlerBase::disableDelayCyclesControlledReply(DeviceReplyInfo* info) { +void DeviceHandlerBase::resetDelayCyclesControlledReply(DeviceReplyInfo* info) { if (info->periodic) { info->delayCycles = info->maxDelayCycles; } else { diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 1945ac65..e29e6596 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -1257,15 +1257,15 @@ class DeviceHandlerBase : public DeviceHandlerIF, void doGetRead(void); /** - * @brief Handles disabling of replies which use a timeout to detect missed replies. + * @brief Resets replies which use a timeout to detect missed replies. */ - void disableTimeoutControlledReply(DeviceReplyInfo *info); + void resetTimeoutControlledReply(DeviceReplyInfo *info); /** - * @brief Handles disabling of replies which use a number of maximum delay cycles to detect + * @brief Resets replies which use a number of maximum delay cycles to detect * missed replies. */ - void disableDelayCyclesControlledReply(DeviceReplyInfo *info); + void resetDelayCyclesControlledReply(DeviceReplyInfo *info); /** * Retrive data from the #IPCStore. From 6f7be281ef90d0a25b6a6aa5659452cea5ae193d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 08:59:40 +0200 Subject: [PATCH 034/532] move HAL and tests folder --- hal/CMakeLists.txt | 48 ---- hal/src/CMakeLists.txt | 9 - src/CMakeLists.txt | 2 + {hal/src => src}/fsfw_hal/CMakeLists.txt | 0 .../fsfw_hal/common/CMakeLists.txt | 0 .../fsfw_hal/common/gpio/CMakeLists.txt | 0 .../fsfw_hal/common/gpio/GpioCookie.cpp | 0 .../fsfw_hal/common/gpio/GpioCookie.h | 0 .../src => src}/fsfw_hal/common/gpio/GpioIF.h | 0 .../fsfw_hal/common/gpio/gpioDefinitions.h | 0 .../fsfw_hal/common/spi/spiCommon.h | 0 .../fsfw_hal/devicehandlers/CMakeLists.txt | 0 .../devicehandlers/GyroL3GD20Handler.cpp | 0 .../devicehandlers/GyroL3GD20Handler.h | 0 .../devicehandlers/MgmLIS3MDLHandler.cpp | 0 .../devicehandlers/MgmLIS3MDLHandler.h | 0 .../devicehandlers/MgmRM3100Handler.cpp | 0 .../devicehandlers/MgmRM3100Handler.h | 0 .../devicedefinitions/GyroL3GD20Definitions.h | 0 .../devicedefinitions/MgmLIS3HandlerDefs.h | 0 .../devicedefinitions/MgmRM3100HandlerDefs.h | 0 {hal/src => src}/fsfw_hal/host/CMakeLists.txt | 0 .../src => src}/fsfw_hal/linux/CMakeLists.txt | 0 .../fsfw_hal/linux/CommandExecutor.cpp | 0 .../fsfw_hal/linux/CommandExecutor.h | 0 .../fsfw_hal/linux/UnixFileGuard.cpp | 0 .../fsfw_hal/linux/UnixFileGuard.h | 0 .../fsfw_hal/linux/gpio/CMakeLists.txt | 0 .../fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp | 0 .../fsfw_hal/linux/gpio/LinuxLibgpioIF.h | 0 .../fsfw_hal/linux/i2c/CMakeLists.txt | 0 .../fsfw_hal/linux/i2c/I2cComIF.cpp | 0 .../src => src}/fsfw_hal/linux/i2c/I2cComIF.h | 0 .../fsfw_hal/linux/i2c/I2cCookie.cpp | 0 .../fsfw_hal/linux/i2c/I2cCookie.h | 0 .../fsfw_hal/linux/rpi/CMakeLists.txt | 0 .../fsfw_hal/linux/rpi/GpioRPi.cpp | 0 {hal/src => src}/fsfw_hal/linux/rpi/GpioRPi.h | 0 .../fsfw_hal/linux/spi/CMakeLists.txt | 0 .../fsfw_hal/linux/spi/SpiComIF.cpp | 0 .../src => src}/fsfw_hal/linux/spi/SpiComIF.h | 0 .../fsfw_hal/linux/spi/SpiCookie.cpp | 0 .../fsfw_hal/linux/spi/SpiCookie.h | 0 .../fsfw_hal/linux/spi/spiDefinitions.h | 0 .../fsfw_hal/linux/uart/CMakeLists.txt | 0 .../fsfw_hal/linux/uart/UartComIF.cpp | 0 .../fsfw_hal/linux/uart/UartComIF.h | 0 .../fsfw_hal/linux/uart/UartCookie.cpp | 0 .../fsfw_hal/linux/uart/UartCookie.h | 0 .../fsfw_hal/linux/uio/CMakeLists.txt | 0 .../fsfw_hal/linux/uio/UioMapper.cpp | 0 .../fsfw_hal/linux/uio/UioMapper.h | 0 {hal/src => src}/fsfw_hal/linux/utility.cpp | 0 {hal/src => src}/fsfw_hal/linux/utility.h | 0 .../fsfw_hal/stm32h7/CMakeLists.txt | 0 .../fsfw_hal/stm32h7/definitions.h | 0 .../stm32h7/devicetest/CMakeLists.txt | 0 .../stm32h7/devicetest/GyroL3GD20H.cpp | 0 .../fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h | 0 {hal/src => src}/fsfw_hal/stm32h7/dma.cpp | 0 {hal/src => src}/fsfw_hal/stm32h7/dma.h | 0 .../fsfw_hal/stm32h7/gpio/CMakeLists.txt | 0 .../fsfw_hal/stm32h7/gpio/gpio.cpp | 0 {hal/src => src}/fsfw_hal/stm32h7/gpio/gpio.h | 0 .../fsfw_hal/stm32h7/i2c/CMakeLists.txt | 0 .../src => src}/fsfw_hal/stm32h7/interrupts.h | 0 .../fsfw_hal/stm32h7/spi/CMakeLists.txt | 0 .../fsfw_hal/stm32h7/spi/SpiComIF.cpp | 0 .../fsfw_hal/stm32h7/spi/SpiComIF.h | 0 .../fsfw_hal/stm32h7/spi/SpiCookie.cpp | 0 .../fsfw_hal/stm32h7/spi/SpiCookie.h | 0 .../fsfw_hal/stm32h7/spi/mspInit.cpp | 0 .../fsfw_hal/stm32h7/spi/mspInit.h | 0 .../fsfw_hal/stm32h7/spi/spiCore.cpp | 0 .../fsfw_hal/stm32h7/spi/spiCore.h | 0 .../fsfw_hal/stm32h7/spi/spiDefinitions.cpp | 0 .../fsfw_hal/stm32h7/spi/spiDefinitions.h | 0 .../fsfw_hal/stm32h7/spi/spiInterrupts.cpp | 0 .../fsfw_hal/stm32h7/spi/spiInterrupts.h | 0 .../fsfw_hal/stm32h7/spi/stm32h743zi.cpp | 0 .../fsfw_hal/stm32h7/spi/stm32h743zi.h | 0 .../fsfw_hal/stm32h7/uart/CMakeLists.txt | 0 {tests/src => src}/fsfw_tests/CMakeLists.txt | 0 .../fsfw_tests/integration/CMakeLists.txt | 0 .../integration/assemblies/CMakeLists.txt | 0 .../integration/assemblies/TestAssembly.cpp | 0 .../integration/assemblies/TestAssembly.h | 0 .../integration/controller/CMakeLists.txt | 0 .../integration/controller/TestController.cpp | 0 .../integration/controller/TestController.h | 0 .../ctrldefinitions/testCtrlDefinitions.h | 0 .../integration/devices/CMakeLists.txt | 0 .../integration/devices/TestCookie.cpp | 0 .../integration/devices/TestCookie.h | 0 .../integration/devices/TestDeviceHandler.cpp | 0 .../integration/devices/TestDeviceHandler.h | 0 .../integration/devices/TestEchoComIF.cpp | 0 .../integration/devices/TestEchoComIF.h | 0 .../devicedefinitions/testDeviceDefinitions.h | 0 .../integration/task/CMakeLists.txt | 0 .../fsfw_tests/integration/task/TestTask.cpp | 0 .../fsfw_tests/integration/task/TestTask.h | 0 .../fsfw_tests/internal/CMakeLists.txt | 0 .../internal/InternalUnitTester.cpp | 0 .../fsfw_tests/internal/InternalUnitTester.h | 0 .../fsfw_tests/internal/UnittDefinitions.cpp | 0 .../fsfw_tests/internal/UnittDefinitions.h | 0 .../internal/globalfunctions/CMakeLists.txt | 0 .../globalfunctions/TestArrayPrinter.cpp | 0 .../globalfunctions/TestArrayPrinter.h | 0 .../fsfw_tests/internal/osal/CMakeLists.txt | 0 .../fsfw_tests/internal/osal/testMq.cpp | 0 .../fsfw_tests/internal/osal/testMq.h | 0 .../fsfw_tests/internal/osal/testMutex.cpp | 0 .../fsfw_tests/internal/osal/testMutex.h | 0 .../internal/osal/testSemaphore.cpp | 0 .../fsfw_tests/internal/osal/testSemaphore.h | 0 .../internal/serialize/CMakeLists.txt | 0 .../serialize/IntTestSerialization.cpp | 0 .../internal/serialize/IntTestSerialization.h | 0 .../fsfw_tests/unit/CMakeLists.txt | 0 .../fsfw_tests/unit/CatchDefinitions.cpp | 0 .../fsfw_tests/unit/CatchDefinitions.h | 0 .../fsfw_tests/unit/CatchFactory.cpp | 0 .../fsfw_tests/unit/CatchFactory.h | 0 .../fsfw_tests/unit/CatchRunner.cpp | 0 .../src => src}/fsfw_tests/unit/CatchRunner.h | 0 .../fsfw_tests/unit/CatchSetup.cpp | 0 .../fsfw_tests/unit/action/CMakeLists.txt | 0 .../unit/action/TestActionHelper.cpp | 0 .../fsfw_tests/unit/action/TestActionHelper.h | 0 .../fsfw_tests/unit/cfdp/CMakeLists.txt | 0 .../fsfw_tests/unit/cfdp/testAckPdu.cpp | 0 .../fsfw_tests/unit/cfdp/testCfdp.cpp | 0 .../fsfw_tests/unit/cfdp/testEofPdu.cpp | 0 .../fsfw_tests/unit/cfdp/testFileData.cpp | 0 .../fsfw_tests/unit/cfdp/testFinishedPdu.cpp | 0 .../fsfw_tests/unit/cfdp/testKeepAlivePdu.cpp | 0 .../fsfw_tests/unit/cfdp/testMetadataPdu.cpp | 0 .../fsfw_tests/unit/cfdp/testNakPdu.cpp | 0 .../fsfw_tests/unit/cfdp/testPromptPdu.cpp | 0 .../fsfw_tests/unit/cfdp/testTlvsLvs.cpp | 0 .../fsfw_tests/unit/container/CMakeLists.txt | 0 .../unit/container/RingBufferTest.cpp | 0 .../unit/container/TestArrayList.cpp | 0 .../unit/container/TestDynamicFifo.cpp | 0 .../fsfw_tests/unit/container/TestFifo.cpp | 0 .../unit/container/TestFixedArrayList.cpp | 0 .../unit/container/TestFixedMap.cpp | 0 .../container/TestFixedOrderedMultimap.cpp | 0 .../unit/container/TestPlacementFactory.cpp | 0 .../unit/datapoollocal/CMakeLists.txt | 0 .../unit/datapoollocal/DataSetTest.cpp | 0 .../datapoollocal/LocalPoolManagerTest.cpp | 0 .../unit/datapoollocal/LocalPoolOwnerBase.cpp | 0 .../unit/datapoollocal/LocalPoolOwnerBase.h | 0 .../datapoollocal/LocalPoolVariableTest.cpp | 0 .../datapoollocal/LocalPoolVectorTest.cpp | 0 .../unit/devicehandler/CMakeLists.txt | 0 .../unit/devicehandler/ComIFMock.cpp | 92 ++++---- .../fsfw_tests/unit/devicehandler/ComIFMock.h | 74 +++---- .../unit/devicehandler/CookieIFMock.cpp | 10 +- .../unit/devicehandler/CookieIFMock.h | 24 +- .../unit/devicehandler/DeviceFdirMock.cpp | 0 .../unit/devicehandler/DeviceFdirMock.h | 0 .../devicehandler/DeviceHandlerCommander.cpp | 128 +++++------ .../devicehandler/DeviceHandlerCommander.h | 100 ++++----- .../unit/devicehandler/DeviceHandlerMock.cpp | 206 +++++++++--------- .../unit/devicehandler/DeviceHandlerMock.h | 92 ++++---- .../devicehandler/TestDeviceHandlerBase.cpp | 190 ++++++++-------- .../unit/globalfunctions/CMakeLists.txt | 0 .../unit/globalfunctions/testBitutil.cpp | 0 .../unit/globalfunctions/testCRC.cpp | 0 .../unit/globalfunctions/testDleEncoder.cpp | 0 .../unit/globalfunctions/testOpDivider.cpp | 0 .../globalfunctions/testTimevalOperations.cpp | 0 .../fsfw_tests/unit/hal/CMakeLists.txt | 0 .../unit/hal/testCommandExecutor.cpp | 0 .../unit/internalerror/CMakeLists.txt | 0 .../TestInternalErrorReporter.cpp | 0 .../fsfw_tests/unit/mocks/CMakeLists.txt | 0 .../fsfw_tests/unit/mocks/HkReceiverMock.h | 0 .../unit/mocks/MessageQueueMockBase.h | 0 .../unit/mocks/PeriodicTaskIFMock.h | 0 .../unit/mocks/PowerSwitcherMock.cpp | 0 .../fsfw_tests/unit/mocks/PowerSwitcherMock.h | 0 .../fsfw_tests/unit/osal/CMakeLists.txt | 0 .../fsfw_tests/unit/osal/TestClock.cpp | 0 .../fsfw_tests/unit/osal/TestMessageQueue.cpp | 0 .../fsfw_tests/unit/osal/TestSemaphore.cpp | 0 .../fsfw_tests/unit/power/CMakeLists.txt | 0 .../unit/power/testPowerSwitcher.cpp | 0 .../src => src}/fsfw_tests/unit/printChar.cpp | 0 .../src => src}/fsfw_tests/unit/printChar.h | 0 .../fsfw_tests/unit/serialize/CMakeLists.txt | 0 .../serialize/TestSerialBufferAdapter.cpp | 0 .../unit/serialize/TestSerialLinkedPacket.cpp | 0 .../unit/serialize/TestSerialLinkedPacket.h | 0 .../unit/serialize/TestSerialization.cpp | 0 .../unit/storagemanager/CMakeLists.txt | 0 .../unit/storagemanager/TestNewAccessor.cpp | 0 .../unit/storagemanager/TestPool.cpp | 0 .../fsfw_tests/unit/testcfg/CMakeLists.txt | 0 .../fsfw_tests/unit/testcfg/FSFWConfig.h.in | 0 .../fsfw_tests/unit/testcfg/OBSWConfig.h.in | 0 .../fsfw_tests/unit/testcfg/TestsConfig.h.in | 0 .../unit/testcfg/devices/logicalAddresses.cpp | 0 .../unit/testcfg/devices/logicalAddresses.h | 0 .../testcfg/devices/powerSwitcherList.cpp | 0 .../unit/testcfg/devices/powerSwitcherList.h | 0 .../unit/testcfg/events/subsystemIdRanges.h | 0 .../unit/testcfg/ipc/MissionMessageTypes.cpp | 0 .../unit/testcfg/ipc/MissionMessageTypes.h | 0 .../unit/testcfg/objects/systemObjectList.h | 68 +++--- .../PollingSequenceFactory.cpp | 0 .../pollingsequence/PollingSequenceFactory.h | 0 .../unit/testcfg/returnvalues/classIds.h | 0 .../fsfw_tests/unit/testcfg/tmtc/apid.h | 0 .../fsfw_tests/unit/testcfg/tmtc/pusIds.h | 0 .../unit/testtemplate/TestTemplate.cpp | 0 .../unit/timemanager/CMakeLists.txt | 0 .../unit/timemanager/TestCCSDSTime.cpp | 0 .../unit/timemanager/TestCountdown.cpp | 0 .../fsfw_tests/unit/tmtcpacket/CMakeLists.txt | 0 .../fsfw_tests/unit/tmtcpacket/PusTmTest.cpp | 0 .../fsfw_tests/unit/tmtcpacket/testCcsds.cpp | 0 .../src => src}/fsfw_tests/unit/version.cpp | 0 tests/CMakeLists.txt | 1 - tests/src/CMakeLists.txt | 9 - 229 files changed, 494 insertions(+), 559 deletions(-) delete mode 100644 hal/CMakeLists.txt delete mode 100644 hal/src/CMakeLists.txt rename {hal/src => src}/fsfw_hal/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/common/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/common/gpio/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/common/gpio/GpioCookie.cpp (100%) rename {hal/src => src}/fsfw_hal/common/gpio/GpioCookie.h (100%) rename {hal/src => src}/fsfw_hal/common/gpio/GpioIF.h (100%) rename {hal/src => src}/fsfw_hal/common/gpio/gpioDefinitions.h (100%) rename {hal/src => src}/fsfw_hal/common/spi/spiCommon.h (100%) rename {hal/src => src}/fsfw_hal/devicehandlers/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp (100%) rename {hal/src => src}/fsfw_hal/devicehandlers/GyroL3GD20Handler.h (100%) rename {hal/src => src}/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp (100%) rename {hal/src => src}/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h (100%) rename {hal/src => src}/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp (100%) rename {hal/src => src}/fsfw_hal/devicehandlers/MgmRM3100Handler.h (100%) rename {hal/src => src}/fsfw_hal/devicehandlers/devicedefinitions/GyroL3GD20Definitions.h (100%) rename {hal/src => src}/fsfw_hal/devicehandlers/devicedefinitions/MgmLIS3HandlerDefs.h (100%) rename {hal/src => src}/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h (100%) rename {hal/src => src}/fsfw_hal/host/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/linux/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/linux/CommandExecutor.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/CommandExecutor.h (100%) rename {hal/src => src}/fsfw_hal/linux/UnixFileGuard.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/UnixFileGuard.h (100%) rename {hal/src => src}/fsfw_hal/linux/gpio/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/gpio/LinuxLibgpioIF.h (100%) rename {hal/src => src}/fsfw_hal/linux/i2c/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/linux/i2c/I2cComIF.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/i2c/I2cComIF.h (100%) rename {hal/src => src}/fsfw_hal/linux/i2c/I2cCookie.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/i2c/I2cCookie.h (100%) rename {hal/src => src}/fsfw_hal/linux/rpi/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/linux/rpi/GpioRPi.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/rpi/GpioRPi.h (100%) rename {hal/src => src}/fsfw_hal/linux/spi/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/linux/spi/SpiComIF.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/spi/SpiComIF.h (100%) rename {hal/src => src}/fsfw_hal/linux/spi/SpiCookie.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/spi/SpiCookie.h (100%) rename {hal/src => src}/fsfw_hal/linux/spi/spiDefinitions.h (100%) rename {hal/src => src}/fsfw_hal/linux/uart/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/linux/uart/UartComIF.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/uart/UartComIF.h (100%) rename {hal/src => src}/fsfw_hal/linux/uart/UartCookie.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/uart/UartCookie.h (100%) rename {hal/src => src}/fsfw_hal/linux/uio/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/linux/uio/UioMapper.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/uio/UioMapper.h (100%) rename {hal/src => src}/fsfw_hal/linux/utility.cpp (100%) rename {hal/src => src}/fsfw_hal/linux/utility.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/stm32h7/definitions.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/devicetest/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp (100%) rename {hal/src => src}/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/dma.cpp (100%) rename {hal/src => src}/fsfw_hal/stm32h7/dma.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/gpio/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/stm32h7/gpio/gpio.cpp (100%) rename {hal/src => src}/fsfw_hal/stm32h7/gpio/gpio.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/i2c/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/stm32h7/interrupts.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/CMakeLists.txt (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/SpiComIF.cpp (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/SpiComIF.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/SpiCookie.cpp (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/SpiCookie.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/mspInit.cpp (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/mspInit.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/spiCore.cpp (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/spiCore.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/spiDefinitions.cpp (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/spiDefinitions.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/spiInterrupts.cpp (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/spiInterrupts.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/stm32h743zi.cpp (100%) rename {hal/src => src}/fsfw_hal/stm32h7/spi/stm32h743zi.h (100%) rename {hal/src => src}/fsfw_hal/stm32h7/uart/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/integration/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/integration/assemblies/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/integration/assemblies/TestAssembly.cpp (100%) rename {tests/src => src}/fsfw_tests/integration/assemblies/TestAssembly.h (100%) rename {tests/src => src}/fsfw_tests/integration/controller/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/integration/controller/TestController.cpp (100%) rename {tests/src => src}/fsfw_tests/integration/controller/TestController.h (100%) rename {tests/src => src}/fsfw_tests/integration/controller/ctrldefinitions/testCtrlDefinitions.h (100%) rename {tests/src => src}/fsfw_tests/integration/devices/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/integration/devices/TestCookie.cpp (100%) rename {tests/src => src}/fsfw_tests/integration/devices/TestCookie.h (100%) rename {tests/src => src}/fsfw_tests/integration/devices/TestDeviceHandler.cpp (100%) rename {tests/src => src}/fsfw_tests/integration/devices/TestDeviceHandler.h (100%) rename {tests/src => src}/fsfw_tests/integration/devices/TestEchoComIF.cpp (100%) rename {tests/src => src}/fsfw_tests/integration/devices/TestEchoComIF.h (100%) rename {tests/src => src}/fsfw_tests/integration/devices/devicedefinitions/testDeviceDefinitions.h (100%) rename {tests/src => src}/fsfw_tests/integration/task/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/integration/task/TestTask.cpp (100%) rename {tests/src => src}/fsfw_tests/integration/task/TestTask.h (100%) rename {tests/src => src}/fsfw_tests/internal/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/internal/InternalUnitTester.cpp (100%) rename {tests/src => src}/fsfw_tests/internal/InternalUnitTester.h (100%) rename {tests/src => src}/fsfw_tests/internal/UnittDefinitions.cpp (100%) rename {tests/src => src}/fsfw_tests/internal/UnittDefinitions.h (100%) rename {tests/src => src}/fsfw_tests/internal/globalfunctions/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/internal/globalfunctions/TestArrayPrinter.cpp (100%) rename {tests/src => src}/fsfw_tests/internal/globalfunctions/TestArrayPrinter.h (100%) rename {tests/src => src}/fsfw_tests/internal/osal/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/internal/osal/testMq.cpp (100%) rename {tests/src => src}/fsfw_tests/internal/osal/testMq.h (100%) rename {tests/src => src}/fsfw_tests/internal/osal/testMutex.cpp (100%) rename {tests/src => src}/fsfw_tests/internal/osal/testMutex.h (100%) rename {tests/src => src}/fsfw_tests/internal/osal/testSemaphore.cpp (100%) rename {tests/src => src}/fsfw_tests/internal/osal/testSemaphore.h (100%) rename {tests/src => src}/fsfw_tests/internal/serialize/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/internal/serialize/IntTestSerialization.cpp (100%) rename {tests/src => src}/fsfw_tests/internal/serialize/IntTestSerialization.h (100%) rename {tests/src => src}/fsfw_tests/unit/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/CatchDefinitions.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/CatchDefinitions.h (100%) rename {tests/src => src}/fsfw_tests/unit/CatchFactory.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/CatchFactory.h (100%) rename {tests/src => src}/fsfw_tests/unit/CatchRunner.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/CatchRunner.h (100%) rename {tests/src => src}/fsfw_tests/unit/CatchSetup.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/action/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/action/TestActionHelper.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/action/TestActionHelper.h (100%) rename {tests/src => src}/fsfw_tests/unit/cfdp/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/cfdp/testAckPdu.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/cfdp/testCfdp.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/cfdp/testEofPdu.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/cfdp/testFileData.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/cfdp/testFinishedPdu.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/cfdp/testKeepAlivePdu.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/cfdp/testMetadataPdu.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/cfdp/testNakPdu.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/cfdp/testPromptPdu.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/cfdp/testTlvsLvs.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/container/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/container/RingBufferTest.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/container/TestArrayList.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/container/TestDynamicFifo.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/container/TestFifo.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/container/TestFixedArrayList.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/container/TestFixedMap.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/container/TestFixedOrderedMultimap.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/container/TestPlacementFactory.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/datapoollocal/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/datapoollocal/DataSetTest.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.h (100%) rename {tests/src => src}/fsfw_tests/unit/datapoollocal/LocalPoolVariableTest.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/datapoollocal/LocalPoolVectorTest.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/ComIFMock.cpp (96%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/ComIFMock.h (97%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/CookieIFMock.cpp (94%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/CookieIFMock.h (96%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/DeviceFdirMock.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/DeviceFdirMock.h (100%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp (97%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h (97%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp (96%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h (97%) rename {tests/src => src}/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp (98%) rename {tests/src => src}/fsfw_tests/unit/globalfunctions/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/globalfunctions/testBitutil.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/globalfunctions/testCRC.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/globalfunctions/testOpDivider.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/globalfunctions/testTimevalOperations.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/hal/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/hal/testCommandExecutor.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/internalerror/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/internalerror/TestInternalErrorReporter.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/mocks/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/mocks/HkReceiverMock.h (100%) rename {tests/src => src}/fsfw_tests/unit/mocks/MessageQueueMockBase.h (100%) rename {tests/src => src}/fsfw_tests/unit/mocks/PeriodicTaskIFMock.h (100%) rename {tests/src => src}/fsfw_tests/unit/mocks/PowerSwitcherMock.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/mocks/PowerSwitcherMock.h (100%) rename {tests/src => src}/fsfw_tests/unit/osal/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/osal/TestClock.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/osal/TestMessageQueue.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/osal/TestSemaphore.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/power/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/power/testPowerSwitcher.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/printChar.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/printChar.h (100%) rename {tests/src => src}/fsfw_tests/unit/serialize/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/serialize/TestSerialBufferAdapter.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/serialize/TestSerialLinkedPacket.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/serialize/TestSerialLinkedPacket.h (100%) rename {tests/src => src}/fsfw_tests/unit/serialize/TestSerialization.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/storagemanager/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/storagemanager/TestNewAccessor.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/storagemanager/TestPool.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/FSFWConfig.h.in (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/OBSWConfig.h.in (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/TestsConfig.h.in (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/devices/logicalAddresses.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/devices/logicalAddresses.h (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/devices/powerSwitcherList.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/devices/powerSwitcherList.h (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/events/subsystemIdRanges.h (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.h (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/objects/systemObjectList.h (95%) rename {tests/src => src}/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.h (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/returnvalues/classIds.h (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/tmtc/apid.h (100%) rename {tests/src => src}/fsfw_tests/unit/testcfg/tmtc/pusIds.h (100%) rename {tests/src => src}/fsfw_tests/unit/testtemplate/TestTemplate.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/timemanager/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/timemanager/TestCountdown.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/tmtcpacket/CMakeLists.txt (100%) rename {tests/src => src}/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/tmtcpacket/testCcsds.cpp (100%) rename {tests/src => src}/fsfw_tests/unit/version.cpp (100%) delete mode 100644 tests/CMakeLists.txt delete mode 100644 tests/src/CMakeLists.txt diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt deleted file mode 100644 index 7a97ae0f..00000000 --- a/hal/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -cmake_minimum_required(VERSION 3.13) - -# Can also be changed by upper CMakeLists.txt file -find_library(LIB_FSFW_NAME fsfw REQUIRED) - -option(FSFW_HAL_ADD_LINUX "Add the Linux HAL to the sources. Requires gpiod library" OFF) -# On by default for now because I did not have an issue including and compiling those files -# and libraries on a Desktop Linux system and the primary target of the FSFW is still embedded -# Linux. The only exception from this is the gpiod library which requires a dedicated installation, -# but CMake is able to determine whether this library is installed with find_library. -option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add peripheral drivers for embedded Linux" ON) -option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Target implements libgpiod" ON) - -option(FSFW_HAL_ADD_RASPBERRY_PI "Add Raspberry Pi specific code to the sources" OFF) -option(FSFW_HAL_ADD_STM32H7 "Add the STM32H7 HAL to the sources" OFF) -option(FSFW_HAL_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON) - -set(LINUX_HAL_PATH_NAME linux) -set(STM32H7_PATH_NAME stm32h7) - -add_subdirectory(src) - -foreach(INCLUDE_PATH ${FSFW_HAL_ADDITIONAL_INC_PATHS}) - if(IS_ABSOLUTE ${INCLUDE_PATH}) - set(CURR_ABS_INC_PATH "${INCLUDE_PATH}") - else() - get_filename_component(CURR_ABS_INC_PATH - ${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR}) - endif() - - if(CMAKE_VERBOSE) - message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}") - endif() - - list(APPEND FSFW_HAL_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH}) -endforeach() - -target_include_directories(${LIB_FSFW_NAME} PRIVATE - ${FSFW_HAL_ADD_INC_PATHS_ABS} -) - -target_compile_definitions(${LIB_FSFW_NAME} PRIVATE - ${FSFW_HAL_DEFINES} -) - -target_link_libraries(${LIB_FSFW_NAME} PRIVATE - ${FSFW_HAL_LINK_LIBS} -) diff --git a/hal/src/CMakeLists.txt b/hal/src/CMakeLists.txt deleted file mode 100644 index 76ee45c6..00000000 --- a/hal/src/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -target_include_directories(${LIB_FSFW_NAME} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} -) - -target_include_directories(${LIB_FSFW_NAME} INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR} -) - -add_subdirectory(fsfw_hal) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34f21c2f..6d7f83b3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,3 +4,5 @@ target_include_directories(${LIB_FSFW_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(fsfw) +add_subdirectory(fsfw_hal) +add_subdirectory(fsfw_tests) diff --git a/hal/src/fsfw_hal/CMakeLists.txt b/src/fsfw_hal/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/CMakeLists.txt rename to src/fsfw_hal/CMakeLists.txt diff --git a/hal/src/fsfw_hal/common/CMakeLists.txt b/src/fsfw_hal/common/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/common/CMakeLists.txt rename to src/fsfw_hal/common/CMakeLists.txt diff --git a/hal/src/fsfw_hal/common/gpio/CMakeLists.txt b/src/fsfw_hal/common/gpio/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/common/gpio/CMakeLists.txt rename to src/fsfw_hal/common/gpio/CMakeLists.txt diff --git a/hal/src/fsfw_hal/common/gpio/GpioCookie.cpp b/src/fsfw_hal/common/gpio/GpioCookie.cpp similarity index 100% rename from hal/src/fsfw_hal/common/gpio/GpioCookie.cpp rename to src/fsfw_hal/common/gpio/GpioCookie.cpp diff --git a/hal/src/fsfw_hal/common/gpio/GpioCookie.h b/src/fsfw_hal/common/gpio/GpioCookie.h similarity index 100% rename from hal/src/fsfw_hal/common/gpio/GpioCookie.h rename to src/fsfw_hal/common/gpio/GpioCookie.h diff --git a/hal/src/fsfw_hal/common/gpio/GpioIF.h b/src/fsfw_hal/common/gpio/GpioIF.h similarity index 100% rename from hal/src/fsfw_hal/common/gpio/GpioIF.h rename to src/fsfw_hal/common/gpio/GpioIF.h diff --git a/hal/src/fsfw_hal/common/gpio/gpioDefinitions.h b/src/fsfw_hal/common/gpio/gpioDefinitions.h similarity index 100% rename from hal/src/fsfw_hal/common/gpio/gpioDefinitions.h rename to src/fsfw_hal/common/gpio/gpioDefinitions.h diff --git a/hal/src/fsfw_hal/common/spi/spiCommon.h b/src/fsfw_hal/common/spi/spiCommon.h similarity index 100% rename from hal/src/fsfw_hal/common/spi/spiCommon.h rename to src/fsfw_hal/common/spi/spiCommon.h diff --git a/hal/src/fsfw_hal/devicehandlers/CMakeLists.txt b/src/fsfw_hal/devicehandlers/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/devicehandlers/CMakeLists.txt rename to src/fsfw_hal/devicehandlers/CMakeLists.txt diff --git a/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp b/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp similarity index 100% rename from hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp rename to src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp diff --git a/hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.h b/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.h similarity index 100% rename from hal/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.h rename to src/fsfw_hal/devicehandlers/GyroL3GD20Handler.h diff --git a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp similarity index 100% rename from hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp rename to src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp diff --git a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h similarity index 100% rename from hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h rename to src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h diff --git a/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp similarity index 100% rename from hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp rename to src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp diff --git a/hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h similarity index 100% rename from hal/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h rename to src/fsfw_hal/devicehandlers/MgmRM3100Handler.h diff --git a/hal/src/fsfw_hal/devicehandlers/devicedefinitions/GyroL3GD20Definitions.h b/src/fsfw_hal/devicehandlers/devicedefinitions/GyroL3GD20Definitions.h similarity index 100% rename from hal/src/fsfw_hal/devicehandlers/devicedefinitions/GyroL3GD20Definitions.h rename to src/fsfw_hal/devicehandlers/devicedefinitions/GyroL3GD20Definitions.h diff --git a/hal/src/fsfw_hal/devicehandlers/devicedefinitions/MgmLIS3HandlerDefs.h b/src/fsfw_hal/devicehandlers/devicedefinitions/MgmLIS3HandlerDefs.h similarity index 100% rename from hal/src/fsfw_hal/devicehandlers/devicedefinitions/MgmLIS3HandlerDefs.h rename to src/fsfw_hal/devicehandlers/devicedefinitions/MgmLIS3HandlerDefs.h diff --git a/hal/src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h b/src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h similarity index 100% rename from hal/src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h rename to src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h diff --git a/hal/src/fsfw_hal/host/CMakeLists.txt b/src/fsfw_hal/host/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/host/CMakeLists.txt rename to src/fsfw_hal/host/CMakeLists.txt diff --git a/hal/src/fsfw_hal/linux/CMakeLists.txt b/src/fsfw_hal/linux/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/linux/CMakeLists.txt rename to src/fsfw_hal/linux/CMakeLists.txt diff --git a/hal/src/fsfw_hal/linux/CommandExecutor.cpp b/src/fsfw_hal/linux/CommandExecutor.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/CommandExecutor.cpp rename to src/fsfw_hal/linux/CommandExecutor.cpp diff --git a/hal/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h similarity index 100% rename from hal/src/fsfw_hal/linux/CommandExecutor.h rename to src/fsfw_hal/linux/CommandExecutor.h diff --git a/hal/src/fsfw_hal/linux/UnixFileGuard.cpp b/src/fsfw_hal/linux/UnixFileGuard.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/UnixFileGuard.cpp rename to src/fsfw_hal/linux/UnixFileGuard.cpp diff --git a/hal/src/fsfw_hal/linux/UnixFileGuard.h b/src/fsfw_hal/linux/UnixFileGuard.h similarity index 100% rename from hal/src/fsfw_hal/linux/UnixFileGuard.h rename to src/fsfw_hal/linux/UnixFileGuard.h diff --git a/hal/src/fsfw_hal/linux/gpio/CMakeLists.txt b/src/fsfw_hal/linux/gpio/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/linux/gpio/CMakeLists.txt rename to src/fsfw_hal/linux/gpio/CMakeLists.txt diff --git a/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp rename to src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp diff --git a/hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h similarity index 100% rename from hal/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h rename to src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h diff --git a/hal/src/fsfw_hal/linux/i2c/CMakeLists.txt b/src/fsfw_hal/linux/i2c/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/linux/i2c/CMakeLists.txt rename to src/fsfw_hal/linux/i2c/CMakeLists.txt diff --git a/hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/i2c/I2cComIF.cpp rename to src/fsfw_hal/linux/i2c/I2cComIF.cpp diff --git a/hal/src/fsfw_hal/linux/i2c/I2cComIF.h b/src/fsfw_hal/linux/i2c/I2cComIF.h similarity index 100% rename from hal/src/fsfw_hal/linux/i2c/I2cComIF.h rename to src/fsfw_hal/linux/i2c/I2cComIF.h diff --git a/hal/src/fsfw_hal/linux/i2c/I2cCookie.cpp b/src/fsfw_hal/linux/i2c/I2cCookie.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/i2c/I2cCookie.cpp rename to src/fsfw_hal/linux/i2c/I2cCookie.cpp diff --git a/hal/src/fsfw_hal/linux/i2c/I2cCookie.h b/src/fsfw_hal/linux/i2c/I2cCookie.h similarity index 100% rename from hal/src/fsfw_hal/linux/i2c/I2cCookie.h rename to src/fsfw_hal/linux/i2c/I2cCookie.h diff --git a/hal/src/fsfw_hal/linux/rpi/CMakeLists.txt b/src/fsfw_hal/linux/rpi/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/linux/rpi/CMakeLists.txt rename to src/fsfw_hal/linux/rpi/CMakeLists.txt diff --git a/hal/src/fsfw_hal/linux/rpi/GpioRPi.cpp b/src/fsfw_hal/linux/rpi/GpioRPi.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/rpi/GpioRPi.cpp rename to src/fsfw_hal/linux/rpi/GpioRPi.cpp diff --git a/hal/src/fsfw_hal/linux/rpi/GpioRPi.h b/src/fsfw_hal/linux/rpi/GpioRPi.h similarity index 100% rename from hal/src/fsfw_hal/linux/rpi/GpioRPi.h rename to src/fsfw_hal/linux/rpi/GpioRPi.h diff --git a/hal/src/fsfw_hal/linux/spi/CMakeLists.txt b/src/fsfw_hal/linux/spi/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/linux/spi/CMakeLists.txt rename to src/fsfw_hal/linux/spi/CMakeLists.txt diff --git a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp b/src/fsfw_hal/linux/spi/SpiComIF.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/spi/SpiComIF.cpp rename to src/fsfw_hal/linux/spi/SpiComIF.cpp diff --git a/hal/src/fsfw_hal/linux/spi/SpiComIF.h b/src/fsfw_hal/linux/spi/SpiComIF.h similarity index 100% rename from hal/src/fsfw_hal/linux/spi/SpiComIF.h rename to src/fsfw_hal/linux/spi/SpiComIF.h diff --git a/hal/src/fsfw_hal/linux/spi/SpiCookie.cpp b/src/fsfw_hal/linux/spi/SpiCookie.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/spi/SpiCookie.cpp rename to src/fsfw_hal/linux/spi/SpiCookie.cpp diff --git a/hal/src/fsfw_hal/linux/spi/SpiCookie.h b/src/fsfw_hal/linux/spi/SpiCookie.h similarity index 100% rename from hal/src/fsfw_hal/linux/spi/SpiCookie.h rename to src/fsfw_hal/linux/spi/SpiCookie.h diff --git a/hal/src/fsfw_hal/linux/spi/spiDefinitions.h b/src/fsfw_hal/linux/spi/spiDefinitions.h similarity index 100% rename from hal/src/fsfw_hal/linux/spi/spiDefinitions.h rename to src/fsfw_hal/linux/spi/spiDefinitions.h diff --git a/hal/src/fsfw_hal/linux/uart/CMakeLists.txt b/src/fsfw_hal/linux/uart/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/linux/uart/CMakeLists.txt rename to src/fsfw_hal/linux/uart/CMakeLists.txt diff --git a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp b/src/fsfw_hal/linux/uart/UartComIF.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/uart/UartComIF.cpp rename to src/fsfw_hal/linux/uart/UartComIF.cpp diff --git a/hal/src/fsfw_hal/linux/uart/UartComIF.h b/src/fsfw_hal/linux/uart/UartComIF.h similarity index 100% rename from hal/src/fsfw_hal/linux/uart/UartComIF.h rename to src/fsfw_hal/linux/uart/UartComIF.h diff --git a/hal/src/fsfw_hal/linux/uart/UartCookie.cpp b/src/fsfw_hal/linux/uart/UartCookie.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/uart/UartCookie.cpp rename to src/fsfw_hal/linux/uart/UartCookie.cpp diff --git a/hal/src/fsfw_hal/linux/uart/UartCookie.h b/src/fsfw_hal/linux/uart/UartCookie.h similarity index 100% rename from hal/src/fsfw_hal/linux/uart/UartCookie.h rename to src/fsfw_hal/linux/uart/UartCookie.h diff --git a/hal/src/fsfw_hal/linux/uio/CMakeLists.txt b/src/fsfw_hal/linux/uio/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/linux/uio/CMakeLists.txt rename to src/fsfw_hal/linux/uio/CMakeLists.txt diff --git a/hal/src/fsfw_hal/linux/uio/UioMapper.cpp b/src/fsfw_hal/linux/uio/UioMapper.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/uio/UioMapper.cpp rename to src/fsfw_hal/linux/uio/UioMapper.cpp diff --git a/hal/src/fsfw_hal/linux/uio/UioMapper.h b/src/fsfw_hal/linux/uio/UioMapper.h similarity index 100% rename from hal/src/fsfw_hal/linux/uio/UioMapper.h rename to src/fsfw_hal/linux/uio/UioMapper.h diff --git a/hal/src/fsfw_hal/linux/utility.cpp b/src/fsfw_hal/linux/utility.cpp similarity index 100% rename from hal/src/fsfw_hal/linux/utility.cpp rename to src/fsfw_hal/linux/utility.cpp diff --git a/hal/src/fsfw_hal/linux/utility.h b/src/fsfw_hal/linux/utility.h similarity index 100% rename from hal/src/fsfw_hal/linux/utility.h rename to src/fsfw_hal/linux/utility.h diff --git a/hal/src/fsfw_hal/stm32h7/CMakeLists.txt b/src/fsfw_hal/stm32h7/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/stm32h7/CMakeLists.txt rename to src/fsfw_hal/stm32h7/CMakeLists.txt diff --git a/hal/src/fsfw_hal/stm32h7/definitions.h b/src/fsfw_hal/stm32h7/definitions.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/definitions.h rename to src/fsfw_hal/stm32h7/definitions.h diff --git a/hal/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt b/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt rename to src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt diff --git a/hal/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp b/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp similarity index 100% rename from hal/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp rename to src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp diff --git a/hal/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h b/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h rename to src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h diff --git a/hal/src/fsfw_hal/stm32h7/dma.cpp b/src/fsfw_hal/stm32h7/dma.cpp similarity index 100% rename from hal/src/fsfw_hal/stm32h7/dma.cpp rename to src/fsfw_hal/stm32h7/dma.cpp diff --git a/hal/src/fsfw_hal/stm32h7/dma.h b/src/fsfw_hal/stm32h7/dma.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/dma.h rename to src/fsfw_hal/stm32h7/dma.h diff --git a/hal/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt b/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt rename to src/fsfw_hal/stm32h7/gpio/CMakeLists.txt diff --git a/hal/src/fsfw_hal/stm32h7/gpio/gpio.cpp b/src/fsfw_hal/stm32h7/gpio/gpio.cpp similarity index 100% rename from hal/src/fsfw_hal/stm32h7/gpio/gpio.cpp rename to src/fsfw_hal/stm32h7/gpio/gpio.cpp diff --git a/hal/src/fsfw_hal/stm32h7/gpio/gpio.h b/src/fsfw_hal/stm32h7/gpio/gpio.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/gpio/gpio.h rename to src/fsfw_hal/stm32h7/gpio/gpio.h diff --git a/hal/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt b/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt rename to src/fsfw_hal/stm32h7/i2c/CMakeLists.txt diff --git a/hal/src/fsfw_hal/stm32h7/interrupts.h b/src/fsfw_hal/stm32h7/interrupts.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/interrupts.h rename to src/fsfw_hal/stm32h7/interrupts.h diff --git a/hal/src/fsfw_hal/stm32h7/spi/CMakeLists.txt b/src/fsfw_hal/stm32h7/spi/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/CMakeLists.txt rename to src/fsfw_hal/stm32h7/spi/CMakeLists.txt diff --git a/hal/src/fsfw_hal/stm32h7/spi/SpiComIF.cpp b/src/fsfw_hal/stm32h7/spi/SpiComIF.cpp similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/SpiComIF.cpp rename to src/fsfw_hal/stm32h7/spi/SpiComIF.cpp diff --git a/hal/src/fsfw_hal/stm32h7/spi/SpiComIF.h b/src/fsfw_hal/stm32h7/spi/SpiComIF.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/SpiComIF.h rename to src/fsfw_hal/stm32h7/spi/SpiComIF.h diff --git a/hal/src/fsfw_hal/stm32h7/spi/SpiCookie.cpp b/src/fsfw_hal/stm32h7/spi/SpiCookie.cpp similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/SpiCookie.cpp rename to src/fsfw_hal/stm32h7/spi/SpiCookie.cpp diff --git a/hal/src/fsfw_hal/stm32h7/spi/SpiCookie.h b/src/fsfw_hal/stm32h7/spi/SpiCookie.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/SpiCookie.h rename to src/fsfw_hal/stm32h7/spi/SpiCookie.h diff --git a/hal/src/fsfw_hal/stm32h7/spi/mspInit.cpp b/src/fsfw_hal/stm32h7/spi/mspInit.cpp similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/mspInit.cpp rename to src/fsfw_hal/stm32h7/spi/mspInit.cpp diff --git a/hal/src/fsfw_hal/stm32h7/spi/mspInit.h b/src/fsfw_hal/stm32h7/spi/mspInit.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/mspInit.h rename to src/fsfw_hal/stm32h7/spi/mspInit.h diff --git a/hal/src/fsfw_hal/stm32h7/spi/spiCore.cpp b/src/fsfw_hal/stm32h7/spi/spiCore.cpp similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/spiCore.cpp rename to src/fsfw_hal/stm32h7/spi/spiCore.cpp diff --git a/hal/src/fsfw_hal/stm32h7/spi/spiCore.h b/src/fsfw_hal/stm32h7/spi/spiCore.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/spiCore.h rename to src/fsfw_hal/stm32h7/spi/spiCore.h diff --git a/hal/src/fsfw_hal/stm32h7/spi/spiDefinitions.cpp b/src/fsfw_hal/stm32h7/spi/spiDefinitions.cpp similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/spiDefinitions.cpp rename to src/fsfw_hal/stm32h7/spi/spiDefinitions.cpp diff --git a/hal/src/fsfw_hal/stm32h7/spi/spiDefinitions.h b/src/fsfw_hal/stm32h7/spi/spiDefinitions.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/spiDefinitions.h rename to src/fsfw_hal/stm32h7/spi/spiDefinitions.h diff --git a/hal/src/fsfw_hal/stm32h7/spi/spiInterrupts.cpp b/src/fsfw_hal/stm32h7/spi/spiInterrupts.cpp similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/spiInterrupts.cpp rename to src/fsfw_hal/stm32h7/spi/spiInterrupts.cpp diff --git a/hal/src/fsfw_hal/stm32h7/spi/spiInterrupts.h b/src/fsfw_hal/stm32h7/spi/spiInterrupts.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/spiInterrupts.h rename to src/fsfw_hal/stm32h7/spi/spiInterrupts.h diff --git a/hal/src/fsfw_hal/stm32h7/spi/stm32h743zi.cpp b/src/fsfw_hal/stm32h7/spi/stm32h743zi.cpp similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/stm32h743zi.cpp rename to src/fsfw_hal/stm32h7/spi/stm32h743zi.cpp diff --git a/hal/src/fsfw_hal/stm32h7/spi/stm32h743zi.h b/src/fsfw_hal/stm32h7/spi/stm32h743zi.h similarity index 100% rename from hal/src/fsfw_hal/stm32h7/spi/stm32h743zi.h rename to src/fsfw_hal/stm32h7/spi/stm32h743zi.h diff --git a/hal/src/fsfw_hal/stm32h7/uart/CMakeLists.txt b/src/fsfw_hal/stm32h7/uart/CMakeLists.txt similarity index 100% rename from hal/src/fsfw_hal/stm32h7/uart/CMakeLists.txt rename to src/fsfw_hal/stm32h7/uart/CMakeLists.txt diff --git a/tests/src/fsfw_tests/CMakeLists.txt b/src/fsfw_tests/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/CMakeLists.txt rename to src/fsfw_tests/CMakeLists.txt diff --git a/tests/src/fsfw_tests/integration/CMakeLists.txt b/src/fsfw_tests/integration/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/integration/CMakeLists.txt rename to src/fsfw_tests/integration/CMakeLists.txt diff --git a/tests/src/fsfw_tests/integration/assemblies/CMakeLists.txt b/src/fsfw_tests/integration/assemblies/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/integration/assemblies/CMakeLists.txt rename to src/fsfw_tests/integration/assemblies/CMakeLists.txt diff --git a/tests/src/fsfw_tests/integration/assemblies/TestAssembly.cpp b/src/fsfw_tests/integration/assemblies/TestAssembly.cpp similarity index 100% rename from tests/src/fsfw_tests/integration/assemblies/TestAssembly.cpp rename to src/fsfw_tests/integration/assemblies/TestAssembly.cpp diff --git a/tests/src/fsfw_tests/integration/assemblies/TestAssembly.h b/src/fsfw_tests/integration/assemblies/TestAssembly.h similarity index 100% rename from tests/src/fsfw_tests/integration/assemblies/TestAssembly.h rename to src/fsfw_tests/integration/assemblies/TestAssembly.h diff --git a/tests/src/fsfw_tests/integration/controller/CMakeLists.txt b/src/fsfw_tests/integration/controller/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/integration/controller/CMakeLists.txt rename to src/fsfw_tests/integration/controller/CMakeLists.txt diff --git a/tests/src/fsfw_tests/integration/controller/TestController.cpp b/src/fsfw_tests/integration/controller/TestController.cpp similarity index 100% rename from tests/src/fsfw_tests/integration/controller/TestController.cpp rename to src/fsfw_tests/integration/controller/TestController.cpp diff --git a/tests/src/fsfw_tests/integration/controller/TestController.h b/src/fsfw_tests/integration/controller/TestController.h similarity index 100% rename from tests/src/fsfw_tests/integration/controller/TestController.h rename to src/fsfw_tests/integration/controller/TestController.h diff --git a/tests/src/fsfw_tests/integration/controller/ctrldefinitions/testCtrlDefinitions.h b/src/fsfw_tests/integration/controller/ctrldefinitions/testCtrlDefinitions.h similarity index 100% rename from tests/src/fsfw_tests/integration/controller/ctrldefinitions/testCtrlDefinitions.h rename to src/fsfw_tests/integration/controller/ctrldefinitions/testCtrlDefinitions.h diff --git a/tests/src/fsfw_tests/integration/devices/CMakeLists.txt b/src/fsfw_tests/integration/devices/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/integration/devices/CMakeLists.txt rename to src/fsfw_tests/integration/devices/CMakeLists.txt diff --git a/tests/src/fsfw_tests/integration/devices/TestCookie.cpp b/src/fsfw_tests/integration/devices/TestCookie.cpp similarity index 100% rename from tests/src/fsfw_tests/integration/devices/TestCookie.cpp rename to src/fsfw_tests/integration/devices/TestCookie.cpp diff --git a/tests/src/fsfw_tests/integration/devices/TestCookie.h b/src/fsfw_tests/integration/devices/TestCookie.h similarity index 100% rename from tests/src/fsfw_tests/integration/devices/TestCookie.h rename to src/fsfw_tests/integration/devices/TestCookie.h diff --git a/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp similarity index 100% rename from tests/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp rename to src/fsfw_tests/integration/devices/TestDeviceHandler.cpp diff --git a/tests/src/fsfw_tests/integration/devices/TestDeviceHandler.h b/src/fsfw_tests/integration/devices/TestDeviceHandler.h similarity index 100% rename from tests/src/fsfw_tests/integration/devices/TestDeviceHandler.h rename to src/fsfw_tests/integration/devices/TestDeviceHandler.h diff --git a/tests/src/fsfw_tests/integration/devices/TestEchoComIF.cpp b/src/fsfw_tests/integration/devices/TestEchoComIF.cpp similarity index 100% rename from tests/src/fsfw_tests/integration/devices/TestEchoComIF.cpp rename to src/fsfw_tests/integration/devices/TestEchoComIF.cpp diff --git a/tests/src/fsfw_tests/integration/devices/TestEchoComIF.h b/src/fsfw_tests/integration/devices/TestEchoComIF.h similarity index 100% rename from tests/src/fsfw_tests/integration/devices/TestEchoComIF.h rename to src/fsfw_tests/integration/devices/TestEchoComIF.h diff --git a/tests/src/fsfw_tests/integration/devices/devicedefinitions/testDeviceDefinitions.h b/src/fsfw_tests/integration/devices/devicedefinitions/testDeviceDefinitions.h similarity index 100% rename from tests/src/fsfw_tests/integration/devices/devicedefinitions/testDeviceDefinitions.h rename to src/fsfw_tests/integration/devices/devicedefinitions/testDeviceDefinitions.h diff --git a/tests/src/fsfw_tests/integration/task/CMakeLists.txt b/src/fsfw_tests/integration/task/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/integration/task/CMakeLists.txt rename to src/fsfw_tests/integration/task/CMakeLists.txt diff --git a/tests/src/fsfw_tests/integration/task/TestTask.cpp b/src/fsfw_tests/integration/task/TestTask.cpp similarity index 100% rename from tests/src/fsfw_tests/integration/task/TestTask.cpp rename to src/fsfw_tests/integration/task/TestTask.cpp diff --git a/tests/src/fsfw_tests/integration/task/TestTask.h b/src/fsfw_tests/integration/task/TestTask.h similarity index 100% rename from tests/src/fsfw_tests/integration/task/TestTask.h rename to src/fsfw_tests/integration/task/TestTask.h diff --git a/tests/src/fsfw_tests/internal/CMakeLists.txt b/src/fsfw_tests/internal/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/internal/CMakeLists.txt rename to src/fsfw_tests/internal/CMakeLists.txt diff --git a/tests/src/fsfw_tests/internal/InternalUnitTester.cpp b/src/fsfw_tests/internal/InternalUnitTester.cpp similarity index 100% rename from tests/src/fsfw_tests/internal/InternalUnitTester.cpp rename to src/fsfw_tests/internal/InternalUnitTester.cpp diff --git a/tests/src/fsfw_tests/internal/InternalUnitTester.h b/src/fsfw_tests/internal/InternalUnitTester.h similarity index 100% rename from tests/src/fsfw_tests/internal/InternalUnitTester.h rename to src/fsfw_tests/internal/InternalUnitTester.h diff --git a/tests/src/fsfw_tests/internal/UnittDefinitions.cpp b/src/fsfw_tests/internal/UnittDefinitions.cpp similarity index 100% rename from tests/src/fsfw_tests/internal/UnittDefinitions.cpp rename to src/fsfw_tests/internal/UnittDefinitions.cpp diff --git a/tests/src/fsfw_tests/internal/UnittDefinitions.h b/src/fsfw_tests/internal/UnittDefinitions.h similarity index 100% rename from tests/src/fsfw_tests/internal/UnittDefinitions.h rename to src/fsfw_tests/internal/UnittDefinitions.h diff --git a/tests/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt b/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt rename to src/fsfw_tests/internal/globalfunctions/CMakeLists.txt diff --git a/tests/src/fsfw_tests/internal/globalfunctions/TestArrayPrinter.cpp b/src/fsfw_tests/internal/globalfunctions/TestArrayPrinter.cpp similarity index 100% rename from tests/src/fsfw_tests/internal/globalfunctions/TestArrayPrinter.cpp rename to src/fsfw_tests/internal/globalfunctions/TestArrayPrinter.cpp diff --git a/tests/src/fsfw_tests/internal/globalfunctions/TestArrayPrinter.h b/src/fsfw_tests/internal/globalfunctions/TestArrayPrinter.h similarity index 100% rename from tests/src/fsfw_tests/internal/globalfunctions/TestArrayPrinter.h rename to src/fsfw_tests/internal/globalfunctions/TestArrayPrinter.h diff --git a/tests/src/fsfw_tests/internal/osal/CMakeLists.txt b/src/fsfw_tests/internal/osal/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/internal/osal/CMakeLists.txt rename to src/fsfw_tests/internal/osal/CMakeLists.txt diff --git a/tests/src/fsfw_tests/internal/osal/testMq.cpp b/src/fsfw_tests/internal/osal/testMq.cpp similarity index 100% rename from tests/src/fsfw_tests/internal/osal/testMq.cpp rename to src/fsfw_tests/internal/osal/testMq.cpp diff --git a/tests/src/fsfw_tests/internal/osal/testMq.h b/src/fsfw_tests/internal/osal/testMq.h similarity index 100% rename from tests/src/fsfw_tests/internal/osal/testMq.h rename to src/fsfw_tests/internal/osal/testMq.h diff --git a/tests/src/fsfw_tests/internal/osal/testMutex.cpp b/src/fsfw_tests/internal/osal/testMutex.cpp similarity index 100% rename from tests/src/fsfw_tests/internal/osal/testMutex.cpp rename to src/fsfw_tests/internal/osal/testMutex.cpp diff --git a/tests/src/fsfw_tests/internal/osal/testMutex.h b/src/fsfw_tests/internal/osal/testMutex.h similarity index 100% rename from tests/src/fsfw_tests/internal/osal/testMutex.h rename to src/fsfw_tests/internal/osal/testMutex.h diff --git a/tests/src/fsfw_tests/internal/osal/testSemaphore.cpp b/src/fsfw_tests/internal/osal/testSemaphore.cpp similarity index 100% rename from tests/src/fsfw_tests/internal/osal/testSemaphore.cpp rename to src/fsfw_tests/internal/osal/testSemaphore.cpp diff --git a/tests/src/fsfw_tests/internal/osal/testSemaphore.h b/src/fsfw_tests/internal/osal/testSemaphore.h similarity index 100% rename from tests/src/fsfw_tests/internal/osal/testSemaphore.h rename to src/fsfw_tests/internal/osal/testSemaphore.h diff --git a/tests/src/fsfw_tests/internal/serialize/CMakeLists.txt b/src/fsfw_tests/internal/serialize/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/internal/serialize/CMakeLists.txt rename to src/fsfw_tests/internal/serialize/CMakeLists.txt diff --git a/tests/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp b/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp similarity index 100% rename from tests/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp rename to src/fsfw_tests/internal/serialize/IntTestSerialization.cpp diff --git a/tests/src/fsfw_tests/internal/serialize/IntTestSerialization.h b/src/fsfw_tests/internal/serialize/IntTestSerialization.h similarity index 100% rename from tests/src/fsfw_tests/internal/serialize/IntTestSerialization.h rename to src/fsfw_tests/internal/serialize/IntTestSerialization.h diff --git a/tests/src/fsfw_tests/unit/CMakeLists.txt b/src/fsfw_tests/unit/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/CMakeLists.txt rename to src/fsfw_tests/unit/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/CatchDefinitions.cpp b/src/fsfw_tests/unit/CatchDefinitions.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/CatchDefinitions.cpp rename to src/fsfw_tests/unit/CatchDefinitions.cpp diff --git a/tests/src/fsfw_tests/unit/CatchDefinitions.h b/src/fsfw_tests/unit/CatchDefinitions.h similarity index 100% rename from tests/src/fsfw_tests/unit/CatchDefinitions.h rename to src/fsfw_tests/unit/CatchDefinitions.h diff --git a/tests/src/fsfw_tests/unit/CatchFactory.cpp b/src/fsfw_tests/unit/CatchFactory.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/CatchFactory.cpp rename to src/fsfw_tests/unit/CatchFactory.cpp diff --git a/tests/src/fsfw_tests/unit/CatchFactory.h b/src/fsfw_tests/unit/CatchFactory.h similarity index 100% rename from tests/src/fsfw_tests/unit/CatchFactory.h rename to src/fsfw_tests/unit/CatchFactory.h diff --git a/tests/src/fsfw_tests/unit/CatchRunner.cpp b/src/fsfw_tests/unit/CatchRunner.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/CatchRunner.cpp rename to src/fsfw_tests/unit/CatchRunner.cpp diff --git a/tests/src/fsfw_tests/unit/CatchRunner.h b/src/fsfw_tests/unit/CatchRunner.h similarity index 100% rename from tests/src/fsfw_tests/unit/CatchRunner.h rename to src/fsfw_tests/unit/CatchRunner.h diff --git a/tests/src/fsfw_tests/unit/CatchSetup.cpp b/src/fsfw_tests/unit/CatchSetup.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/CatchSetup.cpp rename to src/fsfw_tests/unit/CatchSetup.cpp diff --git a/tests/src/fsfw_tests/unit/action/CMakeLists.txt b/src/fsfw_tests/unit/action/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/action/CMakeLists.txt rename to src/fsfw_tests/unit/action/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/action/TestActionHelper.cpp b/src/fsfw_tests/unit/action/TestActionHelper.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/action/TestActionHelper.cpp rename to src/fsfw_tests/unit/action/TestActionHelper.cpp diff --git a/tests/src/fsfw_tests/unit/action/TestActionHelper.h b/src/fsfw_tests/unit/action/TestActionHelper.h similarity index 100% rename from tests/src/fsfw_tests/unit/action/TestActionHelper.h rename to src/fsfw_tests/unit/action/TestActionHelper.h diff --git a/tests/src/fsfw_tests/unit/cfdp/CMakeLists.txt b/src/fsfw_tests/unit/cfdp/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/cfdp/CMakeLists.txt rename to src/fsfw_tests/unit/cfdp/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/cfdp/testAckPdu.cpp b/src/fsfw_tests/unit/cfdp/testAckPdu.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/cfdp/testAckPdu.cpp rename to src/fsfw_tests/unit/cfdp/testAckPdu.cpp diff --git a/tests/src/fsfw_tests/unit/cfdp/testCfdp.cpp b/src/fsfw_tests/unit/cfdp/testCfdp.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/cfdp/testCfdp.cpp rename to src/fsfw_tests/unit/cfdp/testCfdp.cpp diff --git a/tests/src/fsfw_tests/unit/cfdp/testEofPdu.cpp b/src/fsfw_tests/unit/cfdp/testEofPdu.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/cfdp/testEofPdu.cpp rename to src/fsfw_tests/unit/cfdp/testEofPdu.cpp diff --git a/tests/src/fsfw_tests/unit/cfdp/testFileData.cpp b/src/fsfw_tests/unit/cfdp/testFileData.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/cfdp/testFileData.cpp rename to src/fsfw_tests/unit/cfdp/testFileData.cpp diff --git a/tests/src/fsfw_tests/unit/cfdp/testFinishedPdu.cpp b/src/fsfw_tests/unit/cfdp/testFinishedPdu.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/cfdp/testFinishedPdu.cpp rename to src/fsfw_tests/unit/cfdp/testFinishedPdu.cpp diff --git a/tests/src/fsfw_tests/unit/cfdp/testKeepAlivePdu.cpp b/src/fsfw_tests/unit/cfdp/testKeepAlivePdu.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/cfdp/testKeepAlivePdu.cpp rename to src/fsfw_tests/unit/cfdp/testKeepAlivePdu.cpp diff --git a/tests/src/fsfw_tests/unit/cfdp/testMetadataPdu.cpp b/src/fsfw_tests/unit/cfdp/testMetadataPdu.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/cfdp/testMetadataPdu.cpp rename to src/fsfw_tests/unit/cfdp/testMetadataPdu.cpp diff --git a/tests/src/fsfw_tests/unit/cfdp/testNakPdu.cpp b/src/fsfw_tests/unit/cfdp/testNakPdu.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/cfdp/testNakPdu.cpp rename to src/fsfw_tests/unit/cfdp/testNakPdu.cpp diff --git a/tests/src/fsfw_tests/unit/cfdp/testPromptPdu.cpp b/src/fsfw_tests/unit/cfdp/testPromptPdu.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/cfdp/testPromptPdu.cpp rename to src/fsfw_tests/unit/cfdp/testPromptPdu.cpp diff --git a/tests/src/fsfw_tests/unit/cfdp/testTlvsLvs.cpp b/src/fsfw_tests/unit/cfdp/testTlvsLvs.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/cfdp/testTlvsLvs.cpp rename to src/fsfw_tests/unit/cfdp/testTlvsLvs.cpp diff --git a/tests/src/fsfw_tests/unit/container/CMakeLists.txt b/src/fsfw_tests/unit/container/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/container/CMakeLists.txt rename to src/fsfw_tests/unit/container/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/container/RingBufferTest.cpp b/src/fsfw_tests/unit/container/RingBufferTest.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/container/RingBufferTest.cpp rename to src/fsfw_tests/unit/container/RingBufferTest.cpp diff --git a/tests/src/fsfw_tests/unit/container/TestArrayList.cpp b/src/fsfw_tests/unit/container/TestArrayList.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/container/TestArrayList.cpp rename to src/fsfw_tests/unit/container/TestArrayList.cpp diff --git a/tests/src/fsfw_tests/unit/container/TestDynamicFifo.cpp b/src/fsfw_tests/unit/container/TestDynamicFifo.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/container/TestDynamicFifo.cpp rename to src/fsfw_tests/unit/container/TestDynamicFifo.cpp diff --git a/tests/src/fsfw_tests/unit/container/TestFifo.cpp b/src/fsfw_tests/unit/container/TestFifo.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/container/TestFifo.cpp rename to src/fsfw_tests/unit/container/TestFifo.cpp diff --git a/tests/src/fsfw_tests/unit/container/TestFixedArrayList.cpp b/src/fsfw_tests/unit/container/TestFixedArrayList.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/container/TestFixedArrayList.cpp rename to src/fsfw_tests/unit/container/TestFixedArrayList.cpp diff --git a/tests/src/fsfw_tests/unit/container/TestFixedMap.cpp b/src/fsfw_tests/unit/container/TestFixedMap.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/container/TestFixedMap.cpp rename to src/fsfw_tests/unit/container/TestFixedMap.cpp diff --git a/tests/src/fsfw_tests/unit/container/TestFixedOrderedMultimap.cpp b/src/fsfw_tests/unit/container/TestFixedOrderedMultimap.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/container/TestFixedOrderedMultimap.cpp rename to src/fsfw_tests/unit/container/TestFixedOrderedMultimap.cpp diff --git a/tests/src/fsfw_tests/unit/container/TestPlacementFactory.cpp b/src/fsfw_tests/unit/container/TestPlacementFactory.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/container/TestPlacementFactory.cpp rename to src/fsfw_tests/unit/container/TestPlacementFactory.cpp diff --git a/tests/src/fsfw_tests/unit/datapoollocal/CMakeLists.txt b/src/fsfw_tests/unit/datapoollocal/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/datapoollocal/CMakeLists.txt rename to src/fsfw_tests/unit/datapoollocal/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/datapoollocal/DataSetTest.cpp b/src/fsfw_tests/unit/datapoollocal/DataSetTest.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/datapoollocal/DataSetTest.cpp rename to src/fsfw_tests/unit/datapoollocal/DataSetTest.cpp diff --git a/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp b/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp rename to src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp diff --git a/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.cpp b/src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.cpp rename to src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.cpp diff --git a/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.h b/src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.h similarity index 100% rename from tests/src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.h rename to src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.h diff --git a/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolVariableTest.cpp b/src/fsfw_tests/unit/datapoollocal/LocalPoolVariableTest.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/datapoollocal/LocalPoolVariableTest.cpp rename to src/fsfw_tests/unit/datapoollocal/LocalPoolVariableTest.cpp diff --git a/tests/src/fsfw_tests/unit/datapoollocal/LocalPoolVectorTest.cpp b/src/fsfw_tests/unit/datapoollocal/LocalPoolVectorTest.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/datapoollocal/LocalPoolVectorTest.cpp rename to src/fsfw_tests/unit/datapoollocal/LocalPoolVectorTest.cpp diff --git a/tests/src/fsfw_tests/unit/devicehandler/CMakeLists.txt b/src/fsfw_tests/unit/devicehandler/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/devicehandler/CMakeLists.txt rename to src/fsfw_tests/unit/devicehandler/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp b/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp similarity index 96% rename from tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp rename to src/fsfw_tests/unit/devicehandler/ComIFMock.cpp index 4d985f94..650b74bd 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp +++ b/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp @@ -1,46 +1,46 @@ -#include "ComIFMock.h" - -#include "DeviceHandlerMock.h" - -ComIFMock::ComIFMock(object_id_t objectId) : SystemObject(objectId) {} - -ComIFMock::~ComIFMock() {} - -ReturnValue_t ComIFMock::initializeInterface(CookieIF *cookie) { return RETURN_OK; } - -ReturnValue_t ComIFMock::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) { - data = *sendData; - return RETURN_OK; -} - -ReturnValue_t ComIFMock::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } - -ReturnValue_t ComIFMock::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { - return RETURN_OK; -} - -ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { - switch (testCase) { - case TestCase::MISSED_REPLY: { - *size = 0; - return RETURN_OK; - } - case TestCase::SIMPLE_COMMAND_NOMINAL: { - *size = 1; - data = DeviceHandlerMock::SIMPLE_COMMAND_DATA; - *buffer = &data; - break; - } - case TestCase::PERIODIC_REPLY_NOMINAL: { - *size = 1; - data = DeviceHandlerMock::PERIODIC_REPLY_DATA; - *buffer = &data; - break; - } - default: - break; - } - return RETURN_OK; -} - -void ComIFMock::setTestCase(TestCase testCase_) { testCase = testCase_; } +#include "ComIFMock.h" + +#include "DeviceHandlerMock.h" + +ComIFMock::ComIFMock(object_id_t objectId) : SystemObject(objectId) {} + +ComIFMock::~ComIFMock() {} + +ReturnValue_t ComIFMock::initializeInterface(CookieIF *cookie) { return RETURN_OK; } + +ReturnValue_t ComIFMock::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) { + data = *sendData; + return RETURN_OK; +} + +ReturnValue_t ComIFMock::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } + +ReturnValue_t ComIFMock::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { + return RETURN_OK; +} + +ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { + switch (testCase) { + case TestCase::MISSED_REPLY: { + *size = 0; + return RETURN_OK; + } + case TestCase::SIMPLE_COMMAND_NOMINAL: { + *size = 1; + data = DeviceHandlerMock::SIMPLE_COMMAND_DATA; + *buffer = &data; + break; + } + case TestCase::PERIODIC_REPLY_NOMINAL: { + *size = 1; + data = DeviceHandlerMock::PERIODIC_REPLY_DATA; + *buffer = &data; + break; + } + default: + break; + } + return RETURN_OK; +} + +void ComIFMock::setTestCase(TestCase testCase_) { testCase = testCase_; } diff --git a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h b/src/fsfw_tests/unit/devicehandler/ComIFMock.h similarity index 97% rename from tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h rename to src/fsfw_tests/unit/devicehandler/ComIFMock.h index 1463deb6..d16cc0a6 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/ComIFMock.h +++ b/src/fsfw_tests/unit/devicehandler/ComIFMock.h @@ -1,37 +1,37 @@ -#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ -#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ - -#include -#include - -/** - * @brief The ComIFMock supports the simulation of various device communication error cases - * like incomplete or wrong replies and can be used to test the - * DeviceHandlerBase. - */ -class ComIFMock : public DeviceCommunicationIF, public SystemObject { - public: - enum class TestCase { SIMPLE_COMMAND_NOMINAL, PERIODIC_REPLY_NOMINAL, MISSED_REPLY }; - - ComIFMock(object_id_t objectId); - virtual ~ComIFMock(); - - virtual ReturnValue_t initializeInterface(CookieIF *cookie) override; - virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, - size_t sendLen) override; - virtual ReturnValue_t getSendSuccess(CookieIF *cookie) override; - virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; - virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, - size_t *size) override; - void setTestCase(TestCase testCase_); - - private: - TestCase testCase = TestCase::SIMPLE_COMMAND_NOMINAL; - - static const uint8_t SIMPLE_COMMAND_DATA = 1; - static const uint8_t PERIODIC_REPLY_DATA = 2; - - uint8_t data = 0; -}; - -#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ */ +#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ +#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ + +#include +#include + +/** + * @brief The ComIFMock supports the simulation of various device communication error cases + * like incomplete or wrong replies and can be used to test the + * DeviceHandlerBase. + */ +class ComIFMock : public DeviceCommunicationIF, public SystemObject { + public: + enum class TestCase { SIMPLE_COMMAND_NOMINAL, PERIODIC_REPLY_NOMINAL, MISSED_REPLY }; + + ComIFMock(object_id_t objectId); + virtual ~ComIFMock(); + + virtual ReturnValue_t initializeInterface(CookieIF *cookie) override; + virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, + size_t sendLen) override; + virtual ReturnValue_t getSendSuccess(CookieIF *cookie) override; + virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie, size_t requestLen) override; + virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, + size_t *size) override; + void setTestCase(TestCase testCase_); + + private: + TestCase testCase = TestCase::SIMPLE_COMMAND_NOMINAL; + + static const uint8_t SIMPLE_COMMAND_DATA = 1; + static const uint8_t PERIODIC_REPLY_DATA = 2; + + uint8_t data = 0; +}; + +#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COMIFMOCK_H_ */ diff --git a/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp b/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp similarity index 94% rename from tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp rename to src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp index e9b03a6c..1ae2eb6e 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp +++ b/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp @@ -1,5 +1,5 @@ -#include "CookieIFMock.h" - -CookieIFMock::CookieIFMock() {} - -CookieIFMock::~CookieIFMock() {} +#include "CookieIFMock.h" + +CookieIFMock::CookieIFMock() {} + +CookieIFMock::~CookieIFMock() {} diff --git a/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.h b/src/fsfw_tests/unit/devicehandler/CookieIFMock.h similarity index 96% rename from tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.h rename to src/fsfw_tests/unit/devicehandler/CookieIFMock.h index 5c868932..1243b0a7 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/CookieIFMock.h +++ b/src/fsfw_tests/unit/devicehandler/CookieIFMock.h @@ -1,12 +1,12 @@ -#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COOKIEIFMOCK_H_ -#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COOKIEIFMOCK_H_ - -#include "fsfw/devicehandlers/CookieIF.h" - -class CookieIFMock : public CookieIF { - public: - CookieIFMock(); - virtual ~CookieIFMock(); -}; - -#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COOKIEIFMOCK_H_ */ +#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COOKIEIFMOCK_H_ +#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COOKIEIFMOCK_H_ + +#include "fsfw/devicehandlers/CookieIF.h" + +class CookieIFMock : public CookieIF { + public: + CookieIFMock(); + virtual ~CookieIFMock(); +}; + +#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_COOKIEIFMOCK_H_ */ diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.cpp b/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.cpp rename to src/fsfw_tests/unit/devicehandler/DeviceFdirMock.cpp diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.h b/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.h similarity index 100% rename from tests/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.h rename to src/fsfw_tests/unit/devicehandler/DeviceFdirMock.h diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp b/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp similarity index 97% rename from tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp rename to src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp index 4540a388..d38166ad 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp +++ b/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp @@ -1,64 +1,64 @@ -#include "DeviceHandlerCommander.h" - -#include - -DeviceHandlerCommander::DeviceHandlerCommander(object_id_t objectId) - : SystemObject(objectId), commandActionHelper(this) { - auto mqArgs = MqArgs(this->getObjectId()); - commandQueue = QueueFactory::instance()->createMessageQueue( - QUEUE_SIZE, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); -} - -DeviceHandlerCommander::~DeviceHandlerCommander() {} - -ReturnValue_t DeviceHandlerCommander::performOperation(uint8_t operationCode) { - readCommandQueue(); - return RETURN_OK; -} - -ReturnValue_t DeviceHandlerCommander::initialize() { - ReturnValue_t result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - return HasReturnvaluesIF::RETURN_OK; -} - -MessageQueueIF* DeviceHandlerCommander::getCommandQueuePtr() { return commandQueue; } - -void DeviceHandlerCommander::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {} - -void DeviceHandlerCommander::stepFailedReceived(ActionId_t actionId, uint8_t step, - ReturnValue_t returnCode) {} - -void DeviceHandlerCommander::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { -} - -void DeviceHandlerCommander::completionSuccessfulReceived(ActionId_t actionId) { - lastReplyReturnCode = RETURN_OK; -} - -void DeviceHandlerCommander::completionFailedReceived(ActionId_t actionId, - ReturnValue_t returnCode) { - lastReplyReturnCode = returnCode; -} - -void DeviceHandlerCommander::readCommandQueue() { - CommandMessage message; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; - result = commandQueue->receiveMessage(&message)) { - result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { - continue; - } - } -} - -ReturnValue_t DeviceHandlerCommander::sendCommand(object_id_t target, ActionId_t actionId) { - return commandActionHelper.commandAction(target, actionId, nullptr, 0); -} - -ReturnValue_t DeviceHandlerCommander::getReplyReturnCode() { return lastReplyReturnCode; } - -void DeviceHandlerCommander::resetReplyReturnCode() { lastReplyReturnCode = RETURN_FAILED; } +#include "DeviceHandlerCommander.h" + +#include + +DeviceHandlerCommander::DeviceHandlerCommander(object_id_t objectId) + : SystemObject(objectId), commandActionHelper(this) { + auto mqArgs = MqArgs(this->getObjectId()); + commandQueue = QueueFactory::instance()->createMessageQueue( + QUEUE_SIZE, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); +} + +DeviceHandlerCommander::~DeviceHandlerCommander() {} + +ReturnValue_t DeviceHandlerCommander::performOperation(uint8_t operationCode) { + readCommandQueue(); + return RETURN_OK; +} + +ReturnValue_t DeviceHandlerCommander::initialize() { + ReturnValue_t result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return HasReturnvaluesIF::RETURN_OK; +} + +MessageQueueIF* DeviceHandlerCommander::getCommandQueuePtr() { return commandQueue; } + +void DeviceHandlerCommander::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) {} + +void DeviceHandlerCommander::stepFailedReceived(ActionId_t actionId, uint8_t step, + ReturnValue_t returnCode) {} + +void DeviceHandlerCommander::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { +} + +void DeviceHandlerCommander::completionSuccessfulReceived(ActionId_t actionId) { + lastReplyReturnCode = RETURN_OK; +} + +void DeviceHandlerCommander::completionFailedReceived(ActionId_t actionId, + ReturnValue_t returnCode) { + lastReplyReturnCode = returnCode; +} + +void DeviceHandlerCommander::readCommandQueue() { + CommandMessage message; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + } +} + +ReturnValue_t DeviceHandlerCommander::sendCommand(object_id_t target, ActionId_t actionId) { + return commandActionHelper.commandAction(target, actionId, nullptr, 0); +} + +ReturnValue_t DeviceHandlerCommander::getReplyReturnCode() { return lastReplyReturnCode; } + +void DeviceHandlerCommander::resetReplyReturnCode() { lastReplyReturnCode = RETURN_FAILED; } diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h b/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h similarity index 97% rename from tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h rename to src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h index 82183baf..435d0017 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h +++ b/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h @@ -1,50 +1,50 @@ -#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ -#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ - -#include "fsfw/action/CommandActionHelper.h" -#include "fsfw/action/CommandsActionsIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/tasks/ExecutableObjectIF.h" - -class DeviceHandlerCommander : public ExecutableObjectIF, - public SystemObject, - public CommandsActionsIF, - public HasReturnvaluesIF { - public: - DeviceHandlerCommander(object_id_t objectId); - virtual ~DeviceHandlerCommander(); - - ReturnValue_t performOperation(uint8_t operationCode = 0); - ReturnValue_t initialize() override; - MessageQueueIF* getCommandQueuePtr() override; - void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; - void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; - void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; - void completionSuccessfulReceived(ActionId_t actionId) override; - void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; - - /** - * @brief Calling this function will send the command to the device handler object. - * - * @param target Object ID of the device handler - * @param actionId Action ID of the command to send - */ - ReturnValue_t sendCommand(object_id_t target, ActionId_t actionId); - - ReturnValue_t getReplyReturnCode(); - void resetReplyReturnCode(); - - private: - static const uint32_t QUEUE_SIZE = 20; - - MessageQueueIF* commandQueue = nullptr; - - CommandActionHelper commandActionHelper; - - ReturnValue_t lastReplyReturnCode = RETURN_FAILED; - - void readCommandQueue(); -}; - -#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ */ +#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ +#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ + +#include "fsfw/action/CommandActionHelper.h" +#include "fsfw/action/CommandsActionsIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" + +class DeviceHandlerCommander : public ExecutableObjectIF, + public SystemObject, + public CommandsActionsIF, + public HasReturnvaluesIF { + public: + DeviceHandlerCommander(object_id_t objectId); + virtual ~DeviceHandlerCommander(); + + ReturnValue_t performOperation(uint8_t operationCode = 0); + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + + /** + * @brief Calling this function will send the command to the device handler object. + * + * @param target Object ID of the device handler + * @param actionId Action ID of the command to send + */ + ReturnValue_t sendCommand(object_id_t target, ActionId_t actionId); + + ReturnValue_t getReplyReturnCode(); + void resetReplyReturnCode(); + + private: + static const uint32_t QUEUE_SIZE = 20; + + MessageQueueIF* commandQueue = nullptr; + + CommandActionHelper commandActionHelper; + + ReturnValue_t lastReplyReturnCode = RETURN_FAILED; + + void readCommandQueue(); +}; + +#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERCOMMANDER_H_ */ diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp b/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp similarity index 96% rename from tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp rename to src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp index 1e05f8f3..ea30ff6a 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp +++ b/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp @@ -1,103 +1,103 @@ -#include "DeviceHandlerMock.h" - -#include - -DeviceHandlerMock::DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, - CookieIF *comCookie, FailureIsolationBase *fdirInstance) - : DeviceHandlerBase(objectId, deviceCommunication, comCookie, fdirInstance) { - mode = MODE_ON; -} - -DeviceHandlerMock::~DeviceHandlerMock() {} - -void DeviceHandlerMock::doStartUp() { setMode(_MODE_TO_ON); } - -void DeviceHandlerMock::doShutDown() { setMode(_MODE_POWER_DOWN); } - -ReturnValue_t DeviceHandlerMock::buildNormalDeviceCommand(DeviceCommandId_t *id) { - return NOTHING_TO_SEND; -} - -ReturnValue_t DeviceHandlerMock::buildTransitionDeviceCommand(DeviceCommandId_t *id) { - return NOTHING_TO_SEND; -} - -ReturnValue_t DeviceHandlerMock::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, - size_t commandDataLen) { - switch (deviceCommand) { - case SIMPLE_COMMAND: { - commandBuffer[0] = SIMPLE_COMMAND_DATA; - rawPacket = commandBuffer; - rawPacketLen = sizeof(SIMPLE_COMMAND_DATA); - break; - } - default: - WARN("DeviceHandlerMock::buildCommandFromCommand: Invalid device command"); - break; - } - return RETURN_OK; -} - -ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, - DeviceCommandId_t *foundId, size_t *foundLen) { - switch (*start) { - case SIMPLE_COMMAND_DATA: { - *foundId = SIMPLE_COMMAND; - *foundLen = sizeof(SIMPLE_COMMAND_DATA); - return RETURN_OK; - break; - } - case PERIODIC_REPLY_DATA: { - *foundId = PERIODIC_REPLY; - *foundLen = sizeof(PERIODIC_REPLY_DATA); - return RETURN_OK; - break; - } - default: - break; - } - return RETURN_FAILED; -} - -ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { - switch (id) { - case SIMPLE_COMMAND: - case PERIODIC_REPLY: { - periodicReplyReceived = true; - break; - } - default: - break; - } - return RETURN_OK; -} - -void DeviceHandlerMock::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(SIMPLE_COMMAND, 0, nullptr, 0, false, false, 0, - &simpleCommandReplyTimeout); - insertInCommandAndReplyMap(PERIODIC_REPLY, 0, nullptr, 0, true, false, 0, - &periodicReplyCountdown); -} - -uint32_t DeviceHandlerMock::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } - -void DeviceHandlerMock::changePeriodicReplyCountdown(uint32_t timeout) { - periodicReplyCountdown.setTimeout(timeout); -} - -void DeviceHandlerMock::changeSimpleCommandReplyCountdown(uint32_t timeout) { - simpleCommandReplyTimeout.setTimeout(timeout); -} - -void DeviceHandlerMock::resetPeriodicReplyState() { periodicReplyReceived = false; } - -bool DeviceHandlerMock::getPeriodicReplyReceived() { return periodicReplyReceived; } - -ReturnValue_t DeviceHandlerMock::enablePeriodicReply(DeviceCommandId_t replyId) { - return updatePeriodicReply(true, replyId); -} - -ReturnValue_t DeviceHandlerMock::disablePeriodicReply(DeviceCommandId_t replyId) { - return updatePeriodicReply(false, replyId); -} +#include "DeviceHandlerMock.h" + +#include + +DeviceHandlerMock::DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, + CookieIF *comCookie, FailureIsolationBase *fdirInstance) + : DeviceHandlerBase(objectId, deviceCommunication, comCookie, fdirInstance) { + mode = MODE_ON; +} + +DeviceHandlerMock::~DeviceHandlerMock() {} + +void DeviceHandlerMock::doStartUp() { setMode(_MODE_TO_ON); } + +void DeviceHandlerMock::doShutDown() { setMode(_MODE_POWER_DOWN); } + +ReturnValue_t DeviceHandlerMock::buildNormalDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t DeviceHandlerMock::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t DeviceHandlerMock::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + switch (deviceCommand) { + case SIMPLE_COMMAND: { + commandBuffer[0] = SIMPLE_COMMAND_DATA; + rawPacket = commandBuffer; + rawPacketLen = sizeof(SIMPLE_COMMAND_DATA); + break; + } + default: + WARN("DeviceHandlerMock::buildCommandFromCommand: Invalid device command"); + break; + } + return RETURN_OK; +} + +ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) { + switch (*start) { + case SIMPLE_COMMAND_DATA: { + *foundId = SIMPLE_COMMAND; + *foundLen = sizeof(SIMPLE_COMMAND_DATA); + return RETURN_OK; + break; + } + case PERIODIC_REPLY_DATA: { + *foundId = PERIODIC_REPLY; + *foundLen = sizeof(PERIODIC_REPLY_DATA); + return RETURN_OK; + break; + } + default: + break; + } + return RETURN_FAILED; +} + +ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + switch (id) { + case SIMPLE_COMMAND: + case PERIODIC_REPLY: { + periodicReplyReceived = true; + break; + } + default: + break; + } + return RETURN_OK; +} + +void DeviceHandlerMock::fillCommandAndReplyMap() { + insertInCommandAndReplyMap(SIMPLE_COMMAND, 0, nullptr, 0, false, false, 0, + &simpleCommandReplyTimeout); + insertInCommandAndReplyMap(PERIODIC_REPLY, 0, nullptr, 0, true, false, 0, + &periodicReplyCountdown); +} + +uint32_t DeviceHandlerMock::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } + +void DeviceHandlerMock::changePeriodicReplyCountdown(uint32_t timeout) { + periodicReplyCountdown.setTimeout(timeout); +} + +void DeviceHandlerMock::changeSimpleCommandReplyCountdown(uint32_t timeout) { + simpleCommandReplyTimeout.setTimeout(timeout); +} + +void DeviceHandlerMock::resetPeriodicReplyState() { periodicReplyReceived = false; } + +bool DeviceHandlerMock::getPeriodicReplyReceived() { return periodicReplyReceived; } + +ReturnValue_t DeviceHandlerMock::enablePeriodicReply(DeviceCommandId_t replyId) { + return updatePeriodicReply(true, replyId); +} + +ReturnValue_t DeviceHandlerMock::disablePeriodicReply(DeviceCommandId_t replyId) { + return updatePeriodicReply(false, replyId); +} diff --git a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h b/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h similarity index 97% rename from tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h rename to src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h index f5fcb4aa..ef1649c3 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h +++ b/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h @@ -1,46 +1,46 @@ -#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ -#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ - -#include - -class DeviceHandlerMock : public DeviceHandlerBase { - public: - static const DeviceCommandId_t SIMPLE_COMMAND = 1; - static const DeviceCommandId_t PERIODIC_REPLY = 2; - - static const uint8_t SIMPLE_COMMAND_DATA = 1; - static const uint8_t PERIODIC_REPLY_DATA = 2; - - DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, - FailureIsolationBase *fdirInstance); - virtual ~DeviceHandlerMock(); - void changePeriodicReplyCountdown(uint32_t timeout); - void changeSimpleCommandReplyCountdown(uint32_t timeout); - void resetPeriodicReplyState(); - bool getPeriodicReplyReceived(); - ReturnValue_t enablePeriodicReply(DeviceCommandId_t replyId); - ReturnValue_t disablePeriodicReply(DeviceCommandId_t replyId); - - protected: - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, - size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; - void fillCommandAndReplyMap() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - - private: - Countdown simpleCommandReplyTimeout = Countdown(1000); - Countdown periodicReplyCountdown = Countdown(1000); - - uint8_t commandBuffer[1]; - - bool periodicReplyReceived = false; -}; - -#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ */ +#ifndef TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ +#define TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ + +#include + +class DeviceHandlerMock : public DeviceHandlerBase { + public: + static const DeviceCommandId_t SIMPLE_COMMAND = 1; + static const DeviceCommandId_t PERIODIC_REPLY = 2; + + static const uint8_t SIMPLE_COMMAND_DATA = 1; + static const uint8_t PERIODIC_REPLY_DATA = 2; + + DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, + FailureIsolationBase *fdirInstance); + virtual ~DeviceHandlerMock(); + void changePeriodicReplyCountdown(uint32_t timeout); + void changeSimpleCommandReplyCountdown(uint32_t timeout); + void resetPeriodicReplyState(); + bool getPeriodicReplyReceived(); + ReturnValue_t enablePeriodicReply(DeviceCommandId_t replyId); + ReturnValue_t disablePeriodicReply(DeviceCommandId_t replyId); + + protected: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + + private: + Countdown simpleCommandReplyTimeout = Countdown(1000); + Countdown periodicReplyCountdown = Countdown(1000); + + uint8_t commandBuffer[1]; + + bool periodicReplyReceived = false; +}; + +#endif /* TESTS_SRC_FSFW_TESTS_UNIT_DEVICEHANDLER_DEVICEHANDLERMOCK_H_ */ diff --git a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp b/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp similarity index 98% rename from tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp rename to src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp index 873329c3..e82a39b7 100644 --- a/tests/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp +++ b/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp @@ -1,95 +1,95 @@ -#include - -#include "ComIFMock.h" -#include "DeviceFdirMock.h" -#include "fsfw_tests/unit/devicehandler/CookieIFMock.h" -#include "fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h" -#include "fsfw_tests/unit/devicehandler/DeviceHandlerMock.h" -#include "fsfw_tests/unit/testcfg/objects/systemObjectList.h" - -TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { - // Will be deleted with DHB destructor - CookieIFMock* cookieIFMock = new CookieIFMock; - ComIFMock comIF(objects::COM_IF_MOCK); - DeviceFdirMock deviceFdirMock(objects::DEVICE_HANDLER_MOCK, objects::NO_OBJECT); - DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK, - cookieIFMock, &deviceFdirMock); - ReturnValue_t result = deviceHandlerMock.initialize(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER); - result = deviceHandlerCommander.initialize(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - - SECTION("Commanding nominal") { - comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL); - result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, - DeviceHandlerMock::SIMPLE_COMMAND); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); - deviceHandlerCommander.performOperation(); - result = deviceHandlerCommander.getReplyReturnCode(); - uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); - REQUIRE(missedReplies == 0); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - } - - SECTION("Commanding missed reply") { - comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); - deviceHandlerCommander.resetReplyReturnCode(); - // Set the timeout to 0 to immediately timeout the reply - deviceHandlerMock.changeSimpleCommandReplyCountdown(0); - result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, - DeviceHandlerMock::SIMPLE_COMMAND); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); - deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); - deviceHandlerCommander.performOperation(); - result = deviceHandlerCommander.getReplyReturnCode(); - REQUIRE(result == DeviceHandlerIF::TIMEOUT); - uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); - REQUIRE(missedReplies == 1); - } - - SECTION("Periodic reply nominal") { - comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL); - deviceHandlerMock.enablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY); - deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); - REQUIRE(deviceHandlerMock.getPeriodicReplyReceived() == true); - } - - SECTION("Missed periodic reply") { - comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); - // Set the timeout to 0 to immediately timeout the reply - deviceHandlerMock.changePeriodicReplyCountdown(0); - deviceHandlerMock.enablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY); - deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); - uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); - REQUIRE(missedReplies == 1); - // Test if disabling of periodic reply - deviceHandlerMock.disablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY); - deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); - deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); - deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); - missedReplies = deviceFdirMock.getMissedReplyCount(); - // Should still be 1 because periodic reply is now disabled - REQUIRE(missedReplies == 1); - } -} +#include + +#include "ComIFMock.h" +#include "DeviceFdirMock.h" +#include "fsfw_tests/unit/devicehandler/CookieIFMock.h" +#include "fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h" +#include "fsfw_tests/unit/devicehandler/DeviceHandlerMock.h" +#include "fsfw_tests/unit/testcfg/objects/systemObjectList.h" + +TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { + // Will be deleted with DHB destructor + CookieIFMock* cookieIFMock = new CookieIFMock; + ComIFMock comIF(objects::COM_IF_MOCK); + DeviceFdirMock deviceFdirMock(objects::DEVICE_HANDLER_MOCK, objects::NO_OBJECT); + DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK, + cookieIFMock, &deviceFdirMock); + ReturnValue_t result = deviceHandlerMock.initialize(); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER); + result = deviceHandlerCommander.initialize(); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + + SECTION("Commanding nominal") { + comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL); + result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, + DeviceHandlerMock::SIMPLE_COMMAND); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + deviceHandlerCommander.performOperation(); + result = deviceHandlerCommander.getReplyReturnCode(); + uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); + REQUIRE(missedReplies == 0); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + } + + SECTION("Commanding missed reply") { + comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); + deviceHandlerCommander.resetReplyReturnCode(); + // Set the timeout to 0 to immediately timeout the reply + deviceHandlerMock.changeSimpleCommandReplyCountdown(0); + result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, + DeviceHandlerMock::SIMPLE_COMMAND); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerCommander.performOperation(); + result = deviceHandlerCommander.getReplyReturnCode(); + REQUIRE(result == DeviceHandlerIF::TIMEOUT); + uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); + REQUIRE(missedReplies == 1); + } + + SECTION("Periodic reply nominal") { + comIF.setTestCase(ComIFMock::TestCase::PERIODIC_REPLY_NOMINAL); + deviceHandlerMock.enablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + REQUIRE(deviceHandlerMock.getPeriodicReplyReceived() == true); + } + + SECTION("Missed periodic reply") { + comIF.setTestCase(ComIFMock::TestCase::MISSED_REPLY); + // Set the timeout to 0 to immediately timeout the reply + deviceHandlerMock.changePeriodicReplyCountdown(0); + deviceHandlerMock.enablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); + REQUIRE(missedReplies == 1); + // Test if disabling of periodic reply + deviceHandlerMock.disablePeriodicReply(DeviceHandlerMock::PERIODIC_REPLY); + deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); + deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_READ); + deviceHandlerMock.performOperation(DeviceHandlerIF::GET_READ); + missedReplies = deviceFdirMock.getMissedReplyCount(); + // Should still be 1 because periodic reply is now disabled + REQUIRE(missedReplies == 1); + } +} diff --git a/tests/src/fsfw_tests/unit/globalfunctions/CMakeLists.txt b/src/fsfw_tests/unit/globalfunctions/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/globalfunctions/CMakeLists.txt rename to src/fsfw_tests/unit/globalfunctions/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/globalfunctions/testBitutil.cpp b/src/fsfw_tests/unit/globalfunctions/testBitutil.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/globalfunctions/testBitutil.cpp rename to src/fsfw_tests/unit/globalfunctions/testBitutil.cpp diff --git a/tests/src/fsfw_tests/unit/globalfunctions/testCRC.cpp b/src/fsfw_tests/unit/globalfunctions/testCRC.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/globalfunctions/testCRC.cpp rename to src/fsfw_tests/unit/globalfunctions/testCRC.cpp diff --git a/tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp b/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp rename to src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp diff --git a/tests/src/fsfw_tests/unit/globalfunctions/testOpDivider.cpp b/src/fsfw_tests/unit/globalfunctions/testOpDivider.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/globalfunctions/testOpDivider.cpp rename to src/fsfw_tests/unit/globalfunctions/testOpDivider.cpp diff --git a/tests/src/fsfw_tests/unit/globalfunctions/testTimevalOperations.cpp b/src/fsfw_tests/unit/globalfunctions/testTimevalOperations.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/globalfunctions/testTimevalOperations.cpp rename to src/fsfw_tests/unit/globalfunctions/testTimevalOperations.cpp diff --git a/tests/src/fsfw_tests/unit/hal/CMakeLists.txt b/src/fsfw_tests/unit/hal/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/hal/CMakeLists.txt rename to src/fsfw_tests/unit/hal/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp b/src/fsfw_tests/unit/hal/testCommandExecutor.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/hal/testCommandExecutor.cpp rename to src/fsfw_tests/unit/hal/testCommandExecutor.cpp diff --git a/tests/src/fsfw_tests/unit/internalerror/CMakeLists.txt b/src/fsfw_tests/unit/internalerror/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/internalerror/CMakeLists.txt rename to src/fsfw_tests/unit/internalerror/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/internalerror/TestInternalErrorReporter.cpp b/src/fsfw_tests/unit/internalerror/TestInternalErrorReporter.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/internalerror/TestInternalErrorReporter.cpp rename to src/fsfw_tests/unit/internalerror/TestInternalErrorReporter.cpp diff --git a/tests/src/fsfw_tests/unit/mocks/CMakeLists.txt b/src/fsfw_tests/unit/mocks/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/mocks/CMakeLists.txt rename to src/fsfw_tests/unit/mocks/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/mocks/HkReceiverMock.h b/src/fsfw_tests/unit/mocks/HkReceiverMock.h similarity index 100% rename from tests/src/fsfw_tests/unit/mocks/HkReceiverMock.h rename to src/fsfw_tests/unit/mocks/HkReceiverMock.h diff --git a/tests/src/fsfw_tests/unit/mocks/MessageQueueMockBase.h b/src/fsfw_tests/unit/mocks/MessageQueueMockBase.h similarity index 100% rename from tests/src/fsfw_tests/unit/mocks/MessageQueueMockBase.h rename to src/fsfw_tests/unit/mocks/MessageQueueMockBase.h diff --git a/tests/src/fsfw_tests/unit/mocks/PeriodicTaskIFMock.h b/src/fsfw_tests/unit/mocks/PeriodicTaskIFMock.h similarity index 100% rename from tests/src/fsfw_tests/unit/mocks/PeriodicTaskIFMock.h rename to src/fsfw_tests/unit/mocks/PeriodicTaskIFMock.h diff --git a/tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.cpp b/src/fsfw_tests/unit/mocks/PowerSwitcherMock.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.cpp rename to src/fsfw_tests/unit/mocks/PowerSwitcherMock.cpp diff --git a/tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.h b/src/fsfw_tests/unit/mocks/PowerSwitcherMock.h similarity index 100% rename from tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.h rename to src/fsfw_tests/unit/mocks/PowerSwitcherMock.h diff --git a/tests/src/fsfw_tests/unit/osal/CMakeLists.txt b/src/fsfw_tests/unit/osal/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/osal/CMakeLists.txt rename to src/fsfw_tests/unit/osal/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/osal/TestClock.cpp b/src/fsfw_tests/unit/osal/TestClock.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/osal/TestClock.cpp rename to src/fsfw_tests/unit/osal/TestClock.cpp diff --git a/tests/src/fsfw_tests/unit/osal/TestMessageQueue.cpp b/src/fsfw_tests/unit/osal/TestMessageQueue.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/osal/TestMessageQueue.cpp rename to src/fsfw_tests/unit/osal/TestMessageQueue.cpp diff --git a/tests/src/fsfw_tests/unit/osal/TestSemaphore.cpp b/src/fsfw_tests/unit/osal/TestSemaphore.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/osal/TestSemaphore.cpp rename to src/fsfw_tests/unit/osal/TestSemaphore.cpp diff --git a/tests/src/fsfw_tests/unit/power/CMakeLists.txt b/src/fsfw_tests/unit/power/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/power/CMakeLists.txt rename to src/fsfw_tests/unit/power/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/power/testPowerSwitcher.cpp b/src/fsfw_tests/unit/power/testPowerSwitcher.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/power/testPowerSwitcher.cpp rename to src/fsfw_tests/unit/power/testPowerSwitcher.cpp diff --git a/tests/src/fsfw_tests/unit/printChar.cpp b/src/fsfw_tests/unit/printChar.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/printChar.cpp rename to src/fsfw_tests/unit/printChar.cpp diff --git a/tests/src/fsfw_tests/unit/printChar.h b/src/fsfw_tests/unit/printChar.h similarity index 100% rename from tests/src/fsfw_tests/unit/printChar.h rename to src/fsfw_tests/unit/printChar.h diff --git a/tests/src/fsfw_tests/unit/serialize/CMakeLists.txt b/src/fsfw_tests/unit/serialize/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/serialize/CMakeLists.txt rename to src/fsfw_tests/unit/serialize/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/serialize/TestSerialBufferAdapter.cpp b/src/fsfw_tests/unit/serialize/TestSerialBufferAdapter.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/serialize/TestSerialBufferAdapter.cpp rename to src/fsfw_tests/unit/serialize/TestSerialBufferAdapter.cpp diff --git a/tests/src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.cpp b/src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.cpp rename to src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.cpp diff --git a/tests/src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.h b/src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.h similarity index 100% rename from tests/src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.h rename to src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.h diff --git a/tests/src/fsfw_tests/unit/serialize/TestSerialization.cpp b/src/fsfw_tests/unit/serialize/TestSerialization.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/serialize/TestSerialization.cpp rename to src/fsfw_tests/unit/serialize/TestSerialization.cpp diff --git a/tests/src/fsfw_tests/unit/storagemanager/CMakeLists.txt b/src/fsfw_tests/unit/storagemanager/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/storagemanager/CMakeLists.txt rename to src/fsfw_tests/unit/storagemanager/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/storagemanager/TestNewAccessor.cpp b/src/fsfw_tests/unit/storagemanager/TestNewAccessor.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/storagemanager/TestNewAccessor.cpp rename to src/fsfw_tests/unit/storagemanager/TestNewAccessor.cpp diff --git a/tests/src/fsfw_tests/unit/storagemanager/TestPool.cpp b/src/fsfw_tests/unit/storagemanager/TestPool.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/storagemanager/TestPool.cpp rename to src/fsfw_tests/unit/storagemanager/TestPool.cpp diff --git a/tests/src/fsfw_tests/unit/testcfg/CMakeLists.txt b/src/fsfw_tests/unit/testcfg/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/CMakeLists.txt rename to src/fsfw_tests/unit/testcfg/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in b/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in rename to src/fsfw_tests/unit/testcfg/FSFWConfig.h.in diff --git a/tests/src/fsfw_tests/unit/testcfg/OBSWConfig.h.in b/src/fsfw_tests/unit/testcfg/OBSWConfig.h.in similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/OBSWConfig.h.in rename to src/fsfw_tests/unit/testcfg/OBSWConfig.h.in diff --git a/tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in b/src/fsfw_tests/unit/testcfg/TestsConfig.h.in similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in rename to src/fsfw_tests/unit/testcfg/TestsConfig.h.in diff --git a/tests/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.cpp b/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.cpp rename to src/fsfw_tests/unit/testcfg/devices/logicalAddresses.cpp diff --git a/tests/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.h b/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.h similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.h rename to src/fsfw_tests/unit/testcfg/devices/logicalAddresses.h diff --git a/tests/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.cpp b/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.cpp rename to src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.cpp diff --git a/tests/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.h b/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.h similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.h rename to src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.h diff --git a/tests/src/fsfw_tests/unit/testcfg/events/subsystemIdRanges.h b/src/fsfw_tests/unit/testcfg/events/subsystemIdRanges.h similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/events/subsystemIdRanges.h rename to src/fsfw_tests/unit/testcfg/events/subsystemIdRanges.h diff --git a/tests/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.cpp b/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.cpp rename to src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.cpp diff --git a/tests/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.h b/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.h similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.h rename to src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.h diff --git a/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h b/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h similarity index 95% rename from tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h rename to src/fsfw_tests/unit/testcfg/objects/systemObjectList.h index 17b980e9..7d12e5c6 100644 --- a/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h +++ b/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h @@ -1,34 +1,34 @@ -#ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ -#define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ - -#include - -#include "fsfw/objectmanager/frameworkObjects.h" - -// The objects will be instantiated in the ID order -namespace objects { -enum sourceObjects : uint32_t { - /* All addresses between start and end are reserved for the FSFW */ - FSFW_CONFIG_RESERVED_START = PUS_SERVICE_1_VERIFICATION, - FSFW_CONFIG_RESERVED_END = TM_STORE, - - UDP_BRIDGE = 15, - UDP_POLLING_TASK = 16, - - TEST_ECHO_COM_IF = 20, - TEST_DEVICE = 21, - - HK_RECEIVER_MOCK = 22, - TEST_LOCAL_POOL_OWNER_BASE = 25, - - SHARED_SET_ID = 26, - - DUMMY_POWER_SWITCHER = 28, - - DEVICE_HANDLER_MOCK = 29, - COM_IF_MOCK = 30, - DEVICE_HANDLER_COMMANDER = 40, -}; -} - -#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ +#ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ +#define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ + +#include + +#include "fsfw/objectmanager/frameworkObjects.h" + +// The objects will be instantiated in the ID order +namespace objects { +enum sourceObjects : uint32_t { + /* All addresses between start and end are reserved for the FSFW */ + FSFW_CONFIG_RESERVED_START = PUS_SERVICE_1_VERIFICATION, + FSFW_CONFIG_RESERVED_END = TM_STORE, + + UDP_BRIDGE = 15, + UDP_POLLING_TASK = 16, + + TEST_ECHO_COM_IF = 20, + TEST_DEVICE = 21, + + HK_RECEIVER_MOCK = 22, + TEST_LOCAL_POOL_OWNER_BASE = 25, + + SHARED_SET_ID = 26, + + DUMMY_POWER_SWITCHER = 28, + + DEVICE_HANDLER_MOCK = 29, + COM_IF_MOCK = 30, + DEVICE_HANDLER_COMMANDER = 40, +}; +} + +#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ diff --git a/tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp b/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp rename to src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp diff --git a/tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.h b/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.h similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.h rename to src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.h diff --git a/tests/src/fsfw_tests/unit/testcfg/returnvalues/classIds.h b/src/fsfw_tests/unit/testcfg/returnvalues/classIds.h similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/returnvalues/classIds.h rename to src/fsfw_tests/unit/testcfg/returnvalues/classIds.h diff --git a/tests/src/fsfw_tests/unit/testcfg/tmtc/apid.h b/src/fsfw_tests/unit/testcfg/tmtc/apid.h similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/tmtc/apid.h rename to src/fsfw_tests/unit/testcfg/tmtc/apid.h diff --git a/tests/src/fsfw_tests/unit/testcfg/tmtc/pusIds.h b/src/fsfw_tests/unit/testcfg/tmtc/pusIds.h similarity index 100% rename from tests/src/fsfw_tests/unit/testcfg/tmtc/pusIds.h rename to src/fsfw_tests/unit/testcfg/tmtc/pusIds.h diff --git a/tests/src/fsfw_tests/unit/testtemplate/TestTemplate.cpp b/src/fsfw_tests/unit/testtemplate/TestTemplate.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/testtemplate/TestTemplate.cpp rename to src/fsfw_tests/unit/testtemplate/TestTemplate.cpp diff --git a/tests/src/fsfw_tests/unit/timemanager/CMakeLists.txt b/src/fsfw_tests/unit/timemanager/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/timemanager/CMakeLists.txt rename to src/fsfw_tests/unit/timemanager/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp b/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp rename to src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp diff --git a/tests/src/fsfw_tests/unit/timemanager/TestCountdown.cpp b/src/fsfw_tests/unit/timemanager/TestCountdown.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/timemanager/TestCountdown.cpp rename to src/fsfw_tests/unit/timemanager/TestCountdown.cpp diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt b/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt similarity index 100% rename from tests/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt rename to src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp b/src/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp rename to src/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp b/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp rename to src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp diff --git a/tests/src/fsfw_tests/unit/version.cpp b/src/fsfw_tests/unit/version.cpp similarity index 100% rename from tests/src/fsfw_tests/unit/version.cpp rename to src/fsfw_tests/unit/version.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt deleted file mode 100644 index febd4f0a..00000000 --- a/tests/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(src) diff --git a/tests/src/CMakeLists.txt b/tests/src/CMakeLists.txt deleted file mode 100644 index 6673f1e4..00000000 --- a/tests/src/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -target_include_directories(${LIB_FSFW_NAME} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} -) - -target_include_directories(${LIB_FSFW_NAME} INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR} -) - -add_subdirectory(fsfw_tests) From 3b23fb77b48b70f310894936afac3ac3fd3c8194 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 09:01:45 +0200 Subject: [PATCH 035/532] add obsolete add_subdirectory calls --- CMakeLists.txt | 4 ---- src/CMakeLists.txt | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9e3e471..dcfa89ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,10 +282,6 @@ message( ) add_subdirectory(src) -add_subdirectory(tests) -if(FSFW_ADD_HAL) - add_subdirectory(hal) -endif() add_subdirectory(contrib) if(FSFW_BUILD_DOCS) add_subdirectory(docs) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6d7f83b3..57b24bd5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,5 +4,8 @@ target_include_directories(${LIB_FSFW_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(fsfw) -add_subdirectory(fsfw_hal) +if(FSFW_ADD_HAL) + add_subdirectory(fsfw_hal) +endif() + add_subdirectory(fsfw_tests) From 0a7f2c6646481e1af22afa667aea9abac0497ce0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 10:20:26 +0200 Subject: [PATCH 036/532] refactored space packet interface --- CMakeLists.txt | 2 +- src/fsfw/osal/linux/MessageQueue.cpp | 3 +- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 2 +- src/fsfw/tcdistribution/TcPacketCheckPUS.cpp | 12 +-- src/fsfw/tmtcpacket/CMakeLists.txt | 2 +- .../tmtcpacket/RedirectableDataPointerIF.h | 9 +- src/fsfw/tmtcpacket/SpacePacket.cpp | 28 ------ src/fsfw/tmtcpacket/SpacePacket.h | 89 ------------------ src/fsfw/tmtcpacket/SpacePacketBase.cpp | 86 ++++++------------ src/fsfw/tmtcpacket/SpacePacketBase.h | 85 +++-------------- src/fsfw/tmtcpacket/SpacePacketIF.h | 91 +++++++++++++++++++ src/fsfw/tmtcpacket/ccsds_header.h | 14 +-- src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp | 30 +++--- src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h | 7 -- .../tmtcpacket/packetmatcher/ApidMatcher.h | 19 ++-- .../packetmatcher/PacketMatchTree.cpp | 4 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp | 4 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h | 2 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h | 2 +- .../tmtcpacket/pus/tc/TcPacketStoredPus.cpp | 8 +- src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp | 10 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp | 12 +-- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h | 2 +- .../tmtcpacket/pus/tm/TmPacketStoredPusC.cpp | 6 +- .../tmtcpacket/pus/tm/TmPacketStoredPusC.h | 2 +- .../tmtcservices/CommandingServiceBase.cpp | 2 +- .../tmtcservices/VerificationReporter.cpp | 10 +- .../fsfw_tests/unit/tmtcpacket/testCcsds.cpp | 10 +- 29 files changed, 218 insertions(+), 339 deletions(-) delete mode 100644 src/fsfw/tmtcpacket/SpacePacket.cpp delete mode 100644 src/fsfw/tmtcpacket/SpacePacket.h create mode 100644 src/fsfw/tmtcpacket/SpacePacketIF.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e9e3e471..440d7f9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,7 +133,7 @@ option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF) set(FSFW_TEST_TGT fsfw-tests) set(FSFW_DUMMY_TGT fsfw-dummy) -add_library(${LIB_FSFW_NAME}) +add_library(${LIB_FSFW_NAME} src/fsfw/tmtcpacket/SpacePacketIF.h) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index 4ef7f756..ec212165 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -292,7 +292,8 @@ ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messag sif::error << "MessageQueue::MessageQueue: Default MQ size " << defaultMqMaxMsg << " is too small for requested message depth " << messageDepth << std::endl; sif::error << "This error can be fixed by setting the maximum " - "allowed message depth higher" << std::endl; + "allowed message depth higher" + << std::endl; #else sif::printError( "MessageQueue::MessageQueue: Default MQ size %d is too small for" diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index 628dd8d0..0be177bf 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -46,7 +46,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex << currentPacket.getAPID() << std::dec << std::endl; #endif - auto position = this->queueMap.find(currentPacket.getAPID()); + auto position = this->queueMap.find(currentPacket.getApid()); if (position != this->queueMap.end()) { return position; } else { diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp index 83844337..6d7092e5 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp @@ -11,8 +11,8 @@ TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid) : apid(setApid) {} ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) { - TcPacketStoredBase* storedPacket = dynamic_cast(currentPacket); - TcPacketPusBase* tcPacketBase = dynamic_cast(currentPacket); + auto* storedPacket = dynamic_cast(currentPacket); + auto* tcPacketBase = dynamic_cast(currentPacket); if (tcPacketBase == nullptr or storedPacket == nullptr) { return RETURN_FAILED; } @@ -21,13 +21,13 @@ ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) { if (calculated_crc != 0) { return INCORRECT_CHECKSUM; } - bool condition = (not tcPacketBase->hasSecondaryHeader()) or - (tcPacketBase->getPacketVersionNumber() != CCSDS_VERSION_NUMBER) or - (not tcPacketBase->isTelecommand()); + bool condition = (not tcPacketBase->hasSecHeader()) or + (tcPacketBase->getVersion() != CCSDS_VERSION_NUMBER) or + (not tcPacketBase->isTc()); if (condition) { return INCORRECT_PRIMARY_HEADER; } - if (tcPacketBase->getAPID() != this->apid) return ILLEGAL_APID; + if (tcPacketBase->getApid() != this->apid) return ILLEGAL_APID; if (not storedPacket->isSizeCorrect()) { return INCOMPLETE_PACKET; diff --git a/src/fsfw/tmtcpacket/CMakeLists.txt b/src/fsfw/tmtcpacket/CMakeLists.txt index 196ba752..dc09c9c9 100644 --- a/src/fsfw/tmtcpacket/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE SpacePacket.cpp SpacePacketBase.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE SpacePacketBase.cpp) add_subdirectory(cfdp) add_subdirectory(packetmatcher) diff --git a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h index 364feb4e..6eb16edd 100644 --- a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h +++ b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h @@ -11,7 +11,7 @@ */ class RedirectableDataPointerIF { public: - virtual ~RedirectableDataPointerIF(){}; + virtual ~RedirectableDataPointerIF() = default; /** * Redirect the data pointer, but allow an implementation to change the data. @@ -25,9 +25,12 @@ class RedirectableDataPointerIF { * - RETURN_OK if the pointer was set successfully * - RETURN_FAILED on general error of if the maximum size is too small */ - virtual ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) = 0; + virtual ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) = 0; + virtual ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize) { + return setData(dataPtr, maxSize, nullptr); + } private: }; -#endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_ */ +#endif /* TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_ */ diff --git a/src/fsfw/tmtcpacket/SpacePacket.cpp b/src/fsfw/tmtcpacket/SpacePacket.cpp deleted file mode 100644 index 16d968fb..00000000 --- a/src/fsfw/tmtcpacket/SpacePacket.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "fsfw/tmtcpacket/SpacePacket.h" - -#include - -#include "fsfw/tmtcpacket/ccsds_header.h" - -SpacePacket::SpacePacket(uint16_t packetDataLength, bool isTelecommand, uint16_t apid, - uint16_t sequenceCount) - : SpacePacketBase((uint8_t*)&this->localData) { - initSpacePacketHeader(isTelecommand, false, apid, sequenceCount); - this->setPacketSequenceCount(sequenceCount); - if (packetDataLength <= sizeof(this->localData.fields.buffer)) { - this->setPacketDataLength(packetDataLength); - } else { - this->setPacketDataLength(sizeof(this->localData.fields.buffer)); - } -} - -SpacePacket::~SpacePacket(void) {} - -bool SpacePacket::addWholeData(const uint8_t* p_Data, uint32_t packet_size) { - if (packet_size <= sizeof(this->localData)) { - memcpy(this->localData.byteStream, p_Data, packet_size); - return true; - } else { - return false; - } -} diff --git a/src/fsfw/tmtcpacket/SpacePacket.h b/src/fsfw/tmtcpacket/SpacePacket.h deleted file mode 100644 index 10140db1..00000000 --- a/src/fsfw/tmtcpacket/SpacePacket.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef SPACEPACKET_H_ -#define SPACEPACKET_H_ - -#include "SpacePacketBase.h" - -/** - * The SpacePacket class is a representation of a simple CCSDS Space Packet - * without (control over) a secondary header. - * It can be instantiated with a size smaller than \c PACKET_MAX_SIZE. Its - * main use is to serve as an idle packet in case no other packets are sent. - * For the ECSS PUS part the TcPacket and TmPacket classes are used. - * A pointer to \c local_data is passed to the \c SpacePacketBase parent class, - * so the parent's methods are reachable. - * @ingroup tmtcpackets - */ -class SpacePacket : public SpacePacketBase { - public: - static const uint16_t PACKET_MAX_SIZE = 1024; - /** - * The constructor initializes the packet and sets all header information - * according to the passed parameters. - * @param packetDataLength Sets the packet data length field and therefore specifies - * the size of the packet. - * @param isTelecommand Sets the packet type field to either TC (true) or TM (false). - * @param apid Sets the packet's APID field. The default value describes an idle packet. - * @param sequenceCount ets the packet's Source Sequence Count field. - */ - SpacePacket(uint16_t packetDataLength, bool isTelecommand = false, - uint16_t apid = APID_IDLE_PACKET, uint16_t sequenceCount = 0); - /** - * The class's default destructor. - */ - virtual ~SpacePacket(); - /** - * With this call, the complete data content (including the CCSDS Primary - * Header) is overwritten with the byte stream given. - * @param p_data Pointer to data to overwrite the content with - * @param packet_size Size of the data - * @return @li \c true if packet_size is smaller than \c MAX_PACKET_SIZE. - * @li \c false else. - */ - bool addWholeData(const uint8_t* p_data, uint32_t packet_size); - - protected: - /** - * This structure defines the data structure of a Space Packet as local data. - * There's a buffer which corresponds to the Space Packet Data Field with a - * maximum size of \c PACKET_MAX_SIZE. - */ - struct PacketStructured { - CCSDSPrimaryHeader header; - uint8_t buffer[PACKET_MAX_SIZE]; - }; - /** - * This union simplifies accessing the full data content of the Space Packet. - * This is achieved by putting the \c PacketStructured struct in a union with - * a plain buffer. - */ - union SpacePacketData { - PacketStructured fields; - uint8_t byteStream[PACKET_MAX_SIZE + sizeof(CCSDSPrimaryHeader)]; - }; - /** - * This is the data representation of the class. - * It is a struct of CCSDS Primary Header and a data field, which again is - * packed in an union, so the data can be accessed as a byte stream without - * a cast. - */ - SpacePacketData localData; -}; - -namespace spacepacket { - -constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid, - bool secondaryHeaderFlag = true) { - return ((isTc << 4) | (secondaryHeaderFlag << 3) | ((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff); -} - -constexpr uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { - return getSpacePacketIdFromApid(true, apid, secondaryHeaderFlag); -} - -constexpr uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { - return getSpacePacketIdFromApid(false, apid, secondaryHeaderFlag); -} - -} // namespace spacepacket - -#endif /* SPACEPACKET_H_ */ diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.cpp b/src/fsfw/tmtcpacket/SpacePacketBase.cpp index 756d7e50..cb18519e 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketBase.cpp @@ -8,12 +8,7 @@ SpacePacketBase::SpacePacketBase(const uint8_t* setAddress) { this->data = reinterpret_cast(const_cast(setAddress)); } -SpacePacketBase::~SpacePacketBase(){}; - -// CCSDS Methods: -uint8_t SpacePacketBase::getPacketVersionNumber(void) { - return (this->data->header.packet_id_h & 0b11100000) >> 5; -} +SpacePacketBase::~SpacePacketBase() = default; ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid, uint16_t sequenceCount) { @@ -30,82 +25,49 @@ ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool ha // reset header to zero: memset(data, 0, sizeof(this->data->header)); // Set TC/TM bit. - data->header.packet_id_h = ((isTelecommand ? 1 : 0)) << 4; + data->header.packetIdHAndVersion = ((isTelecommand ? 1 : 0)) << 4; // Set secondaryHeader bit - data->header.packet_id_h |= ((hasSecondaryHeader ? 1 : 0)) << 3; - this->setAPID(apid); + data->header.packetIdHAndVersion |= ((hasSecondaryHeader ? 1 : 0)) << 3; + this->setApid(apid); // Always initialize as standalone packets. - data->header.sequence_control_h = 0b11000000; + data->header.packetSeqCtrlH = 0b11000000; setPacketSequenceCount(sequenceCount); return HasReturnvaluesIF::RETURN_OK; } -bool SpacePacketBase::isTelecommand(void) { - return (this->data->header.packet_id_h & 0b00010000) >> 4; +inline uint16_t SpacePacketBase::getPacketId() const { + return ((this->data->header.packetIdHAndVersion) << 8) + this->data->header.packetIdL; } -bool SpacePacketBase::hasSecondaryHeader(void) { - return (this->data->header.packet_id_h & 0b00001000) >> 3; -} - -uint16_t SpacePacketBase::getPacketId() { - return ((this->data->header.packet_id_h) << 8) + this->data->header.packet_id_l; -} - -uint16_t SpacePacketBase::getAPID(void) const { - return ((this->data->header.packet_id_h & 0b00000111) << 8) + this->data->header.packet_id_l; -} - -void SpacePacketBase::setAPID(uint16_t new_apid) { +void SpacePacketBase::setApid(uint16_t setAPID) { // Use first three bits of new APID, but keep rest of packet id as it was (see specification). - this->data->header.packet_id_h = - (this->data->header.packet_id_h & 0b11111000) | ((new_apid & 0x0700) >> 8); - this->data->header.packet_id_l = (new_apid & 0x00FF); + this->data->header.packetIdHAndVersion = + (this->data->header.packetIdHAndVersion & 0b11111000) | ((setAPID & 0x0700) >> 8); + this->data->header.packetIdL = (setAPID & 0x00FF); } void SpacePacketBase::setSequenceFlags(uint8_t sequenceflags) { - this->data->header.sequence_control_h &= 0x3F; - this->data->header.sequence_control_h |= sequenceflags << 6; -} - -uint16_t SpacePacketBase::getPacketSequenceControl(void) { - return ((this->data->header.sequence_control_h) << 8) + this->data->header.sequence_control_l; -} - -uint8_t SpacePacketBase::getSequenceFlags(void) { - return (this->data->header.sequence_control_h & 0b11000000) >> 6; -} - -uint16_t SpacePacketBase::getPacketSequenceCount(void) const { - return ((this->data->header.sequence_control_h & 0b00111111) << 8) + - this->data->header.sequence_control_l; + this->data->header.packetSeqCtrlH &= 0x3F; + this->data->header.packetSeqCtrlH |= sequenceflags << 6; } void SpacePacketBase::setPacketSequenceCount(uint16_t new_count) { - this->data->header.sequence_control_h = (this->data->header.sequence_control_h & 0b11000000) | - (((new_count % LIMIT_SEQUENCE_COUNT) & 0x3F00) >> 8); - this->data->header.sequence_control_l = ((new_count % LIMIT_SEQUENCE_COUNT) & 0x00FF); -} - -uint16_t SpacePacketBase::getPacketDataLength() const { - return ((this->data->header.packet_length_h) << 8) + this->data->header.packet_length_l; + this->data->header.packetSeqCtrlH = (this->data->header.packetSeqCtrlH & 0b11000000) | + (((new_count % ccsds::LIMIT_SEQUENCE_COUNT) & 0x3F00) >> 8); + this->data->header.packetSeqCtrlL = ((new_count % ccsds::LIMIT_SEQUENCE_COUNT) & 0x00FF); } void SpacePacketBase::setPacketDataLength(uint16_t new_length) { - this->data->header.packet_length_h = ((new_length & 0xFF00) >> 8); - this->data->header.packet_length_l = (new_length & 0x00FF); + this->data->header.packetLenH = ((new_length & 0xFF00) >> 8); + this->data->header.packetLenL = (new_length & 0x00FF); } size_t SpacePacketBase::getFullSize() { // +1 is done because size in packet data length field is: size of data field -1 - return this->getPacketDataLength() + sizeof(this->data->header) + 1; + return this->getPacketDataLen() + sizeof(this->data->header) + 1; } -uint8_t* SpacePacketBase::getWholeData() { return (uint8_t*)this->data; } - -uint32_t SpacePacketBase::getApidAndSequenceCount() const { - return (getAPID() << 16) + getPacketSequenceCount(); -} +uint8_t* SpacePacketBase::getWholeData() { return reinterpret_cast(this->data); } uint8_t* SpacePacketBase::getPacketData() { return &(data->packet_data); } @@ -116,3 +78,11 @@ ReturnValue_t SpacePacketBase::setData(uint8_t* pData, size_t maxSize, void* arg this->data = reinterpret_cast(const_cast(pData)); return HasReturnvaluesIF::RETURN_OK; } +uint16_t SpacePacketBase::getPacketSeqCtrl() const { + return ((this->data->header.packetSeqCtrlH & 0b00111111) << 8) + + this->data->header.packetSeqCtrlL; +} + +uint16_t SpacePacketBase::getPacketDataLen() const { + return ((this->data->header.packetLenH) << 8) + this->data->header.packetLenL; +} diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.h b/src/fsfw/tmtcpacket/SpacePacketBase.h index d9ee2b83..862e4725 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.h +++ b/src/fsfw/tmtcpacket/SpacePacketBase.h @@ -5,6 +5,7 @@ #include +#include "SpacePacketIF.h" #include "ccsds_header.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" @@ -39,7 +40,7 @@ struct SpacePacketPointer { * the most significant bit (from left). * @ingroup tmtcpackets */ -class SpacePacketBase : virtual public RedirectableDataPointerIF { +class SpacePacketBase : public SpacePacketIF, public RedirectableDataPointerIF { protected: /** * A pointer to a structure which defines the data structure of @@ -49,11 +50,6 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { SpacePacketPointer* data; public: - static const uint16_t LIMIT_APID = 2048; // 2^1 - static const uint16_t LIMIT_SEQUENCE_COUNT = 16384; // 2^14 - static const uint16_t APID_IDLE_PACKET = 0x7FF; - static const uint8_t TELECOMMAND_PACKET = 1; - static const uint8_t TELEMETRY_PACKET = 0; /** * This definition defines the CRC size in byte. */ @@ -67,53 +63,26 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { * It sets its internal data pointer to the address passed. * @param set_address The position where the packet data lies. */ - SpacePacketBase(const uint8_t* set_address); + explicit SpacePacketBase(const uint8_t* set_address); /** * No data is allocated, so the destructor is empty. */ - virtual ~SpacePacketBase(); - - // CCSDS Methods: - /** - * Getter for the packet version number field. - * @return Returns the highest three bit of the packet in one byte. - */ - uint8_t getPacketVersionNumber(void); - /** - * This method checks the type field in the header. - * This bit specifies, if the command is interpreted as Telecommand of - * as Telemetry. For a Telecommand, the bit is set. - * @return Returns true if the bit is set and false if not. - */ - bool isTelecommand(void); + ~SpacePacketBase() override; ReturnValue_t initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid, uint16_t sequenceCount = 0); - /** - * The CCSDS header provides a secondary header flag (the fifth-highest bit), - * which is checked with this method. - * @return Returns true if the bit is set and false if not. - */ - bool hasSecondaryHeader(void); - /** - * Returns the complete first two bytes of the packet, which together form - * the CCSDS packet id. - * @return The CCSDS packet id. - */ - uint16_t getPacketId(void); - /** - * Returns the APID of a packet, which are the lowest 11 bit of the packet - * id. - * @return The CCSDS APID. - */ - uint16_t getAPID(void) const; + + [[nodiscard]] uint16_t getPacketId() const override; + [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketDataLen() const override; + /** * Sets the APID of a packet, which are the lowest 11 bit of the packet * id. * @param The APID to set. The highest five bits of the parameter are * ignored. */ - void setAPID(uint16_t setAPID); + void setApid(uint16_t setAPID); /** * Sets the sequence flags of a packet, which are bit 17 and 18 in the space packet header. @@ -121,24 +90,6 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { */ void setSequenceFlags(uint8_t sequenceflags); - /** - * Returns the CCSDS packet sequence control field, which are the third and - * the fourth byte of the CCSDS primary header. - * @return The CCSDS packet sequence control field. - */ - uint16_t getPacketSequenceControl(void); - /** - * Returns the SequenceFlags, which are the highest two bit of the packet - * sequence control field. - * @return The CCSDS sequence flags. - */ - uint8_t getSequenceFlags(void); - /** - * Returns the packet sequence count, which are the lowest 14 bit of the - * packet sequence control field. - * @return The CCSDS sequence count. - */ - uint16_t getPacketSequenceCount(void) const; /** * Sets the packet sequence count, which are the lowest 14 bit of the * packet sequence control field. @@ -146,15 +97,7 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { * @param setCount The value to set the count to. */ void setPacketSequenceCount(uint16_t setCount); - /** - * Returns the packet data length, which is the fifth and sixth byte of the - * CCSDS Primary Header. The packet data length is the size of every kind - * of data \b after the CCSDS Primary Header \b -1. - * @return - * The CCSDS packet data length. uint16_t is sufficient, - * because this is limit in CCSDS standard - */ - uint16_t getPacketDataLength(void) const; + /** * Sets the packet data length, which is the fifth and sixth byte of the * CCSDS Primary Header. @@ -170,7 +113,7 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { * This method returns a raw uint8_t pointer to the packet. * @return A \c uint8_t pointer to the first byte of the CCSDS primary header. */ - virtual uint8_t* getWholeData(void); + virtual uint8_t* getWholeData(); uint8_t* getPacketData(); @@ -179,14 +122,12 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { * location. * @param p_Data A pointer to another raw Space Packet. */ - virtual ReturnValue_t setData(uint8_t* p_Data, size_t maxSize, void* args = nullptr) override; + ReturnValue_t setData(uint8_t* p_Data, size_t maxSize, void* args) override; /** * This method returns the full raw packet size. * @return The full size of the packet in bytes. */ size_t getFullSize(); - - uint32_t getApidAndSequenceCount() const; }; #endif /* FSFW_TMTCPACKET_SPACEPACKETBASE_H_ */ diff --git a/src/fsfw/tmtcpacket/SpacePacketIF.h b/src/fsfw/tmtcpacket/SpacePacketIF.h new file mode 100644 index 00000000..291ba8f9 --- /dev/null +++ b/src/fsfw/tmtcpacket/SpacePacketIF.h @@ -0,0 +1,91 @@ +#ifndef FSFW_TMTCPACKET_SPACEPACKETIF_H +#define FSFW_TMTCPACKET_SPACEPACKETIF_H + +#include + +namespace ccsds { + +enum PacketType : uint8_t { TM = 0, TC = 1 }; + +enum SequenceFlags : uint8_t { + CONTINUATION = 0b00, + FIRST_SEGMENT = 0b01, + LAST_SEGMENT = 0b10, + UNSEGMENTED = 0b11 +}; + +static const uint16_t LIMIT_APID = 2048; // 2^11 +static const uint16_t LIMIT_SEQUENCE_COUNT = 16384; // 2^14 +static const uint16_t APID_IDLE_PACKET = 0x7FF; + +constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid, + bool secondaryHeaderFlag = true) { + return ((isTc << 4) | (secondaryHeaderFlag << 3) | ((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff); +} + +constexpr uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { + return getSpacePacketIdFromApid(true, apid, secondaryHeaderFlag); +} + +constexpr uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { + return getSpacePacketIdFromApid(false, apid, secondaryHeaderFlag); +} + +} // namespace ccsds + +class SpacePacketIF { + public: + virtual ~SpacePacketIF() = default; + + /** + * Returns the complete first two bytes of the packet, which together form + * the CCSDS packet ID + * @return The CCSDS packet ID + */ + [[nodiscard]] virtual uint16_t getPacketId() const = 0; + /** + * Returns the third and the fourth byte of the CCSDS header which are the packet sequence + * control field + * @return + */ + [[nodiscard]] virtual uint16_t getPacketSeqCtrl() const = 0; + /** + * Returns the fifth and the sixth byte of the CCSDS header which is the packet length field + * @return + */ + [[nodiscard]] virtual uint16_t getPacketDataLen() const = 0; + + [[nodiscard]] virtual uint16_t getApid() const { + uint16_t packetId = getPacketId(); + // Uppermost 11 bits of packet ID + return ((packetId >> 8) & 0b111) | (packetId & 0xFF); + } + + [[nodiscard]] virtual uint8_t getVersion() const { + uint16_t packetId = getPacketId(); + return (packetId >> 13) & 0b111; + } + + [[nodiscard]] virtual ccsds::PacketType getPacketType() const { + return static_cast((getPacketId() >> 12) & 0b1); + } + + [[nodiscard]] virtual bool isTc() const { return getPacketType() == ccsds::PacketType::TC; } + + [[nodiscard]] virtual bool isTm() const { return not isTc(); } + + /** + * The CCSDS header provides a secondary header flag (the fifth-highest bit), + * which is checked with this method. + * @return Returns true if the bit is set and false if not. + */ + [[nodiscard]] virtual bool hasSecHeader() const { return (getPacketId() >> 11) & 0b1; } + + [[nodiscard]] virtual ccsds::SequenceFlags getSequenceFlags() const { + return static_cast(getPacketSeqCtrl() >> 14 & 0b11); + } + + [[nodiscard]] virtual uint16_t getSequenceCount() const { return getPacketSeqCtrl() & 0x3FFF; } +}; + +#endif // FSFW_TMTCPACKET_SPACEPACKETIF_H diff --git a/src/fsfw/tmtcpacket/ccsds_header.h b/src/fsfw/tmtcpacket/ccsds_header.h index 232790c0..c0db194e 100644 --- a/src/fsfw/tmtcpacket/ccsds_header.h +++ b/src/fsfw/tmtcpacket/ccsds_header.h @@ -1,15 +1,15 @@ #ifndef CCSDS_HEADER_H_ #define CCSDS_HEADER_H_ -#include +#include struct CCSDSPrimaryHeader { - uint8_t packet_id_h; - uint8_t packet_id_l; - uint8_t sequence_control_h; - uint8_t sequence_control_l; - uint8_t packet_length_h; - uint8_t packet_length_l; + uint8_t packetIdHAndVersion; + uint8_t packetIdL; + uint8_t packetSeqCtrlH; + uint8_t packetSeqCtrlL; + uint8_t packetLenH; + uint8_t packetLenL; }; #endif /* CCSDS_HEADER_H_ */ diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp index 9a410b40..260331ac 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp @@ -2,8 +2,6 @@ #include "fsfw/objectmanager/ObjectManager.h" -StorageManagerIF* CFDPPacketStored::store = nullptr; - CFDPPacketStored::CFDPPacketStored() : CFDPPacket(nullptr) {} CFDPPacketStored::CFDPPacketStored(store_address_t setAddress) : CFDPPacket(nullptr) { @@ -15,22 +13,22 @@ CFDPPacketStored::CFDPPacketStored(const uint8_t* data, size_t size) : CFDPPacke return; } if (this->checkAndSetStore()) { - ReturnValue_t status = store->addData(&storeAddress, data, size); + ReturnValue_t status = STORE->addData(&storeAddress, data, size); if (status != HasReturnvaluesIF::RETURN_OK) { - this->setData(nullptr, -1); + this->setData(nullptr, -1, nullptr); } const uint8_t* storePtr = nullptr; // Repoint base data pointer to the data in the store. - store->getData(storeAddress, &storePtr, &size); - this->setData(const_cast(storePtr), size); + STORE->getData(storeAddress, &storePtr, &size); + this->setData(const_cast(storePtr), size, nullptr); } } ReturnValue_t CFDPPacketStored::deletePacket() { - ReturnValue_t result = this->store->deleteData(this->storeAddress); + ReturnValue_t result = STORE->deleteData(this->storeAddress); this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; // To circumvent size checks - this->setData(nullptr, -1); + this->setData(nullptr, -1, nullptr); return result; } @@ -43,20 +41,20 @@ void CFDPPacketStored::setStoreAddress(store_address_t setAddress) { size_t tempSize; ReturnValue_t status = StorageManagerIF::RETURN_FAILED; if (this->checkAndSetStore()) { - status = this->store->getData(this->storeAddress, &tempData, &tempSize); + status = STORE->getData(this->storeAddress, &tempData, &tempSize); } if (status == StorageManagerIF::RETURN_OK) { - this->setData(const_cast(tempData), tempSize); + this->setData(const_cast(tempData), tempSize, nullptr); } else { // To circumvent size checks - this->setData(nullptr, -1); + this->setData(nullptr, -1, nullptr); this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; } } store_address_t CFDPPacketStored::getStoreAddress() { return this->storeAddress; } -CFDPPacketStored::~CFDPPacketStored() {} +CFDPPacketStored::~CFDPPacketStored() = default; ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSize) { return HasReturnvaluesIF::RETURN_OK; @@ -67,9 +65,9 @@ ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSiz // } bool CFDPPacketStored::checkAndSetStore() { - if (this->store == nullptr) { - this->store = ObjectManager::instance()->get(objects::TC_STORE); - if (this->store == nullptr) { + if (STORE == nullptr) { + STORE = ObjectManager::instance()->get(objects::TC_STORE); + if (STORE == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CFDPPacketStored::CFDPPacketStored: TC Store not found!" << std::endl; #endif @@ -82,7 +80,7 @@ bool CFDPPacketStored::checkAndSetStore() { bool CFDPPacketStored::isSizeCorrect() { const uint8_t* temp_data = nullptr; size_t temp_size; - ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data, &temp_size); + ReturnValue_t status = STORE->getData(this->storeAddress, &temp_data, &temp_size); if (status == StorageManagerIF::RETURN_OK) { if (this->getFullSize() == temp_size) { return true; diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h index f9c73bdd..688067f9 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h @@ -39,13 +39,6 @@ class CFDPPacketStored : public CFDPPacket, public TcPacketStoredBase { bool isSizeCorrect(); protected: - /** - * This is a pointer to the store all instances of the class use. - * If the store is not yet set (i.e. @c store is NULL), every constructor - * call tries to set it and throws an error message in case of failures. - * The default store is objects::TC_STORE. - */ - static StorageManagerIF* store; /** * The address where the packet data of the object instance is stored. */ diff --git a/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h b/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h index cf4c88f2..3c835ef8 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h +++ b/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h @@ -10,23 +10,26 @@ class ApidMatcher : public SerializeableMatcherIF { uint16_t apid; public: - ApidMatcher(uint16_t setApid) : apid(setApid) {} - ApidMatcher(TmPacketMinimal* test) : apid(test->getAPID()) {} - bool match(TmPacketMinimal* packet) { - if (packet->getAPID() == apid) { + explicit ApidMatcher(uint16_t setApid) : apid(setApid) {} + explicit ApidMatcher(TmPacketMinimal* test) : apid(test->getApid()) {} + bool match(TmPacketMinimal* packet) override { + if (packet->getApid() == apid) { return true; } else { return false; } } ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const { + Endianness streamEndianness) const override { return SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness); } - size_t getSerializedSize() const { return SerializeAdapter::getSerializedSize(&apid); } - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { + [[nodiscard]] size_t getSerializedSize() const override { + return SerializeAdapter::getSerializedSize(&apid); + } + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override { return SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness); } }; -#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_ */ +#endif /* FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_ */ diff --git a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp index 6b900030..55fd3227 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp +++ b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp @@ -34,7 +34,7 @@ ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t sub data.data_field.service_type = type; data.data_field.service_subtype = subtype; TmPacketMinimal testPacket((uint8_t*)&data); - testPacket.setAPID(apid); + testPacket.setApid(apid); iterator lastTest; iterator rollback; ReturnValue_t result = @@ -126,7 +126,7 @@ ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type, uint8_t data.data_field.service_type = type; data.data_field.service_subtype = subtype; TmPacketMinimal testPacket((uint8_t*)&data); - testPacket.setAPID(apid); + testPacket.setApid(apid); iterator foundElement = findMatch(begin(), &testPacket); if (foundElement == this->end()) { return NO_MATCH; diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp index f5ebe38c..c9f10b4b 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp @@ -37,7 +37,7 @@ uint8_t TcPacketPus::getAcknowledgeFlags() const { const uint8_t *TcPacketPus::getApplicationData() const { return &tcData->appData; } uint16_t TcPacketPus::getApplicationDataSize() const { - return getPacketDataLength() - sizeof(tcData->dataField) - CRC_SIZE + 1; + return SpacePacketBase::getPacketDataLen() - sizeof(tcData->dataField) - CRC_SIZE + 1; } uint16_t TcPacketPus::getErrorControl() const { @@ -85,7 +85,7 @@ size_t TcPacketPus::calculateFullPacketLength(size_t appDataLen) const { } ReturnValue_t TcPacketPus::setData(uint8_t *dataPtr, size_t maxSize, void *args) { - ReturnValue_t result = SpacePacketBase::setData(dataPtr, maxSize); + ReturnValue_t result = SpacePacketBase::setData(dataPtr, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h index 47173dad..b630cfee 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h @@ -63,7 +63,7 @@ class TcPacketPus : public TcPacketPusBase { size_t calculateFullPacketLength(size_t appDataLen) const override; protected: - ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) override; + ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) override; /** * Initializes the Tc Packet header. diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h index 9f1d07ed..c84fc67d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h @@ -18,7 +18,7 @@ * check can be performed by making use of the getWholeData method. * @ingroup tmtcpackets */ -class TcPacketPusBase : public SpacePacketBase, virtual public RedirectableDataPointerIF { +class TcPacketPusBase : public SpacePacketBase { friend class TcPacketStoredBase; public: diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp index 643c2ecc..95350ac2 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp @@ -21,7 +21,7 @@ TcPacketStoredPus::TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t sub #endif return; } - this->setData(pData, TC_PACKET_MIN_SIZE + size); + this->setData(pData, TC_PACKET_MIN_SIZE + size, nullptr); #if FSFW_USE_PUS_C_TELECOMMANDS == 1 pus::PusVersion pusVersion = pus::PusVersion::PUS_C_VERSION; #else @@ -46,12 +46,12 @@ TcPacketStoredPus::TcPacketStoredPus(const uint8_t* data, size_t size) : TcPacke if (this->checkAndSetStore()) { ReturnValue_t status = STORE->addData(&storeAddress, data, size); if (status != HasReturnvaluesIF::RETURN_OK) { - this->setData(nullptr, size); + this->setData(nullptr, size, nullptr); } const uint8_t* storePtr = nullptr; // Repoint base data pointer to the data in the store. STORE->getData(storeAddress, &storePtr, &size); - this->setData(const_cast(storePtr), size); + this->setData(const_cast(storePtr), size, nullptr); } } @@ -59,7 +59,7 @@ ReturnValue_t TcPacketStoredPus::deletePacket() { ReturnValue_t result = this->STORE->deleteData(this->storeAddress); this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; // To circumvent size checks - this->setData(nullptr, -1); + this->setData(nullptr, -1, nullptr); return result; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp index bc761d0d..e04f2b85 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp @@ -13,12 +13,10 @@ object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT; TmPacketBase::TmPacketBase(uint8_t* setData) : SpacePacketBase(setData) {} -TmPacketBase::~TmPacketBase() { - // Nothing to do. -} +TmPacketBase::~TmPacketBase() = default; uint16_t TmPacketBase::getSourceDataSize() { - return getPacketDataLength() - getDataFieldSize() - CRC_SIZE + 1; + return SpacePacketBase::getPacketDataLen() - getDataFieldSize() - CRC_SIZE + 1; } uint16_t TmPacketBase::getErrorControl() { @@ -41,9 +39,9 @@ ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const { } bool TmPacketBase::checkAndSetStamper() { - if (timeStamper == NULL) { + if (timeStamper == nullptr) { timeStamper = ObjectManager::instance()->get(timeStamperId); - if (timeStamper == NULL) { + if (timeStamper == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TmPacketBase::checkAndSetStamper: Stamper not found!" << std::endl; #else diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp index e8f71717..1a830004 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp @@ -25,11 +25,11 @@ uint8_t TmPacketPusA::getSubService() { return tmData->data_field.service_subtyp uint8_t* TmPacketPusA::getSourceData() { return &tmData->data; } uint16_t TmPacketPusA::getSourceDataSize() { - return getPacketDataLength() - sizeof(tmData->data_field) - CRC_SIZE + 1; + return SpacePacketBase::getPacketDataLen() - sizeof(tmData->data_field) - CRC_SIZE + 1; } ReturnValue_t TmPacketPusA::setData(uint8_t* p_Data, size_t maxSize, void* args) { - ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize); + ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp index ab690414..c402a577 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp @@ -14,9 +14,7 @@ TmPacketPusC::TmPacketPusC(uint8_t* setData) : TmPacketBase(setData) { tmData = reinterpret_cast(setData); } -TmPacketPusC::~TmPacketPusC() { - // Nothing to do. -} +TmPacketPusC::~TmPacketPusC() = default; uint8_t TmPacketPusC::getService() { return tmData->dataField.serviceType; } @@ -25,11 +23,11 @@ uint8_t TmPacketPusC::getSubService() { return tmData->dataField.serviceSubtype; uint8_t* TmPacketPusC::getSourceData() { return &tmData->data; } uint16_t TmPacketPusC::getSourceDataSize() { - return getPacketDataLength() - sizeof(tmData->dataField) - CRC_SIZE + 1; + return SpacePacketBase::getPacketDataLen() - sizeof(tmData->dataField) - CRC_SIZE + 1; } ReturnValue_t TmPacketPusC::setData(uint8_t* p_Data, size_t maxSize, void* args) { - ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize); + ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -64,9 +62,9 @@ ReturnValue_t TmPacketPusC::initializeTmPacket(uint16_t apid, uint8_t service, u (pus::PusVersion::PUS_C_VERSION << 4) | timeRefField; tmData->dataField.serviceType = service; tmData->dataField.serviceSubtype = subservice; - tmData->dataField.subcounterMsb = packetSubcounter << 8 & 0xff; + tmData->dataField.subcounterMsb = (packetSubcounter << 8) & 0xff; tmData->dataField.subcounterLsb = packetSubcounter & 0xff; - tmData->dataField.destinationIdMsb = destinationId << 8 & 0xff; + tmData->dataField.destinationIdMsb = (destinationId << 8) & 0xff; tmData->dataField.destinationIdLsb = destinationId & 0xff; // Timestamp packet if (TmPacketBase::checkAndSetStamper()) { diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h index bbd69693..4b3ca18c 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h @@ -114,7 +114,7 @@ class TmPacketPusC : public TmPacketBase { * * @param pData A pointer to another PUS Telemetry Packet. */ - ReturnValue_t setData(uint8_t* pData, size_t maxSize, void* args = nullptr) override; + ReturnValue_t setData(uint8_t* pData, size_t maxSize, void* args) override; /** * In case data was filled manually (almost never the case). diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp index 9c170aa3..5ade4191 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp @@ -26,7 +26,7 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t s handleStoreFailure("C", returnValue, sizeToReserve); return; } - setData(pData, sizeToReserve); + setData(pData, sizeToReserve, nullptr); initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField); memcpy(getSourceData(), headerData, headerSize); memcpy(getSourceData() + headerSize, data, size); @@ -56,7 +56,7 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t s handleStoreFailure("C", returnValue, sizeToReserve); return; } - TmPacketPusC::setData(pData, sizeToReserve); + TmPacketPusC::setData(pData, sizeToReserve, nullptr); initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField); uint8_t *putDataHere = getSourceData(); size_t size = 0; @@ -72,5 +72,5 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t s uint8_t *TmPacketStoredPusC::getAllTmData() { return getWholeData(); } ReturnValue_t TmPacketStoredPusC::setData(uint8_t *newPointer, size_t maxSize, void *args) { - return TmPacketPusC::setData(newPointer, maxSize); + return TmPacketPusC::setData(newPointer, maxSize, args); } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h index ef84e238..fe65e2ca 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h @@ -66,7 +66,7 @@ class TmPacketStoredPusC : public TmPacketStoredBase, public TmPacketPusC { * @param args * @return */ - ReturnValue_t setData(uint8_t* newPointer, size_t maxSize, void* args = nullptr) override; + ReturnValue_t setData(uint8_t* newPointer, size_t maxSize, void* args) override; }; #endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ */ diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index bbdf8d2a..37232c49 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -350,7 +350,7 @@ void CommandingServiceBase::startExecution(TcPacketStoredPus* storedPacket, Comm iter->second.command = command.getCommand(); iter->second.tcInfo.ackFlags = storedPacket->getAcknowledgeFlags(); iter->second.tcInfo.tcPacketId = storedPacket->getPacketId(); - iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSequenceControl(); + iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSeqCtrl(); acceptPacket(tc_verification::START_SUCCESS, storedPacket); } else { command.clearCommandMessage(); diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 9d06adc4..19277bf3 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -22,8 +22,8 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, TcPacketPusB return; } PusVerificationMessage message(set_report_id, currentPacket->getAcknowledgeFlags(), - currentPacket->getPacketId(), - currentPacket->getPacketSequenceControl(), 0, set_step); + currentPacket->getPacketId(), currentPacket->getPacketSeqCtrl(), 0, + set_step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -59,9 +59,9 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, TcPacketPusBase* if (currentPacket == nullptr) { return; } - PusVerificationMessage message( - report_id, currentPacket->getAcknowledgeFlags(), currentPacket->getPacketId(), - currentPacket->getPacketSequenceControl(), error_code, step, parameter1, parameter2); + PusVerificationMessage message(report_id, currentPacket->getAcknowledgeFlags(), + currentPacket->getPacketId(), currentPacket->getPacketSeqCtrl(), + error_code, step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp index d395449d..76140c26 100644 --- a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp +++ b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp @@ -1,11 +1,11 @@ #include -#include "fsfw/tmtcpacket/SpacePacket.h" +#include "fsfw/tmtcpacket/SpacePacketBase.h" TEST_CASE("CCSDS Test", "[ccsds]") { - REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x22) == 0x1822); - REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x22) == 0x0822); + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822); - REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); - REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); } From 546e173cef61917714258a14e4eb801be26c7ab5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 10:29:39 +0200 Subject: [PATCH 037/532] add new PUS TC IF --- CMakeLists.txt | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcIF.h | 79 +++++++++++++++++++ .../pus/tc/TcPacketDeserializer.cpp | 3 + .../tmtcpacket/pus/tc/TcPacketDeserializer.h | 14 ++++ .../tmtcpacket/pus/tc/TcPacketStoredBase.h | 2 +- 5 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 src/fsfw/tmtcpacket/pus/tc/PusTcIF.h create mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp create mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 440d7f9b..1a8b703d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,7 +133,7 @@ option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF) set(FSFW_TEST_TGT fsfw-tests) set(FSFW_DUMMY_TGT fsfw-dummy) -add_library(${LIB_FSFW_NAME} src/fsfw/tmtcpacket/SpacePacketIF.h) +add_library(${LIB_FSFW_NAME} src/fsfw/tmtcpacket/SpacePacketIF.h src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp src/fsfw/tmtcpacket/pus/tc/PusTcIF.h) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h new file mode 100644 index 00000000..91f8fe1e --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h @@ -0,0 +1,79 @@ +#ifndef FSFW_TMTCPACKET_PUSTCIF_H +#define FSFW_TMTCPACKET_PUSTCIF_H + +#include + +class PusTcIF { + public: + virtual ~PusTcIF() = default; + + /** + * This command returns the CCSDS Secondary Header Flag. + * It shall always be zero for PUS Packets. This is the + * highest bit of the first byte of the Data Field Header. + * @return the CCSDS Secondary Header Flag + */ + [[nodiscard]] virtual uint8_t getSecondaryHeaderFlag() const = 0; + /** + * This command returns the TC Packet PUS Version Number. + * The version number of ECSS PUS 2003 is 1. + * It consists of the second to fourth highest bits of the + * first byte. + * @return + */ + [[nodiscard]] virtual uint8_t getPusVersion() const = 0; + /** + * This is a getter for the packet's Ack field, which are the lowest four + * bits of the first byte of the Data Field Header. + * + * It is packed in a uint8_t variable. + * @return The packet's PUS Ack field. + */ + [[nodiscard]] virtual uint8_t getAcknowledgeFlags() const = 0; + /** + * This is a getter for the packet's PUS Service ID, which is the second + * byte of the Data Field Header. + * @return The packet's PUS Service ID. + */ + [[nodiscard]] virtual uint8_t getService() const = 0; + /** + * This is a getter for the packet's PUS Service Subtype, which is the + * third byte of the Data Field Header. + * @return The packet's PUS Service Subtype. + */ + [[nodiscard]] virtual uint8_t getSubService() const = 0; + /** + * The source ID can be used to have an additional identifier, e.g. for different ground + * station. + * @return + */ + [[nodiscard]] virtual uint16_t getSourceId() const = 0; + + /** + * This is a getter for a pointer to the packet's Application data. + * + * These are the bytes that follow after the Data Field Header. They form + * the packet's application data. + * @return A pointer to the PUS Application Data. + */ + [[nodiscard]] virtual const uint8_t* getApplicationData() const = 0; + /** + * This method calculates the size of the PUS Application data field. + * + * It takes the information stored in the CCSDS Packet Data Length field + * and subtracts the Data Field Header size and the CRC size. + * @return The size of the PUS Application Data (without Error Control + * field) + */ + [[nodiscard]] virtual uint16_t getApplicationDataSize() const = 0; + /** + * This getter returns the Error Control Field of the packet. + * + * The field is placed after any possible Application Data. If no + * Application Data is present there's still an Error Control field. It is + * supposed to be a 16bit-CRC. + * @return The PUS Error Control + */ + [[nodiscard]] virtual uint16_t getErrorControl() const = 0; + }; +#endif // FSFW_TMTCPACKET_PUSTCIF_H diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp new file mode 100644 index 00000000..a93db348 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp @@ -0,0 +1,3 @@ +#include "TcPacketDeserializer.h" + +TcPacketDeserializer::TcPacketDeserializer(const uint8_t *data, size_t maxSize) {} diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h new file mode 100644 index 00000000..b3b35084 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h @@ -0,0 +1,14 @@ +#ifndef FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H +#define FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H + +#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" +#include "fsfw/tmtcpacket/SpacePacketIF.h" + +class TcPacketDeserializer: public SpacePacketIF, public RedirectableDataPointerIF { + public: + TcPacketDeserializer(const uint8_t* data, size_t maxSize); + private: + +}; + +#endif // FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h index ece0e482..4d27565a 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h @@ -19,7 +19,7 @@ class TcPacketStoredBase : public TcPacketStoredIF { * Constructor to set to an existing store address. * @param setAddress */ - TcPacketStoredBase(store_address_t setAddress); + explicit TcPacketStoredBase(store_address_t setAddress); /** * Another constructor to create a TcPacket from a raw packet stream. * Takes the data and adds it unchecked to the TcStore. From d7a2eada945a3d1b77d71153d88d15ca1ce1bff3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 10:42:56 +0200 Subject: [PATCH 038/532] add space packet creator class --- CMakeLists.txt | 9 ++- .../datalinklayer/MapPacketExtraction.cpp | 2 +- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 4 +- src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp | 2 +- src/fsfw/tcdistribution/TcPacketCheckCFDP.h | 2 +- src/fsfw/tcdistribution/TcPacketCheckIF.h | 4 +- src/fsfw/tcdistribution/TcPacketCheckPUS.cpp | 2 +- src/fsfw/tcdistribution/TcPacketCheckPUS.h | 2 +- src/fsfw/tmtcpacket/CMakeLists.txt | 2 +- src/fsfw/tmtcpacket/SpacePacketCreator.cpp | 36 +++++++++++ src/fsfw/tmtcpacket/SpacePacketCreator.h | 26 ++++++++ ...cePacketBase.cpp => SpacePacketReader.cpp} | 32 +++++----- ...{SpacePacketBase.h => SpacePacketReader.h} | 8 ++- src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp | 2 +- src/fsfw/tmtcpacket/cfdp/CFDPPacket.h | 4 +- src/fsfw/tmtcpacket/pus/tc/PusTcIF.h | 60 +++++++++---------- .../tmtcpacket/pus/tc/TcPacketDeserializer.h | 4 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp | 4 +- .../tmtcpacket/pus/tc/TcPacketPusBase.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h | 4 +- .../tmtcpacket/pus/tm/TmPacketMinimal.cpp | 2 +- src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h | 2 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h | 2 +- src/fsfw/tmtcservices/SourceSequenceCounter.h | 2 +- .../fsfw_tests/unit/tmtcpacket/testCcsds.cpp | 14 +++-- 30 files changed, 164 insertions(+), 89 deletions(-) create mode 100644 src/fsfw/tmtcpacket/SpacePacketCreator.cpp create mode 100644 src/fsfw/tmtcpacket/SpacePacketCreator.h rename src/fsfw/tmtcpacket/{SpacePacketBase.cpp => SpacePacketReader.cpp} (69%) rename src/fsfw/tmtcpacket/{SpacePacketBase.h => SpacePacketReader.h} (93%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a8b703d..066f1028 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,7 +133,14 @@ option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF) set(FSFW_TEST_TGT fsfw-tests) set(FSFW_DUMMY_TGT fsfw-dummy) -add_library(${LIB_FSFW_NAME} src/fsfw/tmtcpacket/SpacePacketIF.h src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp src/fsfw/tmtcpacket/pus/tc/PusTcIF.h) +add_library( + ${LIB_FSFW_NAME} + src/fsfw/tmtcpacket/SpacePacketIF.h + src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h + src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp + src/fsfw/tmtcpacket/pus/tc/PusTcIF.h + src/fsfw/tmtcpacket/SpacePacketCreator.h + src/fsfw/tmtcpacket/SpacePacketCreator.cpp) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.cpp b/src/fsfw/datalinklayer/MapPacketExtraction.cpp index 57aa2f08..1467f2aa 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.cpp +++ b/src/fsfw/datalinklayer/MapPacketExtraction.cpp @@ -6,7 +6,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/TmTcMessage.h" diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index 0be177bf..a32cbc75 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -2,7 +2,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" #define CCSDS_DISTRIBUTOR_DEBUGGING 0 @@ -40,7 +40,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { #endif return queueMap.end(); } - SpacePacketBase currentPacket(packet); + SpacePacketReader currentPacket(packet); #if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1 sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp index d1eb43bc..7d2bfe88 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp @@ -4,6 +4,6 @@ TcPacketCheckCFDP::TcPacketCheckCFDP(uint16_t setApid) : apid(setApid) {} -ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketBase* currentPacket) { return RETURN_OK; } +ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketReader* currentPacket) { return RETURN_OK; } uint16_t TcPacketCheckCFDP::getApid() const { return apid; } diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.h b/src/fsfw/tcdistribution/TcPacketCheckCFDP.h index 3fe281d1..5a4abd4f 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.h +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.h @@ -25,7 +25,7 @@ class TcPacketCheckCFDP : public TcPacketCheckIF, public HasReturnvaluesIF { */ TcPacketCheckCFDP(uint16_t setApid); - ReturnValue_t checkPacket(SpacePacketBase* currentPacket) override; + ReturnValue_t checkPacket(SpacePacketReader* currentPacket) override; uint16_t getApid() const; }; diff --git a/src/fsfw/tcdistribution/TcPacketCheckIF.h b/src/fsfw/tcdistribution/TcPacketCheckIF.h index 858c3093..a9ec14a2 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckIF.h +++ b/src/fsfw/tcdistribution/TcPacketCheckIF.h @@ -3,7 +3,7 @@ #include "../returnvalues/HasReturnvaluesIF.h" -class SpacePacketBase; +class SpacePacketReader; /** * This interface is used by PacketCheckers for PUS packets and CFDP packets . @@ -24,7 +24,7 @@ class TcPacketCheckIF { * - @c INCORRECT_CHECKSUM if checksum is invalid. * - @c ILLEGAL_APID if APID does not match. */ - virtual ReturnValue_t checkPacket(SpacePacketBase* currentPacket) = 0; + virtual ReturnValue_t checkPacket(SpacePacketReader* currentPacket) = 0; }; #endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ */ diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp index 6d7092e5..304c644a 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp @@ -10,7 +10,7 @@ TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid) : apid(setApid) {} -ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) { +ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketReader* currentPacket) { auto* storedPacket = dynamic_cast(currentPacket); auto* tcPacketBase = dynamic_cast(currentPacket); if (tcPacketBase == nullptr or storedPacket == nullptr) { diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.h b/src/fsfw/tcdistribution/TcPacketCheckPUS.h index e3eca1a4..4804a619 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.h +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.h @@ -53,7 +53,7 @@ class TcPacketCheckPUS : public TcPacketCheckIF, public HasReturnvaluesIF { */ TcPacketCheckPUS(uint16_t setApid); - ReturnValue_t checkPacket(SpacePacketBase* currentPacket) override; + ReturnValue_t checkPacket(SpacePacketReader* currentPacket) override; uint16_t getApid() const; }; diff --git a/src/fsfw/tmtcpacket/CMakeLists.txt b/src/fsfw/tmtcpacket/CMakeLists.txt index dc09c9c9..85376d01 100644 --- a/src/fsfw/tmtcpacket/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE SpacePacketBase.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE SpacePacketReader.cpp) add_subdirectory(cfdp) add_subdirectory(packetmatcher) diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp new file mode 100644 index 00000000..d5eb73c2 --- /dev/null +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp @@ -0,0 +1,36 @@ +#include "SpacePacketCreator.h" + +#include "fsfw/serialize/SerializeAdapter.h" + +SpacePacketCreator::SpacePacketCreator(uint16_t packetId_, uint16_t packetSeqCtrl_, + uint16_t packetLen_, uint8_t version_) { + packetId = packetId_; + packetSeqCtrl = packetSeqCtrl_; + packetLen = packetLen_; + version = version_; +} + +uint16_t SpacePacketCreator::getPacketId() const { return 0; } +uint16_t SpacePacketCreator::getPacketSeqCtrl() const { return 0; } +uint16_t SpacePacketCreator::getPacketDataLen() const { return 0; } + +ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const { + uint16_t packetIdAndVersion = version << 13 | packetId; + ReturnValue_t result = + SerializeAdapter::serialize(&packetIdAndVersion, buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = SerializeAdapter::serialize(&packetSeqCtrl, buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return SerializeAdapter::serialize(&packetLen, buffer, size, maxSize, streamEndianness); +} + +size_t SpacePacketCreator::getSerializedSize() const { return 0; } +ReturnValue_t SpacePacketCreator::deSerialize(const uint8_t **buffer, size_t *size, + SerializeIF::Endianness streamEndianness) { + return HasReturnvaluesIF::RETURN_FAILED; +} diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.h b/src/fsfw/tmtcpacket/SpacePacketCreator.h new file mode 100644 index 00000000..2e7d2537 --- /dev/null +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.h @@ -0,0 +1,26 @@ +#ifndef FSFW_TMTCPACKET_SPACEPACKETCREATOR_H +#define FSFW_TMTCPACKET_SPACEPACKETCREATOR_H + +#include "SpacePacketIF.h" +#include "fsfw/serialize/SerializeIF.h" + +class SpacePacketCreator : public SerializeIF, public SpacePacketIF { + public: + SpacePacketCreator(uint16_t packetId, uint16_t packetSeqCtrl, uint16_t packetLen, + uint8_t version = 0); + [[nodiscard]] uint16_t getPacketId() const override; + [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketDataLen() const override; + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override; + size_t getSerializedSize() const override; + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override; + + private: + uint16_t packetId; + uint16_t packetSeqCtrl; + uint16_t packetLen; + uint8_t version; +}; +#endif // FSFW_TMTCPACKET_SPACEPACKETCREATOR_H diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.cpp b/src/fsfw/tmtcpacket/SpacePacketReader.cpp similarity index 69% rename from src/fsfw/tmtcpacket/SpacePacketBase.cpp rename to src/fsfw/tmtcpacket/SpacePacketReader.cpp index cb18519e..a1bcd465 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketReader.cpp @@ -1,17 +1,17 @@ -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" #include #include "fsfw/serviceinterface/ServiceInterface.h" -SpacePacketBase::SpacePacketBase(const uint8_t* setAddress) { +SpacePacketReader::SpacePacketReader(const uint8_t* setAddress) { this->data = reinterpret_cast(const_cast(setAddress)); } -SpacePacketBase::~SpacePacketBase() = default; +SpacePacketReader::~SpacePacketReader() = default; -ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, - uint16_t apid, uint16_t sequenceCount) { +ReturnValue_t SpacePacketReader::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, + uint16_t apid, uint16_t sequenceCount) { if (data == nullptr) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -35,54 +35,54 @@ ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool ha return HasReturnvaluesIF::RETURN_OK; } -inline uint16_t SpacePacketBase::getPacketId() const { +inline uint16_t SpacePacketReader::getPacketId() const { return ((this->data->header.packetIdHAndVersion) << 8) + this->data->header.packetIdL; } -void SpacePacketBase::setApid(uint16_t setAPID) { +void SpacePacketReader::setApid(uint16_t setAPID) { // Use first three bits of new APID, but keep rest of packet id as it was (see specification). this->data->header.packetIdHAndVersion = (this->data->header.packetIdHAndVersion & 0b11111000) | ((setAPID & 0x0700) >> 8); this->data->header.packetIdL = (setAPID & 0x00FF); } -void SpacePacketBase::setSequenceFlags(uint8_t sequenceflags) { +void SpacePacketReader::setSequenceFlags(uint8_t sequenceflags) { this->data->header.packetSeqCtrlH &= 0x3F; this->data->header.packetSeqCtrlH |= sequenceflags << 6; } -void SpacePacketBase::setPacketSequenceCount(uint16_t new_count) { +void SpacePacketReader::setPacketSequenceCount(uint16_t new_count) { this->data->header.packetSeqCtrlH = (this->data->header.packetSeqCtrlH & 0b11000000) | (((new_count % ccsds::LIMIT_SEQUENCE_COUNT) & 0x3F00) >> 8); this->data->header.packetSeqCtrlL = ((new_count % ccsds::LIMIT_SEQUENCE_COUNT) & 0x00FF); } -void SpacePacketBase::setPacketDataLength(uint16_t new_length) { +void SpacePacketReader::setPacketDataLength(uint16_t new_length) { this->data->header.packetLenH = ((new_length & 0xFF00) >> 8); this->data->header.packetLenL = (new_length & 0x00FF); } -size_t SpacePacketBase::getFullSize() { +size_t SpacePacketReader::getFullSize() { // +1 is done because size in packet data length field is: size of data field -1 return this->getPacketDataLen() + sizeof(this->data->header) + 1; } -uint8_t* SpacePacketBase::getWholeData() { return reinterpret_cast(this->data); } +uint8_t* SpacePacketReader::getWholeData() { return reinterpret_cast(this->data); } -uint8_t* SpacePacketBase::getPacketData() { return &(data->packet_data); } +uint8_t* SpacePacketReader::getPacketData() { return &(data->packet_data); } -ReturnValue_t SpacePacketBase::setData(uint8_t* pData, size_t maxSize, void* args) { +ReturnValue_t SpacePacketReader::setData(uint8_t* pData, size_t maxSize, void* args) { if (maxSize < 6) { return HasReturnvaluesIF::RETURN_FAILED; } this->data = reinterpret_cast(const_cast(pData)); return HasReturnvaluesIF::RETURN_OK; } -uint16_t SpacePacketBase::getPacketSeqCtrl() const { +uint16_t SpacePacketReader::getPacketSeqCtrl() const { return ((this->data->header.packetSeqCtrlH & 0b00111111) << 8) + this->data->header.packetSeqCtrlL; } -uint16_t SpacePacketBase::getPacketDataLen() const { +uint16_t SpacePacketReader::getPacketDataLen() const { return ((this->data->header.packetLenH) << 8) + this->data->header.packetLenL; } diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.h b/src/fsfw/tmtcpacket/SpacePacketReader.h similarity index 93% rename from src/fsfw/tmtcpacket/SpacePacketBase.h rename to src/fsfw/tmtcpacket/SpacePacketReader.h index 862e4725..7fc88577 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.h +++ b/src/fsfw/tmtcpacket/SpacePacketReader.h @@ -40,7 +40,7 @@ struct SpacePacketPointer { * the most significant bit (from left). * @ingroup tmtcpackets */ -class SpacePacketBase : public SpacePacketIF, public RedirectableDataPointerIF { +class SpacePacketReader : public SpacePacketIF, public RedirectableDataPointerIF { protected: /** * A pointer to a structure which defines the data structure of @@ -58,16 +58,18 @@ class SpacePacketBase : public SpacePacketIF, public RedirectableDataPointerIF { * This is the minimum size of a SpacePacket. */ static const uint16_t MINIMUM_SIZE = sizeof(CCSDSPrimaryHeader) + CRC_SIZE; + SpacePacketReader(uint16_t apid, ccsds::PacketType packetType, bool secHeader, uint16_t seqCount, + uint16_t dataLen); /** * This is the default constructor. * It sets its internal data pointer to the address passed. * @param set_address The position where the packet data lies. */ - explicit SpacePacketBase(const uint8_t* set_address); + explicit SpacePacketReader(const uint8_t* set_address); /** * No data is allocated, so the destructor is empty. */ - ~SpacePacketBase() override; + ~SpacePacketReader() override; ReturnValue_t initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid, uint16_t sequenceCount = 0); diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp index 5df50cd7..29b6c561 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp @@ -6,7 +6,7 @@ #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serviceinterface/ServiceInterface.h" -CFDPPacket::CFDPPacket(const uint8_t* setData) : SpacePacketBase(setData) {} +CFDPPacket::CFDPPacket(const uint8_t* setData) : SpacePacketReader(setData) {} CFDPPacket::~CFDPPacket() {} diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.h b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.h index 30ba98ae..a70c3938 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.h +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.h @@ -1,9 +1,9 @@ #ifndef FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_ #define FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_ -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" -class CFDPPacket : public SpacePacketBase { +class CFDPPacket : public SpacePacketReader { public: /** * This is the default constructor. diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h index 91f8fe1e..3a2eaddc 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h @@ -4,76 +4,76 @@ #include class PusTcIF { - public: - virtual ~PusTcIF() = default; + public: + virtual ~PusTcIF() = default; - /** + /** * This command returns the CCSDS Secondary Header Flag. * It shall always be zero for PUS Packets. This is the * highest bit of the first byte of the Data Field Header. * @return the CCSDS Secondary Header Flag - */ - [[nodiscard]] virtual uint8_t getSecondaryHeaderFlag() const = 0; - /** + */ + [[nodiscard]] virtual uint8_t getSecondaryHeaderFlag() const = 0; + /** * This command returns the TC Packet PUS Version Number. * The version number of ECSS PUS 2003 is 1. * It consists of the second to fourth highest bits of the * first byte. * @return - */ - [[nodiscard]] virtual uint8_t getPusVersion() const = 0; - /** + */ + [[nodiscard]] virtual uint8_t getPusVersion() const = 0; + /** * This is a getter for the packet's Ack field, which are the lowest four * bits of the first byte of the Data Field Header. * * It is packed in a uint8_t variable. * @return The packet's PUS Ack field. - */ - [[nodiscard]] virtual uint8_t getAcknowledgeFlags() const = 0; - /** + */ + [[nodiscard]] virtual uint8_t getAcknowledgeFlags() const = 0; + /** * This is a getter for the packet's PUS Service ID, which is the second * byte of the Data Field Header. * @return The packet's PUS Service ID. - */ - [[nodiscard]] virtual uint8_t getService() const = 0; - /** + */ + [[nodiscard]] virtual uint8_t getService() const = 0; + /** * This is a getter for the packet's PUS Service Subtype, which is the * third byte of the Data Field Header. * @return The packet's PUS Service Subtype. - */ - [[nodiscard]] virtual uint8_t getSubService() const = 0; - /** + */ + [[nodiscard]] virtual uint8_t getSubService() const = 0; + /** * The source ID can be used to have an additional identifier, e.g. for different ground * station. * @return - */ - [[nodiscard]] virtual uint16_t getSourceId() const = 0; + */ + [[nodiscard]] virtual uint16_t getSourceId() const = 0; - /** + /** * This is a getter for a pointer to the packet's Application data. * * These are the bytes that follow after the Data Field Header. They form * the packet's application data. * @return A pointer to the PUS Application Data. - */ - [[nodiscard]] virtual const uint8_t* getApplicationData() const = 0; - /** + */ + [[nodiscard]] virtual const uint8_t* getApplicationData() const = 0; + /** * This method calculates the size of the PUS Application data field. * * It takes the information stored in the CCSDS Packet Data Length field * and subtracts the Data Field Header size and the CRC size. * @return The size of the PUS Application Data (without Error Control * field) - */ - [[nodiscard]] virtual uint16_t getApplicationDataSize() const = 0; - /** + */ + [[nodiscard]] virtual uint16_t getApplicationDataSize() const = 0; + /** * This getter returns the Error Control Field of the packet. * * The field is placed after any possible Application Data. If no * Application Data is present there's still an Error Control field. It is * supposed to be a 16bit-CRC. * @return The PUS Error Control - */ - [[nodiscard]] virtual uint16_t getErrorControl() const = 0; - }; + */ + [[nodiscard]] virtual uint16_t getErrorControl() const = 0; +}; #endif // FSFW_TMTCPACKET_PUSTCIF_H diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h index b3b35084..1e2e7bba 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h @@ -4,11 +4,11 @@ #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" #include "fsfw/tmtcpacket/SpacePacketIF.h" -class TcPacketDeserializer: public SpacePacketIF, public RedirectableDataPointerIF { +class TcPacketDeserializer : public SpacePacketIF, public RedirectableDataPointerIF { public: TcPacketDeserializer(const uint8_t* data, size_t maxSize); - private: + private: }; #endif // FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp index c9f10b4b..faada828 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp @@ -37,7 +37,7 @@ uint8_t TcPacketPus::getAcknowledgeFlags() const { const uint8_t *TcPacketPus::getApplicationData() const { return &tcData->appData; } uint16_t TcPacketPus::getApplicationDataSize() const { - return SpacePacketBase::getPacketDataLen() - sizeof(tcData->dataField) - CRC_SIZE + 1; + return SpacePacketReader::getPacketDataLen() - sizeof(tcData->dataField) - CRC_SIZE + 1; } uint16_t TcPacketPus::getErrorControl() const { @@ -85,7 +85,7 @@ size_t TcPacketPus::calculateFullPacketLength(size_t appDataLen) const { } ReturnValue_t TcPacketPus::setData(uint8_t *dataPtr, size_t maxSize, void *args) { - ReturnValue_t result = SpacePacketBase::setData(dataPtr, maxSize, args); + ReturnValue_t result = SpacePacketReader::setData(dataPtr, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp index 812bae43..3d7ff888 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp @@ -6,7 +6,7 @@ #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serviceinterface/ServiceInterface.h" -TcPacketPusBase::TcPacketPusBase(const uint8_t* setData) : SpacePacketBase(setData) {} +TcPacketPusBase::TcPacketPusBase(const uint8_t* setData) : SpacePacketReader(setData) {} TcPacketPusBase::~TcPacketPusBase() {} diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h index c84fc67d..ce30cb18 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h @@ -5,7 +5,7 @@ #include -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" /** * This class is the basic data handler for any ECSS PUS Telecommand packet. @@ -18,7 +18,7 @@ * check can be performed by making use of the getWholeData method. * @ingroup tmtcpackets */ -class TcPacketPusBase : public SpacePacketBase { +class TcPacketPusBase : public SpacePacketReader { friend class TcPacketStoredBase; public: diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp index e04f2b85..c81c2d4d 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp @@ -11,12 +11,12 @@ TimeStamperIF* TmPacketBase::timeStamper = nullptr; object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT; -TmPacketBase::TmPacketBase(uint8_t* setData) : SpacePacketBase(setData) {} +TmPacketBase::TmPacketBase(uint8_t* setData) : SpacePacketReader(setData) {} TmPacketBase::~TmPacketBase() = default; uint16_t TmPacketBase::getSourceDataSize() { - return SpacePacketBase::getPacketDataLen() - getDataFieldSize() - CRC_SIZE + 1; + return SpacePacketReader::getPacketDataLen() - getDataFieldSize() - CRC_SIZE + 1; } uint16_t TmPacketBase::getErrorControl() { diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h index 72f3abd4..e1622466 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h @@ -4,7 +4,7 @@ #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/timemanager/Clock.h" #include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" namespace Factory { @@ -23,7 +23,7 @@ void setStaticFrameworkObjectIds(); * check can be performed by making use of the getWholeData method. * @ingroup tmtcpackets */ -class TmPacketBase : public SpacePacketBase { +class TmPacketBase : public SpacePacketReader { friend void(Factory::setStaticFrameworkObjectIds)(); public: diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp index 388a4098..c1a5c4ba 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp @@ -5,7 +5,7 @@ #include "fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h" -TmPacketMinimal::TmPacketMinimal(const uint8_t* set_data) : SpacePacketBase(set_data) { +TmPacketMinimal::TmPacketMinimal(const uint8_t* set_data) : SpacePacketReader(set_data) { this->tm_data = (TmPacketMinimalPointer*)set_data; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h index dc9c33ae..197bf6e6 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h @@ -2,7 +2,7 @@ #define FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_ #include "../../../returnvalues/HasReturnvaluesIF.h" -#include "../../SpacePacketBase.h" +#include "../../SpacePacketReader.h" struct timeval; class PacketTimestampInterpreterIF; @@ -12,7 +12,7 @@ class PacketTimestampInterpreterIF; * This is required for handling TM packets with different APIDs with different * secondary headers. */ -class TmPacketMinimal : public SpacePacketBase { +class TmPacketMinimal : public SpacePacketReader { public: /** * This is the default constructor. diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp index 1a830004..8ccb87b5 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp @@ -25,11 +25,11 @@ uint8_t TmPacketPusA::getSubService() { return tmData->data_field.service_subtyp uint8_t* TmPacketPusA::getSourceData() { return &tmData->data; } uint16_t TmPacketPusA::getSourceDataSize() { - return SpacePacketBase::getPacketDataLen() - sizeof(tmData->data_field) - CRC_SIZE + 1; + return SpacePacketReader::getPacketDataLen() - sizeof(tmData->data_field) - CRC_SIZE + 1; } ReturnValue_t TmPacketPusA::setData(uint8_t* p_Data, size_t maxSize, void* args) { - ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize, args); + ReturnValue_t result = SpacePacketReader::setData(p_Data, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h index a84547ff..6808a8d6 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h @@ -5,7 +5,7 @@ #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/timemanager/Clock.h" #include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" namespace Factory { void setStaticFrameworkObjectIds(); diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp index c402a577..fd2248aa 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp @@ -23,11 +23,11 @@ uint8_t TmPacketPusC::getSubService() { return tmData->dataField.serviceSubtype; uint8_t* TmPacketPusC::getSourceData() { return &tmData->data; } uint16_t TmPacketPusC::getSourceDataSize() { - return SpacePacketBase::getPacketDataLen() - sizeof(tmData->dataField) - CRC_SIZE + 1; + return SpacePacketReader::getPacketDataLen() - sizeof(tmData->dataField) - CRC_SIZE + 1; } ReturnValue_t TmPacketPusC::setData(uint8_t* p_Data, size_t maxSize, void* args) { - ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize, args); + ReturnValue_t result = SpacePacketReader::setData(p_Data, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h index 4b3ca18c..bf9de122 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h @@ -5,7 +5,7 @@ #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/timemanager/Clock.h" #include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" namespace Factory { void setStaticFrameworkObjectIds(); diff --git a/src/fsfw/tmtcservices/SourceSequenceCounter.h b/src/fsfw/tmtcservices/SourceSequenceCounter.h index e981a945..836ac5e9 100644 --- a/src/fsfw/tmtcservices/SourceSequenceCounter.h +++ b/src/fsfw/tmtcservices/SourceSequenceCounter.h @@ -1,7 +1,7 @@ #ifndef FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ #define FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ -#include "../tmtcpacket/SpacePacketBase.h" +#include "../tmtcpacket/SpacePacketReader.h" class SourceSequenceCounter { private: diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp index 76140c26..6d3b63a7 100644 --- a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp +++ b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp @@ -1,11 +1,15 @@ #include -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" TEST_CASE("CCSDS Test", "[ccsds]") { - REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822); - REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822); + SECTION("Constexpr Helpers") { + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822); - REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); - REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); + } + + SECTION("Header Tests") { SpacePacketReader base = SpacePacketReader(); } } From 0c5f6237807166a602d2a49e57a5027f2d80bd09 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 10:53:55 +0200 Subject: [PATCH 039/532] additional ctor for space packet creator --- src/fsfw/serialize/SerializeAdapter.h | 4 +-- src/fsfw/tmtcpacket/SpacePacketCreator.cpp | 25 ++++++++++++++++--- src/fsfw/tmtcpacket/SpacePacketCreator.h | 10 +++++--- .../fsfw_tests/unit/tmtcpacket/testCcsds.cpp | 7 +++++- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/fsfw/serialize/SerializeAdapter.h b/src/fsfw/serialize/SerializeAdapter.h index 5feda889..4580986f 100644 --- a/src/fsfw/serialize/SerializeAdapter.h +++ b/src/fsfw/serialize/SerializeAdapter.h @@ -74,7 +74,7 @@ class SerializeAdapter { return HasReturnvaluesIF::RETURN_FAILED; } InternalSerializeAdapter::value> adapter; - uint8_t **tempPtr = const_cast(&buffer); + auto **tempPtr = const_cast(&buffer); size_t tmpSize = 0; ReturnValue_t result = adapter.serialize(object, tempPtr, &tmpSize, maxSize, streamEndianness); if (serSize != nullptr) { @@ -232,7 +232,7 @@ class SerializeAdapter { } } - uint32_t getSerializedSize(const T *object) { return sizeof(T); } + uint32_t getSerializedSize(const T *) { return sizeof(T); } }; /** diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp index d5eb73c2..0263dad3 100644 --- a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp @@ -3,11 +3,30 @@ #include "fsfw/serialize/SerializeAdapter.h" SpacePacketCreator::SpacePacketCreator(uint16_t packetId_, uint16_t packetSeqCtrl_, - uint16_t packetLen_, uint8_t version_) { + uint16_t dataLen_, uint8_t version_) { packetId = packetId_; packetSeqCtrl = packetSeqCtrl_; - packetLen = packetLen_; + dataLen = dataLen_; version = version_; + valid = true; +} + +SpacePacketCreator::SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, + uint16_t apid, ccsds::SequenceFlags seqFlags, + uint16_t seqCount, uint16_t dataLen_, uint8_t version_) { + if (apid > ccsds::LIMIT_APID) { + valid = false; + return; + } + if (seqCount > ccsds::LIMIT_SEQUENCE_COUNT) { + valid = false; + return; + } + version = version_; + packetId = + (version_ << 13) | (static_cast(packetType) << 12) | (secHeaderFlag << 11) | apid; + packetSeqCtrl = static_cast(seqFlags) << 14 | seqCount; + dataLen = dataLen_; } uint16_t SpacePacketCreator::getPacketId() const { return 0; } @@ -26,7 +45,7 @@ ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - return SerializeAdapter::serialize(&packetLen, buffer, size, maxSize, streamEndianness); + return SerializeAdapter::serialize(&dataLen, buffer, size, maxSize, streamEndianness); } size_t SpacePacketCreator::getSerializedSize() const { return 0; } diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.h b/src/fsfw/tmtcpacket/SpacePacketCreator.h index 2e7d2537..79ea47dc 100644 --- a/src/fsfw/tmtcpacket/SpacePacketCreator.h +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.h @@ -6,21 +6,25 @@ class SpacePacketCreator : public SerializeIF, public SpacePacketIF { public: - SpacePacketCreator(uint16_t packetId, uint16_t packetSeqCtrl, uint16_t packetLen, + SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid, + ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen, uint8_t version = 0); + SpacePacketCreator(uint16_t packetId, uint16_t packetSeqCtrl, uint16_t dataLen, + uint8_t version = 0); + bool valid; [[nodiscard]] uint16_t getPacketId() const override; [[nodiscard]] uint16_t getPacketSeqCtrl() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; - size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; private: uint16_t packetId; uint16_t packetSeqCtrl; - uint16_t packetLen; + uint16_t dataLen; uint8_t version; }; #endif // FSFW_TMTCPACKET_SPACEPACKETCREATOR_H diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp index 6d3b63a7..0fd2a19c 100644 --- a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp +++ b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp @@ -1,5 +1,6 @@ #include +#include "fsfw/tmtcpacket/SpacePacketCreator.h" #include "fsfw/tmtcpacket/SpacePacketReader.h" TEST_CASE("CCSDS Test", "[ccsds]") { @@ -11,5 +12,9 @@ TEST_CASE("CCSDS Test", "[ccsds]") { REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); } - SECTION("Header Tests") { SpacePacketReader base = SpacePacketReader(); } + SECTION("Header Creator Tests") { + SpacePacketCreator base = SpacePacketCreator( + ccsds::PacketType::TM, true, 0x22, + ccsds::SequenceFlags::CONTINUATION, 12, 0x42); + } } From 846567037418eda973848791a19225d71a77abd9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 11:42:51 +0200 Subject: [PATCH 040/532] separate unittest folder --- {src/fsfw_tests/unit => unittests}/CMakeLists.txt | 2 +- {src/fsfw_tests/unit => unittests}/CatchDefinitions.cpp | 0 {src/fsfw_tests/unit => unittests}/CatchDefinitions.h | 0 {src/fsfw_tests/unit => unittests}/CatchFactory.cpp | 0 {src/fsfw_tests/unit => unittests}/CatchFactory.h | 0 {src/fsfw_tests/unit => unittests}/CatchRunner.cpp | 0 {src/fsfw_tests/unit => unittests}/CatchRunner.h | 0 {src/fsfw_tests/unit => unittests}/CatchSetup.cpp | 0 {src/fsfw_tests/unit => unittests}/action/CMakeLists.txt | 0 {src/fsfw_tests/unit => unittests}/action/TestActionHelper.cpp | 0 {src/fsfw_tests/unit => unittests}/action/TestActionHelper.h | 0 {src/fsfw_tests/unit => unittests}/cfdp/CMakeLists.txt | 0 {src/fsfw_tests/unit => unittests}/cfdp/testAckPdu.cpp | 0 {src/fsfw_tests/unit => unittests}/cfdp/testCfdp.cpp | 0 {src/fsfw_tests/unit => unittests}/cfdp/testEofPdu.cpp | 0 {src/fsfw_tests/unit => unittests}/cfdp/testFileData.cpp | 0 {src/fsfw_tests/unit => unittests}/cfdp/testFinishedPdu.cpp | 0 {src/fsfw_tests/unit => unittests}/cfdp/testKeepAlivePdu.cpp | 0 {src/fsfw_tests/unit => unittests}/cfdp/testMetadataPdu.cpp | 0 {src/fsfw_tests/unit => unittests}/cfdp/testNakPdu.cpp | 0 {src/fsfw_tests/unit => unittests}/cfdp/testPromptPdu.cpp | 0 {src/fsfw_tests/unit => unittests}/cfdp/testTlvsLvs.cpp | 0 {src/fsfw_tests/unit => unittests}/container/CMakeLists.txt | 0 {src/fsfw_tests/unit => unittests}/container/RingBufferTest.cpp | 0 {src/fsfw_tests/unit => unittests}/container/TestArrayList.cpp | 0 .../fsfw_tests/unit => unittests}/container/TestDynamicFifo.cpp | 0 {src/fsfw_tests/unit => unittests}/container/TestFifo.cpp | 0 .../unit => unittests}/container/TestFixedArrayList.cpp | 0 {src/fsfw_tests/unit => unittests}/container/TestFixedMap.cpp | 0 .../unit => unittests}/container/TestFixedOrderedMultimap.cpp | 0 .../unit => unittests}/container/TestPlacementFactory.cpp | 0 {src/fsfw_tests/unit => unittests}/datapoollocal/CMakeLists.txt | 0 .../fsfw_tests/unit => unittests}/datapoollocal/DataSetTest.cpp | 0 .../unit => unittests}/datapoollocal/LocalPoolManagerTest.cpp | 0 .../unit => unittests}/datapoollocal/LocalPoolOwnerBase.cpp | 0 .../unit => unittests}/datapoollocal/LocalPoolOwnerBase.h | 0 .../unit => unittests}/datapoollocal/LocalPoolVariableTest.cpp | 0 .../unit => unittests}/datapoollocal/LocalPoolVectorTest.cpp | 0 {src/fsfw_tests/unit => unittests}/devicehandler/CMakeLists.txt | 0 {src/fsfw_tests/unit => unittests}/devicehandler/ComIFMock.cpp | 0 {src/fsfw_tests/unit => unittests}/devicehandler/ComIFMock.h | 0 .../unit => unittests}/devicehandler/CookieIFMock.cpp | 0 {src/fsfw_tests/unit => unittests}/devicehandler/CookieIFMock.h | 0 .../unit => unittests}/devicehandler/DeviceFdirMock.cpp | 0 .../unit => unittests}/devicehandler/DeviceFdirMock.h | 0 .../unit => unittests}/devicehandler/DeviceHandlerCommander.cpp | 0 .../unit => unittests}/devicehandler/DeviceHandlerCommander.h | 0 .../unit => unittests}/devicehandler/DeviceHandlerMock.cpp | 0 .../unit => unittests}/devicehandler/DeviceHandlerMock.h | 0 .../unit => unittests}/devicehandler/TestDeviceHandlerBase.cpp | 0 .../unit => unittests}/globalfunctions/CMakeLists.txt | 0 .../unit => unittests}/globalfunctions/testBitutil.cpp | 0 {src/fsfw_tests/unit => unittests}/globalfunctions/testCRC.cpp | 0 .../unit => unittests}/globalfunctions/testDleEncoder.cpp | 0 .../unit => unittests}/globalfunctions/testOpDivider.cpp | 0 .../globalfunctions/testTimevalOperations.cpp | 0 {src/fsfw_tests/unit => unittests}/hal/CMakeLists.txt | 0 {src/fsfw_tests/unit => unittests}/hal/testCommandExecutor.cpp | 0 {src/fsfw_tests/unit => unittests}/internalerror/CMakeLists.txt | 0 .../internalerror/TestInternalErrorReporter.cpp | 0 {src/fsfw_tests/unit => unittests}/mocks/CMakeLists.txt | 0 {src/fsfw_tests/unit => unittests}/mocks/HkReceiverMock.h | 0 {src/fsfw_tests/unit => unittests}/mocks/MessageQueueMockBase.h | 0 {src/fsfw_tests/unit => unittests}/mocks/PeriodicTaskIFMock.h | 0 {src/fsfw_tests/unit => unittests}/mocks/PowerSwitcherMock.cpp | 0 {src/fsfw_tests/unit => unittests}/mocks/PowerSwitcherMock.h | 0 {src/fsfw_tests/unit => unittests}/osal/CMakeLists.txt | 0 {src/fsfw_tests/unit => unittests}/osal/TestClock.cpp | 0 {src/fsfw_tests/unit => unittests}/osal/TestMessageQueue.cpp | 0 {src/fsfw_tests/unit => unittests}/osal/TestSemaphore.cpp | 0 {src/fsfw_tests/unit => unittests}/power/CMakeLists.txt | 0 {src/fsfw_tests/unit => unittests}/power/testPowerSwitcher.cpp | 0 {src/fsfw_tests/unit => unittests}/printChar.cpp | 0 {src/fsfw_tests/unit => unittests}/printChar.h | 0 {src/fsfw_tests/unit => unittests}/serialize/CMakeLists.txt | 0 .../unit => unittests}/serialize/TestSerialBufferAdapter.cpp | 0 .../unit => unittests}/serialize/TestSerialLinkedPacket.cpp | 0 .../unit => unittests}/serialize/TestSerialLinkedPacket.h | 0 .../unit => unittests}/serialize/TestSerialization.cpp | 0 .../fsfw_tests/unit => unittests}/storagemanager/CMakeLists.txt | 0 .../unit => unittests}/storagemanager/TestNewAccessor.cpp | 0 {src/fsfw_tests/unit => unittests}/storagemanager/TestPool.cpp | 0 src/fsfw_tests/unit/version.cpp => unittests/testVersion.cpp | 0 {src/fsfw_tests/unit => unittests}/testcfg/CMakeLists.txt | 0 {src/fsfw_tests/unit => unittests}/testcfg/FSFWConfig.h.in | 0 {src/fsfw_tests/unit => unittests}/testcfg/OBSWConfig.h.in | 0 {src/fsfw_tests/unit => unittests}/testcfg/TestsConfig.h.in | 0 .../unit => unittests}/testcfg/devices/logicalAddresses.cpp | 0 .../unit => unittests}/testcfg/devices/logicalAddresses.h | 0 .../unit => unittests}/testcfg/devices/powerSwitcherList.cpp | 0 .../unit => unittests}/testcfg/devices/powerSwitcherList.h | 0 .../unit => unittests}/testcfg/events/subsystemIdRanges.h | 0 .../unit => unittests}/testcfg/ipc/MissionMessageTypes.cpp | 0 .../unit => unittests}/testcfg/ipc/MissionMessageTypes.h | 0 .../unit => unittests}/testcfg/objects/systemObjectList.h | 0 .../testcfg/pollingsequence/PollingSequenceFactory.cpp | 0 .../testcfg/pollingsequence/PollingSequenceFactory.h | 0 .../unit => unittests}/testcfg/returnvalues/classIds.h | 0 {src/fsfw_tests/unit => unittests}/testcfg/tmtc/apid.h | 0 {src/fsfw_tests/unit => unittests}/testcfg/tmtc/pusIds.h | 0 .../fsfw_tests/unit => unittests}/testtemplate/TestTemplate.cpp | 0 {src/fsfw_tests/unit => unittests}/timemanager/CMakeLists.txt | 0 .../fsfw_tests/unit => unittests}/timemanager/TestCCSDSTime.cpp | 0 .../fsfw_tests/unit => unittests}/timemanager/TestCountdown.cpp | 0 {src/fsfw_tests/unit => unittests}/tmtcpacket/CMakeLists.txt | 0 {src/fsfw_tests/unit => unittests}/tmtcpacket/PusTmTest.cpp | 0 {src/fsfw_tests/unit => unittests}/tmtcpacket/testCcsds.cpp | 0 107 files changed, 1 insertion(+), 1 deletion(-) rename {src/fsfw_tests/unit => unittests}/CMakeLists.txt (96%) rename {src/fsfw_tests/unit => unittests}/CatchDefinitions.cpp (100%) rename {src/fsfw_tests/unit => unittests}/CatchDefinitions.h (100%) rename {src/fsfw_tests/unit => unittests}/CatchFactory.cpp (100%) rename {src/fsfw_tests/unit => unittests}/CatchFactory.h (100%) rename {src/fsfw_tests/unit => unittests}/CatchRunner.cpp (100%) rename {src/fsfw_tests/unit => unittests}/CatchRunner.h (100%) rename {src/fsfw_tests/unit => unittests}/CatchSetup.cpp (100%) rename {src/fsfw_tests/unit => unittests}/action/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/action/TestActionHelper.cpp (100%) rename {src/fsfw_tests/unit => unittests}/action/TestActionHelper.h (100%) rename {src/fsfw_tests/unit => unittests}/cfdp/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/cfdp/testAckPdu.cpp (100%) rename {src/fsfw_tests/unit => unittests}/cfdp/testCfdp.cpp (100%) rename {src/fsfw_tests/unit => unittests}/cfdp/testEofPdu.cpp (100%) rename {src/fsfw_tests/unit => unittests}/cfdp/testFileData.cpp (100%) rename {src/fsfw_tests/unit => unittests}/cfdp/testFinishedPdu.cpp (100%) rename {src/fsfw_tests/unit => unittests}/cfdp/testKeepAlivePdu.cpp (100%) rename {src/fsfw_tests/unit => unittests}/cfdp/testMetadataPdu.cpp (100%) rename {src/fsfw_tests/unit => unittests}/cfdp/testNakPdu.cpp (100%) rename {src/fsfw_tests/unit => unittests}/cfdp/testPromptPdu.cpp (100%) rename {src/fsfw_tests/unit => unittests}/cfdp/testTlvsLvs.cpp (100%) rename {src/fsfw_tests/unit => unittests}/container/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/container/RingBufferTest.cpp (100%) rename {src/fsfw_tests/unit => unittests}/container/TestArrayList.cpp (100%) rename {src/fsfw_tests/unit => unittests}/container/TestDynamicFifo.cpp (100%) rename {src/fsfw_tests/unit => unittests}/container/TestFifo.cpp (100%) rename {src/fsfw_tests/unit => unittests}/container/TestFixedArrayList.cpp (100%) rename {src/fsfw_tests/unit => unittests}/container/TestFixedMap.cpp (100%) rename {src/fsfw_tests/unit => unittests}/container/TestFixedOrderedMultimap.cpp (100%) rename {src/fsfw_tests/unit => unittests}/container/TestPlacementFactory.cpp (100%) rename {src/fsfw_tests/unit => unittests}/datapoollocal/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/datapoollocal/DataSetTest.cpp (100%) rename {src/fsfw_tests/unit => unittests}/datapoollocal/LocalPoolManagerTest.cpp (100%) rename {src/fsfw_tests/unit => unittests}/datapoollocal/LocalPoolOwnerBase.cpp (100%) rename {src/fsfw_tests/unit => unittests}/datapoollocal/LocalPoolOwnerBase.h (100%) rename {src/fsfw_tests/unit => unittests}/datapoollocal/LocalPoolVariableTest.cpp (100%) rename {src/fsfw_tests/unit => unittests}/datapoollocal/LocalPoolVectorTest.cpp (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/ComIFMock.cpp (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/ComIFMock.h (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/CookieIFMock.cpp (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/CookieIFMock.h (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/DeviceFdirMock.cpp (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/DeviceFdirMock.h (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/DeviceHandlerCommander.cpp (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/DeviceHandlerCommander.h (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/DeviceHandlerMock.cpp (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/DeviceHandlerMock.h (100%) rename {src/fsfw_tests/unit => unittests}/devicehandler/TestDeviceHandlerBase.cpp (100%) rename {src/fsfw_tests/unit => unittests}/globalfunctions/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/globalfunctions/testBitutil.cpp (100%) rename {src/fsfw_tests/unit => unittests}/globalfunctions/testCRC.cpp (100%) rename {src/fsfw_tests/unit => unittests}/globalfunctions/testDleEncoder.cpp (100%) rename {src/fsfw_tests/unit => unittests}/globalfunctions/testOpDivider.cpp (100%) rename {src/fsfw_tests/unit => unittests}/globalfunctions/testTimevalOperations.cpp (100%) rename {src/fsfw_tests/unit => unittests}/hal/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/hal/testCommandExecutor.cpp (100%) rename {src/fsfw_tests/unit => unittests}/internalerror/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/internalerror/TestInternalErrorReporter.cpp (100%) rename {src/fsfw_tests/unit => unittests}/mocks/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/mocks/HkReceiverMock.h (100%) rename {src/fsfw_tests/unit => unittests}/mocks/MessageQueueMockBase.h (100%) rename {src/fsfw_tests/unit => unittests}/mocks/PeriodicTaskIFMock.h (100%) rename {src/fsfw_tests/unit => unittests}/mocks/PowerSwitcherMock.cpp (100%) rename {src/fsfw_tests/unit => unittests}/mocks/PowerSwitcherMock.h (100%) rename {src/fsfw_tests/unit => unittests}/osal/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/osal/TestClock.cpp (100%) rename {src/fsfw_tests/unit => unittests}/osal/TestMessageQueue.cpp (100%) rename {src/fsfw_tests/unit => unittests}/osal/TestSemaphore.cpp (100%) rename {src/fsfw_tests/unit => unittests}/power/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/power/testPowerSwitcher.cpp (100%) rename {src/fsfw_tests/unit => unittests}/printChar.cpp (100%) rename {src/fsfw_tests/unit => unittests}/printChar.h (100%) rename {src/fsfw_tests/unit => unittests}/serialize/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/serialize/TestSerialBufferAdapter.cpp (100%) rename {src/fsfw_tests/unit => unittests}/serialize/TestSerialLinkedPacket.cpp (100%) rename {src/fsfw_tests/unit => unittests}/serialize/TestSerialLinkedPacket.h (100%) rename {src/fsfw_tests/unit => unittests}/serialize/TestSerialization.cpp (100%) rename {src/fsfw_tests/unit => unittests}/storagemanager/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/storagemanager/TestNewAccessor.cpp (100%) rename {src/fsfw_tests/unit => unittests}/storagemanager/TestPool.cpp (100%) rename src/fsfw_tests/unit/version.cpp => unittests/testVersion.cpp (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/FSFWConfig.h.in (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/OBSWConfig.h.in (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/TestsConfig.h.in (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/devices/logicalAddresses.cpp (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/devices/logicalAddresses.h (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/devices/powerSwitcherList.cpp (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/devices/powerSwitcherList.h (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/events/subsystemIdRanges.h (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/ipc/MissionMessageTypes.cpp (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/ipc/MissionMessageTypes.h (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/objects/systemObjectList.h (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/pollingsequence/PollingSequenceFactory.cpp (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/pollingsequence/PollingSequenceFactory.h (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/returnvalues/classIds.h (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/tmtc/apid.h (100%) rename {src/fsfw_tests/unit => unittests}/testcfg/tmtc/pusIds.h (100%) rename {src/fsfw_tests/unit => unittests}/testtemplate/TestTemplate.cpp (100%) rename {src/fsfw_tests/unit => unittests}/timemanager/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/timemanager/TestCCSDSTime.cpp (100%) rename {src/fsfw_tests/unit => unittests}/timemanager/TestCountdown.cpp (100%) rename {src/fsfw_tests/unit => unittests}/tmtcpacket/CMakeLists.txt (100%) rename {src/fsfw_tests/unit => unittests}/tmtcpacket/PusTmTest.cpp (100%) rename {src/fsfw_tests/unit => unittests}/tmtcpacket/testCcsds.cpp (100%) diff --git a/src/fsfw_tests/unit/CMakeLists.txt b/unittests/CMakeLists.txt similarity index 96% rename from src/fsfw_tests/unit/CMakeLists.txt rename to unittests/CMakeLists.txt index f54e1fc9..49b1840f 100644 --- a/src/fsfw_tests/unit/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -2,7 +2,7 @@ target_sources(${FSFW_TEST_TGT} PRIVATE CatchDefinitions.cpp CatchFactory.cpp printChar.cpp - version.cpp + testVersion.cpp ) target_sources(${FSFW_TEST_TGT} PRIVATE diff --git a/src/fsfw_tests/unit/CatchDefinitions.cpp b/unittests/CatchDefinitions.cpp similarity index 100% rename from src/fsfw_tests/unit/CatchDefinitions.cpp rename to unittests/CatchDefinitions.cpp diff --git a/src/fsfw_tests/unit/CatchDefinitions.h b/unittests/CatchDefinitions.h similarity index 100% rename from src/fsfw_tests/unit/CatchDefinitions.h rename to unittests/CatchDefinitions.h diff --git a/src/fsfw_tests/unit/CatchFactory.cpp b/unittests/CatchFactory.cpp similarity index 100% rename from src/fsfw_tests/unit/CatchFactory.cpp rename to unittests/CatchFactory.cpp diff --git a/src/fsfw_tests/unit/CatchFactory.h b/unittests/CatchFactory.h similarity index 100% rename from src/fsfw_tests/unit/CatchFactory.h rename to unittests/CatchFactory.h diff --git a/src/fsfw_tests/unit/CatchRunner.cpp b/unittests/CatchRunner.cpp similarity index 100% rename from src/fsfw_tests/unit/CatchRunner.cpp rename to unittests/CatchRunner.cpp diff --git a/src/fsfw_tests/unit/CatchRunner.h b/unittests/CatchRunner.h similarity index 100% rename from src/fsfw_tests/unit/CatchRunner.h rename to unittests/CatchRunner.h diff --git a/src/fsfw_tests/unit/CatchSetup.cpp b/unittests/CatchSetup.cpp similarity index 100% rename from src/fsfw_tests/unit/CatchSetup.cpp rename to unittests/CatchSetup.cpp diff --git a/src/fsfw_tests/unit/action/CMakeLists.txt b/unittests/action/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/action/CMakeLists.txt rename to unittests/action/CMakeLists.txt diff --git a/src/fsfw_tests/unit/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp similarity index 100% rename from src/fsfw_tests/unit/action/TestActionHelper.cpp rename to unittests/action/TestActionHelper.cpp diff --git a/src/fsfw_tests/unit/action/TestActionHelper.h b/unittests/action/TestActionHelper.h similarity index 100% rename from src/fsfw_tests/unit/action/TestActionHelper.h rename to unittests/action/TestActionHelper.h diff --git a/src/fsfw_tests/unit/cfdp/CMakeLists.txt b/unittests/cfdp/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/cfdp/CMakeLists.txt rename to unittests/cfdp/CMakeLists.txt diff --git a/src/fsfw_tests/unit/cfdp/testAckPdu.cpp b/unittests/cfdp/testAckPdu.cpp similarity index 100% rename from src/fsfw_tests/unit/cfdp/testAckPdu.cpp rename to unittests/cfdp/testAckPdu.cpp diff --git a/src/fsfw_tests/unit/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp similarity index 100% rename from src/fsfw_tests/unit/cfdp/testCfdp.cpp rename to unittests/cfdp/testCfdp.cpp diff --git a/src/fsfw_tests/unit/cfdp/testEofPdu.cpp b/unittests/cfdp/testEofPdu.cpp similarity index 100% rename from src/fsfw_tests/unit/cfdp/testEofPdu.cpp rename to unittests/cfdp/testEofPdu.cpp diff --git a/src/fsfw_tests/unit/cfdp/testFileData.cpp b/unittests/cfdp/testFileData.cpp similarity index 100% rename from src/fsfw_tests/unit/cfdp/testFileData.cpp rename to unittests/cfdp/testFileData.cpp diff --git a/src/fsfw_tests/unit/cfdp/testFinishedPdu.cpp b/unittests/cfdp/testFinishedPdu.cpp similarity index 100% rename from src/fsfw_tests/unit/cfdp/testFinishedPdu.cpp rename to unittests/cfdp/testFinishedPdu.cpp diff --git a/src/fsfw_tests/unit/cfdp/testKeepAlivePdu.cpp b/unittests/cfdp/testKeepAlivePdu.cpp similarity index 100% rename from src/fsfw_tests/unit/cfdp/testKeepAlivePdu.cpp rename to unittests/cfdp/testKeepAlivePdu.cpp diff --git a/src/fsfw_tests/unit/cfdp/testMetadataPdu.cpp b/unittests/cfdp/testMetadataPdu.cpp similarity index 100% rename from src/fsfw_tests/unit/cfdp/testMetadataPdu.cpp rename to unittests/cfdp/testMetadataPdu.cpp diff --git a/src/fsfw_tests/unit/cfdp/testNakPdu.cpp b/unittests/cfdp/testNakPdu.cpp similarity index 100% rename from src/fsfw_tests/unit/cfdp/testNakPdu.cpp rename to unittests/cfdp/testNakPdu.cpp diff --git a/src/fsfw_tests/unit/cfdp/testPromptPdu.cpp b/unittests/cfdp/testPromptPdu.cpp similarity index 100% rename from src/fsfw_tests/unit/cfdp/testPromptPdu.cpp rename to unittests/cfdp/testPromptPdu.cpp diff --git a/src/fsfw_tests/unit/cfdp/testTlvsLvs.cpp b/unittests/cfdp/testTlvsLvs.cpp similarity index 100% rename from src/fsfw_tests/unit/cfdp/testTlvsLvs.cpp rename to unittests/cfdp/testTlvsLvs.cpp diff --git a/src/fsfw_tests/unit/container/CMakeLists.txt b/unittests/container/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/container/CMakeLists.txt rename to unittests/container/CMakeLists.txt diff --git a/src/fsfw_tests/unit/container/RingBufferTest.cpp b/unittests/container/RingBufferTest.cpp similarity index 100% rename from src/fsfw_tests/unit/container/RingBufferTest.cpp rename to unittests/container/RingBufferTest.cpp diff --git a/src/fsfw_tests/unit/container/TestArrayList.cpp b/unittests/container/TestArrayList.cpp similarity index 100% rename from src/fsfw_tests/unit/container/TestArrayList.cpp rename to unittests/container/TestArrayList.cpp diff --git a/src/fsfw_tests/unit/container/TestDynamicFifo.cpp b/unittests/container/TestDynamicFifo.cpp similarity index 100% rename from src/fsfw_tests/unit/container/TestDynamicFifo.cpp rename to unittests/container/TestDynamicFifo.cpp diff --git a/src/fsfw_tests/unit/container/TestFifo.cpp b/unittests/container/TestFifo.cpp similarity index 100% rename from src/fsfw_tests/unit/container/TestFifo.cpp rename to unittests/container/TestFifo.cpp diff --git a/src/fsfw_tests/unit/container/TestFixedArrayList.cpp b/unittests/container/TestFixedArrayList.cpp similarity index 100% rename from src/fsfw_tests/unit/container/TestFixedArrayList.cpp rename to unittests/container/TestFixedArrayList.cpp diff --git a/src/fsfw_tests/unit/container/TestFixedMap.cpp b/unittests/container/TestFixedMap.cpp similarity index 100% rename from src/fsfw_tests/unit/container/TestFixedMap.cpp rename to unittests/container/TestFixedMap.cpp diff --git a/src/fsfw_tests/unit/container/TestFixedOrderedMultimap.cpp b/unittests/container/TestFixedOrderedMultimap.cpp similarity index 100% rename from src/fsfw_tests/unit/container/TestFixedOrderedMultimap.cpp rename to unittests/container/TestFixedOrderedMultimap.cpp diff --git a/src/fsfw_tests/unit/container/TestPlacementFactory.cpp b/unittests/container/TestPlacementFactory.cpp similarity index 100% rename from src/fsfw_tests/unit/container/TestPlacementFactory.cpp rename to unittests/container/TestPlacementFactory.cpp diff --git a/src/fsfw_tests/unit/datapoollocal/CMakeLists.txt b/unittests/datapoollocal/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/datapoollocal/CMakeLists.txt rename to unittests/datapoollocal/CMakeLists.txt diff --git a/src/fsfw_tests/unit/datapoollocal/DataSetTest.cpp b/unittests/datapoollocal/DataSetTest.cpp similarity index 100% rename from src/fsfw_tests/unit/datapoollocal/DataSetTest.cpp rename to unittests/datapoollocal/DataSetTest.cpp diff --git a/src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp b/unittests/datapoollocal/LocalPoolManagerTest.cpp similarity index 100% rename from src/fsfw_tests/unit/datapoollocal/LocalPoolManagerTest.cpp rename to unittests/datapoollocal/LocalPoolManagerTest.cpp diff --git a/src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.cpp b/unittests/datapoollocal/LocalPoolOwnerBase.cpp similarity index 100% rename from src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.cpp rename to unittests/datapoollocal/LocalPoolOwnerBase.cpp diff --git a/src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.h b/unittests/datapoollocal/LocalPoolOwnerBase.h similarity index 100% rename from src/fsfw_tests/unit/datapoollocal/LocalPoolOwnerBase.h rename to unittests/datapoollocal/LocalPoolOwnerBase.h diff --git a/src/fsfw_tests/unit/datapoollocal/LocalPoolVariableTest.cpp b/unittests/datapoollocal/LocalPoolVariableTest.cpp similarity index 100% rename from src/fsfw_tests/unit/datapoollocal/LocalPoolVariableTest.cpp rename to unittests/datapoollocal/LocalPoolVariableTest.cpp diff --git a/src/fsfw_tests/unit/datapoollocal/LocalPoolVectorTest.cpp b/unittests/datapoollocal/LocalPoolVectorTest.cpp similarity index 100% rename from src/fsfw_tests/unit/datapoollocal/LocalPoolVectorTest.cpp rename to unittests/datapoollocal/LocalPoolVectorTest.cpp diff --git a/src/fsfw_tests/unit/devicehandler/CMakeLists.txt b/unittests/devicehandler/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/devicehandler/CMakeLists.txt rename to unittests/devicehandler/CMakeLists.txt diff --git a/src/fsfw_tests/unit/devicehandler/ComIFMock.cpp b/unittests/devicehandler/ComIFMock.cpp similarity index 100% rename from src/fsfw_tests/unit/devicehandler/ComIFMock.cpp rename to unittests/devicehandler/ComIFMock.cpp diff --git a/src/fsfw_tests/unit/devicehandler/ComIFMock.h b/unittests/devicehandler/ComIFMock.h similarity index 100% rename from src/fsfw_tests/unit/devicehandler/ComIFMock.h rename to unittests/devicehandler/ComIFMock.h diff --git a/src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp b/unittests/devicehandler/CookieIFMock.cpp similarity index 100% rename from src/fsfw_tests/unit/devicehandler/CookieIFMock.cpp rename to unittests/devicehandler/CookieIFMock.cpp diff --git a/src/fsfw_tests/unit/devicehandler/CookieIFMock.h b/unittests/devicehandler/CookieIFMock.h similarity index 100% rename from src/fsfw_tests/unit/devicehandler/CookieIFMock.h rename to unittests/devicehandler/CookieIFMock.h diff --git a/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.cpp b/unittests/devicehandler/DeviceFdirMock.cpp similarity index 100% rename from src/fsfw_tests/unit/devicehandler/DeviceFdirMock.cpp rename to unittests/devicehandler/DeviceFdirMock.cpp diff --git a/src/fsfw_tests/unit/devicehandler/DeviceFdirMock.h b/unittests/devicehandler/DeviceFdirMock.h similarity index 100% rename from src/fsfw_tests/unit/devicehandler/DeviceFdirMock.h rename to unittests/devicehandler/DeviceFdirMock.h diff --git a/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp b/unittests/devicehandler/DeviceHandlerCommander.cpp similarity index 100% rename from src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.cpp rename to unittests/devicehandler/DeviceHandlerCommander.cpp diff --git a/src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h b/unittests/devicehandler/DeviceHandlerCommander.h similarity index 100% rename from src/fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h rename to unittests/devicehandler/DeviceHandlerCommander.h diff --git a/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp b/unittests/devicehandler/DeviceHandlerMock.cpp similarity index 100% rename from src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.cpp rename to unittests/devicehandler/DeviceHandlerMock.cpp diff --git a/src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h b/unittests/devicehandler/DeviceHandlerMock.h similarity index 100% rename from src/fsfw_tests/unit/devicehandler/DeviceHandlerMock.h rename to unittests/devicehandler/DeviceHandlerMock.h diff --git a/src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp b/unittests/devicehandler/TestDeviceHandlerBase.cpp similarity index 100% rename from src/fsfw_tests/unit/devicehandler/TestDeviceHandlerBase.cpp rename to unittests/devicehandler/TestDeviceHandlerBase.cpp diff --git a/src/fsfw_tests/unit/globalfunctions/CMakeLists.txt b/unittests/globalfunctions/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/globalfunctions/CMakeLists.txt rename to unittests/globalfunctions/CMakeLists.txt diff --git a/src/fsfw_tests/unit/globalfunctions/testBitutil.cpp b/unittests/globalfunctions/testBitutil.cpp similarity index 100% rename from src/fsfw_tests/unit/globalfunctions/testBitutil.cpp rename to unittests/globalfunctions/testBitutil.cpp diff --git a/src/fsfw_tests/unit/globalfunctions/testCRC.cpp b/unittests/globalfunctions/testCRC.cpp similarity index 100% rename from src/fsfw_tests/unit/globalfunctions/testCRC.cpp rename to unittests/globalfunctions/testCRC.cpp diff --git a/src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp b/unittests/globalfunctions/testDleEncoder.cpp similarity index 100% rename from src/fsfw_tests/unit/globalfunctions/testDleEncoder.cpp rename to unittests/globalfunctions/testDleEncoder.cpp diff --git a/src/fsfw_tests/unit/globalfunctions/testOpDivider.cpp b/unittests/globalfunctions/testOpDivider.cpp similarity index 100% rename from src/fsfw_tests/unit/globalfunctions/testOpDivider.cpp rename to unittests/globalfunctions/testOpDivider.cpp diff --git a/src/fsfw_tests/unit/globalfunctions/testTimevalOperations.cpp b/unittests/globalfunctions/testTimevalOperations.cpp similarity index 100% rename from src/fsfw_tests/unit/globalfunctions/testTimevalOperations.cpp rename to unittests/globalfunctions/testTimevalOperations.cpp diff --git a/src/fsfw_tests/unit/hal/CMakeLists.txt b/unittests/hal/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/hal/CMakeLists.txt rename to unittests/hal/CMakeLists.txt diff --git a/src/fsfw_tests/unit/hal/testCommandExecutor.cpp b/unittests/hal/testCommandExecutor.cpp similarity index 100% rename from src/fsfw_tests/unit/hal/testCommandExecutor.cpp rename to unittests/hal/testCommandExecutor.cpp diff --git a/src/fsfw_tests/unit/internalerror/CMakeLists.txt b/unittests/internalerror/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/internalerror/CMakeLists.txt rename to unittests/internalerror/CMakeLists.txt diff --git a/src/fsfw_tests/unit/internalerror/TestInternalErrorReporter.cpp b/unittests/internalerror/TestInternalErrorReporter.cpp similarity index 100% rename from src/fsfw_tests/unit/internalerror/TestInternalErrorReporter.cpp rename to unittests/internalerror/TestInternalErrorReporter.cpp diff --git a/src/fsfw_tests/unit/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/mocks/CMakeLists.txt rename to unittests/mocks/CMakeLists.txt diff --git a/src/fsfw_tests/unit/mocks/HkReceiverMock.h b/unittests/mocks/HkReceiverMock.h similarity index 100% rename from src/fsfw_tests/unit/mocks/HkReceiverMock.h rename to unittests/mocks/HkReceiverMock.h diff --git a/src/fsfw_tests/unit/mocks/MessageQueueMockBase.h b/unittests/mocks/MessageQueueMockBase.h similarity index 100% rename from src/fsfw_tests/unit/mocks/MessageQueueMockBase.h rename to unittests/mocks/MessageQueueMockBase.h diff --git a/src/fsfw_tests/unit/mocks/PeriodicTaskIFMock.h b/unittests/mocks/PeriodicTaskIFMock.h similarity index 100% rename from src/fsfw_tests/unit/mocks/PeriodicTaskIFMock.h rename to unittests/mocks/PeriodicTaskIFMock.h diff --git a/src/fsfw_tests/unit/mocks/PowerSwitcherMock.cpp b/unittests/mocks/PowerSwitcherMock.cpp similarity index 100% rename from src/fsfw_tests/unit/mocks/PowerSwitcherMock.cpp rename to unittests/mocks/PowerSwitcherMock.cpp diff --git a/src/fsfw_tests/unit/mocks/PowerSwitcherMock.h b/unittests/mocks/PowerSwitcherMock.h similarity index 100% rename from src/fsfw_tests/unit/mocks/PowerSwitcherMock.h rename to unittests/mocks/PowerSwitcherMock.h diff --git a/src/fsfw_tests/unit/osal/CMakeLists.txt b/unittests/osal/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/osal/CMakeLists.txt rename to unittests/osal/CMakeLists.txt diff --git a/src/fsfw_tests/unit/osal/TestClock.cpp b/unittests/osal/TestClock.cpp similarity index 100% rename from src/fsfw_tests/unit/osal/TestClock.cpp rename to unittests/osal/TestClock.cpp diff --git a/src/fsfw_tests/unit/osal/TestMessageQueue.cpp b/unittests/osal/TestMessageQueue.cpp similarity index 100% rename from src/fsfw_tests/unit/osal/TestMessageQueue.cpp rename to unittests/osal/TestMessageQueue.cpp diff --git a/src/fsfw_tests/unit/osal/TestSemaphore.cpp b/unittests/osal/TestSemaphore.cpp similarity index 100% rename from src/fsfw_tests/unit/osal/TestSemaphore.cpp rename to unittests/osal/TestSemaphore.cpp diff --git a/src/fsfw_tests/unit/power/CMakeLists.txt b/unittests/power/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/power/CMakeLists.txt rename to unittests/power/CMakeLists.txt diff --git a/src/fsfw_tests/unit/power/testPowerSwitcher.cpp b/unittests/power/testPowerSwitcher.cpp similarity index 100% rename from src/fsfw_tests/unit/power/testPowerSwitcher.cpp rename to unittests/power/testPowerSwitcher.cpp diff --git a/src/fsfw_tests/unit/printChar.cpp b/unittests/printChar.cpp similarity index 100% rename from src/fsfw_tests/unit/printChar.cpp rename to unittests/printChar.cpp diff --git a/src/fsfw_tests/unit/printChar.h b/unittests/printChar.h similarity index 100% rename from src/fsfw_tests/unit/printChar.h rename to unittests/printChar.h diff --git a/src/fsfw_tests/unit/serialize/CMakeLists.txt b/unittests/serialize/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/serialize/CMakeLists.txt rename to unittests/serialize/CMakeLists.txt diff --git a/src/fsfw_tests/unit/serialize/TestSerialBufferAdapter.cpp b/unittests/serialize/TestSerialBufferAdapter.cpp similarity index 100% rename from src/fsfw_tests/unit/serialize/TestSerialBufferAdapter.cpp rename to unittests/serialize/TestSerialBufferAdapter.cpp diff --git a/src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.cpp b/unittests/serialize/TestSerialLinkedPacket.cpp similarity index 100% rename from src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.cpp rename to unittests/serialize/TestSerialLinkedPacket.cpp diff --git a/src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.h b/unittests/serialize/TestSerialLinkedPacket.h similarity index 100% rename from src/fsfw_tests/unit/serialize/TestSerialLinkedPacket.h rename to unittests/serialize/TestSerialLinkedPacket.h diff --git a/src/fsfw_tests/unit/serialize/TestSerialization.cpp b/unittests/serialize/TestSerialization.cpp similarity index 100% rename from src/fsfw_tests/unit/serialize/TestSerialization.cpp rename to unittests/serialize/TestSerialization.cpp diff --git a/src/fsfw_tests/unit/storagemanager/CMakeLists.txt b/unittests/storagemanager/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/storagemanager/CMakeLists.txt rename to unittests/storagemanager/CMakeLists.txt diff --git a/src/fsfw_tests/unit/storagemanager/TestNewAccessor.cpp b/unittests/storagemanager/TestNewAccessor.cpp similarity index 100% rename from src/fsfw_tests/unit/storagemanager/TestNewAccessor.cpp rename to unittests/storagemanager/TestNewAccessor.cpp diff --git a/src/fsfw_tests/unit/storagemanager/TestPool.cpp b/unittests/storagemanager/TestPool.cpp similarity index 100% rename from src/fsfw_tests/unit/storagemanager/TestPool.cpp rename to unittests/storagemanager/TestPool.cpp diff --git a/src/fsfw_tests/unit/version.cpp b/unittests/testVersion.cpp similarity index 100% rename from src/fsfw_tests/unit/version.cpp rename to unittests/testVersion.cpp diff --git a/src/fsfw_tests/unit/testcfg/CMakeLists.txt b/unittests/testcfg/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/testcfg/CMakeLists.txt rename to unittests/testcfg/CMakeLists.txt diff --git a/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in b/unittests/testcfg/FSFWConfig.h.in similarity index 100% rename from src/fsfw_tests/unit/testcfg/FSFWConfig.h.in rename to unittests/testcfg/FSFWConfig.h.in diff --git a/src/fsfw_tests/unit/testcfg/OBSWConfig.h.in b/unittests/testcfg/OBSWConfig.h.in similarity index 100% rename from src/fsfw_tests/unit/testcfg/OBSWConfig.h.in rename to unittests/testcfg/OBSWConfig.h.in diff --git a/src/fsfw_tests/unit/testcfg/TestsConfig.h.in b/unittests/testcfg/TestsConfig.h.in similarity index 100% rename from src/fsfw_tests/unit/testcfg/TestsConfig.h.in rename to unittests/testcfg/TestsConfig.h.in diff --git a/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.cpp b/unittests/testcfg/devices/logicalAddresses.cpp similarity index 100% rename from src/fsfw_tests/unit/testcfg/devices/logicalAddresses.cpp rename to unittests/testcfg/devices/logicalAddresses.cpp diff --git a/src/fsfw_tests/unit/testcfg/devices/logicalAddresses.h b/unittests/testcfg/devices/logicalAddresses.h similarity index 100% rename from src/fsfw_tests/unit/testcfg/devices/logicalAddresses.h rename to unittests/testcfg/devices/logicalAddresses.h diff --git a/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.cpp b/unittests/testcfg/devices/powerSwitcherList.cpp similarity index 100% rename from src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.cpp rename to unittests/testcfg/devices/powerSwitcherList.cpp diff --git a/src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.h b/unittests/testcfg/devices/powerSwitcherList.h similarity index 100% rename from src/fsfw_tests/unit/testcfg/devices/powerSwitcherList.h rename to unittests/testcfg/devices/powerSwitcherList.h diff --git a/src/fsfw_tests/unit/testcfg/events/subsystemIdRanges.h b/unittests/testcfg/events/subsystemIdRanges.h similarity index 100% rename from src/fsfw_tests/unit/testcfg/events/subsystemIdRanges.h rename to unittests/testcfg/events/subsystemIdRanges.h diff --git a/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.cpp b/unittests/testcfg/ipc/MissionMessageTypes.cpp similarity index 100% rename from src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.cpp rename to unittests/testcfg/ipc/MissionMessageTypes.cpp diff --git a/src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.h b/unittests/testcfg/ipc/MissionMessageTypes.h similarity index 100% rename from src/fsfw_tests/unit/testcfg/ipc/MissionMessageTypes.h rename to unittests/testcfg/ipc/MissionMessageTypes.h diff --git a/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h b/unittests/testcfg/objects/systemObjectList.h similarity index 100% rename from src/fsfw_tests/unit/testcfg/objects/systemObjectList.h rename to unittests/testcfg/objects/systemObjectList.h diff --git a/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp b/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp similarity index 100% rename from src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.cpp rename to unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp diff --git a/src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.h b/unittests/testcfg/pollingsequence/PollingSequenceFactory.h similarity index 100% rename from src/fsfw_tests/unit/testcfg/pollingsequence/PollingSequenceFactory.h rename to unittests/testcfg/pollingsequence/PollingSequenceFactory.h diff --git a/src/fsfw_tests/unit/testcfg/returnvalues/classIds.h b/unittests/testcfg/returnvalues/classIds.h similarity index 100% rename from src/fsfw_tests/unit/testcfg/returnvalues/classIds.h rename to unittests/testcfg/returnvalues/classIds.h diff --git a/src/fsfw_tests/unit/testcfg/tmtc/apid.h b/unittests/testcfg/tmtc/apid.h similarity index 100% rename from src/fsfw_tests/unit/testcfg/tmtc/apid.h rename to unittests/testcfg/tmtc/apid.h diff --git a/src/fsfw_tests/unit/testcfg/tmtc/pusIds.h b/unittests/testcfg/tmtc/pusIds.h similarity index 100% rename from src/fsfw_tests/unit/testcfg/tmtc/pusIds.h rename to unittests/testcfg/tmtc/pusIds.h diff --git a/src/fsfw_tests/unit/testtemplate/TestTemplate.cpp b/unittests/testtemplate/TestTemplate.cpp similarity index 100% rename from src/fsfw_tests/unit/testtemplate/TestTemplate.cpp rename to unittests/testtemplate/TestTemplate.cpp diff --git a/src/fsfw_tests/unit/timemanager/CMakeLists.txt b/unittests/timemanager/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/timemanager/CMakeLists.txt rename to unittests/timemanager/CMakeLists.txt diff --git a/src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp b/unittests/timemanager/TestCCSDSTime.cpp similarity index 100% rename from src/fsfw_tests/unit/timemanager/TestCCSDSTime.cpp rename to unittests/timemanager/TestCCSDSTime.cpp diff --git a/src/fsfw_tests/unit/timemanager/TestCountdown.cpp b/unittests/timemanager/TestCountdown.cpp similarity index 100% rename from src/fsfw_tests/unit/timemanager/TestCountdown.cpp rename to unittests/timemanager/TestCountdown.cpp diff --git a/src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt b/unittests/tmtcpacket/CMakeLists.txt similarity index 100% rename from src/fsfw_tests/unit/tmtcpacket/CMakeLists.txt rename to unittests/tmtcpacket/CMakeLists.txt diff --git a/src/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp b/unittests/tmtcpacket/PusTmTest.cpp similarity index 100% rename from src/fsfw_tests/unit/tmtcpacket/PusTmTest.cpp rename to unittests/tmtcpacket/PusTmTest.cpp diff --git a/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp similarity index 100% rename from src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp rename to unittests/tmtcpacket/testCcsds.cpp From fdf35232eeee6d0cfb527b66d01a85e97e949d1e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 11:47:00 +0200 Subject: [PATCH 041/532] some fixes --- CMakeLists.txt | 7 +++---- src/fsfw_tests/CMakeLists.txt | 4 +--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dcfa89ae..f38eacff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,10 +163,9 @@ if(FSFW_BUILD_UNITTESTS) list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2) endif() - set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg) - configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h) - configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in - tests/TestsConfig.h) + set(FSFW_CONFIG_PATH unittests/testcfg/) + configure_file(unittests/testcfg/FSFWConfig.h.in FSFWConfig.h) + configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h) project(${FSFW_TEST_TGT} CXX C) add_executable(${FSFW_TEST_TGT}) diff --git a/src/fsfw_tests/CMakeLists.txt b/src/fsfw_tests/CMakeLists.txt index f6e1b8ab..8e047e73 100644 --- a/src/fsfw_tests/CMakeLists.txt +++ b/src/fsfw_tests/CMakeLists.txt @@ -2,8 +2,6 @@ if(FSFW_ADD_INTERNAL_TESTS) add_subdirectory(internal) endif() -if(FSFW_BUILD_UNITTESTS) - add_subdirectory(unit) -else() +if(NOT FSFW_BUILD_UNITTESTS) add_subdirectory(integration) endif() From 78b09ed0c94f4a3517bfafa69e8cc7191736ae8c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 11:58:55 +0200 Subject: [PATCH 042/532] fixes includes --- CMakeLists.txt | 13 ++++++++----- scripts/helper.py | 4 ++-- src/fsfw_tests/CMakeLists.txt | 2 +- unittests/CMakeLists.txt | 2 ++ unittests/action/TestActionHelper.cpp | 2 +- unittests/action/TestActionHelper.h | 2 +- unittests/cfdp/testCfdp.cpp | 2 +- unittests/container/RingBufferTest.cpp | 2 +- unittests/container/TestArrayList.cpp | 2 +- unittests/container/TestDynamicFifo.cpp | 2 +- unittests/container/TestFifo.cpp | 2 +- unittests/container/TestFixedArrayList.cpp | 2 +- unittests/container/TestFixedMap.cpp | 2 +- unittests/container/TestFixedOrderedMultimap.cpp | 2 +- unittests/container/TestPlacementFactory.cpp | 2 +- unittests/datapoollocal/DataSetTest.cpp | 2 +- unittests/datapoollocal/LocalPoolManagerTest.cpp | 2 +- unittests/datapoollocal/LocalPoolVariableTest.cpp | 4 ++-- unittests/datapoollocal/LocalPoolVectorTest.cpp | 2 +- unittests/devicehandler/DeviceFdirMock.cpp | 2 +- unittests/devicehandler/TestDeviceHandlerBase.cpp | 10 +++++----- unittests/globalfunctions/testCRC.cpp | 2 +- unittests/globalfunctions/testDleEncoder.cpp | 2 +- unittests/globalfunctions/testTimevalOperations.cpp | 2 +- .../internalerror/TestInternalErrorReporter.cpp | 6 +++--- unittests/mocks/MessageQueueMockBase.h | 2 +- unittests/osal/TestClock.cpp | 2 +- unittests/osal/TestMessageQueue.cpp | 2 +- unittests/power/testPowerSwitcher.cpp | 2 +- unittests/serialize/TestSerialBufferAdapter.cpp | 2 +- unittests/serialize/TestSerialLinkedPacket.cpp | 2 +- unittests/serialize/TestSerialization.cpp | 2 +- unittests/storagemanager/TestNewAccessor.cpp | 2 +- unittests/storagemanager/TestPool.cpp | 2 +- unittests/testVersion.cpp | 2 +- unittests/timemanager/TestCCSDSTime.cpp | 4 ++-- unittests/timemanager/TestCountdown.cpp | 2 +- 37 files changed, 54 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f38eacff..ae1a621e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,11 +104,11 @@ if(FSFW_GENERATE_SECTIONS) option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) endif() -option(FSFW_BUILD_UNITTESTS +option(FSFW_BUILD_TESTS "Build unittest binary in addition to static library" OFF) option(FSFW_CICD_BUILD "Build for CI/CD. This can disable problematic test" OFF) option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF) -if(FSFW_BUILD_UNITTESTS) +if(FSFW_BUILD_TESTS) option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON) endif() @@ -140,7 +140,7 @@ if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) TRUE) endif() -if(FSFW_BUILD_UNITTESTS) +if(FSFW_BUILD_TESTS) message( STATUS "${MSG_PREFIX} Building the FSFW unittests in addition to the static library" @@ -163,7 +163,7 @@ if(FSFW_BUILD_UNITTESTS) list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2) endif() - set(FSFW_CONFIG_PATH unittests/testcfg/) + set(FSFW_CONFIG_PATH unittests/testcfg) configure_file(unittests/testcfg/FSFWConfig.h.in FSFWConfig.h) configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h) @@ -282,11 +282,14 @@ message( add_subdirectory(src) add_subdirectory(contrib) +if(FSFW_BUILD_TESTS) + add_subdirectory(unittests) +endif() if(FSFW_BUILD_DOCS) add_subdirectory(docs) endif() -if(FSFW_BUILD_UNITTESTS) +if(FSFW_BUILD_TESTS) if(FSFW_TESTS_GEN_COV) if(CMAKE_COMPILER_IS_GNUCXX) include(CodeCoverage) diff --git a/scripts/helper.py b/scripts/helper.py index 56cf352b..0ac616b6 100755 --- a/scripts/helper.py +++ b/scripts/helper.py @@ -165,10 +165,10 @@ def create_tests_build_cfg(args): os.mkdir(UNITTEST_FOLDER_NAME) os.chdir(UNITTEST_FOLDER_NAME) if args.windows: - cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON \ + cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON \ -DGCOVR_PATH="py -m gcovr" ..' else: - cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON ..' + cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON ..' cmd_runner(cmake_cmd) os.chdir("..") diff --git a/src/fsfw_tests/CMakeLists.txt b/src/fsfw_tests/CMakeLists.txt index 8e047e73..5e16e0a7 100644 --- a/src/fsfw_tests/CMakeLists.txt +++ b/src/fsfw_tests/CMakeLists.txt @@ -2,6 +2,6 @@ if(FSFW_ADD_INTERNAL_TESTS) add_subdirectory(internal) endif() -if(NOT FSFW_BUILD_UNITTESTS) +if(NOT FSFW_BUILD_TESTS) add_subdirectory(integration) endif() diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 49b1840f..f32c6e08 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -27,3 +27,5 @@ add_subdirectory(cfdp) add_subdirectory(hal) add_subdirectory(internalerror) add_subdirectory(devicehandler) + +target_include_directories(${FSFW_TEST_TGT} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index 923b7436..6461a195 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -6,7 +6,7 @@ #include #include -#include "fsfw_tests/unit/mocks/MessageQueueMockBase.h" +#include "mocks/MessageQueueMockBase.h" TEST_CASE("Action Helper", "[ActionHelper]") { ActionHelperOwnerMockBase testDhMock; diff --git a/unittests/action/TestActionHelper.h b/unittests/action/TestActionHelper.h index 243f030a..75a9f3fe 100644 --- a/unittests/action/TestActionHelper.h +++ b/unittests/action/TestActionHelper.h @@ -6,7 +6,7 @@ #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" class ActionHelperOwnerMockBase : public HasActionsIF { public: diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 19b1ec7f..6ca95fbc 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -9,7 +9,7 @@ #include "fsfw/cfdp/pdu/HeaderSerializer.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serialize/SerializeAdapter.h" -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("CFDP Base", "[CfdpBase]") { using namespace cfdp; diff --git a/unittests/container/RingBufferTest.cpp b/unittests/container/RingBufferTest.cpp index a83fa2ac..ff5db76b 100644 --- a/unittests/container/RingBufferTest.cpp +++ b/unittests/container/RingBufferTest.cpp @@ -3,7 +3,7 @@ #include #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("Ring Buffer Test", "[RingBufferTest]") { uint8_t testData[13] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; diff --git a/unittests/container/TestArrayList.cpp b/unittests/container/TestArrayList.cpp index 2c5a37d9..4daf59d4 100644 --- a/unittests/container/TestArrayList.cpp +++ b/unittests/container/TestArrayList.cpp @@ -3,7 +3,7 @@ #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" /** * @brief Array List test diff --git a/unittests/container/TestDynamicFifo.cpp b/unittests/container/TestDynamicFifo.cpp index 540ea31e..6769c247 100644 --- a/unittests/container/TestDynamicFifo.cpp +++ b/unittests/container/TestDynamicFifo.cpp @@ -4,7 +4,7 @@ #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { INFO("Dynamic Fifo Tests"); diff --git a/unittests/container/TestFifo.cpp b/unittests/container/TestFifo.cpp index a9eb7956..0b4b41af 100644 --- a/unittests/container/TestFifo.cpp +++ b/unittests/container/TestFifo.cpp @@ -4,7 +4,7 @@ #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("Static Fifo Tests", "[TestFifo]") { INFO("Fifo Tests"); diff --git a/unittests/container/TestFixedArrayList.cpp b/unittests/container/TestFixedArrayList.cpp index 42ae01d5..6beb8d5d 100644 --- a/unittests/container/TestFixedArrayList.cpp +++ b/unittests/container/TestFixedArrayList.cpp @@ -3,7 +3,7 @@ #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("FixedArrayList Tests", "[TestFixedArrayList]") { INFO("FixedArrayList Tests"); diff --git a/unittests/container/TestFixedMap.cpp b/unittests/container/TestFixedMap.cpp index 4c3cad1e..d3c65760 100644 --- a/unittests/container/TestFixedMap.cpp +++ b/unittests/container/TestFixedMap.cpp @@ -3,7 +3,7 @@ #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" template class FixedMap; diff --git a/unittests/container/TestFixedOrderedMultimap.cpp b/unittests/container/TestFixedOrderedMultimap.cpp index 7dd63b34..88b32694 100644 --- a/unittests/container/TestFixedOrderedMultimap.cpp +++ b/unittests/container/TestFixedOrderedMultimap.cpp @@ -3,7 +3,7 @@ #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { INFO("FixedOrderedMultimap Tests"); diff --git a/unittests/container/TestPlacementFactory.cpp b/unittests/container/TestPlacementFactory.cpp index 0140ce05..1333567e 100644 --- a/unittests/container/TestPlacementFactory.cpp +++ b/unittests/container/TestPlacementFactory.cpp @@ -5,7 +5,7 @@ #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("PlacementFactory Tests", "[TestPlacementFactory]") { INFO("PlacementFactory Tests"); diff --git a/unittests/datapoollocal/DataSetTest.cpp b/unittests/datapoollocal/DataSetTest.cpp index 902d59ef..c56ed768 100644 --- a/unittests/datapoollocal/DataSetTest.cpp +++ b/unittests/datapoollocal/DataSetTest.cpp @@ -9,7 +9,7 @@ #include #include "LocalPoolOwnerBase.h" -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" #include "tests/TestsConfig.h" TEST_CASE("DataSetTest", "[DataSetTest]") { diff --git a/unittests/datapoollocal/LocalPoolManagerTest.cpp b/unittests/datapoollocal/LocalPoolManagerTest.cpp index f2a5c18a..019c9b59 100644 --- a/unittests/datapoollocal/LocalPoolManagerTest.cpp +++ b/unittests/datapoollocal/LocalPoolManagerTest.cpp @@ -12,7 +12,7 @@ #include #include "LocalPoolOwnerBase.h" -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { LocalPoolOwnerBase* poolOwner = diff --git a/unittests/datapoollocal/LocalPoolVariableTest.cpp b/unittests/datapoollocal/LocalPoolVariableTest.cpp index 73d51d92..86bd6a1e 100644 --- a/unittests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittests/datapoollocal/LocalPoolVariableTest.cpp @@ -4,11 +4,11 @@ #include #include "LocalPoolOwnerBase.h" -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { - LocalPoolOwnerBase* poolOwner = + auto* poolOwner = ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner != nullptr); REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); diff --git a/unittests/datapoollocal/LocalPoolVectorTest.cpp b/unittests/datapoollocal/LocalPoolVectorTest.cpp index 5932db44..3a06c826 100644 --- a/unittests/datapoollocal/LocalPoolVectorTest.cpp +++ b/unittests/datapoollocal/LocalPoolVectorTest.cpp @@ -4,7 +4,7 @@ #include #include "LocalPoolOwnerBase.h" -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { diff --git a/unittests/devicehandler/DeviceFdirMock.cpp b/unittests/devicehandler/DeviceFdirMock.cpp index dfef7cd3..e3ac39ac 100644 --- a/unittests/devicehandler/DeviceFdirMock.cpp +++ b/unittests/devicehandler/DeviceFdirMock.cpp @@ -1,6 +1,6 @@ #include "DeviceFdirMock.h" -#include +#include "devicehandler/DeviceFdirMock.h" DeviceFdirMock::DeviceFdirMock(object_id_t owner, object_id_t parent) : DeviceHandlerFailureIsolation(owner, parent) {} diff --git a/unittests/devicehandler/TestDeviceHandlerBase.cpp b/unittests/devicehandler/TestDeviceHandlerBase.cpp index e82a39b7..328bc4dc 100644 --- a/unittests/devicehandler/TestDeviceHandlerBase.cpp +++ b/unittests/devicehandler/TestDeviceHandlerBase.cpp @@ -2,14 +2,14 @@ #include "ComIFMock.h" #include "DeviceFdirMock.h" -#include "fsfw_tests/unit/devicehandler/CookieIFMock.h" -#include "fsfw_tests/unit/devicehandler/DeviceHandlerCommander.h" -#include "fsfw_tests/unit/devicehandler/DeviceHandlerMock.h" -#include "fsfw_tests/unit/testcfg/objects/systemObjectList.h" +#include "devicehandler/CookieIFMock.h" +#include "DeviceHandlerCommander.h" +#include "DeviceHandlerMock.h" +#include "objects/systemObjectList.h" TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { // Will be deleted with DHB destructor - CookieIFMock* cookieIFMock = new CookieIFMock; + auto* cookieIFMock = new CookieIFMock; ComIFMock comIF(objects::COM_IF_MOCK); DeviceFdirMock deviceFdirMock(objects::DEVICE_HANDLER_MOCK, objects::NO_OBJECT); DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK, diff --git a/unittests/globalfunctions/testCRC.cpp b/unittests/globalfunctions/testCRC.cpp index b163ea1f..884bd281 100644 --- a/unittests/globalfunctions/testCRC.cpp +++ b/unittests/globalfunctions/testCRC.cpp @@ -2,7 +2,7 @@ #include "catch2/catch_test_macros.hpp" #include "fsfw/globalfunctions/CRC.h" -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("CRC", "[CRC]") { std::array testData = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; diff --git a/unittests/globalfunctions/testDleEncoder.cpp b/unittests/globalfunctions/testDleEncoder.cpp index 034cb3a0..1ccaddb5 100644 --- a/unittests/globalfunctions/testDleEncoder.cpp +++ b/unittests/globalfunctions/testDleEncoder.cpp @@ -2,7 +2,7 @@ #include "catch2/catch_test_macros.hpp" #include "fsfw/globalfunctions/DleEncoder.h" -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" const std::vector TEST_ARRAY_0 = {0, 0, 0, 0, 0}; const std::vector TEST_ARRAY_1 = {0, DleEncoder::DLE_CHAR, 5}; diff --git a/unittests/globalfunctions/testTimevalOperations.cpp b/unittests/globalfunctions/testTimevalOperations.cpp index 347d2204..155e6b15 100644 --- a/unittests/globalfunctions/testTimevalOperations.cpp +++ b/unittests/globalfunctions/testTimevalOperations.cpp @@ -3,7 +3,7 @@ #include #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("TimevalTest", "[timevalOperations]") { SECTION("Comparison") { diff --git a/unittests/internalerror/TestInternalErrorReporter.cpp b/unittests/internalerror/TestInternalErrorReporter.cpp index a993fff6..b52c5336 100644 --- a/unittests/internalerror/TestInternalErrorReporter.cpp +++ b/unittests/internalerror/TestInternalErrorReporter.cpp @@ -12,8 +12,8 @@ #include "fsfw/ipc/CommandMessage.h" #include "fsfw/ipc/MessageQueueMessage.h" #include "fsfw/objectmanager/frameworkObjects.h" -#include "fsfw_tests/unit/CatchDefinitions.h" -#include "fsfw_tests/unit/mocks/PeriodicTaskIFMock.h" +#include "CatchDefinitions.h" +#include "mocks/PeriodicTaskIFMock.h" TEST_CASE("Internal Error Reporter", "[TestInternalError]") { PeriodicTaskMock task(10, nullptr); @@ -21,7 +21,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { if (manager == nullptr) { FAIL(); } - InternalErrorReporter* internalErrorReporter = dynamic_cast( + auto* internalErrorReporter = dynamic_cast( ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER)); if (internalErrorReporter == nullptr) { FAIL(); diff --git a/unittests/mocks/MessageQueueMockBase.h b/unittests/mocks/MessageQueueMockBase.h index 4236593e..60a942d9 100644 --- a/unittests/mocks/MessageQueueMockBase.h +++ b/unittests/mocks/MessageQueueMockBase.h @@ -8,7 +8,7 @@ #include "fsfw/ipc/MessageQueueBase.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/MessageQueueMessage.h" -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" class MessageQueueMockBase : public MessageQueueBase { public: diff --git a/unittests/osal/TestClock.cpp b/unittests/osal/TestClock.cpp index 38ec3915..9979b28c 100644 --- a/unittests/osal/TestClock.cpp +++ b/unittests/osal/TestClock.cpp @@ -5,7 +5,7 @@ #include #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") { SECTION("Test getClock") { diff --git a/unittests/osal/TestMessageQueue.cpp b/unittests/osal/TestMessageQueue.cpp index 11c0739b..df15b33d 100644 --- a/unittests/osal/TestMessageQueue.cpp +++ b/unittests/osal/TestMessageQueue.cpp @@ -4,7 +4,7 @@ #include #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("MessageQueue Basic Test", "[TestMq]") { MessageQueueIF* testSenderMq = QueueFactory::instance()->createMessageQueue(1); diff --git a/unittests/power/testPowerSwitcher.cpp b/unittests/power/testPowerSwitcher.cpp index 941055ac..cf2f2148 100644 --- a/unittests/power/testPowerSwitcher.cpp +++ b/unittests/power/testPowerSwitcher.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include "mocks/PowerSwitcherMock.h" #include diff --git a/unittests/serialize/TestSerialBufferAdapter.cpp b/unittests/serialize/TestSerialBufferAdapter.cpp index 9b30427f..2aa76ec8 100644 --- a/unittests/serialize/TestSerialBufferAdapter.cpp +++ b/unittests/serialize/TestSerialBufferAdapter.cpp @@ -3,7 +3,7 @@ #include #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" static bool test_value_bool = true; static uint16_t tv_uint16{283}; diff --git a/unittests/serialize/TestSerialLinkedPacket.cpp b/unittests/serialize/TestSerialLinkedPacket.cpp index e3bdf882..2d6e476f 100644 --- a/unittests/serialize/TestSerialLinkedPacket.cpp +++ b/unittests/serialize/TestSerialLinkedPacket.cpp @@ -5,7 +5,7 @@ #include #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("Serial Linked Packet", "[SerLinkPacket]") { // perform set-up here diff --git a/unittests/serialize/TestSerialization.cpp b/unittests/serialize/TestSerialization.cpp index 52cb70f6..a3340a7d 100644 --- a/unittests/serialize/TestSerialization.cpp +++ b/unittests/serialize/TestSerialization.cpp @@ -5,7 +5,7 @@ #include #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" static bool testBool = true; static uint8_t tvUint8{5}; diff --git a/unittests/storagemanager/TestNewAccessor.cpp b/unittests/storagemanager/TestNewAccessor.cpp index 7b90c86e..2cc2e469 100644 --- a/unittests/storagemanager/TestNewAccessor.cpp +++ b/unittests/storagemanager/TestNewAccessor.cpp @@ -4,7 +4,7 @@ #include #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("New Accessor", "[NewAccessor]") { LocalPool::LocalPoolConfig poolCfg = {{1, 10}}; diff --git a/unittests/storagemanager/TestPool.cpp b/unittests/storagemanager/TestPool.cpp index 51130047..e37c6934 100644 --- a/unittests/storagemanager/TestPool.cpp +++ b/unittests/storagemanager/TestPool.cpp @@ -5,7 +5,7 @@ #include #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { LocalPool::LocalPoolConfig config = {{1, 10}}; diff --git a/unittests/testVersion.cpp b/unittests/testVersion.cpp index 662b1290..e0b9897b 100644 --- a/unittests/testVersion.cpp +++ b/unittests/testVersion.cpp @@ -4,7 +4,7 @@ #include #include "fsfw/serviceinterface.h" -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("Version API Tests", "[TestVersionAPI]") { // Check that major version is non-zero diff --git a/unittests/timemanager/TestCCSDSTime.cpp b/unittests/timemanager/TestCCSDSTime.cpp index e96ddfc9..9c457dda 100644 --- a/unittests/timemanager/TestCCSDSTime.cpp +++ b/unittests/timemanager/TestCCSDSTime.cpp @@ -5,11 +5,11 @@ #include #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { INFO("CCSDSTime Tests"); - CCSDSTime::Ccs_mseconds cssMilliSecconds; + CCSDSTime::Ccs_mseconds cssMilliSecconds{}; Clock::TimeOfDay_t time; time.year = 2020; time.month = 2; diff --git a/unittests/timemanager/TestCountdown.cpp b/unittests/timemanager/TestCountdown.cpp index bc39b02e..d0af659d 100644 --- a/unittests/timemanager/TestCountdown.cpp +++ b/unittests/timemanager/TestCountdown.cpp @@ -2,7 +2,7 @@ #include -#include "fsfw_tests/unit/CatchDefinitions.h" +#include "CatchDefinitions.h" TEST_CASE("Countdown Tests", "[TestCountdown]") { INFO("Countdown Tests"); From 3c72a42ce145cb2b632af83df9975c2625c60556 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 13:51:02 +0200 Subject: [PATCH 043/532] added basic sp creator test --- src/fsfw/tmtcpacket/SpacePacketCreator.cpp | 6 +++--- tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp index 0263dad3..b02bae80 100644 --- a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp @@ -29,9 +29,9 @@ SpacePacketCreator::SpacePacketCreator(ccsds::PacketType packetType, bool secHea dataLen = dataLen_; } -uint16_t SpacePacketCreator::getPacketId() const { return 0; } -uint16_t SpacePacketCreator::getPacketSeqCtrl() const { return 0; } -uint16_t SpacePacketCreator::getPacketDataLen() const { return 0; } +uint16_t SpacePacketCreator::getPacketId() const { return packetId; } +uint16_t SpacePacketCreator::getPacketSeqCtrl() const { return packetSeqCtrl; } +uint16_t SpacePacketCreator::getPacketDataLen() const { return dataLen; } ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp index 0fd2a19c..0925cdc7 100644 --- a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp +++ b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp @@ -14,7 +14,13 @@ TEST_CASE("CCSDS Test", "[ccsds]") { SECTION("Header Creator Tests") { SpacePacketCreator base = SpacePacketCreator( - ccsds::PacketType::TM, true, 0x22, - ccsds::SequenceFlags::CONTINUATION, 12, 0x42); + ccsds::PacketType::TC, true, 0x02, + ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); + REQUIRE(base.getApid() == 0x02); + REQUIRE(base.getSequenceFlags() == ccsds::SequenceFlags::FIRST_SEGMENT); + REQUIRE(base.getVersion() == 0b000); + REQUIRE(base.getSequenceCount() == 0x34); + REQUIRE(base.getPacketDataLen() == 0x16); + REQUIRE(base.getPacketType() == ccsds::PacketType::TC); } } From 7e2fdc06cd53d31a946d0f6c4bf854a15a52bad8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 14:05:43 +0200 Subject: [PATCH 044/532] hmm this is problematic --- src/fsfw/tmtcpacket/SpacePacketCreator.cpp | 4 +-- src/fsfw/tmtcpacket/SpacePacketCreator.h | 3 ++- .../fsfw_tests/unit/tmtcpacket/testCcsds.cpp | 25 ++++++++++++++++--- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp index b02bae80..06df33c0 100644 --- a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp @@ -23,8 +23,7 @@ SpacePacketCreator::SpacePacketCreator(ccsds::PacketType packetType, bool secHea return; } version = version_; - packetId = - (version_ << 13) | (static_cast(packetType) << 12) | (secHeaderFlag << 11) | apid; + packetId = (static_cast(packetType) << 12) | (static_cast(secHeaderFlag) << 11) | apid; packetSeqCtrl = static_cast(seqFlags) << 14 | seqCount; dataLen = dataLen_; } @@ -53,3 +52,4 @@ ReturnValue_t SpacePacketCreator::deSerialize(const uint8_t **buffer, size_t *si SerializeIF::Endianness streamEndianness) { return HasReturnvaluesIF::RETURN_FAILED; } +bool SpacePacketCreator::isValid() const { return valid; } diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.h b/src/fsfw/tmtcpacket/SpacePacketCreator.h index 79ea47dc..f99cb9dd 100644 --- a/src/fsfw/tmtcpacket/SpacePacketCreator.h +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.h @@ -11,7 +11,7 @@ class SpacePacketCreator : public SerializeIF, public SpacePacketIF { uint8_t version = 0); SpacePacketCreator(uint16_t packetId, uint16_t packetSeqCtrl, uint16_t dataLen, uint8_t version = 0); - bool valid; + [[nodiscard]] bool isValid() const; [[nodiscard]] uint16_t getPacketId() const override; [[nodiscard]] uint16_t getPacketSeqCtrl() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; @@ -22,6 +22,7 @@ class SpacePacketCreator : public SerializeIF, public SpacePacketIF { Endianness streamEndianness) override; private: + bool valid; uint16_t packetId; uint16_t packetSeqCtrl; uint16_t dataLen; diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp index 0925cdc7..93cea57a 100644 --- a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp +++ b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp @@ -1,9 +1,14 @@ +#include #include #include "fsfw/tmtcpacket/SpacePacketCreator.h" #include "fsfw/tmtcpacket/SpacePacketReader.h" TEST_CASE("CCSDS Test", "[ccsds]") { + SpacePacketCreator base = SpacePacketCreator( + ccsds::PacketType::TC, true, 0x02, + ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); + SECTION("Constexpr Helpers") { REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822); REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822); @@ -12,15 +17,27 @@ TEST_CASE("CCSDS Test", "[ccsds]") { REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); } - SECTION("Header Creator Tests") { - SpacePacketCreator base = SpacePacketCreator( - ccsds::PacketType::TC, true, 0x02, - ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); + SECTION("Basic Test") { + REQUIRE(base.isValid()); REQUIRE(base.getApid() == 0x02); REQUIRE(base.getSequenceFlags() == ccsds::SequenceFlags::FIRST_SEGMENT); REQUIRE(base.getVersion() == 0b000); REQUIRE(base.getSequenceCount() == 0x34); REQUIRE(base.getPacketDataLen() == 0x16); REQUIRE(base.getPacketType() == ccsds::PacketType::TC); + REQUIRE(base.getPacketId() == 0x1802); + } + + SECTION("Raw Output") { + std::array buf {}; + uint8_t* bufPtr = buf.data(); + size_t serLen = 0; + base.serialize(&bufPtr, &serLen, buf.size(), SerializeIF::Endianness::MACHINE); + REQUIRE(buf[0] == 0x18); + REQUIRE(buf[1] == 0x02); + REQUIRE(buf[2] == 0x40); + REQUIRE(buf[3] == 0x34); + REQUIRE(buf[4] == 0x00); + REQUIRE(buf[5] == 0x16); } } From 6e5239e9a04d1dd13f768d91e74638af69b3883c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 14:36:40 +0200 Subject: [PATCH 045/532] update jenkinsfile --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 7101958e..c5dcbe02 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { stage('Configure') { steps { dir(BUILDDIR) { - sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_UNITTESTS=ON -DFSFW_CICD_BUILD=ON ..' + sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..' } } } From f6ede7cd3e656ee51e73efab12e3e74937b51905 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 14:46:36 +0200 Subject: [PATCH 046/532] bump version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9e3e471..bfdf878e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ list(APPEND CMAKE_MODULE_PATH # Version file handling # # ############################################################################## -set(FSFW_VERSION_IF_GIT_FAILS 4) +set(FSFW_VERSION_IF_GIT_FAILS 5) set(FSFW_SUBVERSION_IF_GIT_FAILS 0) set(FSFW_REVISION_IF_GIT_FAILS 0) From 8b6dd3f86822a0df7de896b180c9cca891696bad Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 14:49:27 +0200 Subject: [PATCH 047/532] add date to changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 394f1e45..80fa81aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] -# [v5.0.0] +# [v5.0.0] 18.07.2022 ## Changes From e4d7182d93b8c5b12c3a5d70123bb49b28d94206 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 14:58:47 +0200 Subject: [PATCH 048/532] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 394f1e45..3854dc79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). creation call. It allows passing context information and an arbitrary user argument into the message queue. Also streamlined and simplified `MessageQueue` implementation for all OSALs PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/583 +- Internal API change: Moved the `fsfw_hal` to the `src` folder and integration and internal + tests part of `fsfw_tests` to `src`. Unittests are now in a deciated folder called `unittests` + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/653 ### Task Module Refactoring From 428018e4f19852fac3e92fa4360d19c79936828f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 14:58:47 +0200 Subject: [PATCH 049/532] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 394f1e45..3854dc79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). creation call. It allows passing context information and an arbitrary user argument into the message queue. Also streamlined and simplified `MessageQueue` implementation for all OSALs PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/583 +- Internal API change: Moved the `fsfw_hal` to the `src` folder and integration and internal + tests part of `fsfw_tests` to `src`. Unittests are now in a deciated folder called `unittests` + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/653 ### Task Module Refactoring From 91067cde981bfa47cce8ed9138a5fbd6e047bb3f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 15:00:40 +0200 Subject: [PATCH 050/532] typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3854dc79..a3f94255 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). the message queue. Also streamlined and simplified `MessageQueue` implementation for all OSALs PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/583 - Internal API change: Moved the `fsfw_hal` to the `src` folder and integration and internal - tests part of `fsfw_tests` to `src`. Unittests are now in a deciated folder called `unittests` + tests part of `fsfw_tests` to `src`. Unittests are now in a dedicated folder called `unittests` PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/653 ### Task Module Refactoring From ddf38b65c34210a6add30f2b62330ef4aa5735e2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 16:07:26 +0200 Subject: [PATCH 051/532] apply auto-formatter --- CMakeLists.txt | 4 +- scripts/auto-formatter.sh | 3 +- src/fsfw/tmtcpacket/SpacePacketCreator.cpp | 63 +++++++++----- src/fsfw/tmtcpacket/SpacePacketCreator.h | 60 ++++++++++++-- src/fsfw_hal/CMakeLists.txt | 4 +- src/fsfw_hal/common/gpio/CMakeLists.txt | 4 +- src/fsfw_hal/devicehandlers/CMakeLists.txt | 8 +- src/fsfw_hal/linux/CMakeLists.txt | 30 +++---- src/fsfw_hal/linux/gpio/CMakeLists.txt | 18 ++-- src/fsfw_hal/linux/i2c/CMakeLists.txt | 9 +- src/fsfw_hal/linux/rpi/CMakeLists.txt | 4 +- src/fsfw_hal/linux/spi/CMakeLists.txt | 9 +- src/fsfw_hal/linux/uart/CMakeLists.txt | 5 +- src/fsfw_hal/linux/uio/CMakeLists.txt | 4 +- src/fsfw_hal/stm32h7/CMakeLists.txt | 4 +- .../stm32h7/devicetest/CMakeLists.txt | 4 +- src/fsfw_hal/stm32h7/gpio/CMakeLists.txt | 4 +- src/fsfw_hal/stm32h7/i2c/CMakeLists.txt | 3 +- src/fsfw_hal/stm32h7/spi/CMakeLists.txt | 18 ++-- src/fsfw_hal/stm32h7/uart/CMakeLists.txt | 3 +- src/fsfw_tests/CMakeLists.txt | 4 +- .../integration/assemblies/CMakeLists.txt | 4 +- .../integration/controller/CMakeLists.txt | 4 +- .../integration/devices/CMakeLists.txt | 7 +- .../integration/task/CMakeLists.txt | 4 +- src/fsfw_tests/internal/CMakeLists.txt | 8 +- .../internal/globalfunctions/CMakeLists.txt | 4 +- src/fsfw_tests/internal/osal/CMakeLists.txt | 7 +- .../internal/serialize/CMakeLists.txt | 4 +- unittests/tmtcpacket/CMakeLists.txt | 2 +- unittests/tmtcpacket/testCcsds.cpp | 43 ---------- unittests/tmtcpacket/testCcsdsReader.cpp | 82 +++++++++++++++++++ 32 files changed, 242 insertions(+), 192 deletions(-) delete mode 100644 unittests/tmtcpacket/testCcsds.cpp create mode 100644 unittests/tmtcpacket/testCcsdsReader.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ebdf809b..98a84cb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,8 +104,8 @@ if(FSFW_GENERATE_SECTIONS) option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) endif() -option(FSFW_BUILD_TESTS - "Build unittest binary in addition to static library" OFF) +option(FSFW_BUILD_TESTS "Build unittest binary in addition to static library" + OFF) option(FSFW_CICD_BUILD "Build for CI/CD. This can disable problematic test" OFF) option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF) if(FSFW_BUILD_TESTS) diff --git a/scripts/auto-formatter.sh b/scripts/auto-formatter.sh index 405d1268..c0ae7099 100755 --- a/scripts/auto-formatter.sh +++ b/scripts/auto-formatter.sh @@ -16,8 +16,7 @@ cpp_format="clang-format" file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp" if command -v ${cpp_format} &> /dev/null; then find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i - find ./hal ${file_selectors} | xargs ${cpp_format} --style=file -i - find ./tests ${file_selectors} | xargs ${cpp_format} --style=file -i + find ./unittests ${file_selectors} | xargs ${cpp_format} --style=file -i else echo "No ${cpp_format} tool found, not formatting C++/C files" fi diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp index 06df33c0..acc2fea2 100644 --- a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp @@ -2,54 +2,75 @@ #include "fsfw/serialize/SerializeAdapter.h" -SpacePacketCreator::SpacePacketCreator(uint16_t packetId_, uint16_t packetSeqCtrl_, - uint16_t dataLen_, uint8_t version_) { - packetId = packetId_; - packetSeqCtrl = packetSeqCtrl_; +SpacePacketCreator::SpacePacketCreator(PacketId packetId_, PacketSeqCtrl psc_, uint16_t dataLen_, + uint8_t version_) + : packetId(packetId_), packetSeqCtrl(psc_) { dataLen = dataLen_; version = version_; - valid = true; + checkFieldValidity(); } SpacePacketCreator::SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid, ccsds::SequenceFlags seqFlags, - uint16_t seqCount, uint16_t dataLen_, uint8_t version_) { - if (apid > ccsds::LIMIT_APID) { - valid = false; - return; - } - if (seqCount > ccsds::LIMIT_SEQUENCE_COUNT) { - valid = false; - return; - } + uint16_t seqCount, uint16_t dataLen_, uint8_t version_) + : SpacePacketCreator(PacketId(packetType, secHeaderFlag, apid), + PacketSeqCtrl(seqFlags, seqCount), dataLen_, version_) { version = version_; - packetId = (static_cast(packetType) << 12) | (static_cast(secHeaderFlag) << 11) | apid; - packetSeqCtrl = static_cast(seqFlags) << 14 | seqCount; dataLen = dataLen_; } -uint16_t SpacePacketCreator::getPacketId() const { return packetId; } -uint16_t SpacePacketCreator::getPacketSeqCtrl() const { return packetSeqCtrl; } +uint16_t SpacePacketCreator::getPacketId() const { return packetId.raw(); } +uint16_t SpacePacketCreator::getPacketSeqCtrl() const { return packetSeqCtrl.raw(); } uint16_t SpacePacketCreator::getPacketDataLen() const { return dataLen; } ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { - uint16_t packetIdAndVersion = version << 13 | packetId; + if (not isValid()) { + return HasReturnvaluesIF::RETURN_FAILED; + } + uint16_t packetIdAndVersion = (static_cast(version) << 13) | packetId.raw(); ReturnValue_t result = SerializeAdapter::serialize(&packetIdAndVersion, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - result = SerializeAdapter::serialize(&packetSeqCtrl, buffer, size, maxSize, streamEndianness); + uint16_t pscRaw = packetSeqCtrl.raw(); + result = SerializeAdapter::serialize(&pscRaw, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } return SerializeAdapter::serialize(&dataLen, buffer, size, maxSize, streamEndianness); } -size_t SpacePacketCreator::getSerializedSize() const { return 0; } +size_t SpacePacketCreator::getSerializedSize() const { return 6; } + ReturnValue_t SpacePacketCreator::deSerialize(const uint8_t **buffer, size_t *size, SerializeIF::Endianness streamEndianness) { return HasReturnvaluesIF::RETURN_FAILED; } bool SpacePacketCreator::isValid() const { return valid; } + +ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize) const { + return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); +} +void SpacePacketCreator::setApid(uint16_t apid) { + if (apid < ccsds::LIMIT_APID) { + packetId.apid = apid; + } + checkFieldValidity(); +} + +void SpacePacketCreator::setSeqCount(uint16_t seqCount) { + if (seqCount < ccsds::LIMIT_SEQUENCE_COUNT) { + packetSeqCtrl.seqCount = seqCount; + } + checkFieldValidity(); +} +void SpacePacketCreator::setSeqFlags(ccsds::SequenceFlags flags) { packetSeqCtrl.seqFlags = flags; } +void SpacePacketCreator::setDataLen(uint16_t dataLen_) { dataLen = dataLen_; } +void SpacePacketCreator::checkFieldValidity() { + valid = true; + if (packetId.apid > ccsds::LIMIT_APID or packetSeqCtrl.seqCount > ccsds::LIMIT_SEQUENCE_COUNT) { + valid = false; + } +} diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.h b/src/fsfw/tmtcpacket/SpacePacketCreator.h index f99cb9dd..9a9a0e2d 100644 --- a/src/fsfw/tmtcpacket/SpacePacketCreator.h +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.h @@ -4,27 +4,77 @@ #include "SpacePacketIF.h" #include "fsfw/serialize/SerializeIF.h" +struct PacketId { + public: + /** + * Simple wrapper for Space Packet IDs. Does not check the APID for validity + * @param packetType_ + * @param secHeaderFlag_ + * @param apid_ + */ + PacketId(ccsds::PacketType packetType_, bool secHeaderFlag_, uint16_t apid_) + : packetType(packetType_), secHeaderFlag(secHeaderFlag_), apid(apid_) {} + + /** + * NOTE: If the APID has an invalid value, the invalid bits will be cut off + * @return + */ + [[nodiscard]] uint16_t raw() const { + return (static_cast(packetType) << 12) | + (static_cast(secHeaderFlag) << 11) | (apid & 0x7ff); + } + + ccsds::PacketType packetType; + bool secHeaderFlag; + uint16_t apid; +}; + +struct PacketSeqCtrl { + public: + PacketSeqCtrl(ccsds::SequenceFlags seqFlags, uint16_t seqCount) + : seqFlags(seqFlags), seqCount(seqCount) {} + + /** + * NOTE: If the sequence control has an invalid value, the invalid bits will be cut off + * @return + */ + [[nodiscard]] uint16_t raw() const { + return (static_cast(seqFlags) << 14) | (seqCount & 0x3FFF); + } + ccsds::SequenceFlags seqFlags; + uint16_t seqCount; +}; + class SpacePacketCreator : public SerializeIF, public SpacePacketIF { public: SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid, ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen, uint8_t version = 0); - SpacePacketCreator(uint16_t packetId, uint16_t packetSeqCtrl, uint16_t dataLen, - uint8_t version = 0); + SpacePacketCreator(PacketId packetId, PacketSeqCtrl psc, uint16_t dataLen, uint8_t version = 0); [[nodiscard]] bool isValid() const; [[nodiscard]] uint16_t getPacketId() const override; [[nodiscard]] uint16_t getPacketSeqCtrl() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; + + void setApid(uint16_t apid); + void setSeqCount(uint16_t seqCount); + void setSeqFlags(ccsds::SequenceFlags flags); + void setDataLen(uint16_t dataLen); + + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const; ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; + [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; private: - bool valid; - uint16_t packetId; - uint16_t packetSeqCtrl; + void checkFieldValidity(); + + bool valid{}; + PacketId packetId; + PacketSeqCtrl packetSeqCtrl; uint16_t dataLen; uint8_t version; }; diff --git a/src/fsfw_hal/CMakeLists.txt b/src/fsfw_hal/CMakeLists.txt index b7559d4b..057ab3a6 100644 --- a/src/fsfw_hal/CMakeLists.txt +++ b/src/fsfw_hal/CMakeLists.txt @@ -2,9 +2,9 @@ add_subdirectory(devicehandlers) add_subdirectory(common) if(UNIX) - add_subdirectory(linux) + add_subdirectory(linux) endif() if(FSFW_HAL_ADD_STM32H7) - add_subdirectory(stm32h7) + add_subdirectory(stm32h7) endif() diff --git a/src/fsfw_hal/common/gpio/CMakeLists.txt b/src/fsfw_hal/common/gpio/CMakeLists.txt index 098c05fa..5c81d9cc 100644 --- a/src/fsfw_hal/common/gpio/CMakeLists.txt +++ b/src/fsfw_hal/common/gpio/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GpioCookie.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE GpioCookie.cpp) diff --git a/src/fsfw_hal/devicehandlers/CMakeLists.txt b/src/fsfw_hal/devicehandlers/CMakeLists.txt index 94e67c72..17139416 100644 --- a/src/fsfw_hal/devicehandlers/CMakeLists.txt +++ b/src/fsfw_hal/devicehandlers/CMakeLists.txt @@ -1,5 +1,3 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GyroL3GD20Handler.cpp - MgmRM3100Handler.cpp - MgmLIS3MDLHandler.cpp -) +target_sources( + ${LIB_FSFW_NAME} PRIVATE GyroL3GD20Handler.cpp MgmRM3100Handler.cpp + MgmLIS3MDLHandler.cpp) diff --git a/src/fsfw_hal/linux/CMakeLists.txt b/src/fsfw_hal/linux/CMakeLists.txt index f6d1a460..ffa5f5ee 100644 --- a/src/fsfw_hal/linux/CMakeLists.txt +++ b/src/fsfw_hal/linux/CMakeLists.txt @@ -1,25 +1,21 @@ if(FSFW_HAL_ADD_RASPBERRY_PI) - add_subdirectory(rpi) + add_subdirectory(rpi) endif() -target_sources(${LIB_FSFW_NAME} PRIVATE - UnixFileGuard.cpp - CommandExecutor.cpp - utility.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE UnixFileGuard.cpp CommandExecutor.cpp + utility.cpp) if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS) -if(FSFW_HAL_LINUX_ADD_LIBGPIOD) - add_subdirectory(gpio) -endif() - add_subdirectory(uart) - # Adding those does not really make sense on Apple systems which - # are generally host systems. It won't even compile as the headers - # are missing - if(NOT APPLE) - add_subdirectory(i2c) - add_subdirectory(spi) - endif() + if(FSFW_HAL_LINUX_ADD_LIBGPIOD) + add_subdirectory(gpio) + endif() + add_subdirectory(uart) + # Adding those does not really make sense on Apple systems which are generally + # host systems. It won't even compile as the headers are missing + if(NOT APPLE) + add_subdirectory(i2c) + add_subdirectory(spi) + endif() endif() add_subdirectory(uio) diff --git a/src/fsfw_hal/linux/gpio/CMakeLists.txt b/src/fsfw_hal/linux/gpio/CMakeLists.txt index b1609850..f6e7f2b0 100644 --- a/src/fsfw_hal/linux/gpio/CMakeLists.txt +++ b/src/fsfw_hal/linux/gpio/CMakeLists.txt @@ -1,16 +1,12 @@ -# This abstraction layer requires the gpiod library. You can install this library -# with "sudo apt-get install -y libgpiod-dev". If you are cross-compiling, you need -# to install the package before syncing the sysroot to your host computer. +# This abstraction layer requires the gpiod library. You can install this +# library with "sudo apt-get install -y libgpiod-dev". If you are +# cross-compiling, you need to install the package before syncing the sysroot to +# your host computer. find_library(LIB_GPIO gpiod) if(${LIB_GPIO} MATCHES LIB_GPIO-NOTFOUND) - message(STATUS "gpiod library not found, not linking against it") + message(STATUS "gpiod library not found, not linking against it") else() - target_sources(${LIB_FSFW_NAME} PRIVATE - LinuxLibgpioIF.cpp - ) - target_link_libraries(${LIB_FSFW_NAME} PRIVATE - ${LIB_GPIO} - ) + target_sources(${LIB_FSFW_NAME} PRIVATE LinuxLibgpioIF.cpp) + target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${LIB_GPIO}) endif() - diff --git a/src/fsfw_hal/linux/i2c/CMakeLists.txt b/src/fsfw_hal/linux/i2c/CMakeLists.txt index 3eb0882c..b94bdc99 100644 --- a/src/fsfw_hal/linux/i2c/CMakeLists.txt +++ b/src/fsfw_hal/linux/i2c/CMakeLists.txt @@ -1,8 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - I2cComIF.cpp - I2cCookie.cpp -) - - - - +target_sources(${LIB_FSFW_NAME} PUBLIC I2cComIF.cpp I2cCookie.cpp) diff --git a/src/fsfw_hal/linux/rpi/CMakeLists.txt b/src/fsfw_hal/linux/rpi/CMakeLists.txt index 47be218c..3a865037 100644 --- a/src/fsfw_hal/linux/rpi/CMakeLists.txt +++ b/src/fsfw_hal/linux/rpi/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GpioRPi.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE GpioRPi.cpp) diff --git a/src/fsfw_hal/linux/spi/CMakeLists.txt b/src/fsfw_hal/linux/spi/CMakeLists.txt index 404e1f47..f242bb3b 100644 --- a/src/fsfw_hal/linux/spi/CMakeLists.txt +++ b/src/fsfw_hal/linux/spi/CMakeLists.txt @@ -1,8 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - SpiComIF.cpp - SpiCookie.cpp -) - - - - +target_sources(${LIB_FSFW_NAME} PUBLIC SpiComIF.cpp SpiCookie.cpp) diff --git a/src/fsfw_hal/linux/uart/CMakeLists.txt b/src/fsfw_hal/linux/uart/CMakeLists.txt index 21ed0278..9cad62a4 100644 --- a/src/fsfw_hal/linux/uart/CMakeLists.txt +++ b/src/fsfw_hal/linux/uart/CMakeLists.txt @@ -1,4 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - UartComIF.cpp - UartCookie.cpp -) +target_sources(${LIB_FSFW_NAME} PUBLIC UartComIF.cpp UartCookie.cpp) diff --git a/src/fsfw_hal/linux/uio/CMakeLists.txt b/src/fsfw_hal/linux/uio/CMakeLists.txt index e98a0865..e3498246 100644 --- a/src/fsfw_hal/linux/uio/CMakeLists.txt +++ b/src/fsfw_hal/linux/uio/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - UioMapper.cpp -) +target_sources(${LIB_FSFW_NAME} PUBLIC UioMapper.cpp) diff --git a/src/fsfw_hal/stm32h7/CMakeLists.txt b/src/fsfw_hal/stm32h7/CMakeLists.txt index bae3b1ac..e8843ed3 100644 --- a/src/fsfw_hal/stm32h7/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/CMakeLists.txt @@ -2,6 +2,4 @@ add_subdirectory(spi) add_subdirectory(gpio) add_subdirectory(devicetest) -target_sources(${LIB_FSFW_NAME} PRIVATE - dma.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE dma.cpp) diff --git a/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt b/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt index 7bd4c3a9..8e789ddb 100644 --- a/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GyroL3GD20H.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE GyroL3GD20H.cpp) diff --git a/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt b/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt index 35245b25..54d76b2d 100644 --- a/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - gpio.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE gpio.cpp) diff --git a/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt b/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt index 5ecb0990..a0d48465 100644 --- a/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt @@ -1,2 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE -) +target_sources(${LIB_FSFW_NAME} PRIVATE) diff --git a/src/fsfw_hal/stm32h7/spi/CMakeLists.txt b/src/fsfw_hal/stm32h7/spi/CMakeLists.txt index aa5541bc..9a98f502 100644 --- a/src/fsfw_hal/stm32h7/spi/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/spi/CMakeLists.txt @@ -1,9 +1,9 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - spiCore.cpp - spiDefinitions.cpp - spiInterrupts.cpp - mspInit.cpp - SpiCookie.cpp - SpiComIF.cpp - stm32h743zi.cpp -) +target_sources( + ${LIB_FSFW_NAME} + PRIVATE spiCore.cpp + spiDefinitions.cpp + spiInterrupts.cpp + mspInit.cpp + SpiCookie.cpp + SpiComIF.cpp + stm32h743zi.cpp) diff --git a/src/fsfw_hal/stm32h7/uart/CMakeLists.txt b/src/fsfw_hal/stm32h7/uart/CMakeLists.txt index 5ecb0990..a0d48465 100644 --- a/src/fsfw_hal/stm32h7/uart/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/uart/CMakeLists.txt @@ -1,2 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE -) +target_sources(${LIB_FSFW_NAME} PRIVATE) diff --git a/src/fsfw_tests/CMakeLists.txt b/src/fsfw_tests/CMakeLists.txt index 5e16e0a7..d161699a 100644 --- a/src/fsfw_tests/CMakeLists.txt +++ b/src/fsfw_tests/CMakeLists.txt @@ -1,7 +1,7 @@ if(FSFW_ADD_INTERNAL_TESTS) - add_subdirectory(internal) + add_subdirectory(internal) endif() if(NOT FSFW_BUILD_TESTS) - add_subdirectory(integration) + add_subdirectory(integration) endif() diff --git a/src/fsfw_tests/integration/assemblies/CMakeLists.txt b/src/fsfw_tests/integration/assemblies/CMakeLists.txt index 22c06600..63a6447a 100644 --- a/src/fsfw_tests/integration/assemblies/CMakeLists.txt +++ b/src/fsfw_tests/integration/assemblies/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestAssembly.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE TestAssembly.cpp) diff --git a/src/fsfw_tests/integration/controller/CMakeLists.txt b/src/fsfw_tests/integration/controller/CMakeLists.txt index f5655b71..5eeb5c68 100644 --- a/src/fsfw_tests/integration/controller/CMakeLists.txt +++ b/src/fsfw_tests/integration/controller/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestController.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE TestController.cpp) diff --git a/src/fsfw_tests/integration/devices/CMakeLists.txt b/src/fsfw_tests/integration/devices/CMakeLists.txt index cfd238d2..d5799197 100644 --- a/src/fsfw_tests/integration/devices/CMakeLists.txt +++ b/src/fsfw_tests/integration/devices/CMakeLists.txt @@ -1,5 +1,2 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestCookie.cpp - TestDeviceHandler.cpp - TestEchoComIF.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE TestCookie.cpp TestDeviceHandler.cpp + TestEchoComIF.cpp) diff --git a/src/fsfw_tests/integration/task/CMakeLists.txt b/src/fsfw_tests/integration/task/CMakeLists.txt index 4cd481bf..62d5e8ef 100644 --- a/src/fsfw_tests/integration/task/CMakeLists.txt +++ b/src/fsfw_tests/integration/task/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestTask.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE TestTask.cpp) diff --git a/src/fsfw_tests/internal/CMakeLists.txt b/src/fsfw_tests/internal/CMakeLists.txt index 2a144a9b..c1af5467 100644 --- a/src/fsfw_tests/internal/CMakeLists.txt +++ b/src/fsfw_tests/internal/CMakeLists.txt @@ -1,8 +1,6 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - InternalUnitTester.cpp - UnittDefinitions.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE InternalUnitTester.cpp + UnittDefinitions.cpp) add_subdirectory(osal) add_subdirectory(serialize) -add_subdirectory(globalfunctions) \ No newline at end of file +add_subdirectory(globalfunctions) diff --git a/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt b/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt index cde97734..6e7e58ad 100644 --- a/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt +++ b/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestArrayPrinter.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE TestArrayPrinter.cpp) diff --git a/src/fsfw_tests/internal/osal/CMakeLists.txt b/src/fsfw_tests/internal/osal/CMakeLists.txt index 8d79d759..db1031a0 100644 --- a/src/fsfw_tests/internal/osal/CMakeLists.txt +++ b/src/fsfw_tests/internal/osal/CMakeLists.txt @@ -1,5 +1,2 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - testMq.cpp - testMutex.cpp - testSemaphore.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE testMq.cpp testMutex.cpp + testSemaphore.cpp) diff --git a/src/fsfw_tests/internal/serialize/CMakeLists.txt b/src/fsfw_tests/internal/serialize/CMakeLists.txt index 47e8b538..ee264d9d 100644 --- a/src/fsfw_tests/internal/serialize/CMakeLists.txt +++ b/src/fsfw_tests/internal/serialize/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - IntTestSerialization.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE IntTestSerialization.cpp) diff --git a/unittests/tmtcpacket/CMakeLists.txt b/unittests/tmtcpacket/CMakeLists.txt index 958bda40..66eb4976 100644 --- a/unittests/tmtcpacket/CMakeLists.txt +++ b/unittests/tmtcpacket/CMakeLists.txt @@ -1,3 +1,3 @@ target_sources(${FSFW_TEST_TGT} PRIVATE - testCcsds.cpp + testCcsdsReader.cpp ) diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp deleted file mode 100644 index 93cea57a..00000000 --- a/unittests/tmtcpacket/testCcsds.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -#include "fsfw/tmtcpacket/SpacePacketCreator.h" -#include "fsfw/tmtcpacket/SpacePacketReader.h" - -TEST_CASE("CCSDS Test", "[ccsds]") { - SpacePacketCreator base = SpacePacketCreator( - ccsds::PacketType::TC, true, 0x02, - ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); - - SECTION("Constexpr Helpers") { - REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822); - REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822); - - REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); - REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); - } - - SECTION("Basic Test") { - REQUIRE(base.isValid()); - REQUIRE(base.getApid() == 0x02); - REQUIRE(base.getSequenceFlags() == ccsds::SequenceFlags::FIRST_SEGMENT); - REQUIRE(base.getVersion() == 0b000); - REQUIRE(base.getSequenceCount() == 0x34); - REQUIRE(base.getPacketDataLen() == 0x16); - REQUIRE(base.getPacketType() == ccsds::PacketType::TC); - REQUIRE(base.getPacketId() == 0x1802); - } - - SECTION("Raw Output") { - std::array buf {}; - uint8_t* bufPtr = buf.data(); - size_t serLen = 0; - base.serialize(&bufPtr, &serLen, buf.size(), SerializeIF::Endianness::MACHINE); - REQUIRE(buf[0] == 0x18); - REQUIRE(buf[1] == 0x02); - REQUIRE(buf[2] == 0x40); - REQUIRE(buf[3] == 0x34); - REQUIRE(buf[4] == 0x00); - REQUIRE(buf[5] == 0x16); - } -} diff --git a/unittests/tmtcpacket/testCcsdsReader.cpp b/unittests/tmtcpacket/testCcsdsReader.cpp new file mode 100644 index 00000000..700e9f1e --- /dev/null +++ b/unittests/tmtcpacket/testCcsdsReader.cpp @@ -0,0 +1,82 @@ +#include +#include +#include + +#include "fsfw/tmtcpacket/SpacePacketCreator.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" + +TEST_CASE("CCSDS Test", "[ccsds]") { + SpacePacketCreator base = SpacePacketCreator( + ccsds::PacketType::TC, true, 0x02, + ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); + std::array buf {}; + uint8_t* bufPtr = buf.data(); + size_t serLen = 0; + + SECTION("Constexpr Helpers") { + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822); + + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); + } + + SECTION("Basic Test") { + REQUIRE(base.isValid()); + REQUIRE(base.getApid() == 0x02); + REQUIRE(base.getSequenceFlags() == ccsds::SequenceFlags::FIRST_SEGMENT); + REQUIRE(base.getVersion() == 0b000); + REQUIRE(base.getSequenceCount() == 0x34); + REQUIRE(base.getPacketDataLen() == 0x16); + REQUIRE(base.getPacketType() == ccsds::PacketType::TC); + REQUIRE(base.getPacketId() == 0x1802); + } + + SECTION("Raw Output") { + REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + // TC, and secondary header flag is set -> 0b0001100 -> 0x18 + REQUIRE(buf[0] == 0x18); + // APID 0x02 + REQUIRE(buf[1] == 0x02); + // Sequence count is one byte value, so the only set bit here is the bit + // from the Sequence flag argument, which is the second bit for + // SequenceFlags.FIRST_SEGMENT + REQUIRE(buf[2] == 0x40); + // Sequence Count specified above + REQUIRE(buf[3] == 0x34); + // This byte and the next byte should be 22 big endian (packet length) + REQUIRE(buf[4] == 0x00); + REQUIRE(buf[5] == 0x16); + } + + SECTION("All Ones Output") { + base.setApid(static_cast(std::pow(2, 11)) - 1); + base.setSeqCount(static_cast(std::pow(2, 14)) - 1); + base.setSeqFlags(ccsds::SequenceFlags::UNSEGMENTED); + base.setDataLen(static_cast(std::pow(2, 16)) - 1); + REQUIRE(base.isValid()); + REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(buf[0] == 0x1F); + REQUIRE(buf[1] == 0xFF); + REQUIRE(buf[2] == 0xFF); + REQUIRE(buf[3] == 0xFF); + REQUIRE(buf[4] == 0xFF); + REQUIRE(buf[5] == 0xFF); + } + + SECTION("Invalid APID") { + SpacePacketCreator invalid = SpacePacketCreator( + PacketId(ccsds::PacketType::TC, true, 0xFFFF), + PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16); + REQUIRE(not invalid.isValid()); + REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); + } + + SECTION("Invalid Seq Count") { + SpacePacketCreator invalid = SpacePacketCreator( + PacketId(ccsds::PacketType::TC, true, 0x02), + PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0xFFFF), 0x16); + REQUIRE(not invalid.isValid()); + REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); + } +} From 74794bb71ba2ee538fe744883b1a7de7435caabb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 16:08:06 +0200 Subject: [PATCH 052/532] apply auto-formatter --- CMakeLists.txt | 4 +-- scripts/auto-formatter.sh | 3 +- src/fsfw/osal/linux/MessageQueue.cpp | 3 +- src/fsfw_hal/CMakeLists.txt | 4 +-- src/fsfw_hal/common/gpio/CMakeLists.txt | 4 +-- src/fsfw_hal/devicehandlers/CMakeLists.txt | 8 ++--- src/fsfw_hal/linux/CMakeLists.txt | 30 ++++++++----------- src/fsfw_hal/linux/gpio/CMakeLists.txt | 18 +++++------ src/fsfw_hal/linux/i2c/CMakeLists.txt | 9 +----- src/fsfw_hal/linux/rpi/CMakeLists.txt | 4 +-- src/fsfw_hal/linux/spi/CMakeLists.txt | 9 +----- src/fsfw_hal/linux/uart/CMakeLists.txt | 5 +--- src/fsfw_hal/linux/uio/CMakeLists.txt | 4 +-- src/fsfw_hal/stm32h7/CMakeLists.txt | 4 +-- .../stm32h7/devicetest/CMakeLists.txt | 4 +-- src/fsfw_hal/stm32h7/gpio/CMakeLists.txt | 4 +-- src/fsfw_hal/stm32h7/i2c/CMakeLists.txt | 3 +- src/fsfw_hal/stm32h7/spi/CMakeLists.txt | 18 +++++------ src/fsfw_hal/stm32h7/uart/CMakeLists.txt | 3 +- src/fsfw_tests/CMakeLists.txt | 4 +-- .../integration/assemblies/CMakeLists.txt | 4 +-- .../integration/controller/CMakeLists.txt | 4 +-- .../integration/devices/CMakeLists.txt | 7 ++--- .../integration/task/CMakeLists.txt | 4 +-- src/fsfw_tests/internal/CMakeLists.txt | 8 ++--- .../internal/globalfunctions/CMakeLists.txt | 4 +-- src/fsfw_tests/internal/osal/CMakeLists.txt | 7 ++--- .../internal/serialize/CMakeLists.txt | 4 +-- unittests/cfdp/testCfdp.cpp | 2 +- unittests/datapoollocal/DataSetTest.cpp | 2 +- .../datapoollocal/LocalPoolManagerTest.cpp | 2 +- .../datapoollocal/LocalPoolVariableTest.cpp | 2 +- .../datapoollocal/LocalPoolVectorTest.cpp | 2 +- .../devicehandler/TestDeviceHandlerBase.cpp | 2 +- unittests/globalfunctions/testCRC.cpp | 2 +- unittests/globalfunctions/testDleEncoder.cpp | 2 +- .../TestInternalErrorReporter.cpp | 2 +- unittests/mocks/MessageQueueMockBase.h | 2 +- unittests/power/testPowerSwitcher.cpp | 2 +- unittests/testVersion.cpp | 5 ++-- 40 files changed, 77 insertions(+), 137 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f74be01d..cfae2acb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,8 +104,8 @@ if(FSFW_GENERATE_SECTIONS) option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) endif() -option(FSFW_BUILD_TESTS - "Build unittest binary in addition to static library" OFF) +option(FSFW_BUILD_TESTS "Build unittest binary in addition to static library" + OFF) option(FSFW_CICD_BUILD "Build for CI/CD. This can disable problematic test" OFF) option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF) if(FSFW_BUILD_TESTS) diff --git a/scripts/auto-formatter.sh b/scripts/auto-formatter.sh index 405d1268..c0ae7099 100755 --- a/scripts/auto-formatter.sh +++ b/scripts/auto-formatter.sh @@ -16,8 +16,7 @@ cpp_format="clang-format" file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp" if command -v ${cpp_format} &> /dev/null; then find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i - find ./hal ${file_selectors} | xargs ${cpp_format} --style=file -i - find ./tests ${file_selectors} | xargs ${cpp_format} --style=file -i + find ./unittests ${file_selectors} | xargs ${cpp_format} --style=file -i else echo "No ${cpp_format} tool found, not formatting C++/C files" fi diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index 4ef7f756..ec212165 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -292,7 +292,8 @@ ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messag sif::error << "MessageQueue::MessageQueue: Default MQ size " << defaultMqMaxMsg << " is too small for requested message depth " << messageDepth << std::endl; sif::error << "This error can be fixed by setting the maximum " - "allowed message depth higher" << std::endl; + "allowed message depth higher" + << std::endl; #else sif::printError( "MessageQueue::MessageQueue: Default MQ size %d is too small for" diff --git a/src/fsfw_hal/CMakeLists.txt b/src/fsfw_hal/CMakeLists.txt index b7559d4b..057ab3a6 100644 --- a/src/fsfw_hal/CMakeLists.txt +++ b/src/fsfw_hal/CMakeLists.txt @@ -2,9 +2,9 @@ add_subdirectory(devicehandlers) add_subdirectory(common) if(UNIX) - add_subdirectory(linux) + add_subdirectory(linux) endif() if(FSFW_HAL_ADD_STM32H7) - add_subdirectory(stm32h7) + add_subdirectory(stm32h7) endif() diff --git a/src/fsfw_hal/common/gpio/CMakeLists.txt b/src/fsfw_hal/common/gpio/CMakeLists.txt index 098c05fa..5c81d9cc 100644 --- a/src/fsfw_hal/common/gpio/CMakeLists.txt +++ b/src/fsfw_hal/common/gpio/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GpioCookie.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE GpioCookie.cpp) diff --git a/src/fsfw_hal/devicehandlers/CMakeLists.txt b/src/fsfw_hal/devicehandlers/CMakeLists.txt index 94e67c72..17139416 100644 --- a/src/fsfw_hal/devicehandlers/CMakeLists.txt +++ b/src/fsfw_hal/devicehandlers/CMakeLists.txt @@ -1,5 +1,3 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GyroL3GD20Handler.cpp - MgmRM3100Handler.cpp - MgmLIS3MDLHandler.cpp -) +target_sources( + ${LIB_FSFW_NAME} PRIVATE GyroL3GD20Handler.cpp MgmRM3100Handler.cpp + MgmLIS3MDLHandler.cpp) diff --git a/src/fsfw_hal/linux/CMakeLists.txt b/src/fsfw_hal/linux/CMakeLists.txt index f6d1a460..ffa5f5ee 100644 --- a/src/fsfw_hal/linux/CMakeLists.txt +++ b/src/fsfw_hal/linux/CMakeLists.txt @@ -1,25 +1,21 @@ if(FSFW_HAL_ADD_RASPBERRY_PI) - add_subdirectory(rpi) + add_subdirectory(rpi) endif() -target_sources(${LIB_FSFW_NAME} PRIVATE - UnixFileGuard.cpp - CommandExecutor.cpp - utility.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE UnixFileGuard.cpp CommandExecutor.cpp + utility.cpp) if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS) -if(FSFW_HAL_LINUX_ADD_LIBGPIOD) - add_subdirectory(gpio) -endif() - add_subdirectory(uart) - # Adding those does not really make sense on Apple systems which - # are generally host systems. It won't even compile as the headers - # are missing - if(NOT APPLE) - add_subdirectory(i2c) - add_subdirectory(spi) - endif() + if(FSFW_HAL_LINUX_ADD_LIBGPIOD) + add_subdirectory(gpio) + endif() + add_subdirectory(uart) + # Adding those does not really make sense on Apple systems which are generally + # host systems. It won't even compile as the headers are missing + if(NOT APPLE) + add_subdirectory(i2c) + add_subdirectory(spi) + endif() endif() add_subdirectory(uio) diff --git a/src/fsfw_hal/linux/gpio/CMakeLists.txt b/src/fsfw_hal/linux/gpio/CMakeLists.txt index b1609850..f6e7f2b0 100644 --- a/src/fsfw_hal/linux/gpio/CMakeLists.txt +++ b/src/fsfw_hal/linux/gpio/CMakeLists.txt @@ -1,16 +1,12 @@ -# This abstraction layer requires the gpiod library. You can install this library -# with "sudo apt-get install -y libgpiod-dev". If you are cross-compiling, you need -# to install the package before syncing the sysroot to your host computer. +# This abstraction layer requires the gpiod library. You can install this +# library with "sudo apt-get install -y libgpiod-dev". If you are +# cross-compiling, you need to install the package before syncing the sysroot to +# your host computer. find_library(LIB_GPIO gpiod) if(${LIB_GPIO} MATCHES LIB_GPIO-NOTFOUND) - message(STATUS "gpiod library not found, not linking against it") + message(STATUS "gpiod library not found, not linking against it") else() - target_sources(${LIB_FSFW_NAME} PRIVATE - LinuxLibgpioIF.cpp - ) - target_link_libraries(${LIB_FSFW_NAME} PRIVATE - ${LIB_GPIO} - ) + target_sources(${LIB_FSFW_NAME} PRIVATE LinuxLibgpioIF.cpp) + target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${LIB_GPIO}) endif() - diff --git a/src/fsfw_hal/linux/i2c/CMakeLists.txt b/src/fsfw_hal/linux/i2c/CMakeLists.txt index 3eb0882c..b94bdc99 100644 --- a/src/fsfw_hal/linux/i2c/CMakeLists.txt +++ b/src/fsfw_hal/linux/i2c/CMakeLists.txt @@ -1,8 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - I2cComIF.cpp - I2cCookie.cpp -) - - - - +target_sources(${LIB_FSFW_NAME} PUBLIC I2cComIF.cpp I2cCookie.cpp) diff --git a/src/fsfw_hal/linux/rpi/CMakeLists.txt b/src/fsfw_hal/linux/rpi/CMakeLists.txt index 47be218c..3a865037 100644 --- a/src/fsfw_hal/linux/rpi/CMakeLists.txt +++ b/src/fsfw_hal/linux/rpi/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GpioRPi.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE GpioRPi.cpp) diff --git a/src/fsfw_hal/linux/spi/CMakeLists.txt b/src/fsfw_hal/linux/spi/CMakeLists.txt index 404e1f47..f242bb3b 100644 --- a/src/fsfw_hal/linux/spi/CMakeLists.txt +++ b/src/fsfw_hal/linux/spi/CMakeLists.txt @@ -1,8 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - SpiComIF.cpp - SpiCookie.cpp -) - - - - +target_sources(${LIB_FSFW_NAME} PUBLIC SpiComIF.cpp SpiCookie.cpp) diff --git a/src/fsfw_hal/linux/uart/CMakeLists.txt b/src/fsfw_hal/linux/uart/CMakeLists.txt index 21ed0278..9cad62a4 100644 --- a/src/fsfw_hal/linux/uart/CMakeLists.txt +++ b/src/fsfw_hal/linux/uart/CMakeLists.txt @@ -1,4 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - UartComIF.cpp - UartCookie.cpp -) +target_sources(${LIB_FSFW_NAME} PUBLIC UartComIF.cpp UartCookie.cpp) diff --git a/src/fsfw_hal/linux/uio/CMakeLists.txt b/src/fsfw_hal/linux/uio/CMakeLists.txt index e98a0865..e3498246 100644 --- a/src/fsfw_hal/linux/uio/CMakeLists.txt +++ b/src/fsfw_hal/linux/uio/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - UioMapper.cpp -) +target_sources(${LIB_FSFW_NAME} PUBLIC UioMapper.cpp) diff --git a/src/fsfw_hal/stm32h7/CMakeLists.txt b/src/fsfw_hal/stm32h7/CMakeLists.txt index bae3b1ac..e8843ed3 100644 --- a/src/fsfw_hal/stm32h7/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/CMakeLists.txt @@ -2,6 +2,4 @@ add_subdirectory(spi) add_subdirectory(gpio) add_subdirectory(devicetest) -target_sources(${LIB_FSFW_NAME} PRIVATE - dma.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE dma.cpp) diff --git a/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt b/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt index 7bd4c3a9..8e789ddb 100644 --- a/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GyroL3GD20H.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE GyroL3GD20H.cpp) diff --git a/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt b/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt index 35245b25..54d76b2d 100644 --- a/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - gpio.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE gpio.cpp) diff --git a/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt b/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt index 5ecb0990..a0d48465 100644 --- a/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt @@ -1,2 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE -) +target_sources(${LIB_FSFW_NAME} PRIVATE) diff --git a/src/fsfw_hal/stm32h7/spi/CMakeLists.txt b/src/fsfw_hal/stm32h7/spi/CMakeLists.txt index aa5541bc..9a98f502 100644 --- a/src/fsfw_hal/stm32h7/spi/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/spi/CMakeLists.txt @@ -1,9 +1,9 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - spiCore.cpp - spiDefinitions.cpp - spiInterrupts.cpp - mspInit.cpp - SpiCookie.cpp - SpiComIF.cpp - stm32h743zi.cpp -) +target_sources( + ${LIB_FSFW_NAME} + PRIVATE spiCore.cpp + spiDefinitions.cpp + spiInterrupts.cpp + mspInit.cpp + SpiCookie.cpp + SpiComIF.cpp + stm32h743zi.cpp) diff --git a/src/fsfw_hal/stm32h7/uart/CMakeLists.txt b/src/fsfw_hal/stm32h7/uart/CMakeLists.txt index 5ecb0990..a0d48465 100644 --- a/src/fsfw_hal/stm32h7/uart/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/uart/CMakeLists.txt @@ -1,2 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE -) +target_sources(${LIB_FSFW_NAME} PRIVATE) diff --git a/src/fsfw_tests/CMakeLists.txt b/src/fsfw_tests/CMakeLists.txt index 5e16e0a7..d161699a 100644 --- a/src/fsfw_tests/CMakeLists.txt +++ b/src/fsfw_tests/CMakeLists.txt @@ -1,7 +1,7 @@ if(FSFW_ADD_INTERNAL_TESTS) - add_subdirectory(internal) + add_subdirectory(internal) endif() if(NOT FSFW_BUILD_TESTS) - add_subdirectory(integration) + add_subdirectory(integration) endif() diff --git a/src/fsfw_tests/integration/assemblies/CMakeLists.txt b/src/fsfw_tests/integration/assemblies/CMakeLists.txt index 22c06600..63a6447a 100644 --- a/src/fsfw_tests/integration/assemblies/CMakeLists.txt +++ b/src/fsfw_tests/integration/assemblies/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestAssembly.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE TestAssembly.cpp) diff --git a/src/fsfw_tests/integration/controller/CMakeLists.txt b/src/fsfw_tests/integration/controller/CMakeLists.txt index f5655b71..5eeb5c68 100644 --- a/src/fsfw_tests/integration/controller/CMakeLists.txt +++ b/src/fsfw_tests/integration/controller/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestController.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE TestController.cpp) diff --git a/src/fsfw_tests/integration/devices/CMakeLists.txt b/src/fsfw_tests/integration/devices/CMakeLists.txt index cfd238d2..d5799197 100644 --- a/src/fsfw_tests/integration/devices/CMakeLists.txt +++ b/src/fsfw_tests/integration/devices/CMakeLists.txt @@ -1,5 +1,2 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestCookie.cpp - TestDeviceHandler.cpp - TestEchoComIF.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE TestCookie.cpp TestDeviceHandler.cpp + TestEchoComIF.cpp) diff --git a/src/fsfw_tests/integration/task/CMakeLists.txt b/src/fsfw_tests/integration/task/CMakeLists.txt index 4cd481bf..62d5e8ef 100644 --- a/src/fsfw_tests/integration/task/CMakeLists.txt +++ b/src/fsfw_tests/integration/task/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestTask.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE TestTask.cpp) diff --git a/src/fsfw_tests/internal/CMakeLists.txt b/src/fsfw_tests/internal/CMakeLists.txt index 2a144a9b..c1af5467 100644 --- a/src/fsfw_tests/internal/CMakeLists.txt +++ b/src/fsfw_tests/internal/CMakeLists.txt @@ -1,8 +1,6 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - InternalUnitTester.cpp - UnittDefinitions.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE InternalUnitTester.cpp + UnittDefinitions.cpp) add_subdirectory(osal) add_subdirectory(serialize) -add_subdirectory(globalfunctions) \ No newline at end of file +add_subdirectory(globalfunctions) diff --git a/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt b/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt index cde97734..6e7e58ad 100644 --- a/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt +++ b/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestArrayPrinter.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE TestArrayPrinter.cpp) diff --git a/src/fsfw_tests/internal/osal/CMakeLists.txt b/src/fsfw_tests/internal/osal/CMakeLists.txt index 8d79d759..db1031a0 100644 --- a/src/fsfw_tests/internal/osal/CMakeLists.txt +++ b/src/fsfw_tests/internal/osal/CMakeLists.txt @@ -1,5 +1,2 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - testMq.cpp - testMutex.cpp - testSemaphore.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE testMq.cpp testMutex.cpp + testSemaphore.cpp) diff --git a/src/fsfw_tests/internal/serialize/CMakeLists.txt b/src/fsfw_tests/internal/serialize/CMakeLists.txt index 47e8b538..ee264d9d 100644 --- a/src/fsfw_tests/internal/serialize/CMakeLists.txt +++ b/src/fsfw_tests/internal/serialize/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - IntTestSerialization.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE IntTestSerialization.cpp) diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 6ca95fbc..78ef618b 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -2,6 +2,7 @@ #include #include +#include "CatchDefinitions.h" #include "fsfw/cfdp/FileSize.h" #include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" @@ -9,7 +10,6 @@ #include "fsfw/cfdp/pdu/HeaderSerializer.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serialize/SerializeAdapter.h" -#include "CatchDefinitions.h" TEST_CASE("CFDP Base", "[CfdpBase]") { using namespace cfdp; diff --git a/unittests/datapoollocal/DataSetTest.cpp b/unittests/datapoollocal/DataSetTest.cpp index c56ed768..c9f023ef 100644 --- a/unittests/datapoollocal/DataSetTest.cpp +++ b/unittests/datapoollocal/DataSetTest.cpp @@ -8,8 +8,8 @@ #include #include -#include "LocalPoolOwnerBase.h" #include "CatchDefinitions.h" +#include "LocalPoolOwnerBase.h" #include "tests/TestsConfig.h" TEST_CASE("DataSetTest", "[DataSetTest]") { diff --git a/unittests/datapoollocal/LocalPoolManagerTest.cpp b/unittests/datapoollocal/LocalPoolManagerTest.cpp index 019c9b59..58a6065e 100644 --- a/unittests/datapoollocal/LocalPoolManagerTest.cpp +++ b/unittests/datapoollocal/LocalPoolManagerTest.cpp @@ -11,8 +11,8 @@ #include #include -#include "LocalPoolOwnerBase.h" #include "CatchDefinitions.h" +#include "LocalPoolOwnerBase.h" TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { LocalPoolOwnerBase* poolOwner = diff --git a/unittests/datapoollocal/LocalPoolVariableTest.cpp b/unittests/datapoollocal/LocalPoolVariableTest.cpp index 86bd6a1e..3479cdbe 100644 --- a/unittests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittests/datapoollocal/LocalPoolVariableTest.cpp @@ -3,8 +3,8 @@ #include -#include "LocalPoolOwnerBase.h" #include "CatchDefinitions.h" +#include "LocalPoolOwnerBase.h" #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { diff --git a/unittests/datapoollocal/LocalPoolVectorTest.cpp b/unittests/datapoollocal/LocalPoolVectorTest.cpp index 3a06c826..2235ad39 100644 --- a/unittests/datapoollocal/LocalPoolVectorTest.cpp +++ b/unittests/datapoollocal/LocalPoolVectorTest.cpp @@ -3,8 +3,8 @@ #include -#include "LocalPoolOwnerBase.h" #include "CatchDefinitions.h" +#include "LocalPoolOwnerBase.h" #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { diff --git a/unittests/devicehandler/TestDeviceHandlerBase.cpp b/unittests/devicehandler/TestDeviceHandlerBase.cpp index 328bc4dc..e8fdd17b 100644 --- a/unittests/devicehandler/TestDeviceHandlerBase.cpp +++ b/unittests/devicehandler/TestDeviceHandlerBase.cpp @@ -2,9 +2,9 @@ #include "ComIFMock.h" #include "DeviceFdirMock.h" -#include "devicehandler/CookieIFMock.h" #include "DeviceHandlerCommander.h" #include "DeviceHandlerMock.h" +#include "devicehandler/CookieIFMock.h" #include "objects/systemObjectList.h" TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { diff --git a/unittests/globalfunctions/testCRC.cpp b/unittests/globalfunctions/testCRC.cpp index 884bd281..2b6de4db 100644 --- a/unittests/globalfunctions/testCRC.cpp +++ b/unittests/globalfunctions/testCRC.cpp @@ -1,8 +1,8 @@ #include +#include "CatchDefinitions.h" #include "catch2/catch_test_macros.hpp" #include "fsfw/globalfunctions/CRC.h" -#include "CatchDefinitions.h" TEST_CASE("CRC", "[CRC]") { std::array testData = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; diff --git a/unittests/globalfunctions/testDleEncoder.cpp b/unittests/globalfunctions/testDleEncoder.cpp index 1ccaddb5..0c707f4c 100644 --- a/unittests/globalfunctions/testDleEncoder.cpp +++ b/unittests/globalfunctions/testDleEncoder.cpp @@ -1,8 +1,8 @@ #include +#include "CatchDefinitions.h" #include "catch2/catch_test_macros.hpp" #include "fsfw/globalfunctions/DleEncoder.h" -#include "CatchDefinitions.h" const std::vector TEST_ARRAY_0 = {0, 0, 0, 0, 0}; const std::vector TEST_ARRAY_1 = {0, DleEncoder::DLE_CHAR, 5}; diff --git a/unittests/internalerror/TestInternalErrorReporter.cpp b/unittests/internalerror/TestInternalErrorReporter.cpp index b52c5336..2b999fae 100644 --- a/unittests/internalerror/TestInternalErrorReporter.cpp +++ b/unittests/internalerror/TestInternalErrorReporter.cpp @@ -8,11 +8,11 @@ #include #include +#include "CatchDefinitions.h" #include "fsfw/action/ActionMessage.h" #include "fsfw/ipc/CommandMessage.h" #include "fsfw/ipc/MessageQueueMessage.h" #include "fsfw/objectmanager/frameworkObjects.h" -#include "CatchDefinitions.h" #include "mocks/PeriodicTaskIFMock.h" TEST_CASE("Internal Error Reporter", "[TestInternalError]") { diff --git a/unittests/mocks/MessageQueueMockBase.h b/unittests/mocks/MessageQueueMockBase.h index 60a942d9..d3323186 100644 --- a/unittests/mocks/MessageQueueMockBase.h +++ b/unittests/mocks/MessageQueueMockBase.h @@ -4,11 +4,11 @@ #include #include +#include "CatchDefinitions.h" #include "fsfw/ipc/CommandMessage.h" #include "fsfw/ipc/MessageQueueBase.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/MessageQueueMessage.h" -#include "CatchDefinitions.h" class MessageQueueMockBase : public MessageQueueBase { public: diff --git a/unittests/power/testPowerSwitcher.cpp b/unittests/power/testPowerSwitcher.cpp index cf2f2148..f6a24583 100644 --- a/unittests/power/testPowerSwitcher.cpp +++ b/unittests/power/testPowerSwitcher.cpp @@ -1,9 +1,9 @@ #include #include -#include "mocks/PowerSwitcherMock.h" #include +#include "mocks/PowerSwitcherMock.h" #include "objects/systemObjectList.h" TEST_CASE("Power Switcher", "[power-switcher]") { diff --git a/unittests/testVersion.cpp b/unittests/testVersion.cpp index e0b9897b..2f487031 100644 --- a/unittests/testVersion.cpp +++ b/unittests/testVersion.cpp @@ -1,10 +1,9 @@ -#include "fsfw/version.h" - #include -#include "fsfw/serviceinterface.h" #include "CatchDefinitions.h" +#include "fsfw/serviceinterface.h" +#include "fsfw/version.h" TEST_CASE("Version API Tests", "[TestVersionAPI]") { // Check that major version is non-zero From 3d2af203f2e365df7f64ce28853d540c5c41ec81 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 16:18:04 +0200 Subject: [PATCH 053/532] finished creator unittests --- unittests/cfdp/testCfdp.cpp | 2 +- unittests/datapoollocal/DataSetTest.cpp | 2 +- .../datapoollocal/LocalPoolManagerTest.cpp | 2 +- .../datapoollocal/LocalPoolVariableTest.cpp | 2 +- .../datapoollocal/LocalPoolVectorTest.cpp | 2 +- .../devicehandler/TestDeviceHandlerBase.cpp | 2 +- unittests/globalfunctions/testCRC.cpp | 2 +- unittests/globalfunctions/testDleEncoder.cpp | 2 +- .../TestInternalErrorReporter.cpp | 2 +- unittests/mocks/MessageQueueMockBase.h | 2 +- unittests/power/testPowerSwitcher.cpp | 2 +- unittests/testVersion.cpp | 5 +-- unittests/tmtcpacket/CMakeLists.txt | 2 +- ...estCcsdsReader.cpp => TestCcsdsReader.cpp} | 44 ++++++++++++++----- .../{PusTmTest.cpp => TestPusTm.cpp} | 0 15 files changed, 47 insertions(+), 26 deletions(-) rename unittests/tmtcpacket/{testCcsdsReader.cpp => TestCcsdsReader.cpp} (65%) rename unittests/tmtcpacket/{PusTmTest.cpp => TestPusTm.cpp} (100%) diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 6ca95fbc..78ef618b 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -2,6 +2,7 @@ #include #include +#include "CatchDefinitions.h" #include "fsfw/cfdp/FileSize.h" #include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" @@ -9,7 +10,6 @@ #include "fsfw/cfdp/pdu/HeaderSerializer.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serialize/SerializeAdapter.h" -#include "CatchDefinitions.h" TEST_CASE("CFDP Base", "[CfdpBase]") { using namespace cfdp; diff --git a/unittests/datapoollocal/DataSetTest.cpp b/unittests/datapoollocal/DataSetTest.cpp index c56ed768..c9f023ef 100644 --- a/unittests/datapoollocal/DataSetTest.cpp +++ b/unittests/datapoollocal/DataSetTest.cpp @@ -8,8 +8,8 @@ #include #include -#include "LocalPoolOwnerBase.h" #include "CatchDefinitions.h" +#include "LocalPoolOwnerBase.h" #include "tests/TestsConfig.h" TEST_CASE("DataSetTest", "[DataSetTest]") { diff --git a/unittests/datapoollocal/LocalPoolManagerTest.cpp b/unittests/datapoollocal/LocalPoolManagerTest.cpp index 019c9b59..58a6065e 100644 --- a/unittests/datapoollocal/LocalPoolManagerTest.cpp +++ b/unittests/datapoollocal/LocalPoolManagerTest.cpp @@ -11,8 +11,8 @@ #include #include -#include "LocalPoolOwnerBase.h" #include "CatchDefinitions.h" +#include "LocalPoolOwnerBase.h" TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { LocalPoolOwnerBase* poolOwner = diff --git a/unittests/datapoollocal/LocalPoolVariableTest.cpp b/unittests/datapoollocal/LocalPoolVariableTest.cpp index 86bd6a1e..3479cdbe 100644 --- a/unittests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittests/datapoollocal/LocalPoolVariableTest.cpp @@ -3,8 +3,8 @@ #include -#include "LocalPoolOwnerBase.h" #include "CatchDefinitions.h" +#include "LocalPoolOwnerBase.h" #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { diff --git a/unittests/datapoollocal/LocalPoolVectorTest.cpp b/unittests/datapoollocal/LocalPoolVectorTest.cpp index 3a06c826..2235ad39 100644 --- a/unittests/datapoollocal/LocalPoolVectorTest.cpp +++ b/unittests/datapoollocal/LocalPoolVectorTest.cpp @@ -3,8 +3,8 @@ #include -#include "LocalPoolOwnerBase.h" #include "CatchDefinitions.h" +#include "LocalPoolOwnerBase.h" #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { diff --git a/unittests/devicehandler/TestDeviceHandlerBase.cpp b/unittests/devicehandler/TestDeviceHandlerBase.cpp index 328bc4dc..e8fdd17b 100644 --- a/unittests/devicehandler/TestDeviceHandlerBase.cpp +++ b/unittests/devicehandler/TestDeviceHandlerBase.cpp @@ -2,9 +2,9 @@ #include "ComIFMock.h" #include "DeviceFdirMock.h" -#include "devicehandler/CookieIFMock.h" #include "DeviceHandlerCommander.h" #include "DeviceHandlerMock.h" +#include "devicehandler/CookieIFMock.h" #include "objects/systemObjectList.h" TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { diff --git a/unittests/globalfunctions/testCRC.cpp b/unittests/globalfunctions/testCRC.cpp index 884bd281..2b6de4db 100644 --- a/unittests/globalfunctions/testCRC.cpp +++ b/unittests/globalfunctions/testCRC.cpp @@ -1,8 +1,8 @@ #include +#include "CatchDefinitions.h" #include "catch2/catch_test_macros.hpp" #include "fsfw/globalfunctions/CRC.h" -#include "CatchDefinitions.h" TEST_CASE("CRC", "[CRC]") { std::array testData = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; diff --git a/unittests/globalfunctions/testDleEncoder.cpp b/unittests/globalfunctions/testDleEncoder.cpp index 1ccaddb5..0c707f4c 100644 --- a/unittests/globalfunctions/testDleEncoder.cpp +++ b/unittests/globalfunctions/testDleEncoder.cpp @@ -1,8 +1,8 @@ #include +#include "CatchDefinitions.h" #include "catch2/catch_test_macros.hpp" #include "fsfw/globalfunctions/DleEncoder.h" -#include "CatchDefinitions.h" const std::vector TEST_ARRAY_0 = {0, 0, 0, 0, 0}; const std::vector TEST_ARRAY_1 = {0, DleEncoder::DLE_CHAR, 5}; diff --git a/unittests/internalerror/TestInternalErrorReporter.cpp b/unittests/internalerror/TestInternalErrorReporter.cpp index b52c5336..2b999fae 100644 --- a/unittests/internalerror/TestInternalErrorReporter.cpp +++ b/unittests/internalerror/TestInternalErrorReporter.cpp @@ -8,11 +8,11 @@ #include #include +#include "CatchDefinitions.h" #include "fsfw/action/ActionMessage.h" #include "fsfw/ipc/CommandMessage.h" #include "fsfw/ipc/MessageQueueMessage.h" #include "fsfw/objectmanager/frameworkObjects.h" -#include "CatchDefinitions.h" #include "mocks/PeriodicTaskIFMock.h" TEST_CASE("Internal Error Reporter", "[TestInternalError]") { diff --git a/unittests/mocks/MessageQueueMockBase.h b/unittests/mocks/MessageQueueMockBase.h index 60a942d9..d3323186 100644 --- a/unittests/mocks/MessageQueueMockBase.h +++ b/unittests/mocks/MessageQueueMockBase.h @@ -4,11 +4,11 @@ #include #include +#include "CatchDefinitions.h" #include "fsfw/ipc/CommandMessage.h" #include "fsfw/ipc/MessageQueueBase.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/MessageQueueMessage.h" -#include "CatchDefinitions.h" class MessageQueueMockBase : public MessageQueueBase { public: diff --git a/unittests/power/testPowerSwitcher.cpp b/unittests/power/testPowerSwitcher.cpp index cf2f2148..f6a24583 100644 --- a/unittests/power/testPowerSwitcher.cpp +++ b/unittests/power/testPowerSwitcher.cpp @@ -1,9 +1,9 @@ #include #include -#include "mocks/PowerSwitcherMock.h" #include +#include "mocks/PowerSwitcherMock.h" #include "objects/systemObjectList.h" TEST_CASE("Power Switcher", "[power-switcher]") { diff --git a/unittests/testVersion.cpp b/unittests/testVersion.cpp index e0b9897b..2f487031 100644 --- a/unittests/testVersion.cpp +++ b/unittests/testVersion.cpp @@ -1,10 +1,9 @@ -#include "fsfw/version.h" - #include -#include "fsfw/serviceinterface.h" #include "CatchDefinitions.h" +#include "fsfw/serviceinterface.h" +#include "fsfw/version.h" TEST_CASE("Version API Tests", "[TestVersionAPI]") { // Check that major version is non-zero diff --git a/unittests/tmtcpacket/CMakeLists.txt b/unittests/tmtcpacket/CMakeLists.txt index 66eb4976..ea3eec21 100644 --- a/unittests/tmtcpacket/CMakeLists.txt +++ b/unittests/tmtcpacket/CMakeLists.txt @@ -1,3 +1,3 @@ target_sources(${FSFW_TEST_TGT} PRIVATE - testCcsdsReader.cpp + TestCcsdsReader.cpp ) diff --git a/unittests/tmtcpacket/testCcsdsReader.cpp b/unittests/tmtcpacket/TestCcsdsReader.cpp similarity index 65% rename from unittests/tmtcpacket/testCcsdsReader.cpp rename to unittests/tmtcpacket/TestCcsdsReader.cpp index 700e9f1e..79d86eb1 100644 --- a/unittests/tmtcpacket/testCcsdsReader.cpp +++ b/unittests/tmtcpacket/TestCcsdsReader.cpp @@ -1,15 +1,14 @@ #include -#include #include +#include #include "fsfw/tmtcpacket/SpacePacketCreator.h" #include "fsfw/tmtcpacket/SpacePacketReader.h" TEST_CASE("CCSDS Test", "[ccsds]") { - SpacePacketCreator base = SpacePacketCreator( - ccsds::PacketType::TC, true, 0x02, - ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); - std::array buf {}; + SpacePacketCreator base = SpacePacketCreator(ccsds::PacketType::TC, true, 0x02, + ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); + std::array buf{}; uint8_t* bufPtr = buf.data(); size_t serLen = 0; @@ -30,6 +29,14 @@ TEST_CASE("CCSDS Test", "[ccsds]") { REQUIRE(base.getPacketDataLen() == 0x16); REQUIRE(base.getPacketType() == ccsds::PacketType::TC); REQUIRE(base.getPacketId() == 0x1802); + REQUIRE(base.getSerializedSize() == 6); + } + + SECTION("Deserialization Fails") { + serLen = 6; + const uint8_t* readOnlyPtr = buf.data(); + REQUIRE(base.deSerialize(&readOnlyPtr, &serLen, SerializeIF::Endianness::BIG) == + HasReturnvaluesIF::RETURN_FAILED); } SECTION("Raw Output") { @@ -65,18 +72,33 @@ TEST_CASE("CCSDS Test", "[ccsds]") { } SECTION("Invalid APID") { - SpacePacketCreator invalid = SpacePacketCreator( - PacketId(ccsds::PacketType::TC, true, 0xFFFF), - PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16); + SpacePacketCreator invalid = + SpacePacketCreator(PacketId(ccsds::PacketType::TC, true, 0xFFFF), + PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16); REQUIRE(not invalid.isValid()); REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); } SECTION("Invalid Seq Count") { - SpacePacketCreator invalid = SpacePacketCreator( - PacketId(ccsds::PacketType::TC, true, 0x02), - PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0xFFFF), 0x16); + SpacePacketCreator invalid = + SpacePacketCreator(PacketId(ccsds::PacketType::TC, true, 0x02), + PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0xFFFF), 0x16); REQUIRE(not invalid.isValid()); REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); } + + SECTION("Invalid Buf Size 1") { + serLen = 2; + REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT); + } + + SECTION("Invalid Buf Size 2") { + serLen = 4; + REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT); + } + + SECTION("Invalid Buf Size 3") { + serLen = 6; + REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT); + } } diff --git a/unittests/tmtcpacket/PusTmTest.cpp b/unittests/tmtcpacket/TestPusTm.cpp similarity index 100% rename from unittests/tmtcpacket/PusTmTest.cpp rename to unittests/tmtcpacket/TestPusTm.cpp From 95b476d4bd936165c2441437c584b6c792ec70ad Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 16:21:00 +0200 Subject: [PATCH 054/532] start ccsds reader unittests --- CMakeLists.txt | 2 +- unittests/tmtcpacket/CMakeLists.txt | 3 ++- .../{TestCcsdsReader.cpp => testCcsdsCreator.cpp} | 4 ++-- unittests/tmtcpacket/testCcsdsReader.cpp | 6 ++++++ unittests/tmtcpacket/{TestPusTm.cpp => testPusTm.cpp} | 0 5 files changed, 11 insertions(+), 4 deletions(-) rename unittests/tmtcpacket/{TestCcsdsReader.cpp => testCcsdsCreator.cpp} (97%) create mode 100644 unittests/tmtcpacket/testCcsdsReader.cpp rename unittests/tmtcpacket/{TestPusTm.cpp => testPusTm.cpp} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98a84cb6..237f186a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,7 +175,7 @@ if(FSFW_BUILD_TESTS) configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h) project(${FSFW_TEST_TGT} CXX C) - add_executable(${FSFW_TEST_TGT}) + add_executable(${FSFW_TEST_TGT} unittests/tmtcpacket/testCcsdsReader.cpp) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) diff --git a/unittests/tmtcpacket/CMakeLists.txt b/unittests/tmtcpacket/CMakeLists.txt index ea3eec21..9a08868e 100644 --- a/unittests/tmtcpacket/CMakeLists.txt +++ b/unittests/tmtcpacket/CMakeLists.txt @@ -1,3 +1,4 @@ target_sources(${FSFW_TEST_TGT} PRIVATE - TestCcsdsReader.cpp + testCcsdsCreator.cpp + testCcsdsReader.cpp ) diff --git a/unittests/tmtcpacket/TestCcsdsReader.cpp b/unittests/tmtcpacket/testCcsdsCreator.cpp similarity index 97% rename from unittests/tmtcpacket/TestCcsdsReader.cpp rename to unittests/tmtcpacket/testCcsdsCreator.cpp index 79d86eb1..fbd73b10 100644 --- a/unittests/tmtcpacket/TestCcsdsReader.cpp +++ b/unittests/tmtcpacket/testCcsdsCreator.cpp @@ -3,9 +3,9 @@ #include #include "fsfw/tmtcpacket/SpacePacketCreator.h" -#include "fsfw/tmtcpacket/SpacePacketReader.h" -TEST_CASE("CCSDS Test", "[ccsds]") { + +TEST_CASE("CCSDS Creator", "[ccsds-creator]") { SpacePacketCreator base = SpacePacketCreator(ccsds::PacketType::TC, true, 0x02, ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); std::array buf{}; diff --git a/unittests/tmtcpacket/testCcsdsReader.cpp b/unittests/tmtcpacket/testCcsdsReader.cpp new file mode 100644 index 00000000..d63f4cf0 --- /dev/null +++ b/unittests/tmtcpacket/testCcsdsReader.cpp @@ -0,0 +1,6 @@ +#include +#include "fsfw/tmtcpacket/SpacePacketReader.h" + +TEST_CASE("CCSDS Reader", "[ccsds-reader]") { + +} \ No newline at end of file diff --git a/unittests/tmtcpacket/TestPusTm.cpp b/unittests/tmtcpacket/testPusTm.cpp similarity index 100% rename from unittests/tmtcpacket/TestPusTm.cpp rename to unittests/tmtcpacket/testPusTm.cpp From 5fffbd4a905494303efba9790ca67e4cf4e5c0ef Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 18:36:41 +0200 Subject: [PATCH 055/532] start PUS TC refactoring --- CMakeLists.txt | 4 +- src/fsfw/serialize.h | 16 +- src/fsfw/tcdistribution/TcPacketCheckPUS.cpp | 2 +- src/fsfw/tmtcpacket/SpacePacketIF.h | 11 ++ src/fsfw/tmtcpacket/SpacePacketReader.cpp | 48 ------ src/fsfw/tmtcpacket/SpacePacketReader.h | 55 ------- src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt | 5 +- ...acketDeserializer.cpp => PusTcCreator.cpp} | 2 +- ...{TcPacketDeserializer.h => PusTcCreator.h} | 4 +- src/fsfw/tmtcpacket/pus/tc/PusTcIF.h | 53 ++++-- src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp | 47 ++++++ src/fsfw/tmtcpacket/pus/tc/PusTcReader.h | 82 ++++++++++ src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h | 31 +--- .../tmtcpacket/pus/tc/TcPacketPusBase.cpp | 20 --- src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h | 151 ------------------ .../tmtcpacket/pus/tc/TcPacketStoredBase.h | 1 + src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h | 2 +- src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt | 9 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp | 68 -------- src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h | 129 --------------- .../tmtcpacket/pus/tm/TmPacketStoredBase.h | 1 - .../tmtcpacket/pus/tm/TmPacketStoredPusA.cpp | 73 --------- .../tmtcpacket/pus/tm/TmPacketStoredPusA.h | 69 -------- src/fsfw/tmtcservices/PusVerificationReport.h | 2 +- unittests/tmtcpacket/testCcsdsCreator.cpp | 1 - unittests/tmtcpacket/testCcsdsReader.cpp | 5 +- 26 files changed, 213 insertions(+), 678 deletions(-) rename src/fsfw/tmtcpacket/pus/tc/{TcPacketDeserializer.cpp => PusTcCreator.cpp} (71%) rename src/fsfw/tmtcpacket/pus/tc/{TcPacketDeserializer.h => PusTcCreator.h} (64%) create mode 100644 src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp create mode 100644 src/fsfw/tmtcpacket/pus/tc/PusTcReader.h delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 237f186a..5601d202 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,8 +136,8 @@ set(FSFW_DUMMY_TGT fsfw-dummy) add_library( ${LIB_FSFW_NAME} src/fsfw/tmtcpacket/SpacePacketIF.h - src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h - src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp + src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h + src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp src/fsfw/tmtcpacket/pus/tc/PusTcIF.h src/fsfw/tmtcpacket/SpacePacketCreator.h src/fsfw/tmtcpacket/SpacePacketCreator.cpp) diff --git a/src/fsfw/serialize.h b/src/fsfw/serialize.h index edd7c9c7..b74c3c32 100644 --- a/src/fsfw/serialize.h +++ b/src/fsfw/serialize.h @@ -1,10 +1,10 @@ -#ifndef FSFW_INC_FSFW_SERIALIZE_H_ -#define FSFW_INC_FSFW_SERIALIZE_H_ +#ifndef FSFW_SERIALIZE_H_ +#define FSFW_SERIALIZE_H_ -#include "src/core/serialize/EndianConverter.h" -#include "src/core/serialize/SerialArrayListAdapter.h" -#include "src/core/serialize/SerialBufferAdapter.h" -#include "src/core/serialize/SerialLinkedListAdapter.h" -#include "src/core/serialize/SerializeElement.h" +#include "serialize/EndianConverter.h" +#include "serialize/SerialArrayListAdapter.h" +#include "serialize/SerialBufferAdapter.h" +#include "serialize/SerialLinkedListAdapter.h" +#include "serialize/SerializeElement.h" -#endif /* FSFW_INC_FSFW_SERIALIZE_H_ */ +#endif /* FSFW_SERIALIZE_H_ */ diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp index 304c644a..963bece7 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp @@ -3,7 +3,7 @@ #include "fsfw/globalfunctions/CRC.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h" +#include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" #include "fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h" #include "fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.h" #include "fsfw/tmtcservices/VerificationCodes.h" diff --git a/src/fsfw/tmtcpacket/SpacePacketIF.h b/src/fsfw/tmtcpacket/SpacePacketIF.h index 291ba8f9..1b2bfb90 100644 --- a/src/fsfw/tmtcpacket/SpacePacketIF.h +++ b/src/fsfw/tmtcpacket/SpacePacketIF.h @@ -3,6 +3,8 @@ #include +#include "ccsds_header.h" + namespace ccsds { enum PacketType : uint8_t { TM = 0, TC = 1 }; @@ -35,6 +37,15 @@ constexpr uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeade class SpacePacketIF { public: + /** + * This definition defines the CRC size in byte. + */ + static const uint8_t CRC_SIZE = 2; + /** + * This is the minimum size of a SpacePacket. + */ + static const uint16_t MINIMUM_SIZE = sizeof(CCSDSPrimaryHeader) + CRC_SIZE; + virtual ~SpacePacketIF() = default; /** diff --git a/src/fsfw/tmtcpacket/SpacePacketReader.cpp b/src/fsfw/tmtcpacket/SpacePacketReader.cpp index a1bcd465..cdb00082 100644 --- a/src/fsfw/tmtcpacket/SpacePacketReader.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketReader.cpp @@ -10,58 +10,10 @@ SpacePacketReader::SpacePacketReader(const uint8_t* setAddress) { SpacePacketReader::~SpacePacketReader() = default; -ReturnValue_t SpacePacketReader::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, - uint16_t apid, uint16_t sequenceCount) { - if (data == nullptr) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "SpacePacketBase::initSpacePacketHeader: Data pointer is invalid" << std::endl; -#else - sif::printWarning("SpacePacketBase::initSpacePacketHeader: Data pointer is invalid!\n"); -#endif -#endif - return HasReturnvaluesIF::RETURN_FAILED; - } - // reset header to zero: - memset(data, 0, sizeof(this->data->header)); - // Set TC/TM bit. - data->header.packetIdHAndVersion = ((isTelecommand ? 1 : 0)) << 4; - // Set secondaryHeader bit - data->header.packetIdHAndVersion |= ((hasSecondaryHeader ? 1 : 0)) << 3; - this->setApid(apid); - // Always initialize as standalone packets. - data->header.packetSeqCtrlH = 0b11000000; - setPacketSequenceCount(sequenceCount); - return HasReturnvaluesIF::RETURN_OK; -} - inline uint16_t SpacePacketReader::getPacketId() const { return ((this->data->header.packetIdHAndVersion) << 8) + this->data->header.packetIdL; } -void SpacePacketReader::setApid(uint16_t setAPID) { - // Use first three bits of new APID, but keep rest of packet id as it was (see specification). - this->data->header.packetIdHAndVersion = - (this->data->header.packetIdHAndVersion & 0b11111000) | ((setAPID & 0x0700) >> 8); - this->data->header.packetIdL = (setAPID & 0x00FF); -} - -void SpacePacketReader::setSequenceFlags(uint8_t sequenceflags) { - this->data->header.packetSeqCtrlH &= 0x3F; - this->data->header.packetSeqCtrlH |= sequenceflags << 6; -} - -void SpacePacketReader::setPacketSequenceCount(uint16_t new_count) { - this->data->header.packetSeqCtrlH = (this->data->header.packetSeqCtrlH & 0b11000000) | - (((new_count % ccsds::LIMIT_SEQUENCE_COUNT) & 0x3F00) >> 8); - this->data->header.packetSeqCtrlL = ((new_count % ccsds::LIMIT_SEQUENCE_COUNT) & 0x00FF); -} - -void SpacePacketReader::setPacketDataLength(uint16_t new_length) { - this->data->header.packetLenH = ((new_length & 0xFF00) >> 8); - this->data->header.packetLenL = (new_length & 0x00FF); -} - size_t SpacePacketReader::getFullSize() { // +1 is done because size in packet data length field is: size of data field -1 return this->getPacketDataLen() + sizeof(this->data->header) + 1; diff --git a/src/fsfw/tmtcpacket/SpacePacketReader.h b/src/fsfw/tmtcpacket/SpacePacketReader.h index 7fc88577..81151fab 100644 --- a/src/fsfw/tmtcpacket/SpacePacketReader.h +++ b/src/fsfw/tmtcpacket/SpacePacketReader.h @@ -19,16 +19,6 @@ * standards. */ -/** - * This struct defines the data structure of a Space Packet when accessed - * via a pointer. - * @ingroup tmtcpackets - */ -struct SpacePacketPointer { - CCSDSPrimaryHeader header; - uint8_t packet_data; -}; - /** * This class is the basic data handler for any CCSDS Space Packet * compatible Telecommand and Telemetry packet. @@ -50,16 +40,6 @@ class SpacePacketReader : public SpacePacketIF, public RedirectableDataPointerIF SpacePacketPointer* data; public: - /** - * This definition defines the CRC size in byte. - */ - static const uint8_t CRC_SIZE = 2; - /** - * This is the minimum size of a SpacePacket. - */ - static const uint16_t MINIMUM_SIZE = sizeof(CCSDSPrimaryHeader) + CRC_SIZE; - SpacePacketReader(uint16_t apid, ccsds::PacketType packetType, bool secHeader, uint16_t seqCount, - uint16_t dataLen); /** * This is the default constructor. * It sets its internal data pointer to the address passed. @@ -71,45 +51,10 @@ class SpacePacketReader : public SpacePacketIF, public RedirectableDataPointerIF */ ~SpacePacketReader() override; - ReturnValue_t initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid, - uint16_t sequenceCount = 0); - [[nodiscard]] uint16_t getPacketId() const override; [[nodiscard]] uint16_t getPacketSeqCtrl() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; - /** - * Sets the APID of a packet, which are the lowest 11 bit of the packet - * id. - * @param The APID to set. The highest five bits of the parameter are - * ignored. - */ - void setApid(uint16_t setAPID); - - /** - * Sets the sequence flags of a packet, which are bit 17 and 18 in the space packet header. - * @param The sequence flags to set - */ - void setSequenceFlags(uint8_t sequenceflags); - - /** - * Sets the packet sequence count, which are the lowest 14 bit of the - * packet sequence control field. - * setCount is modulo-divided by \c LIMIT_SEQUENCE_COUNT to avoid overflows. - * @param setCount The value to set the count to. - */ - void setPacketSequenceCount(uint16_t setCount); - - /** - * Sets the packet data length, which is the fifth and sixth byte of the - * CCSDS Primary Header. - * @param setLength The value of the length to set. It must fit the true - * CCSDS packet data length . The packet data length is - * the size of every kind of data \b after the CCSDS - * Primary Header \b -1. - */ - void setPacketDataLength(uint16_t setLength); - // Helper methods: /** * This method returns a raw uint8_t pointer to the packet. diff --git a/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt b/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt index 09c63bfd..c37c2c55 100644 --- a/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt @@ -1,3 +1,4 @@ target_sources( - ${LIB_FSFW_NAME} PRIVATE TcPacketPusBase.cpp TcPacketPus.cpp - TcPacketStoredBase.cpp TcPacketStoredPus.cpp) + ${LIB_FSFW_NAME} + PRIVATE PusTcReader.cpp TcPacketPus.cpp PusTcReader.cpp PusTcCreator.cpp + TcPacketStoredBase.cpp TcPacketStoredPus.cpp) diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp similarity index 71% rename from src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp rename to src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index a93db348..c73f7a93 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -1,3 +1,3 @@ -#include "TcPacketDeserializer.h" +#include "PusTcCreator.h" TcPacketDeserializer::TcPacketDeserializer(const uint8_t *data, size_t maxSize) {} diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h similarity index 64% rename from src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h rename to src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 1e2e7bba..275cc28f 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -4,9 +4,9 @@ #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" #include "fsfw/tmtcpacket/SpacePacketIF.h" -class TcPacketDeserializer : public SpacePacketIF, public RedirectableDataPointerIF { +class PusTcCreator : public SpacePacketIF { public: - TcPacketDeserializer(const uint8_t* data, size_t maxSize); + PusTcCreator(const uint8_t* data, size_t maxSize); private: }; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h index 3a2eaddc..54afd946 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h @@ -3,17 +3,50 @@ #include -class PusTcIF { - public: - virtual ~PusTcIF() = default; +#include "TcPacketPus.h" + +namespace ecss { + +enum AckField { + //! No acknowledgements are expected. + ACK_NONE = 0b0000, + //! Acknowledgements on acceptance are expected. + ACK_ACCEPTANCE = 0b0001, + //! Acknowledgements on start are expected. + ACK_START = 0b0010, + //! Acknowledgements on step are expected. + ACK_STEP = 0b0100, + //! Acknowledgement on completion are expected. + ACK_COMPLETION = 0b1000 +}; + +static constexpr uint8_t ACK_ALL = ACK_ACCEPTANCE | ACK_START | ACK_STEP | ACK_COMPLETION; + +/** + * This struct defines a byte-wise structured PUS C ata Field Header. + * Any optional fields in the header must be added or removed here. + * Currently, the Source Id field is present with one byte. + * No spare byte support for now. + * @ingroup tmtcpackets + */ +struct PusTcDataFieldHeader { + // Version and ACK byte, Service Byte, Subservice Byte, 2 byte Source ID + static constexpr size_t MIN_LEN = 5; + uint8_t pusVersion; + uint8_t ackFlags; + uint8_t serviceType; + uint8_t serviceSubtype; + uint16_t sourceId; +}; + +} // namespace ecss + +class PusTcIF : public SpacePacketIF { + public: + ~PusTcIF() override = default; + static const uint16_t MIN_LEN = + (sizeof(CCSDSPrimaryHeader) + ecss::PusTcDataFieldHeader::MIN_LEN + 2); - /** - * This command returns the CCSDS Secondary Header Flag. - * It shall always be zero for PUS Packets. This is the - * highest bit of the first byte of the Data Field Header. - * @return the CCSDS Secondary Header Flag - */ - [[nodiscard]] virtual uint8_t getSecondaryHeaderFlag() const = 0; /** * This command returns the TC Packet PUS Version Number. * The version number of ECSS PUS 2003 is 1. diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp new file mode 100644 index 00000000..e2a66e73 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp @@ -0,0 +1,47 @@ +#include "PusTcReader.h" + +#include + +#include "fsfw/globalfunctions/CRC.h" +#include "fsfw/globalfunctions/arrayprinter.h" +#include "fsfw/serialize.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + +PusTcReader::PusTcReader(const uint8_t* setData, size_t size) : spReader(setData), maxSize(size) { + pointers.spHeaderStart = setData; +} + +PusTcReader::~PusTcReader() = default; + +ReturnValue_t PusTcReader::parseData() { + if (maxSize < sizeof(CCSDSPrimaryHeader)) { + return SerializeIF::BUFFER_TOO_SHORT; + } + pointers.secHeaderStart = pointers.spHeaderStart + sizeof(CCSDSPrimaryHeader); + // TODO: No support for spare bytes yet + pointers.userDataStart = pointers.secHeaderStart + ecss::PusTcDataFieldHeader::MIN_LEN; +} + +uint8_t PusTcReader::getAcknowledgeFlags() const { return 0; } +uint8_t PusTcReader::getService() const { return 0; } +uint8_t PusTcReader::getSubService() const { return 0; } +uint16_t PusTcReader::getSourceId() const { return 0; } +const uint8_t* PusTcReader::getApplicationData() const { return nullptr; } +uint16_t PusTcReader::getApplicationDataSize() const { return 0; } +uint16_t PusTcReader::getErrorControl() const { return 0; } + +uint16_t PusTcReader::getPacketId() const { return spReader.getPacketId(); } +uint16_t PusTcReader::getPacketSeqCtrl() const { return spReader.getPacketSeqCtrl(); } +uint16_t PusTcReader::getPacketDataLen() const { return spReader.getPacketDataLen(); } +uint8_t PusTcReader::getPusVersion() const { return spReader.getVersion(); } + +/* +void PusTcReader::print() { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::info << "TcPacketBase::print:" << std::endl; +#else + sif::printInfo("TcPacketBase::print:\n"); +#endif + arrayprinter::print(getWholeData(), getFullSize()); +} +*/ \ No newline at end of file diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h new file mode 100644 index 00000000..43ab26ce --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h @@ -0,0 +1,82 @@ +#ifndef TMTCPACKET_PUS_TCPACKETBASE_H_ +#define TMTCPACKET_PUS_TCPACKETBASE_H_ + +#include + +#include "PusTcIF.h" +#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" + +/** + * This class is the basic data handler for any ECSS PUS Telecommand packet. + * + * In addition to #SpacePacketBase, the class provides methods to handle + * the standardized entries of the PUS TC Packet Data Field Header. + * It does not contain the packet data itself but a pointer to the + * data must be set on instantiation. An invalid pointer may cause + * damage, as no getter method checks data validity. Anyway, a NULL + * check can be performed by making use of the getWholeData method. + * @ingroup tmtcpackets + */ +class PusTcReader : public PusTcIF, public RedirectableDataPointerIF { + friend class TcPacketStoredBase; + + public: + /** + * This is the default constructor. + * It sets its internal data pointer to the address passed and also + * forwards the data pointer to the parent SpacePacketBase class. + * @param setData The position where the packet data lies. + */ + explicit PusTcReader(const uint8_t* setData, size_t size); + + ReturnValue_t parseData(); + /** + * This is the empty default destructor. + */ + ~PusTcReader() override; + + /** + * This is a debugging helper method that prints the whole packet content + * to the screen. + */ + void print(); + [[nodiscard]] uint16_t getPacketId() const override; + [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketDataLen() const override; + [[nodiscard]] uint8_t getPusVersion() const override; + [[nodiscard]] uint8_t getAcknowledgeFlags() const override; + [[nodiscard]] uint8_t getService() const override; + [[nodiscard]] uint8_t getSubService() const override; + [[nodiscard]] uint16_t getSourceId() const override; + [[nodiscard]] const uint8_t* getApplicationData() const override; + [[nodiscard]] uint16_t getApplicationDataSize() const override; + [[nodiscard]] uint16_t getErrorControl() const override; + + protected: + /** + * With this method, the packet data pointer can be redirected to another + * location. + * This call overwrites the parent's setData method to set both its + * @c tc_data pointer and the parent's @c data pointer. + * + * @param p_data A pointer to another PUS Telecommand Packet. + */ + ReturnValue_t setData(uint8_t* pData, size_t maxSize, void* args) override = 0; + SpacePacketReader spReader; + /** + * This struct defines the data structure of a Space Packet when accessed + * via a pointer. + * @ingroup tmtcpackets + */ + struct PusTcPointers { + const uint8_t* spHeaderStart; + const uint8_t* secHeaderStart; + const uint8_t* userDataStart; + }; + + PusTcPointers pointers{}; + size_t maxSize = 0; +}; + +#endif /* TMTCPACKET_PUS_TCPACKETBASE_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h index b630cfee..d7c8d743 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h @@ -4,44 +4,25 @@ #include #include "../definitions.h" -#include "TcPacketPusBase.h" +#include "PusTcReader.h" #include "fsfw/FSFW.h" #include "fsfw/tmtcpacket/ccsds_header.h" -/** - * This struct defines a byte-wise structured PUS TC A Data Field Header. - * Any optional fields in the header must be added or removed here. - * Currently, the Source Id field is present with one byte. - * @ingroup tmtcpackets - */ -struct PUSTcDataFieldHeader { - uint8_t versionTypeAck; - uint8_t serviceType; - uint8_t serviceSubtype; -#if FSFW_USE_PUS_C_TELECOMMANDS == 1 - uint8_t sourceIdH; - uint8_t sourceIdL; -#else - uint8_t sourceId; -#endif -}; - /** * This struct defines the data structure of a PUS Telecommand A packet when * accessed via a pointer. * @ingroup tmtcpackets */ +/* struct TcPacketPointer { - CCSDSPrimaryHeader primary; - PUSTcDataFieldHeader dataField; - uint8_t appData; + CCSDSPrimaryHeader primary; + PusTcDataFieldHeader dataField; + uint8_t appData; }; + */ class TcPacketPus : public TcPacketPusBase { public: - static const uint16_t TC_PACKET_MIN_SIZE = - (sizeof(CCSDSPrimaryHeader) + sizeof(PUSTcDataFieldHeader) + 2); - /** * Initialize a PUS A telecommand packet which already exists. You can also * create an empty (invalid) object by passing nullptr as the data pointer diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp deleted file mode 100644 index 3d7ff888..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "TcPacketPusBase.h" - -#include - -#include "fsfw/globalfunctions/CRC.h" -#include "fsfw/globalfunctions/arrayprinter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" - -TcPacketPusBase::TcPacketPusBase(const uint8_t* setData) : SpacePacketReader(setData) {} - -TcPacketPusBase::~TcPacketPusBase() {} - -void TcPacketPusBase::print() { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TcPacketBase::print:" << std::endl; -#else - sif::printInfo("TcPacketBase::print:\n"); -#endif - arrayprinter::print(getWholeData(), getFullSize()); -} diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h deleted file mode 100644 index ce30cb18..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h +++ /dev/null @@ -1,151 +0,0 @@ -#ifndef TMTCPACKET_PUS_TCPACKETBASE_H_ -#define TMTCPACKET_PUS_TCPACKETBASE_H_ - -#include - -#include - -#include "fsfw/tmtcpacket/SpacePacketReader.h" - -/** - * This class is the basic data handler for any ECSS PUS Telecommand packet. - * - * In addition to #SpacePacketBase, the class provides methods to handle - * the standardized entries of the PUS TC Packet Data Field Header. - * It does not contain the packet data itself but a pointer to the - * data must be set on instantiation. An invalid pointer may cause - * damage, as no getter method checks data validity. Anyway, a NULL - * check can be performed by making use of the getWholeData method. - * @ingroup tmtcpackets - */ -class TcPacketPusBase : public SpacePacketReader { - friend class TcPacketStoredBase; - - public: - enum AckField { - //! No acknowledgements are expected. - ACK_NONE = 0b0000, - //! Acknowledgements on acceptance are expected. - ACK_ACCEPTANCE = 0b0001, - //! Acknowledgements on start are expected. - ACK_START = 0b0010, - //! Acknowledgements on step are expected. - ACK_STEP = 0b0100, - //! Acknowledfgement on completion are expected. - ACK_COMPLETION = 0b1000 - }; - - static constexpr uint8_t ACK_ALL = ACK_ACCEPTANCE | ACK_START | ACK_STEP | ACK_COMPLETION; - - /** - * This is the default constructor. - * It sets its internal data pointer to the address passed and also - * forwards the data pointer to the parent SpacePacketBase class. - * @param setData The position where the packet data lies. - */ - TcPacketPusBase(const uint8_t* setData); - /** - * This is the empty default destructor. - */ - virtual ~TcPacketPusBase(); - - /** - * This command returns the CCSDS Secondary Header Flag. - * It shall always be zero for PUS Packets. This is the - * highest bit of the first byte of the Data Field Header. - * @return the CCSDS Secondary Header Flag - */ - virtual uint8_t getSecondaryHeaderFlag() const = 0; - /** - * This command returns the TC Packet PUS Version Number. - * The version number of ECSS PUS 2003 is 1. - * It consists of the second to fourth highest bits of the - * first byte. - * @return - */ - virtual uint8_t getPusVersionNumber() const = 0; - /** - * This is a getter for the packet's Ack field, which are the lowest four - * bits of the first byte of the Data Field Header. - * - * It is packed in a uint8_t variable. - * @return The packet's PUS Ack field. - */ - virtual uint8_t getAcknowledgeFlags() const = 0; - /** - * This is a getter for the packet's PUS Service ID, which is the second - * byte of the Data Field Header. - * @return The packet's PUS Service ID. - */ - virtual uint8_t getService() const = 0; - /** - * This is a getter for the packet's PUS Service Subtype, which is the - * third byte of the Data Field Header. - * @return The packet's PUS Service Subtype. - */ - virtual uint8_t getSubService() const = 0; - /** - * The source ID can be used to have an additional identifier, e.g. for different ground - * station. - * @return - */ - virtual uint16_t getSourceId() const = 0; - - /** - * This is a getter for a pointer to the packet's Application data. - * - * These are the bytes that follow after the Data Field Header. They form - * the packet's application data. - * @return A pointer to the PUS Application Data. - */ - virtual const uint8_t* getApplicationData() const = 0; - /** - * This method calculates the size of the PUS Application data field. - * - * It takes the information stored in the CCSDS Packet Data Length field - * and subtracts the Data Field Header size and the CRC size. - * @return The size of the PUS Application Data (without Error Control - * field) - */ - virtual uint16_t getApplicationDataSize() const = 0; - /** - * This getter returns the Error Control Field of the packet. - * - * The field is placed after any possible Application Data. If no - * Application Data is present there's still an Error Control field. It is - * supposed to be a 16bit-CRC. - * @return The PUS Error Control - */ - virtual uint16_t getErrorControl() const = 0; - /** - * With this method, the Error Control Field is updated to match the - * current content of the packet. - */ - virtual void setErrorControl() = 0; - - /** - * Calculate full packet length from application data length. - * @param appDataLen - * @return - */ - virtual size_t calculateFullPacketLength(size_t appDataLen) const = 0; - - /** - * This is a debugging helper method that prints the whole packet content - * to the screen. - */ - void print(); - - protected: - /** - * With this method, the packet data pointer can be redirected to another - * location. - * This call overwrites the parent's setData method to set both its - * @c tc_data pointer and the parent's @c data pointer. - * - * @param p_data A pointer to another PUS Telecommand Packet. - */ - virtual ReturnValue_t setData(uint8_t* pData, size_t maxSize, void* args = nullptr) override = 0; -}; - -#endif /* TMTCPACKET_PUS_TCPACKETBASE_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h index 4d27565a..d0a15cc4 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h @@ -1,6 +1,7 @@ #ifndef TMTCPACKET_PUS_TCPACKETSTORED_H_ #define TMTCPACKET_PUS_TCPACKETSTORED_H_ +#include "PusTcReader.h" #include "TcPacketStoredIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h index 7ac8c331..1fce33d2 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h @@ -3,7 +3,7 @@ #include -#include "TcPacketPusBase.h" +#include "PusTcReader.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/storagemanager/storeAddress.h" diff --git a/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt b/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt index ded74ce2..22fbebcd 100644 --- a/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt @@ -1,9 +1,4 @@ target_sources( ${LIB_FSFW_NAME} - PRIVATE TmPacketStoredPusA.cpp - TmPacketStoredPusC.cpp - TmPacketPusA.cpp - TmPacketPusC.cpp - TmPacketStoredBase.cpp - TmPacketBase.cpp - TmPacketMinimal.cpp) + PRIVATE TmPacketStoredPusC.cpp TmPacketPusC.cpp TmPacketStoredBase.cpp + TmPacketBase.cpp TmPacketMinimal.cpp) diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp deleted file mode 100644 index 8ccb87b5..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "TmPacketPusA.h" - -#include - -#include "../definitions.h" -#include "TmPacketBase.h" -#include "fsfw/globalfunctions/CRC.h" -#include "fsfw/globalfunctions/arrayprinter.h" -#include "fsfw/objectmanager/ObjectManagerIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/timemanager/CCSDSTime.h" - -TmPacketPusA::TmPacketPusA(uint8_t* setData) : TmPacketBase(setData) { - tmData = reinterpret_cast(setData); -} - -TmPacketPusA::~TmPacketPusA() { - // Nothing to do. -} - -uint8_t TmPacketPusA::getService() { return tmData->data_field.service_type; } - -uint8_t TmPacketPusA::getSubService() { return tmData->data_field.service_subtype; } - -uint8_t* TmPacketPusA::getSourceData() { return &tmData->data; } - -uint16_t TmPacketPusA::getSourceDataSize() { - return SpacePacketReader::getPacketDataLen() - sizeof(tmData->data_field) - CRC_SIZE + 1; -} - -ReturnValue_t TmPacketPusA::setData(uint8_t* p_Data, size_t maxSize, void* args) { - ReturnValue_t result = SpacePacketReader::setData(p_Data, maxSize, args); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - tmData = reinterpret_cast(const_cast(p_Data)); - return HasReturnvaluesIF::RETURN_OK; -} - -size_t TmPacketPusA::getPacketMinimumSize() const { return TM_PACKET_MIN_SIZE; } - -uint16_t TmPacketPusA::getDataFieldSize() { return sizeof(PUSTmDataFieldHeaderPusA); } - -uint8_t* TmPacketPusA::getPacketTimeRaw() const { return tmData->data_field.time; } - -void TmPacketPusA::initializeTmPacket(uint16_t apid, uint8_t service, uint8_t subservice, - uint8_t packetSubcounter) { - // Set primary header: - initSpacePacketHeader(false, true, apid); - // Set data Field Header: - // First, set to zero. - memset(&tmData->data_field, 0, sizeof(tmData->data_field)); - - tmData->data_field.version_type_ack = pus::PusVersion::PUS_A_VERSION << 4; - tmData->data_field.service_type = service; - tmData->data_field.service_subtype = subservice; - tmData->data_field.subcounter = packetSubcounter; - // Timestamp packet - if (TmPacketBase::checkAndSetStamper()) { - timeStamper->addTimeStamp(tmData->data_field.time, sizeof(tmData->data_field.time)); - } -} - -void TmPacketPusA::setSourceDataSize(uint16_t size) { - setPacketDataLength(size + sizeof(PUSTmDataFieldHeaderPusA) + CRC_SIZE - 1); -} - -size_t TmPacketPusA::getTimestampSize() const { return sizeof(tmData->data_field.time); } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h deleted file mode 100644 index 6808a8d6..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h +++ /dev/null @@ -1,129 +0,0 @@ -#ifndef FSFW_TMTCPACKET_PUS_TMPACKETPUSA_H_ -#define FSFW_TMTCPACKET_PUS_TMPACKETPUSA_H_ - -#include "TmPacketBase.h" -#include "fsfw/objectmanager/SystemObjectIF.h" -#include "fsfw/timemanager/Clock.h" -#include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/SpacePacketReader.h" - -namespace Factory { -void setStaticFrameworkObjectIds(); -} - -/** - * This struct defines a byte-wise structured PUS TM Data Field Header. - * Any optional fields in the header must be added or removed here. - * Currently, no Destination field is present, but an eigth-byte representation - * for a time tag. - * @ingroup tmtcpackets - */ -struct PUSTmDataFieldHeaderPusA { - uint8_t version_type_ack; - uint8_t service_type; - uint8_t service_subtype; - uint8_t subcounter; - // uint8_t destination; - uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE]; -}; - -/** - * This struct defines the data structure of a PUS Telecommand Packet when - * accessed via a pointer. - * @ingroup tmtcpackets - */ -struct TmPacketPointerPusA { - CCSDSPrimaryHeader primary; - PUSTmDataFieldHeaderPusA data_field; - uint8_t data; -}; - -/** - * PUS A packet implementation - * @ingroup tmtcpackets - */ -class TmPacketPusA : public TmPacketBase { - friend void(Factory::setStaticFrameworkObjectIds)(); - - public: - /** - * This constant defines the minimum size of a valid PUS Telemetry Packet. - */ - static const uint32_t TM_PACKET_MIN_SIZE = - (sizeof(CCSDSPrimaryHeader) + sizeof(PUSTmDataFieldHeaderPusA) + 2); - //! Maximum size of a TM Packet in this mission. - static const uint32_t MISSION_TM_PACKET_MAX_SIZE = fsfwconfig::FSFW_MAX_TM_PACKET_SIZE; - - /** - * This is the default constructor. - * It sets its internal data pointer to the address passed and also - * forwards the data pointer to the parent SpacePacketBase class. - * @param set_address The position where the packet data lies. - */ - TmPacketPusA(uint8_t* setData); - /** - * This is the empty default destructor. - */ - virtual ~TmPacketPusA(); - - /* TmPacketBase implementations */ - uint8_t getService() override; - uint8_t getSubService() override; - uint8_t* getSourceData() override; - uint16_t getSourceDataSize() override; - uint16_t getDataFieldSize() override; - - /** - * Returns a raw pointer to the beginning of the time field. - * @return Raw pointer to time field. - */ - uint8_t* getPacketTimeRaw() const override; - size_t getTimestampSize() const override; - - size_t getPacketMinimumSize() const override; - - protected: - /** - * A pointer to a structure which defines the data structure of - * the packet's data. - * - * To be hardware-safe, all elements are of byte size. - */ - TmPacketPointerPusA* tmData; - - /** - * Initializes the Tm Packet header. - * Does set the timestamp (to now), but not the error control field. - * @param apid APID used. - * @param service PUS Service - * @param subservice PUS Subservice - * @param packetSubcounter Additional subcounter used. - */ - void initializeTmPacket(uint16_t apid, uint8_t service, uint8_t subservice, - uint8_t packetSubcounter); - - /** - * With this method, the packet data pointer can be redirected to another - * location. - * - * This call overwrites the parent's setData method to set both its - * @c tc_data pointer and the parent's @c data pointer. - * - * @param p_data A pointer to another PUS Telemetry Packet. - */ - ReturnValue_t setData(uint8_t* pData, size_t maxSize, void* args = nullptr) override; - - /** - * In case data was filled manually (almost never the case). - * @param size Size of source data (without CRC and data filed header!). - */ - void setSourceDataSize(uint16_t size); - - /** - * Checks if a time stamper is available and tries to set it if not. - * @return Returns false if setting failed. - */ - bool checkAndSetStamper(); -}; - -#endif /* FSFW_TMTCPACKET_PUS_TMPACKETPUSA_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.h index 1732f000..85363ee9 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.h @@ -2,7 +2,6 @@ #define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_ #include "TmPacketBase.h" -#include "TmPacketPusA.h" #include "TmPacketStoredBase.h" #include "fsfw/FSFW.h" #include "fsfw/internalerror/InternalErrorReporterIF.h" diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp deleted file mode 100644 index 37ba63f3..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.h" - -#include - -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tmtcservices/TmTcMessage.h" - -TmPacketStoredPusA::TmPacketStoredPusA(store_address_t setAddress) - : TmPacketStoredBase(setAddress), TmPacketPusA(nullptr) {} - -TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service, uint8_t subservice, - uint8_t packetSubcounter, const uint8_t *data, uint32_t size, - const uint8_t *headerData, uint32_t headerSize) - : TmPacketPusA(nullptr) { - storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; - if (not TmPacketStoredBase::checkAndSetStore()) { - return; - } - uint8_t *pData = nullptr; - size_t sizeToReserve = getPacketMinimumSize() + size + headerSize; - ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData); - - if (returnValue != store->RETURN_OK) { - handleStoreFailure("A", returnValue, sizeToReserve); - return; - } - setData(pData, sizeToReserve); - initializeTmPacket(apid, service, subservice, packetSubcounter); - memcpy(getSourceData(), headerData, headerSize); - memcpy(getSourceData() + headerSize, data, size); - setPacketDataLength(size + headerSize + sizeof(PUSTmDataFieldHeaderPusA) + CRC_SIZE - 1); -} - -TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service, uint8_t subservice, - uint8_t packetSubcounter, SerializeIF *content, - SerializeIF *header) - : TmPacketPusA(nullptr) { - storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; - if (not TmPacketStoredBase::checkAndSetStore()) { - return; - } - size_t sourceDataSize = 0; - if (content != nullptr) { - sourceDataSize += content->getSerializedSize(); - } - if (header != nullptr) { - sourceDataSize += header->getSerializedSize(); - } - uint8_t *pData = nullptr; - size_t sizeToReserve = getPacketMinimumSize() + sourceDataSize; - ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData); - if (returnValue != store->RETURN_OK) { - handleStoreFailure("A", returnValue, sizeToReserve); - return; - } - setData(pData, sizeToReserve); - initializeTmPacket(apid, service, subservice, packetSubcounter); - uint8_t *putDataHere = getSourceData(); - size_t size = 0; - if (header != nullptr) { - header->serialize(&putDataHere, &size, sourceDataSize, SerializeIF::Endianness::BIG); - } - if (content != nullptr) { - content->serialize(&putDataHere, &size, sourceDataSize, SerializeIF::Endianness::BIG); - } - setPacketDataLength(sourceDataSize + sizeof(PUSTmDataFieldHeaderPusA) + CRC_SIZE - 1); -} - -uint8_t *TmPacketStoredPusA::getAllTmData() { return getWholeData(); } - -ReturnValue_t TmPacketStoredPusA::setData(uint8_t *newPointer, size_t maxSize, void *args) { - return TmPacketPusA::setData(newPointer, maxSize); -} diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.h deleted file mode 100644 index f2db99e9..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTORED_PUSA_H_ -#define FSFW_TMTCPACKET_PUS_TMPACKETSTORED_PUSA_H_ - -#include - -#include "TmPacketPusA.h" -#include "TmPacketStoredBase.h" - -/** - * This class generates a ECSS PUS A Telemetry packet within a given - * intermediate storage. - * As most packets are passed between tasks with the help of a storage - * anyway, it seems logical to create a Packet-In-Storage access class - * which saves the user almost all storage handling operation. - * Packets can both be newly created with the class and be "linked" to - * packets in a store with the help of a storeAddress. - * @ingroup tmtcpackets - */ -class TmPacketStoredPusA : public TmPacketStoredBase, public TmPacketPusA { - public: - /** - * This is a default constructor which does not set the data pointer. - * However, it does try to set the packet store. - */ - TmPacketStoredPusA(store_address_t setAddress); - /** - * With this constructor, new space is allocated in the packet store and - * a new PUS Telemetry Packet is created there. - * Packet Application Data passed in data is copied into the packet. - * The Application data is passed in two parts, first a header, then a - * data field. This allows building a Telemetry Packet from two separate - * data sources. - * @param apid Sets the packet's APID field. - * @param service Sets the packet's Service ID field. - * This specifies the source service. - * @param subservice Sets the packet's Service Subtype field. - * This specifies the source sub-service. - * @param packet_counter Sets the Packet counter field of this packet - * @param data The payload data to be copied to the - * Application Data Field - * @param size The amount of data to be copied. - * @param headerData The header Data of the Application field, - * will be copied in front of data - * @param headerSize The size of the headerDataF - */ - TmPacketStoredPusA(uint16_t apid, uint8_t service, uint8_t subservice, uint8_t packet_counter = 0, - const uint8_t* data = nullptr, uint32_t size = 0, - const uint8_t* headerData = nullptr, uint32_t headerSize = 0); - /** - * Another ctor to directly pass structured content and header data to the - * packet to avoid additional buffers. - */ - TmPacketStoredPusA(uint16_t apid, uint8_t service, uint8_t subservice, uint8_t packet_counter, - SerializeIF* content, SerializeIF* header = nullptr); - - uint8_t* getAllTmData() override; - - private: - /** - * Implementation required by base class - * @param newPointer - * @param maxSize - * @param args - * @return - */ - ReturnValue_t setData(uint8_t* newPointer, size_t maxSize, void* args = nullptr) override; -}; - -#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTORED_PUSA_H_ */ diff --git a/src/fsfw/tmtcservices/PusVerificationReport.h b/src/fsfw/tmtcservices/PusVerificationReport.h index 60c01d55..d84f4df3 100644 --- a/src/fsfw/tmtcservices/PusVerificationReport.h +++ b/src/fsfw/tmtcservices/PusVerificationReport.h @@ -4,7 +4,7 @@ #include "VerificationCodes.h" #include "fsfw/ipc/MessageQueueMessage.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h" +#include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" class PusVerificationMessage : public MessageQueueMessage { private: diff --git a/unittests/tmtcpacket/testCcsdsCreator.cpp b/unittests/tmtcpacket/testCcsdsCreator.cpp index fbd73b10..d56669a7 100644 --- a/unittests/tmtcpacket/testCcsdsCreator.cpp +++ b/unittests/tmtcpacket/testCcsdsCreator.cpp @@ -4,7 +4,6 @@ #include "fsfw/tmtcpacket/SpacePacketCreator.h" - TEST_CASE("CCSDS Creator", "[ccsds-creator]") { SpacePacketCreator base = SpacePacketCreator(ccsds::PacketType::TC, true, 0x02, ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); diff --git a/unittests/tmtcpacket/testCcsdsReader.cpp b/unittests/tmtcpacket/testCcsdsReader.cpp index d63f4cf0..b8a6f3dd 100644 --- a/unittests/tmtcpacket/testCcsdsReader.cpp +++ b/unittests/tmtcpacket/testCcsdsReader.cpp @@ -1,6 +1,5 @@ #include + #include "fsfw/tmtcpacket/SpacePacketReader.h" -TEST_CASE("CCSDS Reader", "[ccsds-reader]") { - -} \ No newline at end of file +TEST_CASE("CCSDS Reader", "[ccsds-reader]") {} \ No newline at end of file From 6c636661b6592ce4f4e7f715fcb6173d545f34ce Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 19 Jul 2022 18:13:25 +0200 Subject: [PATCH 056/532] a lot of refactoring --- CMakeLists.txt | 11 +- src/fsfw/cfdp/CFDPHandler.h | 2 +- .../internalerror/InternalErrorReporterIF.h | 2 +- src/fsfw/pus/Service9TimeManagement.cpp | 2 +- src/fsfw/returnvalues/FwClassIds.h | 2 +- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 2 +- src/fsfw/tcdistribution/CCSDSDistributorIF.h | 2 +- src/fsfw/tcdistribution/CFDPDistributor.cpp | 15 +- src/fsfw/tcdistribution/CFDPDistributor.h | 10 +- src/fsfw/tcdistribution/CFDPDistributorIF.h | 2 +- src/fsfw/tcdistribution/CMakeLists.txt | 9 +- ...TcPacketCheckIF.h => CcsdsPacketCheckIF.h} | 14 +- .../tcdistribution/CcsdsPacketCheckerBase.cpp | 22 +++ .../tcdistribution/CcsdsPacketCheckerBase.h | 17 ++ ...cPacketCheckCFDP.h => CfdpPacketChecker.h} | 12 +- ...{PUSDistributor.cpp => PusDistributor.cpp} | 49 +++--- .../{PUSDistributor.h => PusDistributor.h} | 17 +- src/fsfw/tcdistribution/PusPacketChecker.cpp | 44 +++++ src/fsfw/tcdistribution/PusPacketChecker.h | 38 +++++ src/fsfw/tcdistribution/TcDistributor.cpp | 2 +- src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp | 13 +- src/fsfw/tcdistribution/TcPacketCheckPUS.cpp | 44 ----- src/fsfw/tcdistribution/TcPacketCheckPUS.h | 61 ------- src/fsfw/tcdistribution/definitions.h | 24 +++ src/fsfw/tmstorage/TmStorePackets.h | 2 +- src/fsfw/tmtcpacket/CMakeLists.txt | 4 +- src/fsfw/tmtcpacket/PacketStorageHelper.cpp | 25 +++ src/fsfw/tmtcpacket/PacketStorageHelper.h | 63 ++++++++ src/fsfw/tmtcpacket/ReadablePacketIF.h | 13 ++ .../tmtcpacket/RedirectableDataPointerIF.h | 6 +- src/fsfw/tmtcpacket/SpacePacketCreator.cpp | 41 ++--- src/fsfw/tmtcpacket/SpacePacketCreator.h | 18 ++- src/fsfw/tmtcpacket/SpacePacketIF.h | 13 ++ src/fsfw/tmtcpacket/SpacePacketReader.cpp | 45 +++--- src/fsfw/tmtcpacket/SpacePacketReader.h | 42 ++--- src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp | 11 +- src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp | 22 +-- src/fsfw/tmtcpacket/cfdp/CMakeLists.txt | 2 +- .../cfdp/{CFDPPacket.h => CfdpPacket.h} | 6 +- ...{CFDPPacketStored.h => CfdpPacketStored.h} | 18 +-- .../tmtcpacket/packetmatcher/ApidMatcher.h | 13 +- .../packetmatcher/PacketMatchTree.cpp | 52 +++--- .../packetmatcher/PacketMatchTree.h | 17 +- .../tmtcpacket/packetmatcher/ServiceMatcher.h | 19 ++- .../packetmatcher/SubserviceMatcher.h | 21 +-- .../pus/PacketTimestampInterpreterIF.h | 6 +- src/fsfw/tmtcpacket/pus/PusIF.h | 52 ++++++ src/fsfw/tmtcpacket/pus/definitions.h | 6 +- src/fsfw/tmtcpacket/pus/tc.h | 1 - src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt | 8 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 74 ++++++++- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 38 ++++- src/fsfw/tmtcpacket/pus/tc/PusTcIF.h | 55 +------ src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp | 57 +++++-- src/fsfw/tmtcpacket/pus/tc/PusTcReader.h | 25 +-- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h | 88 +++++----- src/fsfw/tmtcpacket/pus/tc/TcPacketStored.cpp | 1 + src/fsfw/tmtcpacket/pus/tc/TcPacketStored.h | 10 ++ .../tmtcpacket/pus/tc/TcPacketStoredBase.cpp | 111 ++++++------- .../tmtcpacket/pus/tc/TcPacketStoredBase.h | 150 +++++++++--------- .../tmtcpacket/pus/tc/TcPacketStoredPus.cpp | 78 --------- .../tmtcpacket/pus/tc/TcPacketStoredPus.h | 48 ------ src/fsfw/tmtcpacket/pus/tm.h | 2 +- src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt | 6 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 10 ++ src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 31 ++++ src/fsfw/tmtcpacket/pus/tm/PusTmIF.h | 20 +++ src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp | 45 ++++++ .../tm/{TmPacketMinimal.h => PusTmMinimal.h} | 65 ++++---- src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp | 3 + src/fsfw/tmtcpacket/pus/tm/PusTmReader.h | 7 + .../tmtcpacket/pus/tm/TmPacketMinimal.cpp | 40 ----- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp | 3 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 23 ++- src/fsfw/tmtcservices/PusServiceBase.h | 20 ++- .../tmtcservices/VerificationReporter.cpp | 9 +- src/fsfw/tmtcservices/VerificationReporter.h | 6 +- 78 files changed, 1134 insertions(+), 835 deletions(-) rename src/fsfw/tcdistribution/{TcPacketCheckIF.h => CcsdsPacketCheckIF.h} (69%) create mode 100644 src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp create mode 100644 src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h rename src/fsfw/tcdistribution/{TcPacketCheckCFDP.h => CfdpPacketChecker.h} (63%) rename src/fsfw/tcdistribution/{PUSDistributor.cpp => PusDistributor.cpp} (75%) rename src/fsfw/tcdistribution/{PUSDistributor.h => PusDistributor.h} (84%) create mode 100644 src/fsfw/tcdistribution/PusPacketChecker.cpp create mode 100644 src/fsfw/tcdistribution/PusPacketChecker.h delete mode 100644 src/fsfw/tcdistribution/TcPacketCheckPUS.cpp delete mode 100644 src/fsfw/tcdistribution/TcPacketCheckPUS.h create mode 100644 src/fsfw/tcdistribution/definitions.h create mode 100644 src/fsfw/tmtcpacket/PacketStorageHelper.cpp create mode 100644 src/fsfw/tmtcpacket/PacketStorageHelper.h create mode 100644 src/fsfw/tmtcpacket/ReadablePacketIF.h rename src/fsfw/tmtcpacket/cfdp/{CFDPPacket.h => CfdpPacket.h} (82%) rename src/fsfw/tmtcpacket/cfdp/{CFDPPacketStored.h => CfdpPacketStored.h} (72%) create mode 100644 src/fsfw/tmtcpacket/pus/PusIF.h create mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketStored.cpp create mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketStored.h delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.h create mode 100644 src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp create mode 100644 src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h create mode 100644 src/fsfw/tmtcpacket/pus/tm/PusTmIF.h create mode 100644 src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp rename src/fsfw/tmtcpacket/pus/tm/{TmPacketMinimal.h => PusTmMinimal.h} (54%) create mode 100644 src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp create mode 100644 src/fsfw/tmtcpacket/pus/tm/PusTmReader.h delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5601d202..e59eb4c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,14 +133,7 @@ option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF) set(FSFW_TEST_TGT fsfw-tests) set(FSFW_DUMMY_TGT fsfw-dummy) -add_library( - ${LIB_FSFW_NAME} - src/fsfw/tmtcpacket/SpacePacketIF.h - src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h - src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp - src/fsfw/tmtcpacket/pus/tc/PusTcIF.h - src/fsfw/tmtcpacket/SpacePacketCreator.h - src/fsfw/tmtcpacket/SpacePacketCreator.cpp) +add_library(${LIB_FSFW_NAME}) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION @@ -175,7 +168,7 @@ if(FSFW_BUILD_TESTS) configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h) project(${FSFW_TEST_TGT} CXX C) - add_executable(${FSFW_TEST_TGT} unittests/tmtcpacket/testCcsdsReader.cpp) + add_executable(${FSFW_TEST_TGT}) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) diff --git a/src/fsfw/cfdp/CFDPHandler.h b/src/fsfw/cfdp/CFDPHandler.h index abbac6b6..3e6f0429 100644 --- a/src/fsfw/cfdp/CFDPHandler.h +++ b/src/fsfw/cfdp/CFDPHandler.h @@ -45,7 +45,7 @@ class CFDPHandler : public ExecutableObjectIF, * The current CFDP packet to be processed. * It is deleted after handleRequest was executed. */ - CFDPPacketStored currentPacket; + CfdpPacketStored currentPacket; static object_id_t packetSource; diff --git a/src/fsfw/internalerror/InternalErrorReporterIF.h b/src/fsfw/internalerror/InternalErrorReporterIF.h index 61bb52e7..aa917d21 100644 --- a/src/fsfw/internalerror/InternalErrorReporterIF.h +++ b/src/fsfw/internalerror/InternalErrorReporterIF.h @@ -12,7 +12,7 @@ */ class InternalErrorReporterIF { public: - virtual ~InternalErrorReporterIF() {} + virtual ~InternalErrorReporterIF() = default; /** * @brief Function to be called if a message queue could not be sent. * @details OSAL Implementations should call this function to indicate that diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 86eef93a..6cd46f3a 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -25,7 +25,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { ReturnValue_t Service9TimeManagement::setTime() { Clock::TimeOfDay_t timeToSet; - TimePacket timePacket(currentPacket.getApplicationData(), currentPacket.getApplicationDataSize()); + TimePacket timePacket(currentPacket.getUserData(), currentPacket.getUserDataSize()); ReturnValue_t result = CCSDSTime::convertFromCcsds(&timeToSet, timePacket.getTime(), timePacket.getTimeSize()); if (result != RETURN_OK) { diff --git a/src/fsfw/returnvalues/FwClassIds.h b/src/fsfw/returnvalues/FwClassIds.h index f5f57276..50efd9c5 100644 --- a/src/fsfw/returnvalues/FwClassIds.h +++ b/src/fsfw/returnvalues/FwClassIds.h @@ -34,7 +34,7 @@ enum : uint8_t { FIFO_CLASS, // FF MESSAGE_PROXY, // MQP TRIPLE_REDUNDACY_CHECK, // TRC - TC_PACKET_CHECK, // TCC + PACKET_CHECK, // TCC PACKET_DISTRIBUTION, // TCD ACCEPTS_TELECOMMANDS_IF, // PUS DEVICE_SERVICE_BASE, // DSB diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index a32cbc75..f18e55de 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -40,7 +40,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { #endif return queueMap.end(); } - SpacePacketReader currentPacket(packet); + SpacePacketReader currentPacket(packet, size); #if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1 sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex diff --git a/src/fsfw/tcdistribution/CCSDSDistributorIF.h b/src/fsfw/tcdistribution/CCSDSDistributorIF.h index d1c88118..da4a943f 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributorIF.h +++ b/src/fsfw/tcdistribution/CCSDSDistributorIF.h @@ -34,7 +34,7 @@ class CCSDSDistributorIF { /** * The empty virtual destructor. */ - virtual ~CCSDSDistributorIF() {} + virtual ~CCSDSDistributorIF() = default; }; #endif /* FSFW_TCDISTRIBUTION_CCSDSDISTRIBUTORIF_H_ */ diff --git a/src/fsfw/tcdistribution/CFDPDistributor.cpp b/src/fsfw/tcdistribution/CFDPDistributor.cpp index d8be1543..5aa84d44 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.cpp +++ b/src/fsfw/tcdistribution/CFDPDistributor.cpp @@ -2,7 +2,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/tcdistribution/CCSDSDistributorIF.h" -#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h" +#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h" #ifndef FSFW_CFDP_DISTRIBUTOR_DEBUGGING #define FSFW_CFDP_DISTRIBUTOR_DEBUGGING 1 @@ -16,7 +16,7 @@ CFDPDistributor::CFDPDistributor(uint16_t setApid, object_id_t setObjectId, tcStatus(RETURN_FAILED), packetSource(setPacketSource) {} -CFDPDistributor::~CFDPDistributor() {} +CFDPDistributor::~CFDPDistributor() = default; CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { #if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 @@ -29,13 +29,13 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { storeId.packetIndex); #endif #endif - TcMqMapIter queueMapIt = this->queueMap.end(); + auto queueMapIt = this->queueMap.end(); if (this->currentPacket == nullptr) { return queueMapIt; } this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); - if (currentPacket->getWholeData() != nullptr) { - tcStatus = checker.checkPacket(currentPacket); + if (currentPacket->getFullData() != nullptr) { + tcStatus = checker.checkPacket(currentPacket, currentPacket->getFullPacketLen()); if (tcStatus != HasReturnvaluesIF::RETURN_OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -121,14 +121,13 @@ MessageQueueId_t CFDPDistributor::getRequestQueue() { return tcQueue->getId(); } uint16_t CFDPDistributor::getIdentifier() { return this->apid; } ReturnValue_t CFDPDistributor::initialize() { - currentPacket = new CFDPPacketStored(); + currentPacket = new CfdpPacketStored(); if (currentPacket == nullptr) { // Should not happen, memory allocation failed! return ObjectManagerIF::CHILD_INIT_FAILED; } - CCSDSDistributorIF* ccsdsDistributor = - ObjectManager::instance()->get(packetSource); + auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); if (ccsdsDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl; diff --git a/src/fsfw/tcdistribution/CFDPDistributor.h b/src/fsfw/tcdistribution/CFDPDistributor.h index 2a901021..e7776f1b 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.h +++ b/src/fsfw/tcdistribution/CFDPDistributor.h @@ -1,10 +1,10 @@ #ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ #define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ -#include +#include #include "../returnvalues/HasReturnvaluesIF.h" -#include "../tmtcpacket/cfdp/CFDPPacketStored.h" +#include "../tmtcpacket/cfdp/CfdpPacketStored.h" #include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../tmtcservices/VerificationReporter.h" #include "CFDPDistributorIF.h" @@ -31,7 +31,7 @@ class CFDPDistributor : public TcDistributor, /** * The destructor is empty. */ - virtual ~CFDPDistributor(); + ~CFDPDistributor() override; ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) override; MessageQueueId_t getRequestQueue() override; ReturnValue_t initialize() override; @@ -42,8 +42,8 @@ class CFDPDistributor : public TcDistributor, /** * The currently handled packet is stored here. */ - CFDPPacketStored* currentPacket = nullptr; - TcPacketCheckCFDP checker; + CfdpPacketStored* currentPacket = nullptr; + CfdpPacketChecker checker; /** * With this variable, the current check status is stored to generate * acceptance messages later. diff --git a/src/fsfw/tcdistribution/CFDPDistributorIF.h b/src/fsfw/tcdistribution/CFDPDistributorIF.h index 3c1836f1..3f048bbf 100644 --- a/src/fsfw/tcdistribution/CFDPDistributorIF.h +++ b/src/fsfw/tcdistribution/CFDPDistributorIF.h @@ -13,7 +13,7 @@ class CFDPDistributorIF { /** * The empty virtual destructor. */ - virtual ~CFDPDistributorIF() {} + virtual ~CFDPDistributorIF() = default; /** * With this method, Handlers can register themselves at the CFDP Distributor. * @param handler A pointer to the registering Handler. diff --git a/src/fsfw/tcdistribution/CMakeLists.txt b/src/fsfw/tcdistribution/CMakeLists.txt index ab32c509..9cc3d170 100644 --- a/src/fsfw/tcdistribution/CMakeLists.txt +++ b/src/fsfw/tcdistribution/CMakeLists.txt @@ -1,4 +1,9 @@ target_sources( ${LIB_FSFW_NAME} - PRIVATE CCSDSDistributor.cpp PUSDistributor.cpp TcDistributor.cpp - TcPacketCheckPUS.cpp TcPacketCheckCFDP.cpp CFDPDistributor.cpp) + PRIVATE CCSDSDistributor.cpp + PusDistributor.cpp + TcDistributor.cpp + PusPacketChecker.cpp + TcPacketCheckCFDP.cpp + CFDPDistributor.cpp + CcsdsPacketCheckerBase.cpp) diff --git a/src/fsfw/tcdistribution/TcPacketCheckIF.h b/src/fsfw/tcdistribution/CcsdsPacketCheckIF.h similarity index 69% rename from src/fsfw/tcdistribution/TcPacketCheckIF.h rename to src/fsfw/tcdistribution/CcsdsPacketCheckIF.h index a9ec14a2..55288ae4 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckIF.h +++ b/src/fsfw/tcdistribution/CcsdsPacketCheckIF.h @@ -1,7 +1,9 @@ #ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ #define FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ -#include "../returnvalues/HasReturnvaluesIF.h" +#include + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" class SpacePacketReader; @@ -9,22 +11,22 @@ class SpacePacketReader; * This interface is used by PacketCheckers for PUS packets and CFDP packets . * @ingroup tc_distribution */ -class TcPacketCheckIF { +class CcsdsPacketCheckIF { public: /** * The empty virtual destructor. */ - virtual ~TcPacketCheckIF() {} + virtual ~CcsdsPacketCheckIF() = default; /** * This is the actual method to formally check a certain Packet. * The packet's Application Data can not be checked here. * @param current_packet The packet to check * @return - @c RETURN_OK on success. - * - @c INCORRECT_CHECKSUM if checksum is invalid. - * - @c ILLEGAL_APID if APID does not match. + * - @c INCORRECT_CHECKSUM if checksum is invalid. + * - @c ILLEGAL_APID if APID does not match. */ - virtual ReturnValue_t checkPacket(SpacePacketReader* currentPacket) = 0; + virtual ReturnValue_t checkPacket(SpacePacketReader* currentPacket, size_t packetLen) = 0; }; #endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ */ diff --git a/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp b/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp new file mode 100644 index 00000000..8c97f646 --- /dev/null +++ b/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp @@ -0,0 +1,22 @@ +#include "CcsdsPacketCheckerBase.h" + +#include "fsfw/tcdistribution/definitions.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" + +CcsdsPacketCheckerBase::CcsdsPacketCheckerBase(uint16_t apid, ccsds::PacketType packetType_, + uint8_t ccsdsVersion_) + : apid(apid), packetType(packetType_), ccsdsVersion(ccsdsVersion_) {} + +ReturnValue_t CcsdsPacketCheckerBase::checkPacket(SpacePacketReader* currentPacket, + size_t packetLen) { + if (currentPacket->getApid() != apid) { + return tcdistrib::INVALID_APID; + } + if (currentPacket->getVersion() != ccsdsVersion) { + return tcdistrib::INVALID_CCSDS_VERSION; + } + if (currentPacket->getPacketType() != packetType) { + return tcdistrib::INVALID_PACKET_TYPE; + } + return HasReturnvaluesIF::RETURN_OK; +} \ No newline at end of file diff --git a/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h b/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h new file mode 100644 index 00000000..f5a9b317 --- /dev/null +++ b/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h @@ -0,0 +1,17 @@ +#ifndef FSFW_TESTS_CCSDSPACKETCHECKERBASE_H +#define FSFW_TESTS_CCSDSPACKETCHECKERBASE_H + +#include "CcsdsPacketCheckIF.h" +#include "fsfw/tmtcpacket/SpacePacketIF.h" + +class CcsdsPacketCheckerBase : public CcsdsPacketCheckIF, public HasReturnvaluesIF { + public: + CcsdsPacketCheckerBase(uint16_t apid, ccsds::PacketType packetType, uint8_t ccsdsVersion = 0b000); + ReturnValue_t checkPacket(SpacePacketReader* currentPacket, size_t packetLen) override; + + protected: + uint16_t apid; + ccsds::PacketType packetType; + uint8_t ccsdsVersion; +}; +#endif // FSFW_TESTS_CCSDSPACKETCHECKERBASE_H diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.h b/src/fsfw/tcdistribution/CfdpPacketChecker.h similarity index 63% rename from src/fsfw/tcdistribution/TcPacketCheckCFDP.h rename to src/fsfw/tcdistribution/CfdpPacketChecker.h index 5a4abd4f..0838efc2 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.h +++ b/src/fsfw/tcdistribution/CfdpPacketChecker.h @@ -1,16 +1,16 @@ #ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_ #define FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_ -#include "TcPacketCheckIF.h" +#include "CcsdsPacketCheckIF.h" #include "fsfw/FSFW.h" -class CFDPPacketStored; +class CfdpPacketStored; /** * This class performs a formal packet check for incoming CFDP Packets. * @ingroup tc_distribution */ -class TcPacketCheckCFDP : public TcPacketCheckIF, public HasReturnvaluesIF { +class CfdpPacketChecker : public CcsdsPacketCheckIF, public HasReturnvaluesIF { protected: /** * The packet id each correct packet should have. @@ -23,11 +23,11 @@ class TcPacketCheckCFDP : public TcPacketCheckIF, public HasReturnvaluesIF { * The constructor only sets the APID attribute. * @param set_apid The APID to set. */ - TcPacketCheckCFDP(uint16_t setApid); + explicit CfdpPacketChecker(uint16_t setApid); - ReturnValue_t checkPacket(SpacePacketReader* currentPacket) override; + ReturnValue_t checkPacket(SpacePacketReader* currentPacket, size_t packetLen) override; - uint16_t getApid() const; + [[nodiscard]] uint16_t getApid() const; }; #endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_ */ diff --git a/src/fsfw/tcdistribution/PUSDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp similarity index 75% rename from src/fsfw/tcdistribution/PUSDistributor.cpp rename to src/fsfw/tcdistribution/PusDistributor.cpp index dad002a1..5975a7f2 100644 --- a/src/fsfw/tcdistribution/PUSDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -1,23 +1,25 @@ -#include "fsfw/tcdistribution/PUSDistributor.h" +#include "fsfw/tcdistribution/PusDistributor.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tcdistribution/CCSDSDistributorIF.h" +#include "fsfw/tmtcpacket/PacketStorageHelper.h" #include "fsfw/tmtcservices/PusVerificationReport.h" #define PUS_DISTRIBUTOR_DEBUGGING 0 -PUSDistributor::PUSDistributor(uint16_t setApid, object_id_t setObjectId, +PusDistributor::PusDistributor(StorageManagerIF* store_, uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource) : TcDistributor(setObjectId), - checker(setApid), + store(store_), + checker(setApid, ccsds::PacketType::TC), verifyChannel(), tcStatus(RETURN_FAILED), packetSource(setPacketSource) {} -PUSDistributor::~PUSDistributor() = default; +PusDistributor::~PusDistributor() = default; -PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { +PusDistributor::TcMqMapIter PusDistributor::selectDestination() { #if FSFW_CPP_OSTREAM_ENABLED == 1 && PUS_DISTRIBUTOR_DEBUGGING == 1 store_address_t storeId = this->currentMessage.getStorageId()); sif::debug << "PUSDistributor::handlePacket received: " << storeId.poolIndex << ", " @@ -27,9 +29,18 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { if (this->currentPacket == nullptr) { return queueMapIt; } - this->currentPacket->setStoreAddress(this->currentMessage.getStorageId(), currentPacket); - if (currentPacket->getWholeData() != nullptr) { - tcStatus = checker.checkPacket(currentPacket); + // TODO: Need to set the data + const uint8_t* packetPtr = nullptr; + size_t packetLen = 0; + if (store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != + HasReturnvaluesIF::RETURN_OK) { + return queueMapIt; + } + reader.setData(packetPtr, packetLen); + // this->currentPacket->setStoreAddress(this->currentMessage.getStorageId(), currentPacket); + if (reader.getFullData() != nullptr) { + tcStatus = + checker.checkPacket(dynamic_cast(&reader), reader.getFullPacketLen()); if (tcStatus != HasReturnvaluesIF::RETURN_OK) { #if FSFW_VERBOSE_LEVEL >= 1 const char* keyword = "unnamed error"; @@ -53,7 +64,7 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { #endif #endif } - uint32_t queue_id = currentPacket->getService(); + uint32_t queue_id = reader.getService(); queueMapIt = this->queueMap.find(queue_id); } else { tcStatus = PACKET_LOST; @@ -77,7 +88,7 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { } } -ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) { +ReturnValue_t PusDistributor::registerService(AcceptsTelecommandsIF* service) { uint16_t serviceId = service->getIdentifier(); #if PUS_DISTRIBUTOR_DEBUGGING == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -103,29 +114,27 @@ ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) { return HasReturnvaluesIF::RETURN_OK; } -MessageQueueId_t PUSDistributor::getRequestQueue() { return tcQueue->getId(); } +MessageQueueId_t PusDistributor::getRequestQueue() { return tcQueue->getId(); } -ReturnValue_t PUSDistributor::callbackAfterSending(ReturnValue_t queueStatus) { +ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { if (queueStatus != RETURN_OK) { tcStatus = queueStatus; } if (tcStatus != RETURN_OK) { - this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, currentPacket, - tcStatus); + this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, &reader, tcStatus); // A failed packet is deleted immediately after reporting, // otherwise it will block memory. - currentPacket->deletePacket(); + store->deleteData(currentMessage.getStorageId()); return RETURN_FAILED; } else { - this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, currentPacket); + this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, &reader); return RETURN_OK; } } -uint16_t PUSDistributor::getIdentifier() { return checker.getApid(); } +uint16_t PusDistributor::getIdentifier() { return checker.getApid(); } -ReturnValue_t PUSDistributor::initialize() { - currentPacket = new TcPacketStoredPus(); +ReturnValue_t PusDistributor::initialize() { if (currentPacket == nullptr) { // Should not happen, memory allocation failed! return ObjectManagerIF::CHILD_INIT_FAILED; @@ -137,7 +146,7 @@ ReturnValue_t PUSDistributor::initialize() { sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl; sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; #else - sif::printError("PUSDistributor::initialize: Packet source invalid\n"); + sif::printError("PusDistributor::initialize: Packet source invalid\n"); sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); #endif return RETURN_FAILED; diff --git a/src/fsfw/tcdistribution/PUSDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h similarity index 84% rename from src/fsfw/tcdistribution/PUSDistributor.h rename to src/fsfw/tcdistribution/PusDistributor.h index c069c81b..fb916263 100644 --- a/src/fsfw/tcdistribution/PUSDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -2,20 +2,22 @@ #define FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ #include "PUSDistributorIF.h" +#include "PusPacketChecker.h" #include "TcDistributor.h" -#include "TcPacketCheckPUS.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tmtcpacket/pus/tc.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/VerificationReporter.h" +class PacketStorageHelper; + /** * This class accepts PUS Telecommands and forwards them to Application * services. In addition, the class performs a formal packet check and * sends acceptance success or failure messages. * @ingroup tc_distribution */ -class PUSDistributor : public TcDistributor, public PUSDistributorIF, public AcceptsTelecommandsIF { +class PusDistributor : public TcDistributor, public PUSDistributorIF, public AcceptsTelecommandsIF { public: /** * The ctor passes @c set_apid to the checker class and calls the @@ -25,21 +27,23 @@ class PUSDistributor : public TcDistributor, public PUSDistributorIF, public Acc * @param setPacketSource Object ID of the source of TC packets. * Must implement CCSDSDistributorIF. */ - PUSDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource); + PusDistributor(StorageManagerIF* store, uint16_t setApid, object_id_t setObjectId, + object_id_t setPacketSource); /** * The destructor is empty. */ - virtual ~PUSDistributor(); + ~PusDistributor() override; ReturnValue_t registerService(AcceptsTelecommandsIF* service) override; MessageQueueId_t getRequestQueue() override; ReturnValue_t initialize() override; uint16_t getIdentifier() override; protected: + StorageManagerIF* store; /** * This attribute contains the class, that performs a formal packet check. */ - TcPacketCheckPUS checker; + PusPacketChecker checker; /** * With this class, verification messages are sent to the * TC Verification service. @@ -48,7 +52,8 @@ class PUSDistributor : public TcDistributor, public PUSDistributorIF, public Acc /** * The currently handled packet is stored here. */ - TcPacketStoredPus* currentPacket = nullptr; + PacketStorageHelper* currentPacket = nullptr; + PusTcReader reader; /** * With this variable, the current check status is stored to generate diff --git a/src/fsfw/tcdistribution/PusPacketChecker.cpp b/src/fsfw/tcdistribution/PusPacketChecker.cpp new file mode 100644 index 00000000..828303b2 --- /dev/null +++ b/src/fsfw/tcdistribution/PusPacketChecker.cpp @@ -0,0 +1,44 @@ +#include "fsfw/tcdistribution/PusPacketChecker.h" + +#include "fsfw/globalfunctions/CRC.h" +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/tcdistribution/definitions.h" +#include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" + +PusPacketChecker::PusPacketChecker(uint16_t setApid, ccsds::PacketType packetType_, + ecss::PusVersion pusVersion_) + : CcsdsPacketCheckerBase(setApid, packetType_), pusVersion(pusVersion_) {} + +ReturnValue_t PusPacketChecker::checkPacket(PacketCheckIF* pusPacket, size_t packetLen) { + if (pusPacket == nullptr) { + return RETURN_FAILED; + } + // Other primary header fields are checked by base class + if (not pusPacket->hasSecHeader()) { + return tcdistrib::INVALID_SEC_HEADER_FIELD; + } + uint16_t calculated_crc = + CRC::crc16ccitt(pusPacket->getFullData(), pusPacket->getFullPacketLen()); + if (calculated_crc != 0) { + return tcdistrib::INCORRECT_CHECKSUM; + } + + // This assumes that the getFullPacketLen version uses the space packet data length field + if (pusPacket->getFullPacketLen() != packetLen) { + return tcdistrib::INCOMPLETE_PACKET; + } + if (pusPacket->getPusVersion() != pusVersion) { + return tcdistrib::INVALID_PUS_VERSION; + } + return RETURN_OK; +} + +uint16_t PusPacketChecker::getApid() const { return apid; } + +ReturnValue_t PusPacketChecker::checkPacket(SpacePacketReader* currentPacket, size_t packetLen) { + ReturnValue_t result = CcsdsPacketCheckerBase::checkPacket(currentPacket, packetLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return checkPacket(dynamic_cast(currentPacket), packetLen); +} diff --git a/src/fsfw/tcdistribution/PusPacketChecker.h b/src/fsfw/tcdistribution/PusPacketChecker.h new file mode 100644 index 00000000..fe341378 --- /dev/null +++ b/src/fsfw/tcdistribution/PusPacketChecker.h @@ -0,0 +1,38 @@ +#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ +#define FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ + +#include "CcsdsPacketCheckIF.h" +#include "CcsdsPacketCheckerBase.h" +#include "fsfw/FSFW.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tmtcpacket/pus/definitions.h" +#include "fsfw/tmtcservices/PusVerificationReport.h" + +class PacketCheckIF : public ReadablePacketIF, public PusIF {}; + +/** + * This class performs a formal packet check for incoming PUS Telecommand Packets. + * Currently, it only checks if the APID and CRC are correct. + * @ingroup tc_distribution + */ +class PusPacketChecker : public CcsdsPacketCheckerBase { + public: + /** + * The constructor only sets the APID attribute. + * @param set_apid The APID to set. + */ + PusPacketChecker(uint16_t setApid, ccsds::PacketType packetType, + ecss::PusVersion = ecss::PusVersion::PUS_C); + + ReturnValue_t checkPacket(PacketCheckIF* currentPacket, size_t packetLen); + + [[nodiscard]] uint16_t getApid() const; + + protected: + ecss::PusVersion pusVersion; + + private: + ReturnValue_t checkPacket(SpacePacketReader* currentPacket, size_t packetLen) override; +}; + +#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ */ diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index a650546c..600b3ca9 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -24,7 +24,7 @@ ReturnValue_t TcDistributor::performOperation(uint8_t opCode) { } ReturnValue_t TcDistributor::handlePacket() { - TcMqMapIter queueMapIt = this->selectDestination(); + auto queueMapIt = this->selectDestination(); ReturnValue_t returnValue = RETURN_FAILED; if (queueMapIt != this->queueMap.end()) { returnValue = this->tcQueue->sendMessage(queueMapIt->second, &this->currentMessage); diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp index 7d2bfe88..555c85b4 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp @@ -1,9 +1,10 @@ -#include "fsfw/tcdistribution/TcPacketCheckCFDP.h" +#include "fsfw/tcdistribution/CfdpPacketChecker.h" +#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h" -#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h" +CfdpPacketChecker::CfdpPacketChecker(uint16_t setApid) : apid(setApid) {} -TcPacketCheckCFDP::TcPacketCheckCFDP(uint16_t setApid) : apid(setApid) {} +ReturnValue_t CfdpPacketChecker::checkPacket(SpacePacketReader* currentPacket, size_t packetLen) { + return RETURN_OK; +} -ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketReader* currentPacket) { return RETURN_OK; } - -uint16_t TcPacketCheckCFDP::getApid() const { return apid; } +uint16_t CfdpPacketChecker::getApid() const { return apid; } diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp deleted file mode 100644 index 963bece7..00000000 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "fsfw/tcdistribution/TcPacketCheckPUS.h" - -#include "fsfw/globalfunctions/CRC.h" -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" -#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h" -#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.h" -#include "fsfw/tmtcservices/VerificationCodes.h" - -TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid) : apid(setApid) {} - -ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketReader* currentPacket) { - auto* storedPacket = dynamic_cast(currentPacket); - auto* tcPacketBase = dynamic_cast(currentPacket); - if (tcPacketBase == nullptr or storedPacket == nullptr) { - return RETURN_FAILED; - } - uint16_t calculated_crc = - CRC::crc16ccitt(tcPacketBase->getWholeData(), tcPacketBase->getFullSize()); - if (calculated_crc != 0) { - return INCORRECT_CHECKSUM; - } - bool condition = (not tcPacketBase->hasSecHeader()) or - (tcPacketBase->getVersion() != CCSDS_VERSION_NUMBER) or - (not tcPacketBase->isTc()); - if (condition) { - return INCORRECT_PRIMARY_HEADER; - } - if (tcPacketBase->getApid() != this->apid) return ILLEGAL_APID; - - if (not storedPacket->isSizeCorrect()) { - return INCOMPLETE_PACKET; - } - - condition = (tcPacketBase->getSecondaryHeaderFlag() != CCSDS_SECONDARY_HEADER_FLAG) || - (tcPacketBase->getPusVersionNumber() != PUS_VERSION_NUMBER); - if (condition) { - return INCORRECT_SECONDARY_HEADER; - } - return RETURN_OK; -} - -uint16_t TcPacketCheckPUS::getApid() const { return apid; } diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.h b/src/fsfw/tcdistribution/TcPacketCheckPUS.h deleted file mode 100644 index 4804a619..00000000 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ -#define FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ - -#include "TcPacketCheckIF.h" -#include "fsfw/FSFW.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/tmtcservices/PusVerificationReport.h" - -class TcPacketStoredBase; - -/** - * This class performs a formal packet check for incoming PUS Telecommand Packets. - * Currently, it only checks if the APID and CRC are correct. - * @ingroup tc_distribution - */ -class TcPacketCheckPUS : public TcPacketCheckIF, public HasReturnvaluesIF { - protected: - /** - * Describes the version number a packet must have to pass. - */ - static constexpr uint8_t CCSDS_VERSION_NUMBER = 0; - /** - * Describes the secondary header a packet must have to pass. - */ - static constexpr uint8_t CCSDS_SECONDARY_HEADER_FLAG = 0; - /** - * Describes the TC Packet PUS Version Number a packet must have to pass. - */ -#if FSFW_USE_PUS_C_TELECOMMANDS == 1 - static constexpr uint8_t PUS_VERSION_NUMBER = 2; -#else - static constexpr uint8_t PUS_VERSION_NUMBER = 1; -#endif - - /** - * The packet id each correct packet should have. - * It is composed of the APID and some static fields. - */ - uint16_t apid; - - public: - static const uint8_t INTERFACE_ID = CLASS_ID::TC_PACKET_CHECK; - static const ReturnValue_t ILLEGAL_APID = MAKE_RETURN_CODE(0); - static const ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE(1); - static const ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE(2); - static const ReturnValue_t ILLEGAL_PACKET_TYPE = MAKE_RETURN_CODE(3); - static const ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE(4); - static const ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE(5); - static const ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE(6); - /** - * The constructor only sets the APID attribute. - * @param set_apid The APID to set. - */ - TcPacketCheckPUS(uint16_t setApid); - - ReturnValue_t checkPacket(SpacePacketReader* currentPacket) override; - - uint16_t getApid() const; -}; - -#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ */ diff --git a/src/fsfw/tcdistribution/definitions.h b/src/fsfw/tcdistribution/definitions.h new file mode 100644 index 00000000..ce640308 --- /dev/null +++ b/src/fsfw/tcdistribution/definitions.h @@ -0,0 +1,24 @@ +#ifndef FSFW_TMTCPACKET_DEFINITIONS_H +#define FSFW_TMTCPACKET_DEFINITIONS_H + +#include + +#include "fsfw/returnvalues/FwClassIds.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +namespace tcdistrib { +static const uint8_t INTERFACE_ID = CLASS_ID::PACKET_CHECK; +static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(0); +static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(1); +static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(2); +static constexpr ReturnValue_t INVALID_SEC_HEADER_FIELD = MAKE_RETURN_CODE(3); +static constexpr ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE(4); + +static constexpr ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE(5); +static constexpr ReturnValue_t INVALID_PUS_VERSION = MAKE_RETURN_CODE(6); +static constexpr ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE(7); +static constexpr ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE(8); +static constexpr ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE(9); + +}; // namespace tcdistrib +#endif // FSFW_TMTCPACKET_DEFINITIONS_H diff --git a/src/fsfw/tmstorage/TmStorePackets.h b/src/fsfw/tmstorage/TmStorePackets.h index d54b7b52..0640fd36 100644 --- a/src/fsfw/tmstorage/TmStorePackets.h +++ b/src/fsfw/tmstorage/TmStorePackets.h @@ -8,7 +8,7 @@ #include "fsfw/serialize/SerializeElement.h" #include "fsfw/timemanager/CCSDSTime.h" #include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h" +#include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h" #include "tmStorageConf.h" class ServiceSubservice : public SerialLinkedListAdapter { diff --git a/src/fsfw/tmtcpacket/CMakeLists.txt b/src/fsfw/tmtcpacket/CMakeLists.txt index 85376d01..69b3cc48 100644 --- a/src/fsfw/tmtcpacket/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/CMakeLists.txt @@ -1,4 +1,6 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE SpacePacketReader.cpp) +target_sources( + ${LIB_FSFW_NAME} PRIVATE SpacePacketReader.cpp SpacePacketCreator.cpp + PacketStorageHelper.cpp) add_subdirectory(cfdp) add_subdirectory(packetmatcher) diff --git a/src/fsfw/tmtcpacket/PacketStorageHelper.cpp b/src/fsfw/tmtcpacket/PacketStorageHelper.cpp new file mode 100644 index 00000000..89184251 --- /dev/null +++ b/src/fsfw/tmtcpacket/PacketStorageHelper.cpp @@ -0,0 +1,25 @@ +#include "PacketStorageHelper.h" + +#include + +#include "fsfw/serialize.h" +#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/storagemanager/StorageManagerIF.h" + +PacketStorageHelper::PacketStorageHelper(StorageManagerIF* store_, + SerializeIF::Endianness endianness_) + : store(store_), endianness(endianness_) {} + +ReturnValue_t PacketStorageHelper::addPacket(SerializeIF* packet, store_address_t& storeId) { + uint8_t* ptr = nullptr; + size_t serLen = 0; + ReturnValue_t result = store->getFreeElement(&storeId, packet->getSerializedSize(), &ptr); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return packet->serialize(&ptr, &serLen, packet->getSerializedSize(), endianness); +} + +ReturnValue_t PacketStorageHelper::deletePacket(store_address_t storeId) { + return store->deleteData(storeId); +} diff --git a/src/fsfw/tmtcpacket/PacketStorageHelper.h b/src/fsfw/tmtcpacket/PacketStorageHelper.h new file mode 100644 index 00000000..1be75b23 --- /dev/null +++ b/src/fsfw/tmtcpacket/PacketStorageHelper.h @@ -0,0 +1,63 @@ +#ifndef FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_ +#define FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_ + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/serialize.h" +#include "fsfw/storagemanager/storeAddress.h" + +class StorageManagerIF; + +class PacketStorageHelper { + public: + explicit PacketStorageHelper(StorageManagerIF* store, SerializeIF::Endianness endianness); + + ReturnValue_t addPacket(SerializeIF* packet, store_address_t& storeId); + ReturnValue_t deletePacket(store_address_t storeId); + + private: + StorageManagerIF* store; + SerializeIF::Endianness endianness; +}; +// class TcPacketStoredPus : public TcPacketStoredBase, public TcPacketPus { +// public: +// /** +// * With this constructor, new space is allocated in the packet store and +// * a new PUS Telecommand Packet is created there. +// * Packet Application Data passed in data is copied into the packet. +// * @param apid Sets the packet's APID field. +// * @param service Sets the packet's Service ID field. +// * This specifies the destination service. +// * @param subservice Sets the packet's Service Subtype field. +// * This specifies the destination sub-service. +// * @param sequence_count Sets the packet's Source Sequence Count field. +// * @param data The data to be copied to the Application Data Field. +// * @param size The amount of data to be copied. +// * @param ack Set's the packet's Ack field, which specifies +// * number of verification packets returned +// * for this command. +// */ +// TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t subservice, uint8_t sequence_count = +// 0, +// const uint8_t* data = nullptr, size_t size = 0, +// uint8_t ack = TcPacketPusBase::ACK_ALL); +// /** +// * Create stored packet with existing data. +// * @param data +// * @param size +// */ +// TcPacketStoredPus(const uint8_t* data, size_t size); +// /** +// * Create stored packet from existing packet in store +// * @param setAddress +// */ +// TcPacketStoredPus(store_address_t setAddress); +// TcPacketStoredPus(); +// +// ReturnValue_t deletePacket() override; +// TcPacketPusBase* getPacketBase(); +// +// private: +// bool isSizeCorrect() override; +// }; + +#endif /* FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_ */ diff --git a/src/fsfw/tmtcpacket/ReadablePacketIF.h b/src/fsfw/tmtcpacket/ReadablePacketIF.h new file mode 100644 index 00000000..c1287e81 --- /dev/null +++ b/src/fsfw/tmtcpacket/ReadablePacketIF.h @@ -0,0 +1,13 @@ +#ifndef FSFW_TMTCPACKET_SPACEPACKETREADERIF_H +#define FSFW_TMTCPACKET_SPACEPACKETREADERIF_H + +#include "SpacePacketIF.h" + +class ReadablePacketIF { + public: + /** + * This method returns a raw uint8_t pointer to the readable data + */ + virtual const uint8_t* getFullData() = 0; +}; +#endif // FSFW_TMTCPACKET_SPACEPACKETREADERIF_H diff --git a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h index 6eb16edd..56038036 100644 --- a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h +++ b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h @@ -25,9 +25,9 @@ class RedirectableDataPointerIF { * - RETURN_OK if the pointer was set successfully * - RETURN_FAILED on general error of if the maximum size is too small */ - virtual ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) = 0; - virtual ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize) { - return setData(dataPtr, maxSize, nullptr); + virtual ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) = 0; + virtual ReturnValue_t setData(uint8_t* dataPtr, size_t size) { + return setData(dataPtr, size, nullptr); } private: diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp index acc2fea2..ff131059 100644 --- a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp @@ -2,44 +2,32 @@ #include "fsfw/serialize/SerializeAdapter.h" -SpacePacketCreator::SpacePacketCreator(PacketId packetId_, PacketSeqCtrl psc_, uint16_t dataLen_, - uint8_t version_) - : packetId(packetId_), packetSeqCtrl(psc_) { - dataLen = dataLen_; - version = version_; +SpacePacketCreator::SpacePacketCreator(SpacePacketParams ¶ms_) : params(params_) { checkFieldValidity(); } -SpacePacketCreator::SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, - uint16_t apid, ccsds::SequenceFlags seqFlags, - uint16_t seqCount, uint16_t dataLen_, uint8_t version_) - : SpacePacketCreator(PacketId(packetType, secHeaderFlag, apid), - PacketSeqCtrl(seqFlags, seqCount), dataLen_, version_) { - version = version_; - dataLen = dataLen_; -} - -uint16_t SpacePacketCreator::getPacketId() const { return packetId.raw(); } -uint16_t SpacePacketCreator::getPacketSeqCtrl() const { return packetSeqCtrl.raw(); } -uint16_t SpacePacketCreator::getPacketDataLen() const { return dataLen; } +uint16_t SpacePacketCreator::getPacketId() const { return params.packetId.raw(); } +uint16_t SpacePacketCreator::getPacketSeqCtrl() const { return params.packetSeqCtrl.raw(); } +uint16_t SpacePacketCreator::getPacketDataLen() const { return params.dataLen; } ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { if (not isValid()) { return HasReturnvaluesIF::RETURN_FAILED; } - uint16_t packetIdAndVersion = (static_cast(version) << 13) | packetId.raw(); + uint16_t packetIdAndVersion = + (static_cast(params.version) << 13) | params.packetId.raw(); ReturnValue_t result = SerializeAdapter::serialize(&packetIdAndVersion, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - uint16_t pscRaw = packetSeqCtrl.raw(); + uint16_t pscRaw = params.packetSeqCtrl.raw(); result = SerializeAdapter::serialize(&pscRaw, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - return SerializeAdapter::serialize(&dataLen, buffer, size, maxSize, streamEndianness); + return SerializeAdapter::serialize(¶ms.dataLen, buffer, size, maxSize, streamEndianness); } size_t SpacePacketCreator::getSerializedSize() const { return 6; } @@ -55,22 +43,25 @@ ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size } void SpacePacketCreator::setApid(uint16_t apid) { if (apid < ccsds::LIMIT_APID) { - packetId.apid = apid; + params.packetId.apid = apid; } checkFieldValidity(); } void SpacePacketCreator::setSeqCount(uint16_t seqCount) { if (seqCount < ccsds::LIMIT_SEQUENCE_COUNT) { - packetSeqCtrl.seqCount = seqCount; + params.packetSeqCtrl.seqCount = seqCount; } checkFieldValidity(); } -void SpacePacketCreator::setSeqFlags(ccsds::SequenceFlags flags) { packetSeqCtrl.seqFlags = flags; } -void SpacePacketCreator::setDataLen(uint16_t dataLen_) { dataLen = dataLen_; } +void SpacePacketCreator::setSeqFlags(ccsds::SequenceFlags flags) { + params.packetSeqCtrl.seqFlags = flags; +} +void SpacePacketCreator::setDataLen(uint16_t dataLen_) { params.dataLen = dataLen_; } void SpacePacketCreator::checkFieldValidity() { valid = true; - if (packetId.apid > ccsds::LIMIT_APID or packetSeqCtrl.seqCount > ccsds::LIMIT_SEQUENCE_COUNT) { + if (params.packetId.apid > ccsds::LIMIT_APID or + params.packetSeqCtrl.seqCount > ccsds::LIMIT_SEQUENCE_COUNT) { valid = false; } } diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.h b/src/fsfw/tmtcpacket/SpacePacketCreator.h index 9a9a0e2d..9c74046b 100644 --- a/src/fsfw/tmtcpacket/SpacePacketCreator.h +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.h @@ -45,12 +45,21 @@ struct PacketSeqCtrl { uint16_t seqCount; }; -class SpacePacketCreator : public SerializeIF, public SpacePacketIF { +struct SpacePacketParams { + PacketId packetId; + PacketSeqCtrl packetSeqCtrl; + uint16_t dataLen; + uint8_t version = 0b000; +}; + +class SpacePacketCreator : public SpacePacketIF, public SerializeIF { public: + /* SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid, ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen, uint8_t version = 0); - SpacePacketCreator(PacketId packetId, PacketSeqCtrl psc, uint16_t dataLen, uint8_t version = 0); + */ + explicit SpacePacketCreator(SpacePacketParams ¶ms); [[nodiscard]] bool isValid() const; [[nodiscard]] uint16_t getPacketId() const override; [[nodiscard]] uint16_t getPacketSeqCtrl() const override; @@ -73,9 +82,6 @@ class SpacePacketCreator : public SerializeIF, public SpacePacketIF { void checkFieldValidity(); bool valid{}; - PacketId packetId; - PacketSeqCtrl packetSeqCtrl; - uint16_t dataLen; - uint8_t version; + SpacePacketParams params; }; #endif // FSFW_TMTCPACKET_SPACEPACKETCREATOR_H diff --git a/src/fsfw/tmtcpacket/SpacePacketIF.h b/src/fsfw/tmtcpacket/SpacePacketIF.h index 1b2bfb90..21ee4c32 100644 --- a/src/fsfw/tmtcpacket/SpacePacketIF.h +++ b/src/fsfw/tmtcpacket/SpacePacketIF.h @@ -1,6 +1,7 @@ #ifndef FSFW_TMTCPACKET_SPACEPACKETIF_H #define FSFW_TMTCPACKET_SPACEPACKETIF_H +#include #include #include "ccsds_header.h" @@ -72,6 +73,10 @@ class SpacePacketIF { return ((packetId >> 8) & 0b111) | (packetId & 0xFF); } + /** + * Returns the CCSDS version number + * @return + */ [[nodiscard]] virtual uint8_t getVersion() const { uint16_t packetId = getPacketId(); return (packetId >> 13) & 0b111; @@ -97,6 +102,14 @@ class SpacePacketIF { } [[nodiscard]] virtual uint16_t getSequenceCount() const { return getPacketSeqCtrl() & 0x3FFF; } + + /** + * Returns the full packet length based of the packet data length field + * @return + */ + [[nodiscard]] virtual size_t getFullPacketLen() const { + return sizeof(CCSDSPrimaryHeader) + getPacketDataLen() + 1; + } }; #endif // FSFW_TMTCPACKET_SPACEPACKETIF_H diff --git a/src/fsfw/tmtcpacket/SpacePacketReader.cpp b/src/fsfw/tmtcpacket/SpacePacketReader.cpp index cdb00082..2d7d2eda 100644 --- a/src/fsfw/tmtcpacket/SpacePacketReader.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketReader.cpp @@ -2,39 +2,44 @@ #include +#include "fsfw/serialize/SerializeIF.h" #include "fsfw/serviceinterface/ServiceInterface.h" -SpacePacketReader::SpacePacketReader(const uint8_t* setAddress) { - this->data = reinterpret_cast(const_cast(setAddress)); +SpacePacketReader::SpacePacketReader(const uint8_t* setAddress, size_t maxSize_) { + setInternalFields(setAddress, maxSize_); +} + +ReturnValue_t SpacePacketReader::checkLength() const { + if (getFullPacketLen() > maxSize) { + return SerializeIF::STREAM_TOO_SHORT; + } + return HasReturnvaluesIF::RETURN_OK; } SpacePacketReader::~SpacePacketReader() = default; inline uint16_t SpacePacketReader::getPacketId() const { - return ((this->data->header.packetIdHAndVersion) << 8) + this->data->header.packetIdL; + return ((spHeader->packetIdHAndVersion) << 8) + spHeader->packetIdL; } -size_t SpacePacketReader::getFullSize() { - // +1 is done because size in packet data length field is: size of data field -1 - return this->getPacketDataLen() + sizeof(this->data->header) + 1; +const uint8_t* SpacePacketReader::getPacketData() { return packetDataField; } + +ReturnValue_t SpacePacketReader::setData(uint8_t* pData, size_t maxSize_, void* args) { + setInternalFields(pData, maxSize_); } -uint8_t* SpacePacketReader::getWholeData() { return reinterpret_cast(this->data); } - -uint8_t* SpacePacketReader::getPacketData() { return &(data->packet_data); } - -ReturnValue_t SpacePacketReader::setData(uint8_t* pData, size_t maxSize, void* args) { - if (maxSize < 6) { - return HasReturnvaluesIF::RETURN_FAILED; - } - this->data = reinterpret_cast(const_cast(pData)); - return HasReturnvaluesIF::RETURN_OK; -} uint16_t SpacePacketReader::getPacketSeqCtrl() const { - return ((this->data->header.packetSeqCtrlH & 0b00111111) << 8) + - this->data->header.packetSeqCtrlL; + return (spHeader->packetSeqCtrlH << 8) + spHeader->packetSeqCtrlL; } uint16_t SpacePacketReader::getPacketDataLen() const { - return ((this->data->header.packetLenH) << 8) + this->data->header.packetLenL; + return (spHeader->packetLenH << 8) | spHeader->packetIdL; } +void SpacePacketReader::setInternalFields(const uint8_t* data, size_t maxSize_) { + maxSize = maxSize_; + spHeader = reinterpret_cast(data); + packetDataField = data + sizeof(CCSDSPrimaryHeader); +} +const uint8_t* SpacePacketReader::getFullData() { + return reinterpret_cast(spHeader); +}; diff --git a/src/fsfw/tmtcpacket/SpacePacketReader.h b/src/fsfw/tmtcpacket/SpacePacketReader.h index 81151fab..eb1d5c93 100644 --- a/src/fsfw/tmtcpacket/SpacePacketReader.h +++ b/src/fsfw/tmtcpacket/SpacePacketReader.h @@ -5,7 +5,7 @@ #include -#include "SpacePacketIF.h" +#include "ReadablePacketIF.h" #include "ccsds_header.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" @@ -30,22 +30,17 @@ * the most significant bit (from left). * @ingroup tmtcpackets */ -class SpacePacketReader : public SpacePacketIF, public RedirectableDataPointerIF { - protected: - /** - * A pointer to a structure which defines the data structure of - * the packet header. - * To be hardware-safe, all elements are of byte size. - */ - SpacePacketPointer* data; - +class SpacePacketReader : public SpacePacketIF, + public ReadablePacketIF, + public RedirectableDataPointerIF { public: + SpacePacketReader() = default; /** * This is the default constructor. * It sets its internal data pointer to the address passed. * @param set_address The position where the packet data lies. */ - explicit SpacePacketReader(const uint8_t* set_address); + explicit SpacePacketReader(const uint8_t* setAddress, size_t maxSize); /** * No data is allocated, so the destructor is empty. */ @@ -55,14 +50,12 @@ class SpacePacketReader : public SpacePacketIF, public RedirectableDataPointerIF [[nodiscard]] uint16_t getPacketSeqCtrl() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; - // Helper methods: - /** - * This method returns a raw uint8_t pointer to the packet. - * @return A \c uint8_t pointer to the first byte of the CCSDS primary header. - */ - virtual uint8_t* getWholeData(); + const uint8_t* getFullData() override; - uint8_t* getPacketData(); + // Helper methods: + [[nodiscard]] ReturnValue_t checkLength() const; + + const uint8_t* getPacketData(); /** * With this method, the packet data pointer can be redirected to another @@ -70,11 +63,18 @@ class SpacePacketReader : public SpacePacketIF, public RedirectableDataPointerIF * @param p_Data A pointer to another raw Space Packet. */ ReturnValue_t setData(uint8_t* p_Data, size_t maxSize, void* args) override; + + protected: /** - * This method returns the full raw packet size. - * @return The full size of the packet in bytes. + * A pointer to a structure which defines the data structure of + * the packet header. + * To be hardware-safe, all elements are of byte size. */ - size_t getFullSize(); + const CCSDSPrimaryHeader* spHeader{}; + const uint8_t* packetDataField{}; + size_t maxSize = 0; + + void setInternalFields(const uint8_t* data, size_t maxSize); }; #endif /* FSFW_TMTCPACKET_SPACEPACKETBASE_H_ */ diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp index 29b6c561..b4a8534c 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp @@ -1,4 +1,4 @@ -#include "fsfw/tmtcpacket/cfdp/CFDPPacket.h" +#include "fsfw/tmtcpacket/cfdp/CfdpPacket.h" #include @@ -6,15 +6,16 @@ #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serviceinterface/ServiceInterface.h" -CFDPPacket::CFDPPacket(const uint8_t* setData) : SpacePacketReader(setData) {} +CfdpReader::CfdpReader(const uint8_t* setData, size_t maxSize) + : SpacePacketReader(setData, maxSize) {} -CFDPPacket::~CFDPPacket() {} +CfdpReader::~CfdpReader() = default; -void CFDPPacket::print() { +void CfdpReader::print() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "CFDPPacket::print:" << std::endl; #else sif::printInfo("CFDPPacket::print:\n"); #endif - arrayprinter::print(getWholeData(), getFullSize()); + // arrayprinter::print(getWholeData(), getFullSize()); } diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp index 260331ac..e597cf35 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp @@ -1,14 +1,14 @@ -#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h" +#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h" #include "fsfw/objectmanager/ObjectManager.h" -CFDPPacketStored::CFDPPacketStored() : CFDPPacket(nullptr) {} +CfdpPacketStored::CfdpPacketStored() : CfdpReader(nullptr) {} -CFDPPacketStored::CFDPPacketStored(store_address_t setAddress) : CFDPPacket(nullptr) { +CfdpPacketStored::CfdpPacketStored(store_address_t setAddress) : CfdpReader(nullptr) { this->setStoreAddress(setAddress); } -CFDPPacketStored::CFDPPacketStored(const uint8_t* data, size_t size) : CFDPPacket(data) { +CfdpPacketStored::CfdpPacketStored(const uint8_t* data, size_t size) : CfdpReader(data) { if (this->getFullSize() != size) { return; } @@ -24,7 +24,7 @@ CFDPPacketStored::CFDPPacketStored(const uint8_t* data, size_t size) : CFDPPacke } } -ReturnValue_t CFDPPacketStored::deletePacket() { +ReturnValue_t CfdpPacketStored::deletePacket() { ReturnValue_t result = STORE->deleteData(this->storeAddress); this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; // To circumvent size checks @@ -35,7 +35,7 @@ ReturnValue_t CFDPPacketStored::deletePacket() { // CFDPPacket* CFDPPacketStored::getPacketBase() { // return this; // } -void CFDPPacketStored::setStoreAddress(store_address_t setAddress) { +void CfdpPacketStored::setStoreAddress(store_address_t setAddress) { this->storeAddress = setAddress; const uint8_t* tempData = nullptr; size_t tempSize; @@ -52,11 +52,11 @@ void CFDPPacketStored::setStoreAddress(store_address_t setAddress) { } } -store_address_t CFDPPacketStored::getStoreAddress() { return this->storeAddress; } +store_address_t CfdpPacketStored::getStoreAddress() { return this->storeAddress; } -CFDPPacketStored::~CFDPPacketStored() = default; +CfdpPacketStored::~CfdpPacketStored() = default; -ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSize) { +ReturnValue_t CfdpPacketStored::getData(const uint8_t** dataPtr, size_t* dataSize) { return HasReturnvaluesIF::RETURN_OK; } @@ -64,7 +64,7 @@ ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSiz // return HasReturnvaluesIF::RETURN_OK; // } -bool CFDPPacketStored::checkAndSetStore() { +bool CfdpPacketStored::checkAndSetStore() { if (STORE == nullptr) { STORE = ObjectManager::instance()->get(objects::TC_STORE); if (STORE == nullptr) { @@ -77,7 +77,7 @@ bool CFDPPacketStored::checkAndSetStore() { return true; } -bool CFDPPacketStored::isSizeCorrect() { +bool CfdpPacketStored::isSizeCorrect() { const uint8_t* temp_data = nullptr; size_t temp_size; ReturnValue_t status = STORE->getData(this->storeAddress, &temp_data, &temp_size); diff --git a/src/fsfw/tmtcpacket/cfdp/CMakeLists.txt b/src/fsfw/tmtcpacket/cfdp/CMakeLists.txt index 7d20aab8..a0d48465 100644 --- a/src/fsfw/tmtcpacket/cfdp/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/cfdp/CMakeLists.txt @@ -1 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE CFDPPacket.cpp CFDPPacketStored.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE) diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.h b/src/fsfw/tmtcpacket/cfdp/CfdpPacket.h similarity index 82% rename from src/fsfw/tmtcpacket/cfdp/CFDPPacket.h rename to src/fsfw/tmtcpacket/cfdp/CfdpPacket.h index a70c3938..e47d3b6f 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.h +++ b/src/fsfw/tmtcpacket/cfdp/CfdpPacket.h @@ -3,7 +3,7 @@ #include "fsfw/tmtcpacket/SpacePacketReader.h" -class CFDPPacket : public SpacePacketReader { +class CfdpReader : public SpacePacketReader { public: /** * This is the default constructor. @@ -11,11 +11,11 @@ class CFDPPacket : public SpacePacketReader { * forwards the data pointer to the parent SpacePacketBase class. * @param setData The position where the packet data lies. */ - CFDPPacket(const uint8_t* setData); + explicit CfdpReader(const uint8_t* setData, size_t maxSize); /** * This is the empty default destructor. */ - virtual ~CFDPPacket(); + ~CfdpReader() override; /** * This is a debugging helper method that prints the whole packet content diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h b/src/fsfw/tmtcpacket/cfdp/CfdpPacketStored.h similarity index 72% rename from src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h rename to src/fsfw/tmtcpacket/cfdp/CfdpPacketStored.h index 688067f9..54f8e5be 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h +++ b/src/fsfw/tmtcpacket/cfdp/CfdpPacketStored.h @@ -1,25 +1,25 @@ -#ifndef FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_ -#define FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_ +#ifndef FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_ +#define FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_ #include "../pus/tc/TcPacketStoredBase.h" -#include "CFDPPacket.h" +#include "CfdpPacket.h" -class CFDPPacketStored : public CFDPPacket, public TcPacketStoredBase { +class CfdpPacketStored : public CfdpReader { public: /** * Create stored packet with existing data. * @param data * @param size */ - CFDPPacketStored(const uint8_t* data, size_t size); + CfdpPacketStored(const uint8_t* data, size_t size); /** * Create stored packet from existing packet in store * @param setAddress */ - CFDPPacketStored(store_address_t setAddress); - CFDPPacketStored(); + explicit CfdpPacketStored(store_address_t setAddress); + CfdpPacketStored(); - virtual ~CFDPPacketStored(); + ~CfdpPacketStored() override; /** * Getter function for the raw data. @@ -53,4 +53,4 @@ class CFDPPacketStored : public CFDPPacket, public TcPacketStoredBase { bool checkAndSetStore(); }; -#endif /* FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_ */ +#endif /* FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_ */ diff --git a/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h b/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h index 3c835ef8..47e23f1c 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h +++ b/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h @@ -1,18 +1,19 @@ #ifndef FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_ #define FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_ -#include "../../globalfunctions/matching/SerializeableMatcherIF.h" -#include "../../serialize/SerializeAdapter.h" -#include "../../tmtcpacket/pus/tm/TmPacketMinimal.h" +#include "fsfw/globalfunctions/matching/SerializeableMatcherIF.h" +#include "fsfw/serialize/SerializeAdapter.h" +#include "fsfw/tmtcpacket/pus/tm/PusTmIF.h" +#include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h" -class ApidMatcher : public SerializeableMatcherIF { +class ApidMatcher : public SerializeableMatcherIF { private: uint16_t apid; public: explicit ApidMatcher(uint16_t setApid) : apid(setApid) {} - explicit ApidMatcher(TmPacketMinimal* test) : apid(test->getApid()) {} - bool match(TmPacketMinimal* packet) override { + explicit ApidMatcher(PusTmIF* test) : apid(test->getApid()) {} + bool match(PusTmIF* packet) override { if (packet->getApid() == apid) { return true; } else { diff --git a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp index 55fd3227..1ab8729b 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp +++ b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp @@ -1,5 +1,6 @@ #include "fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h" +#include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tmtcpacket/packetmatcher/ApidMatcher.h" #include "fsfw/tmtcpacket/packetmatcher/ServiceMatcher.h" #include "fsfw/tmtcpacket/packetmatcher/SubserviceMatcher.h" @@ -12,33 +13,34 @@ const LocalPool::LocalPoolConfig PacketMatchTree::poolConfig = { {40, sizeof(PacketMatchTree::Node)}}; PacketMatchTree::PacketMatchTree(Node* root) - : MatchTree(root, 2), + : MatchTree(root, 2), factoryBackend(0, poolConfig, false, true), factory(&factoryBackend) {} PacketMatchTree::PacketMatchTree(iterator root) - : MatchTree(root.element, 2), + : MatchTree(root.element, 2), factoryBackend(0, poolConfig, false, true), factory(&factoryBackend) {} PacketMatchTree::PacketMatchTree() - : MatchTree((Node*)NULL, 2), + : MatchTree(nullptr, 2), factoryBackend(0, poolConfig, false, true), factory(&factoryBackend) {} -PacketMatchTree::~PacketMatchTree() {} +PacketMatchTree::~PacketMatchTree() = default; ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t subtype) { // We assume adding APID is always requested. - TmPacketMinimal::TmPacketMinimalPointer data; - data.data_field.service_type = type; - data.data_field.service_subtype = subtype; - TmPacketMinimal testPacket((uint8_t*)&data); + PusTmMinimal::TmPacketMinimalPointer data{}; + data.secHeader.service_type = type; + data.secHeader.service_subtype = subtype; + PusTmMinimal testPacket((uint8_t*)&data); testPacket.setApid(apid); + iterator lastTest; iterator rollback; ReturnValue_t result = - findOrInsertMatch(this->begin(), &testPacket, &lastTest); + findOrInsertMatch(this->begin(), &testPacket, &lastTest); if (result == NEW_NODE_CREATED) { rollback = lastTest; } else if (result != RETURN_OK) { @@ -47,38 +49,36 @@ ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t sub if (type == 0) { // Check if lastTest has no children, otherwise, delete them, // as a more general check is requested. - if (lastTest.left() != this->end()) { + if (lastTest.left() != PacketMatchTree::end()) { removeElementAndAllChildren(lastTest.left()); } return RETURN_OK; } // Type insertion required. - result = - findOrInsertMatch(lastTest.left(), &testPacket, &lastTest); + result = findOrInsertMatch(lastTest.left(), &testPacket, &lastTest); if (result == NEW_NODE_CREATED) { - if (rollback == this->end()) { + if (rollback == PacketMatchTree::end()) { rollback = lastTest; } } else if (result != RETURN_OK) { - if (rollback != this->end()) { + if (rollback != PacketMatchTree::end()) { removeElementAndAllChildren(rollback); } return result; } if (subtype == 0) { - if (lastTest.left() != this->end()) { + if (lastTest.left() != PacketMatchTree::end()) { // See above removeElementAndAllChildren(lastTest.left()); } return RETURN_OK; } // Subtype insertion required. - result = findOrInsertMatch(lastTest.left(), &testPacket, - &lastTest); + result = findOrInsertMatch(lastTest.left(), &testPacket, &lastTest); if (result == NEW_NODE_CREATED) { return RETURN_OK; } else if (result != RETURN_OK) { - if (rollback != this->end()) { + if (rollback != PacketMatchTree::end()) { removeElementAndAllChildren(rollback); } return result; @@ -91,7 +91,7 @@ ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test, iterator* lastTest) { bool attachToBranch = AND; iterator iter = startAt; - while (iter != this->end()) { + while (iter != PacketMatchTree::end()) { bool isMatch = iter->match(test); attachToBranch = OR; *lastTest = iter; @@ -104,11 +104,11 @@ ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test, } // Only reached if nothing was found. SerializeableMatcherIF* newContent = factory.generate(test); - if (newContent == NULL) { + if (newContent == nullptr) { return FULL; } Node* newNode = factory.generate(newContent); - if (newNode == NULL) { + if (newNode == nullptr) { // Need to make sure partially generated content is deleted, otherwise, that's a leak. factory.destroy(static_cast(newContent)); return FULL; @@ -122,10 +122,10 @@ ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test, } ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type, uint8_t subtype) { - TmPacketMinimal::TmPacketMinimalPointer data; - data.data_field.service_type = type; - data.data_field.service_subtype = subtype; - TmPacketMinimal testPacket((uint8_t*)&data); + PusTmMinimal::TmPacketMinimalPointer data; + data.secHeader.service_type = type; + data.secHeader.service_subtype = subtype; + PusTmMinimal testPacket((uint8_t*)&data); testPacket.setApid(apid); iterator foundElement = findMatch(begin(), &testPacket); if (foundElement == this->end()) { @@ -158,7 +158,7 @@ ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type, uint8_t return removeElementAndReconnectChildren(foundElement); } -PacketMatchTree::iterator PacketMatchTree::findMatch(iterator startAt, TmPacketMinimal* test) { +PacketMatchTree::iterator PacketMatchTree::findMatch(iterator startAt, PusTmIF* test) { iterator iter = startAt; while (iter != end()) { bool isMatch = iter->match(test); diff --git a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h index 0cbd4494..fa3aab44 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h +++ b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h @@ -4,21 +4,22 @@ #include "fsfw/container/PlacementFactory.h" #include "fsfw/globalfunctions/matching/MatchTree.h" #include "fsfw/storagemanager/LocalPool.h" -#include "fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h" +#include "fsfw/tmtcpacket/pus/tm/PusTmIF.h" +#include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h" -class PacketMatchTree : public MatchTree, public HasReturnvaluesIF { +class PacketMatchTree : public MatchTree, public HasReturnvaluesIF { public: - PacketMatchTree(Node* root); - PacketMatchTree(iterator root); + explicit PacketMatchTree(Node* root); + explicit PacketMatchTree(iterator root); PacketMatchTree(); - virtual ~PacketMatchTree(); + ~PacketMatchTree() override; ReturnValue_t changeMatch(bool addToMatch, uint16_t apid, uint8_t type = 0, uint8_t subtype = 0); ReturnValue_t addMatch(uint16_t apid, uint8_t type = 0, uint8_t subtype = 0); ReturnValue_t removeMatch(uint16_t apid, uint8_t type = 0, uint8_t subtype = 0); ReturnValue_t initialize(); protected: - ReturnValue_t cleanUpElement(iterator position); + ReturnValue_t cleanUpElement(iterator position) override; private: static const uint8_t N_POOLS = 4; @@ -29,7 +30,7 @@ class PacketMatchTree : public MatchTree, public HasReturnvalu static const uint16_t N_ELEMENTS[N_POOLS]; template ReturnValue_t findOrInsertMatch(iterator startAt, VALUE_T test, iterator* lastTest); - iterator findMatch(iterator startAt, TmPacketMinimal* test); + iterator findMatch(iterator startAt, PusTmIF* test); }; -#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_ */ +#endif /* FSFW_TMTCPACKET_PACKETMATCHER_PACKETMATCHTREE_H_ */ diff --git a/src/fsfw/tmtcpacket/packetmatcher/ServiceMatcher.h b/src/fsfw/tmtcpacket/packetmatcher/ServiceMatcher.h index 752c0354..6ccd9a6b 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/ServiceMatcher.h +++ b/src/fsfw/tmtcpacket/packetmatcher/ServiceMatcher.h @@ -3,16 +3,16 @@ #include "../../globalfunctions/matching/SerializeableMatcherIF.h" #include "../../serialize/SerializeAdapter.h" -#include "../pus/tm/TmPacketMinimal.h" +#include "../pus/tm/PusTmMinimal.h" -class ServiceMatcher : public SerializeableMatcherIF { +class ServiceMatcher : public SerializeableMatcherIF { private: uint8_t service; public: - ServiceMatcher(uint8_t setService) : service(setService) {} - ServiceMatcher(TmPacketMinimal* test) : service(test->getService()) {} - bool match(TmPacketMinimal* packet) { + explicit ServiceMatcher(uint8_t setService) : service(setService) {} + explicit ServiceMatcher(PusTmIF* test) : service(test->getService()) {} + bool match(PusTmIF* packet) override { if (packet->getService() == service) { return true; } else { @@ -20,11 +20,14 @@ class ServiceMatcher : public SerializeableMatcherIF { } } ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const { + Endianness streamEndianness) const override { return SerializeAdapter::serialize(&service, buffer, size, maxSize, streamEndianness); } - size_t getSerializedSize() const { return SerializeAdapter::getSerializedSize(&service); } - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { + [[nodiscard]] size_t getSerializedSize() const override { + return SerializeAdapter::getSerializedSize(&service); + } + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override { return SerializeAdapter::deSerialize(&service, buffer, size, streamEndianness); } }; diff --git a/src/fsfw/tmtcpacket/packetmatcher/SubserviceMatcher.h b/src/fsfw/tmtcpacket/packetmatcher/SubserviceMatcher.h index 934e8cb8..8729bbd5 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/SubserviceMatcher.h +++ b/src/fsfw/tmtcpacket/packetmatcher/SubserviceMatcher.h @@ -3,13 +3,13 @@ #include "../../globalfunctions/matching/SerializeableMatcherIF.h" #include "../../serialize/SerializeAdapter.h" -#include "../pus/tm/TmPacketMinimal.h" +#include "../pus/tm/PusTmMinimal.h" -class SubServiceMatcher : public SerializeableMatcherIF { +class SubServiceMatcher : public SerializeableMatcherIF { public: - SubServiceMatcher(uint8_t subService) : subService(subService) {} - SubServiceMatcher(TmPacketMinimal* test) : subService(test->getSubService()) {} - bool match(TmPacketMinimal* packet) { + explicit SubServiceMatcher(uint8_t subService) : subService(subService) {} + explicit SubServiceMatcher(PusTmIF* test) : subService(test->getSubService()) {} + bool match(PusTmIF* packet) override { if (packet->getSubService() == subService) { return true; } else { @@ -17,16 +17,19 @@ class SubServiceMatcher : public SerializeableMatcherIF { } } ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const { + Endianness streamEndianness) const override { return SerializeAdapter::serialize(&subService, buffer, size, maxSize, streamEndianness); } - size_t getSerializedSize() const { return SerializeAdapter::getSerializedSize(&subService); } - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { + [[nodiscard]] size_t getSerializedSize() const override { + return SerializeAdapter::getSerializedSize(&subService); + } + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override { return SerializeAdapter::deSerialize(&subService, buffer, size, streamEndianness); } private: - uint8_t subService; + uint8_t subService{}; }; #endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_SUBSERVICEMATCHER_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h b/src/fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h index 340f7825..d6e96438 100644 --- a/src/fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h +++ b/src/fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h @@ -3,13 +3,13 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -class TmPacketMinimal; +class PusTmMinimal; class PacketTimestampInterpreterIF { public: virtual ~PacketTimestampInterpreterIF() {} - virtual ReturnValue_t getPacketTime(TmPacketMinimal* packet, timeval* timestamp) const = 0; - virtual ReturnValue_t getPacketTimeRaw(TmPacketMinimal* packet, const uint8_t** timePtr, + virtual ReturnValue_t getPacketTime(PusTmMinimal* packet, timeval* timestamp) const = 0; + virtual ReturnValue_t getPacketTimeRaw(PusTmMinimal* packet, const uint8_t** timePtr, uint32_t* size) const = 0; }; diff --git a/src/fsfw/tmtcpacket/pus/PusIF.h b/src/fsfw/tmtcpacket/pus/PusIF.h new file mode 100644 index 00000000..61d4fcff --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/PusIF.h @@ -0,0 +1,52 @@ +#ifndef FSFW_TMTCPACKET_PUSIF_H +#define FSFW_TMTCPACKET_PUSIF_H + +#include + +#include "fsfw/tmtcpacket/SpacePacketIF.h" + +class PusIF : public SpacePacketIF { + public: + ~PusIF() override = default; + /** + * This command returns the TC Packet PUS Version Number. + * The version number of ECSS PUS 2003 is 1. + * It consists of the second to fourth highest bits of the + * first byte. + * @return + */ + [[nodiscard]] virtual uint8_t getPusVersion() const = 0; + + /** + * This is a getter for the packet's PUS Service ID, which is the second + * byte of the Data Field Header. + * @return The packet's PUS Service ID. + */ + [[nodiscard]] virtual uint8_t getService() const = 0; + /** + * This is a getter for the packet's PUS Service Subtype, which is the + * third byte of the Data Field Header. + * @return The packet's PUS Service Subtype. + */ + [[nodiscard]] virtual uint8_t getSubService() const = 0; + + /** + * This is a getter for a pointer to the packet's Application data. + * + * These are the bytes that follow after the Data Field Header. They form + * the packet's application data. + * @return A pointer to the PUS Application Data. + */ + [[nodiscard]] virtual const uint8_t* getUserData(size_t& appDataLen) const = 0; + /** + * This method calculates the size of the PUS Application data field. + * + * It takes the information stored in the CCSDS Packet Data Length field + * and subtracts the Data Field Header size and the CRC size. + * @return The size of the PUS Application Data (without Error Control + * field) + */ + [[nodiscard]] virtual uint16_t getUserDataSize() const = 0; +}; + +#endif // FSFW_TMTCPACKET_PUSIF_H diff --git a/src/fsfw/tmtcpacket/pus/definitions.h b/src/fsfw/tmtcpacket/pus/definitions.h index d4b649d0..369f869a 100644 --- a/src/fsfw/tmtcpacket/pus/definitions.h +++ b/src/fsfw/tmtcpacket/pus/definitions.h @@ -3,11 +3,11 @@ #include -namespace pus { +namespace ecss { //! Version numbers according to ECSS-E-ST-70-41C p.439 -enum PusVersion : uint8_t { PUS_A_VERSION = 1, PUS_C_VERSION = 2 }; +enum PusVersion : uint8_t { PUS_A = 1, PUS_C = 2 }; -} // namespace pus +} // namespace ecss #endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TM_DEFINITIONS_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc.h b/src/fsfw/tmtcpacket/pus/tc.h index f5a467aa..33c6352f 100644 --- a/src/fsfw/tmtcpacket/pus/tc.h +++ b/src/fsfw/tmtcpacket/pus/tc.h @@ -2,6 +2,5 @@ #define FSFW_TMTCPACKET_PUS_TC_H_ #include "tc/TcPacketPus.h" -#include "tc/TcPacketStoredPus.h" #endif /* FSFW_TMTCPACKET_PUS_TC_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt b/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt index c37c2c55..d2e30586 100644 --- a/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources( - ${LIB_FSFW_NAME} - PRIVATE PusTcReader.cpp TcPacketPus.cpp PusTcReader.cpp PusTcCreator.cpp - TcPacketStoredBase.cpp TcPacketStoredPus.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE PusTcReader.cpp PusTcReader.cpp + PusTcCreator.cpp) + +# TcPacketPus.cpp diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index c73f7a93..cbd6da53 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -1,3 +1,75 @@ #include "PusTcCreator.h" -TcPacketDeserializer::TcPacketDeserializer(const uint8_t *data, size_t maxSize) {} +#include "PusTcIF.h" +#include "fsfw/globalfunctions/CRC.h" +#include "fsfw/serialize/SerializeAdapter.h" + +PusTcCreator::PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams) + : spCreator(spParams), pusParams(pusParams) { + updateSpLengthField(); +} + +ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const { + if (*size + PusTcIF::MIN_LEN + pusParams.appDataLen > maxSize) { + return SerializeIF::BUFFER_TOO_SHORT; + } + ReturnValue_t result = spCreator.serialize(buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (pusParams.pusVersion != ecss::PusVersion::PUS_C) { + // TODO: Dedicated returnvalue + return HasReturnvaluesIF::RETURN_FAILED; + } + **buffer = pusParams.pusVersion << 4 | pusParams.ackFlags; + *buffer += 1; + **buffer = pusParams.service; + *buffer += 1; + **buffer = pusParams.subservice; + *buffer += 1; + result = + SerializeAdapter::serialize(&pusParams.sourceId, buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + std::memcpy(*buffer, pusParams.appData, pusParams.appDataLen); + *buffer += pusParams.appDataLen; + *size += pusParams.appDataLen; + uint16_t crc16 = CRC::crc16ccitt(*buffer, getFullPacketLen() - 2); + return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness); +} + +void PusTcCreator::updateSpLengthField() { + spCreator.setDataLen(ecss::PusTcDataFieldHeader::MIN_LEN + pusParams.appDataLen + 1); +} + +size_t PusTcCreator::getSerializedSize() const { return spCreator.getFullPacketLen(); } + +ReturnValue_t PusTcCreator::deSerialize(const uint8_t **buffer, size_t *size, + SerializeIF::Endianness streamEndianness) { + return HasReturnvaluesIF::RETURN_FAILED; +} + +uint16_t PusTcCreator::getPacketId() const { return spCreator.getPacketId(); } + +uint16_t PusTcCreator::getPacketSeqCtrl() const { return spCreator.getPacketSeqCtrl(); } + +uint16_t PusTcCreator::getPacketDataLen() const { return spCreator.getPacketDataLen(); } + +uint8_t PusTcCreator::getPusVersion() const { return pusParams.pusVersion; } + +uint8_t PusTcCreator::getAcknowledgeFlags() const { return pusParams.ackFlags; } + +uint8_t PusTcCreator::getService() const { return pusParams.service; } + +uint8_t PusTcCreator::getSubService() const { return pusParams.subservice; } + +uint16_t PusTcCreator::getSourceId() const { return pusParams.sourceId; } + +const uint8_t *PusTcCreator::getUserData(size_t &appDataLen) const { + appDataLen = getUserDataSize(); + return pusParams.appData; +} + +uint16_t PusTcCreator::getUserDataSize() const { return pusParams.appDataLen; } diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 275cc28f..ffa2ed7c 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -2,13 +2,47 @@ #define FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" +#include "fsfw/tmtcpacket/SpacePacketCreator.h" #include "fsfw/tmtcpacket/SpacePacketIF.h" +#include "fsfw/tmtcpacket/pus/definitions.h" +#include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" -class PusTcCreator : public SpacePacketIF { +struct PusTcParams { + PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {} + + uint8_t service; + uint8_t subservice; + uint8_t ackFlags = ecss::ACK_ALL; + uint16_t sourceId = 0; + uint8_t *appData = nullptr; + size_t appDataLen = 0; + uint8_t pusVersion = ecss::PusVersion::PUS_C; +}; + +class PusTcCreator : public PusTcIF, public SerializeIF { public: - PusTcCreator(const uint8_t* data, size_t maxSize); + PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams); + + void updateSpLengthField(); + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override; + [[nodiscard]] size_t getSerializedSize() const override; + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override; + [[nodiscard]] uint16_t getPacketId() const override; + [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketDataLen() const override; + [[nodiscard]] uint8_t getPusVersion() const override; + [[nodiscard]] uint8_t getAcknowledgeFlags() const override; + [[nodiscard]] uint8_t getService() const override; + [[nodiscard]] uint8_t getSubService() const override; + [[nodiscard]] uint16_t getSourceId() const override; + const uint8_t *getUserData(size_t &appDataLen) const override; + [[nodiscard]] uint16_t getUserDataSize() const override; private: + SpacePacketCreator spCreator; + PusTcParams pusParams; }; #endif // FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h index 54afd946..a8204a1f 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h @@ -3,7 +3,7 @@ #include -#include "TcPacketPus.h" +#include "fsfw/tmtcpacket/pus/PusIF.h" namespace ecss { @@ -41,20 +41,12 @@ struct PusTcDataFieldHeader { } // namespace ecss -class PusTcIF : public SpacePacketIF { +class PusTcIF : public PusIF { public: ~PusTcIF() override = default; - static const uint16_t MIN_LEN = + static const size_t MIN_LEN = (sizeof(CCSDSPrimaryHeader) + ecss::PusTcDataFieldHeader::MIN_LEN + 2); - /** - * This command returns the TC Packet PUS Version Number. - * The version number of ECSS PUS 2003 is 1. - * It consists of the second to fourth highest bits of the - * first byte. - * @return - */ - [[nodiscard]] virtual uint8_t getPusVersion() const = 0; /** * This is a getter for the packet's Ack field, which are the lowest four * bits of the first byte of the Data Field Header. @@ -63,50 +55,13 @@ class PusTcIF : public SpacePacketIF { * @return The packet's PUS Ack field. */ [[nodiscard]] virtual uint8_t getAcknowledgeFlags() const = 0; - /** - * This is a getter for the packet's PUS Service ID, which is the second - * byte of the Data Field Header. - * @return The packet's PUS Service ID. - */ - [[nodiscard]] virtual uint8_t getService() const = 0; - /** - * This is a getter for the packet's PUS Service Subtype, which is the - * third byte of the Data Field Header. - * @return The packet's PUS Service Subtype. - */ - [[nodiscard]] virtual uint8_t getSubService() const = 0; + /** * The source ID can be used to have an additional identifier, e.g. for different ground * station. * @return */ [[nodiscard]] virtual uint16_t getSourceId() const = 0; - - /** - * This is a getter for a pointer to the packet's Application data. - * - * These are the bytes that follow after the Data Field Header. They form - * the packet's application data. - * @return A pointer to the PUS Application Data. - */ - [[nodiscard]] virtual const uint8_t* getApplicationData() const = 0; - /** - * This method calculates the size of the PUS Application data field. - * - * It takes the information stored in the CCSDS Packet Data Length field - * and subtracts the Data Field Header size and the CRC size. - * @return The size of the PUS Application Data (without Error Control - * field) - */ - [[nodiscard]] virtual uint16_t getApplicationDataSize() const = 0; - /** - * This getter returns the Error Control Field of the packet. - * - * The field is placed after any possible Application Data. If no - * Application Data is present there's still an Error Control field. It is - * supposed to be a 16bit-CRC. - * @return The PUS Error Control - */ - [[nodiscard]] virtual uint16_t getErrorControl() const = 0; }; + #endif // FSFW_TMTCPACKET_PUSTCIF_H diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp index e2a66e73..0ead9bde 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp @@ -7,33 +7,64 @@ #include "fsfw/serialize.h" #include "fsfw/serviceinterface/ServiceInterface.h" -PusTcReader::PusTcReader(const uint8_t* setData, size_t size) : spReader(setData), maxSize(size) { - pointers.spHeaderStart = setData; -} +PusTcReader::PusTcReader(const uint8_t* data, size_t size) { setData(data, size); } PusTcReader::~PusTcReader() = default; ReturnValue_t PusTcReader::parseData() { - if (maxSize < sizeof(CCSDSPrimaryHeader)) { - return SerializeIF::BUFFER_TOO_SHORT; + ReturnValue_t result = spReader.checkLength(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } + if (size < PusTcIF::MIN_LEN) { + return SerializeIF::STREAM_TOO_SHORT; + } + // Might become variable sized field in the future + size_t secHeaderLen = ecss::PusTcDataFieldHeader::MIN_LEN; pointers.secHeaderStart = pointers.spHeaderStart + sizeof(CCSDSPrimaryHeader); // TODO: No support for spare bytes yet - pointers.userDataStart = pointers.secHeaderStart + ecss::PusTcDataFieldHeader::MIN_LEN; + pointers.userDataStart = pointers.secHeaderStart + secHeaderLen; + appDataSize = size - (sizeof(CCSDSPrimaryHeader) + secHeaderLen); + pointers.crcStart = pointers.userDataStart + appDataSize; + return HasReturnvaluesIF::RETURN_OK; } -uint8_t PusTcReader::getAcknowledgeFlags() const { return 0; } -uint8_t PusTcReader::getService() const { return 0; } -uint8_t PusTcReader::getSubService() const { return 0; } -uint16_t PusTcReader::getSourceId() const { return 0; } -const uint8_t* PusTcReader::getApplicationData() const { return nullptr; } -uint16_t PusTcReader::getApplicationDataSize() const { return 0; } -uint16_t PusTcReader::getErrorControl() const { return 0; } +uint8_t PusTcReader::getAcknowledgeFlags() const { + return (pointers.secHeaderStart[0] >> 4) & 0b1111; +} + +uint8_t PusTcReader::getService() const { return pointers.secHeaderStart[1]; } + +uint8_t PusTcReader::getSubService() const { return pointers.secHeaderStart[2]; } +uint16_t PusTcReader::getSourceId() const { + return (pointers.secHeaderStart[3] << 8) | pointers.secHeaderStart[4]; +} +const uint8_t* PusTcReader::getUserData(size_t& appDataLen) const { + appDataLen = appDataSize; + return pointers.userDataStart; +} + +uint16_t PusTcReader::getUserDataSize() const { return appDataSize; } + +uint16_t PusTcReader::getErrorControl() const { + return pointers.crcStart[0] << 8 | pointers.crcStart[1]; +} uint16_t PusTcReader::getPacketId() const { return spReader.getPacketId(); } uint16_t PusTcReader::getPacketSeqCtrl() const { return spReader.getPacketSeqCtrl(); } uint16_t PusTcReader::getPacketDataLen() const { return spReader.getPacketDataLen(); } uint8_t PusTcReader::getPusVersion() const { return spReader.getVersion(); } +const uint8_t* PusTcReader::getFullData() { return pointers.spHeaderStart; } + +ReturnValue_t PusTcReader::setData(uint8_t* pData, size_t size_, void* args) { + size = size_; + pointers.spHeaderStart = pData; + spReader.setData(pData, size_, args); + return HasReturnvaluesIF::RETURN_OK; +} +ReturnValue_t PusTcReader::setData(const uint8_t* data, size_t size_) { + setData(const_cast(data), size_, nullptr); +} /* void PusTcReader::print() { diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h index 43ab26ce..85623980 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h @@ -18,17 +18,16 @@ * check can be performed by making use of the getWholeData method. * @ingroup tmtcpackets */ -class PusTcReader : public PusTcIF, public RedirectableDataPointerIF { - friend class TcPacketStoredBase; - +class PusTcReader : public PusTcIF, public ReadablePacketIF, public RedirectableDataPointerIF { public: + PusTcReader() = default; /** * This is the default constructor. * It sets its internal data pointer to the address passed and also * forwards the data pointer to the parent SpacePacketBase class. * @param setData The position where the packet data lies. */ - explicit PusTcReader(const uint8_t* setData, size_t size); + PusTcReader(const uint8_t* setData, size_t size); ReturnValue_t parseData(); /** @@ -40,7 +39,7 @@ class PusTcReader : public PusTcIF, public RedirectableDataPointerIF { * This is a debugging helper method that prints the whole packet content * to the screen. */ - void print(); + // void print(); [[nodiscard]] uint16_t getPacketId() const override; [[nodiscard]] uint16_t getPacketSeqCtrl() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; @@ -49,9 +48,12 @@ class PusTcReader : public PusTcIF, public RedirectableDataPointerIF { [[nodiscard]] uint8_t getService() const override; [[nodiscard]] uint8_t getSubService() const override; [[nodiscard]] uint16_t getSourceId() const override; - [[nodiscard]] const uint8_t* getApplicationData() const override; - [[nodiscard]] uint16_t getApplicationDataSize() const override; - [[nodiscard]] uint16_t getErrorControl() const override; + [[nodiscard]] const uint8_t* getUserData(size_t& appDataLen) const override; + [[nodiscard]] uint16_t getUserDataSize() const override; + [[nodiscard]] uint16_t getErrorControl() const; + const uint8_t* getFullData() override; + + ReturnValue_t setData(const uint8_t* data, size_t size); protected: /** @@ -62,7 +64,8 @@ class PusTcReader : public PusTcIF, public RedirectableDataPointerIF { * * @param p_data A pointer to another PUS Telecommand Packet. */ - ReturnValue_t setData(uint8_t* pData, size_t maxSize, void* args) override = 0; + ReturnValue_t setData(uint8_t* pData, size_t size, void* args) override; + SpacePacketReader spReader; /** * This struct defines the data structure of a Space Packet when accessed @@ -73,10 +76,12 @@ class PusTcReader : public PusTcIF, public RedirectableDataPointerIF { const uint8_t* spHeaderStart; const uint8_t* secHeaderStart; const uint8_t* userDataStart; + const uint8_t* crcStart; }; PusTcPointers pointers{}; - size_t maxSize = 0; + size_t size = 0; + size_t appDataSize = 0; }; #endif /* TMTCPACKET_PUS_TCPACKETBASE_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp index faada828..06f980b7 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp @@ -10,7 +10,7 @@ TcPacketPus::TcPacketPus(const uint8_t *setData) : TcPacketPusBase(setData) { void TcPacketPus::initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack, uint8_t service, uint8_t subservice, - pus::PusVersion pusVersion, uint16_t sourceId) { + ecss::PusVersion pusVersion, uint16_t sourceId) { initSpacePacketHeader(true, true, apid, sequenceCount); std::memset(&tcData->dataField, 0, sizeof(tcData->dataField)); setPacketDataLength(sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1); diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h index d7c8d743..bb2b3642 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h @@ -21,49 +21,49 @@ struct TcPacketPointer { }; */ -class TcPacketPus : public TcPacketPusBase { - public: - /** - * Initialize a PUS A telecommand packet which already exists. You can also - * create an empty (invalid) object by passing nullptr as the data pointer - * @param setData - */ - TcPacketPus(const uint8_t* setData); - - // Base class overrides - uint8_t getSecondaryHeaderFlag() const override; - uint8_t getPusVersionNumber() const override; - uint8_t getAcknowledgeFlags() const override; - uint8_t getService() const override; - uint8_t getSubService() const override; - uint16_t getSourceId() const override; - const uint8_t* getApplicationData() const override; - uint16_t getApplicationDataSize() const override; - uint16_t getErrorControl() const override; - void setErrorControl() override; - size_t calculateFullPacketLength(size_t appDataLen) const override; - - protected: - ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) override; - - /** - * Initializes the Tc Packet header. - * @param apid APID used. - * @param sequenceCount Sequence Count in the primary header. - * @param ack Which acknowledeges are expected from the receiver. - * @param service PUS Service - * @param subservice PUS Subservice - */ - void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack, uint8_t service, - uint8_t subservice, pus::PusVersion pusVersion, uint16_t sourceId = 0); - - /** - * A pointer to a structure which defines the data structure of - * the packet's data. - * - * To be hardware-safe, all elements are of byte size. - */ - TcPacketPointer* tcData = nullptr; -}; +// class TcPacketPus : public TcPacketPusBase { +// public: +// /** +// * Initialize a PUS A telecommand packet which already exists. You can also +// * create an empty (invalid) object by passing nullptr as the data pointer +// * @param setData +// */ +// TcPacketPus(const uint8_t* setData); +// +// // Base class overrides +// uint8_t getSecondaryHeaderFlag() const override; +// uint8_t getPusVersionNumber() const override; +// uint8_t getAcknowledgeFlags() const override; +// uint8_t getService() const override; +// uint8_t getSubService() const override; +// uint16_t getSourceId() const override; +// const uint8_t* getApplicationData() const override; +// uint16_t getApplicationDataSize() const override; +// uint16_t getErrorControl() const override; +// void setErrorControl() override; +// size_t calculateFullPacketLength(size_t appDataLen) const override; +// +// protected: +// ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) override; +// +// /** +// * Initializes the Tc Packet header. +// * @param apid APID used. +// * @param sequenceCount Sequence Count in the primary header. +// * @param ack Which acknowledeges are expected from the receiver. +// * @param service PUS Service +// * @param subservice PUS Subservice +// */ +// void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack, uint8_t service, +// uint8_t subservice, pus::PusVersion pusVersion, uint16_t sourceId = 0); +// +// /** +// * A pointer to a structure which defines the data structure of +// * the packet's data. +// * +// * To be hardware-safe, all elements are of byte size. +// */ +// TcPacketPointer* tcData = nullptr; +// }; #endif /* FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.cpp new file mode 100644 index 00000000..89ebe75a --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.cpp @@ -0,0 +1 @@ +#include "TcPacketStored.h" diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.h new file mode 100644 index 00000000..ddd51303 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.h @@ -0,0 +1,10 @@ +#ifndef FSFW_TMTCPACKET_TCPACKETSTORED_H +#define FSFW_TMTCPACKET_TCPACKETSTORED_H + +#include "fsfw/tmtcpacket/PacketStorageHelper.h" + +class TcPacketStored : public PacketStorageHelper { + TcPacketStored(StorageManagerIF* store); +}; + +#endif // FSFW_TMTCPACKET_TCPACKETSTORED_H diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp index 22918526..88964bfb 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp @@ -6,58 +6,59 @@ #include "fsfw/objectmanager/frameworkObjects.h" #include "fsfw/serviceinterface/ServiceInterface.h" -StorageManagerIF* TcPacketStoredBase::STORE = nullptr; - -TcPacketStoredBase::TcPacketStoredBase() { - this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; - TcPacketStoredBase::checkAndSetStore(); -} - -TcPacketStoredBase::~TcPacketStoredBase() = default; - -ReturnValue_t TcPacketStoredBase::getData(const uint8_t** dataPtr, size_t* dataSize) { - auto result = TcPacketStoredBase::STORE->getData(storeAddress, dataPtr, dataSize); - if (result != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TcPacketStoredBase: Could not get data" << std::endl; -#else - sif::printWarning("TcPacketStoredBase: Could not get data!\n"); -#endif - } - return result; -} - -bool TcPacketStoredBase::checkAndSetStore() { - if (TcPacketStoredBase::STORE == nullptr) { - TcPacketStoredBase::STORE = ObjectManager::instance()->get(objects::TC_STORE); - if (TcPacketStoredBase::STORE == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TcPacketStoredBase::TcPacketStoredBase: TC Store not found" << std::endl; -#else - sif::printError("TcPacketStoredBase::TcPacketStoredBase: TC Store not found\n"); -#endif - return false; - } - } - return true; -} - -void TcPacketStoredBase::setStoreAddress(store_address_t setAddress, - RedirectableDataPointerIF* packet) { - this->storeAddress = setAddress; - const uint8_t* tempData = nullptr; - size_t tempSize; - ReturnValue_t status = StorageManagerIF::RETURN_FAILED; - if (this->checkAndSetStore()) { - status = TcPacketStoredBase::STORE->getData(this->storeAddress, &tempData, &tempSize); - } - - if (status == StorageManagerIF::RETURN_OK) { - packet->setData(const_cast(tempData), tempSize); - } else { - packet->setData(nullptr, -1); - this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; - } -} - -store_address_t TcPacketStoredBase::getStoreAddress() { return this->storeAddress; } +// StorageManagerIF* TcPacketStoredBase::STORE = nullptr; +// +// TcPacketStoredBase::TcPacketStoredBase() { +// this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; +// TcPacketStoredBase::checkAndSetStore(); +// } +// +// TcPacketStoredBase::~TcPacketStoredBase() = default; +// +// ReturnValue_t TcPacketStoredBase::getData(const uint8_t** dataPtr, size_t* dataSize) { +// auto result = TcPacketStoredBase::STORE->getData(storeAddress, dataPtr, dataSize); +// if (result != HasReturnvaluesIF::RETURN_OK) { +//#if FSFW_CPP_OSTREAM_ENABLED == 1 +// sif::warning << "TcPacketStoredBase: Could not get data" << std::endl; +//#else +// sif::printWarning("TcPacketStoredBase: Could not get data!\n"); +//#endif +// } +// return result; +// } +// +// bool TcPacketStoredBase::checkAndSetStore() { +// if (TcPacketStoredBase::STORE == nullptr) { +// TcPacketStoredBase::STORE = +// ObjectManager::instance()->get(objects::TC_STORE); if +// (TcPacketStoredBase::STORE == nullptr) { +//#if FSFW_CPP_OSTREAM_ENABLED == 1 +// sif::error << "TcPacketStoredBase::TcPacketStoredBase: TC Store not found" << std::endl; +//#else +// sif::printError("TcPacketStoredBase::TcPacketStoredBase: TC Store not found\n"); +//#endif +// return false; +// } +// } +// return true; +// } +// +// void TcPacketStoredBase::setStoreAddress(store_address_t setAddress, +// RedirectableDataPointerIF* packet) { +// this->storeAddress = setAddress; +// const uint8_t* tempData = nullptr; +// size_t tempSize; +// ReturnValue_t status = StorageManagerIF::RETURN_FAILED; +// if (this->checkAndSetStore()) { +// status = TcPacketStoredBase::STORE->getData(this->storeAddress, &tempData, &tempSize); +// } +// +// if (status == StorageManagerIF::RETURN_OK) { +// packet->setData(const_cast(tempData), tempSize); +// } else { +// packet->setData(nullptr, -1); +// this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; +// } +// } +// +// store_address_t TcPacketStoredBase::getStoreAddress() { return this->storeAddress; } diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h index d0a15cc4..8291ac6c 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h @@ -5,80 +5,80 @@ #include "TcPacketStoredIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" -/** - * Base class for telecommand packets like CFDP or PUS packets. - * @ingroup tmtcpackets - */ -class TcPacketStoredBase : public TcPacketStoredIF { - public: - /** - * This is a default constructor which does not set the data pointer to initialize - * with an empty cached store address - */ - TcPacketStoredBase(); - /** - * Constructor to set to an existing store address. - * @param setAddress - */ - explicit TcPacketStoredBase(store_address_t setAddress); - /** - * Another constructor to create a TcPacket from a raw packet stream. - * Takes the data and adds it unchecked to the TcStore. - * @param data Pointer to the complete TC Space Packet. - * @param Size size of the packet. - */ - TcPacketStoredBase(const uint8_t* data, uint32_t size); - - virtual ~TcPacketStoredBase(); - - /** - * Getter function for the raw data. - * @param dataPtr [out] Pointer to the data pointer to set - * @param dataSize [out] Address of size to set. - * @return -@c RETURN_OK if data was retrieved successfully. - */ - ReturnValue_t getData(const uint8_t** dataPtr, size_t* dataSize) override; - - void setStoreAddress(store_address_t setAddress, RedirectableDataPointerIF* packet) override; - store_address_t getStoreAddress() override; - - /** - * With this call, the packet is deleted. - * It removes itself from the store and sets its data pointer to NULL. - * @return returncode from deleting the data. - */ - virtual ReturnValue_t deletePacket() = 0; - - /** - * This method performs a size check. - * It reads the stored size and compares it with the size entered in the - * packet header. This class is the optimal place for such a check as it - * has access to both the header data and the store. - * @return true if size is correct, false if packet is not registered in - * store or size is incorrect. - */ - virtual bool isSizeCorrect() = 0; - - protected: - /** - * This is a pointer to the store all instances of the class use. - * If the store is not yet set (i.e. @c store is NULL), every constructor - * call tries to set it and throws an error message in case of failures. - * The default store is objects::TC_STORE. - */ - static StorageManagerIF* STORE; - /** - * The address where the packet data of the object instance is stored. - */ - store_address_t storeAddress; - /** - * A helper method to check if a store is assigned to the class. - * If not, the method tries to retrieve the store from the global - * ObjectManager. - * @return @li @c true if the store is linked or could be created. - * @li @c false otherwise. - */ - static bool checkAndSetStore(); -}; +///** +// * Base class for telecommand packets like CFDP or PUS packets. +// * @ingroup tmtcpackets +// */ +// class TcPacketStoredBase : public TcPacketStoredIF { +// public: +// /** +// * This is a default constructor which does not set the data pointer to initialize +// * with an empty cached store address +// */ +// TcPacketStoredBase(); +// /** +// * Constructor to set to an existing store address. +// * @param setAddress +// */ +// explicit TcPacketStoredBase(store_address_t setAddress); +// /** +// * Another constructor to create a TcPacket from a raw packet stream. +// * Takes the data and adds it unchecked to the TcStore. +// * @param data Pointer to the complete TC Space Packet. +// * @param Size size of the packet. +// */ +// TcPacketStoredBase(const uint8_t* data, uint32_t size); +// +// virtual ~TcPacketStoredBase(); +// +// /** +// * Getter function for the raw data. +// * @param dataPtr [out] Pointer to the data pointer to set +// * @param dataSize [out] Address of size to set. +// * @return -@c RETURN_OK if data was retrieved successfully. +// */ +// ReturnValue_t getData(const uint8_t** dataPtr, size_t* dataSize) override; +// +// void setStoreAddress(store_address_t setAddress, RedirectableDataPointerIF* packet) override; +// store_address_t getStoreAddress() override; +// +// /** +// * With this call, the packet is deleted. +// * It removes itself from the store and sets its data pointer to NULL. +// * @return returncode from deleting the data. +// */ +// virtual ReturnValue_t deletePacket() = 0; +// +// /** +// * This method performs a size check. +// * It reads the stored size and compares it with the size entered in the +// * packet header. This class is the optimal place for such a check as it +// * has access to both the header data and the store. +// * @return true if size is correct, false if packet is not registered in +// * store or size is incorrect. +// */ +// virtual bool isSizeCorrect() = 0; +// +// protected: +// /** +// * This is a pointer to the store all instances of the class use. +// * If the store is not yet set (i.e. @c store is NULL), every constructor +// * call tries to set it and throws an error message in case of failures. +// * The default store is objects::TC_STORE. +// */ +// static StorageManagerIF* STORE; +// /** +// * The address where the packet data of the object instance is stored. +// */ +// store_address_t storeAddress; +// /** +// * A helper method to check if a store is assigned to the class. +// * If not, the method tries to retrieve the store from the global +// * ObjectManager. +// * @return @li @c true if the store is linked or could be created. +// * @li @c false otherwise. +// */ +// static bool checkAndSetStore(); +//}; #endif /* TMTCPACKET_PUS_TCPACKETSTORED_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp deleted file mode 100644 index 95350ac2..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.h" - -#include - -#include "fsfw/serviceinterface/ServiceInterface.h" - -TcPacketStoredPus::TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t subservice, - uint8_t sequenceCount, const uint8_t* data, size_t size, - uint8_t ack) - : TcPacketPus(nullptr) { - this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; - if (not this->checkAndSetStore()) { - return; - } - uint8_t* pData = nullptr; - ReturnValue_t returnValue = - this->STORE->getFreeElement(&this->storeAddress, (TC_PACKET_MIN_SIZE + size), &pData); - if (returnValue != this->STORE->RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TcPacketStoredBase: Could not get free element from store!" << std::endl; -#endif - return; - } - this->setData(pData, TC_PACKET_MIN_SIZE + size, nullptr); -#if FSFW_USE_PUS_C_TELECOMMANDS == 1 - pus::PusVersion pusVersion = pus::PusVersion::PUS_C_VERSION; -#else - pus::PusVersion pusVersion = pus::PusVersion::PUS_A_VERSION; -#endif - initializeTcPacket(apid, sequenceCount, ack, service, subservice, pusVersion); - std::memcpy(&tcData->appData, data, size); - this->setPacketDataLength(size + sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1); - this->setErrorControl(); -} - -TcPacketStoredPus::TcPacketStoredPus() : TcPacketStoredBase(), TcPacketPus(nullptr) {} - -TcPacketStoredPus::TcPacketStoredPus(store_address_t setAddress) : TcPacketPus(nullptr) { - TcPacketStoredBase::setStoreAddress(setAddress, this); -} - -TcPacketStoredPus::TcPacketStoredPus(const uint8_t* data, size_t size) : TcPacketPus(data) { - if (this->getFullSize() != size) { - return; - } - if (this->checkAndSetStore()) { - ReturnValue_t status = STORE->addData(&storeAddress, data, size); - if (status != HasReturnvaluesIF::RETURN_OK) { - this->setData(nullptr, size, nullptr); - } - const uint8_t* storePtr = nullptr; - // Repoint base data pointer to the data in the store. - STORE->getData(storeAddress, &storePtr, &size); - this->setData(const_cast(storePtr), size, nullptr); - } -} - -ReturnValue_t TcPacketStoredPus::deletePacket() { - ReturnValue_t result = this->STORE->deleteData(this->storeAddress); - this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; - // To circumvent size checks - this->setData(nullptr, -1, nullptr); - return result; -} - -TcPacketPusBase* TcPacketStoredPus::getPacketBase() { return this; } - -bool TcPacketStoredPus::isSizeCorrect() { - const uint8_t* temp_data = nullptr; - size_t temp_size; - ReturnValue_t status = this->STORE->getData(this->storeAddress, &temp_data, &temp_size); - if (status == StorageManagerIF::RETURN_OK) { - if (this->getFullSize() == temp_size) { - return true; - } - } - return false; -} diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.h deleted file mode 100644 index 45dec293..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_ -#define FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_ - -#include "TcPacketPus.h" -#include "TcPacketStoredBase.h" - -class TcPacketStoredPus : public TcPacketStoredBase, public TcPacketPus { - public: - /** - * With this constructor, new space is allocated in the packet store and - * a new PUS Telecommand Packet is created there. - * Packet Application Data passed in data is copied into the packet. - * @param apid Sets the packet's APID field. - * @param service Sets the packet's Service ID field. - * This specifies the destination service. - * @param subservice Sets the packet's Service Subtype field. - * This specifies the destination sub-service. - * @param sequence_count Sets the packet's Source Sequence Count field. - * @param data The data to be copied to the Application Data Field. - * @param size The amount of data to be copied. - * @param ack Set's the packet's Ack field, which specifies - * number of verification packets returned - * for this command. - */ - TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t subservice, uint8_t sequence_count = 0, - const uint8_t* data = nullptr, size_t size = 0, - uint8_t ack = TcPacketPusBase::ACK_ALL); - /** - * Create stored packet with existing data. - * @param data - * @param size - */ - TcPacketStoredPus(const uint8_t* data, size_t size); - /** - * Create stored packet from existing packet in store - * @param setAddress - */ - TcPacketStoredPus(store_address_t setAddress); - TcPacketStoredPus(); - - ReturnValue_t deletePacket() override; - TcPacketPusBase* getPacketBase(); - - private: - bool isSizeCorrect() override; -}; - -#endif /* FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tm.h b/src/fsfw/tmtcpacket/pus/tm.h index afbe8251..657790f4 100644 --- a/src/fsfw/tmtcpacket/pus/tm.h +++ b/src/fsfw/tmtcpacket/pus/tm.h @@ -11,6 +11,6 @@ #include "tm/TmPacketStoredPusA.h" #endif -#include "tm/TmPacketMinimal.h" +#include "tm/PusTmMinimal.h" #endif /* FSFW_TMTCPACKET_PUS_TM_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt b/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt index 22fbebcd..57c45927 100644 --- a/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt @@ -1,4 +1,2 @@ -target_sources( - ${LIB_FSFW_NAME} - PRIVATE TmPacketStoredPusC.cpp TmPacketPusC.cpp TmPacketStoredBase.cpp - TmPacketBase.cpp TmPacketMinimal.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE PusTmCreator.cpp PusTmReader.cpp + PusTmMinimal.cpp) diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp new file mode 100644 index 00000000..5a1f4144 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -0,0 +1,10 @@ +#include "PusTmCreator.h" + +PusTmCreator::PusTmCreator(PusTmParams params_) : params(params_){}; + +uint16_t PusTmCreator::getPacketId() const { return 0; } +uint16_t PusTmCreator::getPacketSeqCtrl() const { return 0; } +uint16_t PusTmCreator::getPacketDataLen() const { return 0; } +uint8_t PusTmCreator::getPusVersion() const { return 0; } +uint8_t PusTmCreator::getService() const { return 0; } +uint8_t PusTmCreator::getSubService() const { return 0; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h new file mode 100644 index 00000000..fbdeb7d9 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -0,0 +1,31 @@ +#ifndef FSFW_TMTCPACKET_TMPACKETCREATOR_H +#define FSFW_TMTCPACKET_TMPACKETCREATOR_H + +#include "fsfw/tmtcpacket/pus/PusIF.h" + +struct PusTmParams { + uint8_t pusVersion; + uint8_t scTimeRefStatus; + uint8_t service; + uint8_t subservice; + uint16_t messageTypeCounter; + uint16_t destId; + uint8_t* timestamp; + size_t timestampLen; +}; +class PusTmCreator : public PusIF { + public: + ~PusTmCreator() override = default; + explicit PusTmCreator(PusTmParams params); + + [[nodiscard]] uint16_t getPacketId() const override; + [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketDataLen() const override; + [[nodiscard]] uint8_t getPusVersion() const override; + [[nodiscard]] uint8_t getService() const override; + [[nodiscard]] uint8_t getSubService() const override; + + private: + PusTmParams params; +}; +#endif // FSFW_TMTCPACKET_TMPACKETCREATOR_H diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h b/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h new file mode 100644 index 00000000..b22bdf3d --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h @@ -0,0 +1,20 @@ +#ifndef FSFW_TMTCPACKET_PUSTMIF_H +#define FSFW_TMTCPACKET_PUSTMIF_H + +#include +#include + +#include "fsfw/tmtcpacket/pus/PusIF.h" + +class PusTmIF : public PusIF { + public: + ~PusTmIF() override = default; + + virtual uint8_t getScTimeRefStatus() = 0; + virtual uint16_t getMessageTypeCounter() = 0; + virtual uint16_t getDestId() = 0; + virtual const uint8_t* getTimestamp(size_t& timeStampLen) = 0; + virtual size_t getTimestampLen() = 0; +}; + +#endif // FSFW_TMTCPACKET_PUSTMIF_H diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp new file mode 100644 index 00000000..4042528a --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp @@ -0,0 +1,45 @@ +#include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h" + +#include +#include + +#include "fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h" + +PusTmMinimal::PusTmMinimal(uint8_t* data) { + this->tmData = reinterpret_cast(data); +} + +PusTmMinimal::~PusTmMinimal() = default; + +ReturnValue_t PusTmMinimal::getPacketTime(timeval* timestamp) { + if (timestampInterpreter == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + return timestampInterpreter->getPacketTime(this, timestamp); +} + +void PusTmMinimal::setInterpretTimestampObject(PacketTimestampInterpreterIF* interpreter) { + if (PusTmMinimal::timestampInterpreter == nullptr) { + PusTmMinimal::timestampInterpreter = interpreter; + } +} + +PacketTimestampInterpreterIF* PusTmMinimal::timestampInterpreter = nullptr; +// TODO: Implement all of this +ReturnValue_t PusTmMinimal::setData(uint8_t* dataPtr, size_t size, void* args) { return 0; } +uint16_t PusTmMinimal::getPacketId() const { return 0; } +uint16_t PusTmMinimal::getPacketSeqCtrl() const { return 0; } +uint16_t PusTmMinimal::getPacketDataLen() const { return 0; } +uint8_t PusTmMinimal::getPusVersion() const { return 0; } +uint8_t PusTmMinimal::getService() const { return tmData->secHeader.service; } +uint8_t PusTmMinimal::getSubService() const { return tmData->secHeader.subservice; } +const uint8_t* PusTmMinimal::getUserData(size_t& appDataLen) const { return nullptr; } +uint16_t PusTmMinimal::getUserDataSize() const { return 0; } +uint8_t PusTmMinimal::getScTimeRefStatus() { return 0; } +uint16_t PusTmMinimal::getMessageTypeCounter() { return tmData->secHeader.messageTypeCounter; } +uint16_t PusTmMinimal::getDestId() { return 0; } +const uint8_t* PusTmMinimal::getTimestamp(size_t& timeStampLen) { return nullptr; } +size_t PusTmMinimal::getTimestampLen() { return 0; } +void PusTmMinimal::setApid(uint16_t apid) { + /* TODO: Implement. Maybe provide low level function to do this */ +} diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h similarity index 54% rename from src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h rename to src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h index 197bf6e6..a09523fb 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h @@ -1,8 +1,9 @@ #ifndef FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_ #define FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_ -#include "../../../returnvalues/HasReturnvaluesIF.h" -#include "../../SpacePacketReader.h" +#include "PusTmIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" struct timeval; class PacketTimestampInterpreterIF; @@ -12,7 +13,7 @@ class PacketTimestampInterpreterIF; * This is required for handling TM packets with different APIDs with different * secondary headers. */ -class TmPacketMinimal : public SpacePacketReader { +class PusTmMinimal : public PusTmIF, public RedirectableDataPointerIF { public: /** * This is the default constructor. @@ -20,40 +21,40 @@ class TmPacketMinimal : public SpacePacketReader { * forwards the data pointer to the parent SpacePacketBase class. * @param set_address The position where the packet data lies. */ - TmPacketMinimal(const uint8_t* set_data); + explicit PusTmMinimal(uint8_t* data); /** * This is the empty default destructor. */ - virtual ~TmPacketMinimal(); - /** - * This is a getter for the packet's PUS Service ID, which is the second - * byte of the Data Field Header. - * @return The packet's PUS Service ID. - */ - uint8_t getService(); - /** - * This is a getter for the packet's PUS Service Subtype, which is the - * third byte of the Data Field Header. - * @return The packet's PUS Service Subtype. - */ - uint8_t getSubService(); - /** - * Returns the subcounter. - * @return the subcounter of the Data Field Header. - */ - uint8_t getPacketSubcounter(); - struct PUSTmMinimalHeader { - uint8_t version_type_ack; - uint8_t service_type; - uint8_t service_subtype; - uint8_t subcounter; - }; + ~PusTmMinimal() override; + + void setApid(uint16_t apid); ReturnValue_t getPacketTime(timeval* timestamp); - ReturnValue_t getPacketTimeRaw(const uint8_t** timePtr, uint32_t* size); - static void setInterpretTimestampObject(PacketTimestampInterpreterIF* interpreter); + ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override; + [[nodiscard]] uint16_t getPacketId() const override; + [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketDataLen() const override; + [[nodiscard]] uint8_t getPusVersion() const override; + [[nodiscard]] uint8_t getService() const override; + [[nodiscard]] uint8_t getSubService() const override; + const uint8_t* getUserData(size_t& appDataLen) const override; + [[nodiscard]] uint16_t getUserDataSize() const override; + uint8_t getScTimeRefStatus() override; + uint16_t getMessageTypeCounter() override; + uint16_t getDestId() override; + const uint8_t* getTimestamp(size_t& timeStampLen) override; + size_t getTimestampLen() override; + + // NOTE: Only PUS C compatible! + struct PusTmMinimalSecHeader { + uint8_t versionAndScTimeRefStatus; + uint8_t service; + uint8_t subservice; + uint16_t messageTypeCounter; + }; + /** * This struct defines the data structure of a PUS Telecommand Packet when * accessed via a pointer. @@ -61,7 +62,7 @@ class TmPacketMinimal : public SpacePacketReader { */ struct TmPacketMinimalPointer { CCSDSPrimaryHeader primary; - PUSTmMinimalHeader data_field; + PusTmMinimalSecHeader secHeader; uint8_t rest; }; // Must include a checksum and is therefore at least one larger than the above struct. @@ -74,7 +75,7 @@ class TmPacketMinimal : public SpacePacketReader { * * To be hardware-safe, all elements are of byte size. */ - TmPacketMinimalPointer* tm_data; + TmPacketMinimalPointer* tmData; static PacketTimestampInterpreterIF* timestampInterpreter; }; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp new file mode 100644 index 00000000..d010512a --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp @@ -0,0 +1,3 @@ +// +// Created by rmueller on 7/19/22. +// diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h new file mode 100644 index 00000000..47eff293 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h @@ -0,0 +1,7 @@ +#ifndef FSFW_TMTCPACKET_PUSTMREADER_H +#define FSFW_TMTCPACKET_PUSTMREADER_H + +#include "fsfw/tmtcpacket/pus/tm/PusTmIF.h" + +class PusTmReader : public PusTmIF {}; +#endif // FSFW_TMTCPACKET_PUSTMREADER_H diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp deleted file mode 100644 index c1a5c4ba..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h" - -#include -#include - -#include "fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h" - -TmPacketMinimal::TmPacketMinimal(const uint8_t* set_data) : SpacePacketReader(set_data) { - this->tm_data = (TmPacketMinimalPointer*)set_data; -} - -TmPacketMinimal::~TmPacketMinimal() {} - -uint8_t TmPacketMinimal::getService() { return tm_data->data_field.service_type; } - -uint8_t TmPacketMinimal::getSubService() { return tm_data->data_field.service_subtype; } - -uint8_t TmPacketMinimal::getPacketSubcounter() { return tm_data->data_field.subcounter; } - -ReturnValue_t TmPacketMinimal::getPacketTime(timeval* timestamp) { - if (timestampInterpreter == NULL) { - return HasReturnvaluesIF::RETURN_FAILED; - } - return timestampInterpreter->getPacketTime(this, timestamp); -} - -ReturnValue_t TmPacketMinimal::getPacketTimeRaw(const uint8_t** timePtr, uint32_t* size) { - if (timestampInterpreter == NULL) { - return HasReturnvaluesIF::RETURN_FAILED; - } - return timestampInterpreter->getPacketTimeRaw(this, timePtr, size); -} - -void TmPacketMinimal::setInterpretTimestampObject(PacketTimestampInterpreterIF* interpreter) { - if (TmPacketMinimal::timestampInterpreter == NULL) { - TmPacketMinimal::timestampInterpreter = interpreter; - } -} - -PacketTimestampInterpreterIF* TmPacketMinimal::timestampInterpreter = NULL; diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp index fd2248aa..7ae6de82 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp @@ -58,8 +58,7 @@ ReturnValue_t TmPacketPusC::initializeTmPacket(uint16_t apid, uint8_t service, u /* Only account for last 4 bytes for time reference field */ timeRefField &= 0b1111; - tmData->dataField.versionTimeReferenceField = - (pus::PusVersion::PUS_C_VERSION << 4) | timeRefField; + tmData->dataField.versionTimeReferenceField = (ecss::PusVersion::PUS_C << 4) | timeRefField; tmData->dataField.serviceType = service; tmData->dataField.serviceSubtype = subservice; tmData->dataField.subcounterMsb = (packetSubcounter << 8) & 0xff; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 3af2b82c..f0cdb61b 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -11,8 +11,9 @@ object_id_t PusServiceBase::packetSource = 0; object_id_t PusServiceBase::packetDestination = 0; -PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId) - : SystemObject(setObjectId), apid(setApid), serviceId(setServiceId) { +PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId, + StorageManagerIF* store_) + : SystemObject(setObjectId), apid(setApid), serviceId(setServiceId), store(store_) { requestQueue = QueueFactory::instance()->createMessageQueue(PUS_SERVICE_MAX_RECEPTION); } @@ -31,7 +32,7 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { return RETURN_OK; } -void PusServiceBase::setTaskIF(PeriodicTaskIF* taskHandle) { this->taskHandle = taskHandle; } +void PusServiceBase::setTaskIF(PeriodicTaskIF* taskHandle_) { this->taskHandle = taskHandle_; } void PusServiceBase::handleRequestQueue() { TmTcMessage message; @@ -49,7 +50,14 @@ void PusServiceBase::handleRequestQueue() { // } if (status == RETURN_OK) { - this->currentPacket.setStoreAddress(message.getStorageId(), ¤tPacket); + const uint8_t* dataPtr; + size_t dataLen = 0; + result = store->getData(message.getStorageId(), &dataPtr, &dataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + // TODO: Warning? + } + + currentPacket.setData(dataPtr, dataLen); // info << "Service " << (uint16_t) this->serviceId << // ": new packet!" << std::endl; @@ -65,7 +73,7 @@ void PusServiceBase::handleRequestQueue() { &this->currentPacket, result, 0, errorParameter1, errorParameter2); } - this->currentPacket.deletePacket(); + store->deleteData(message.getStorageId()); errorParameter1 = 0; errorParameter2 = 0; } else if (status == MessageQueueIF::EMPTY) { @@ -92,9 +100,8 @@ ReturnValue_t PusServiceBase::initialize() { if (result != RETURN_OK) { return result; } - AcceptsTelemetryIF* destService = - ObjectManager::instance()->get(packetDestination); - PUSDistributorIF* distributor = ObjectManager::instance()->get(packetSource); + auto* destService = ObjectManager::instance()->get(packetDestination); + auto* distributor = ObjectManager::instance()->get(packetSource); if (destService == nullptr or distributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PusServiceBase::PusServiceBase: Service " << this->serviceId diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 9db1bef0..57547ace 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -9,12 +9,13 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/tmtcpacket/pus/tc.h" namespace Factory { void setStaticFrameworkObjectIds(); } +class StorageManagerIF; + /** * @defgroup pus_services PUS Service Framework * These group contains all implementations of PUS Services in the OBSW. @@ -50,11 +51,12 @@ class PusServiceBase : public ExecutableObjectIF, * @param setServiceId * The Service Identifier as specified in ECSS PUS. */ - PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId); + PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId, + StorageManagerIF* store); /** * The destructor is empty. */ - virtual ~PusServiceBase(); + ~PusServiceBase() override; /** * @brief The handleRequest method shall handle any kind of Telecommand * Request immediately. @@ -97,12 +99,12 @@ class PusServiceBase : public ExecutableObjectIF, * @c RETURN_FAILED else. */ ReturnValue_t performOperation(uint8_t opCode) override; - virtual uint16_t getIdentifier() override; + uint16_t getIdentifier() override; MessageQueueId_t getRequestQueue() override; - virtual ReturnValue_t initialize() override; + ReturnValue_t initialize() override; - virtual void setTaskIF(PeriodicTaskIF* taskHandle) override; - virtual ReturnValue_t initializeAfterTaskCreation() override; + void setTaskIF(PeriodicTaskIF* taskHandle) override; + ReturnValue_t initializeAfterTaskCreation() override; protected: /** @@ -141,7 +143,9 @@ class PusServiceBase : public ExecutableObjectIF, * The current Telecommand to be processed. * It is deleted after handleRequest was executed. */ - TcPacketStoredPus currentPacket; + // TcPacketStoredPus currentPacket; + StorageManagerIF* store; + PusTcReader currentPacket; static object_id_t packetSource; diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 19277bf3..bf33d1c4 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -11,9 +11,9 @@ object_id_t VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIF VerificationReporter::VerificationReporter() : acknowledgeQueue(MessageQueueIF::NO_QUEUE) {} -VerificationReporter::~VerificationReporter() {} +VerificationReporter::~VerificationReporter() = default; -void VerificationReporter::sendSuccessReport(uint8_t set_report_id, TcPacketPusBase* currentPacket, +void VerificationReporter::sendSuccessReport(uint8_t set_report_id, PusTcReader* currentPacket, uint8_t set_step) { if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) { this->initialize(); @@ -50,7 +50,7 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, uint8_t ackF } } -void VerificationReporter::sendFailureReport(uint8_t report_id, TcPacketPusBase* currentPacket, +void VerificationReporter::sendFailureReport(uint8_t report_id, PusTcReader* currentPacket, ReturnValue_t error_code, uint8_t step, uint32_t parameter1, uint32_t parameter2) { if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) { @@ -98,8 +98,7 @@ void VerificationReporter::initialize() { #endif return; } - AcceptsVerifyMessageIF* temp = - ObjectManager::instance()->get(messageReceiver); + auto* temp = ObjectManager::instance()->get(messageReceiver); if (temp == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::initialize: Message " diff --git a/src/fsfw/tmtcservices/VerificationReporter.h b/src/fsfw/tmtcservices/VerificationReporter.h index c29afd60..5b4dbe0a 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.h +++ b/src/fsfw/tmtcservices/VerificationReporter.h @@ -3,6 +3,7 @@ #include "PusVerificationReport.h" #include "fsfw/objectmanager/ObjectManagerIF.h" +#include "fsfw/tmtcpacket/pus/tc/PusTcCreator.h" namespace Factory { void setStaticFrameworkObjectIds(); @@ -26,12 +27,11 @@ class VerificationReporter { VerificationReporter(); virtual ~VerificationReporter(); - void sendSuccessReport(uint8_t set_report_id, TcPacketPusBase* current_packet, - uint8_t set_step = 0); + void sendSuccessReport(uint8_t set_report_id, PusTcReader* current_packet, uint8_t set_step = 0); void sendSuccessReport(uint8_t set_report_id, uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl, uint8_t set_step = 0); - void sendFailureReport(uint8_t report_id, TcPacketPusBase* current_packet, + void sendFailureReport(uint8_t report_id, PusTcReader* current_packet, ReturnValue_t error_code = 0, uint8_t step = 0, uint32_t parameter1 = 0, uint32_t parameter2 = 0); void sendFailureReport(uint8_t report_id, uint8_t ackFlags, uint16_t tcPacketId, From d80941514fe14bdffd5c113633c5b89ab85c4083 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 20 Jul 2022 11:43:16 +0200 Subject: [PATCH 057/532] start refactoring PUS TM handling --- .../datalinklayer/MapPacketExtraction.cpp | 2 +- src/fsfw/pus/Service17Test.cpp | 39 ++--- src/fsfw/pus/Service17Test.h | 13 +- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 2 +- .../tcdistribution/CcsdsPacketCheckerBase.cpp | 2 +- .../tcdistribution/CcsdsPacketCheckerBase.h | 2 +- src/fsfw/tmtcpacket/CMakeLists.txt | 7 +- src/fsfw/tmtcpacket/ReadablePacketIF.h | 2 +- src/fsfw/tmtcpacket/SpacePacketCreator.h | 87 ----------- src/fsfw/tmtcpacket/ccsds/CMakeLists.txt | 2 + src/fsfw/tmtcpacket/ccsds/PacketId.h | 68 ++++++++ src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h | 56 +++++++ .../{ => ccsds}/SpacePacketCreator.cpp | 16 +- .../tmtcpacket/ccsds/SpacePacketCreator.h | 53 +++++++ .../tmtcpacket/{ => ccsds}/SpacePacketIF.h | 59 +++---- .../{ => ccsds}/SpacePacketReader.cpp | 19 +-- .../{ => ccsds}/SpacePacketReader.h | 13 +- src/fsfw/tmtcpacket/ccsds/defs.h | 36 +++++ src/fsfw/tmtcpacket/ccsds/header.cpp | 29 ++++ src/fsfw/tmtcpacket/ccsds/header.h | 30 ++++ src/fsfw/tmtcpacket/ccsds_header.h | 15 -- src/fsfw/tmtcpacket/cfdp/CfdpPacket.h | 2 +- .../packetmatcher/PacketMatchTree.cpp | 12 +- src/fsfw/tmtcpacket/pus/PusIF.h | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 4 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 8 +- src/fsfw/tmtcpacket/pus/tc/PusTcIF.h | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp | 9 +- src/fsfw/tmtcpacket/pus/tc/PusTcReader.h | 6 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 8 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 10 +- src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp | 11 +- src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h | 59 ++++--- src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h | 2 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h | 6 +- .../tmtcpacket/pus/tm/TmPacketStoredPusC.h | 145 +++++++++--------- src/fsfw/tmtcservices/CMakeLists.txt | 3 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 14 +- src/fsfw/tmtcservices/PusServiceBase.h | 4 +- src/fsfw/tmtcservices/SourceSequenceCounter.h | 2 +- src/fsfw/tmtcservices/TmStoreHelper.cpp | 43 ++++++ src/fsfw/tmtcservices/TmStoreHelper.h | 33 ++++ .../tmtcservices/VerificationReporter.cpp | 10 +- unittests/tmtcpacket/testCcsdsCreator.cpp | 19 ++- unittests/tmtcpacket/testCcsdsReader.cpp | 2 +- 46 files changed, 615 insertions(+), 355 deletions(-) delete mode 100644 src/fsfw/tmtcpacket/SpacePacketCreator.h create mode 100644 src/fsfw/tmtcpacket/ccsds/CMakeLists.txt create mode 100644 src/fsfw/tmtcpacket/ccsds/PacketId.h create mode 100644 src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h rename src/fsfw/tmtcpacket/{ => ccsds}/SpacePacketCreator.cpp (75%) create mode 100644 src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h rename src/fsfw/tmtcpacket/{ => ccsds}/SpacePacketIF.h (56%) rename src/fsfw/tmtcpacket/{ => ccsds}/SpacePacketReader.cpp (62%) rename src/fsfw/tmtcpacket/{ => ccsds}/SpacePacketReader.h (88%) create mode 100644 src/fsfw/tmtcpacket/ccsds/defs.h create mode 100644 src/fsfw/tmtcpacket/ccsds/header.cpp create mode 100644 src/fsfw/tmtcpacket/ccsds/header.h delete mode 100644 src/fsfw/tmtcpacket/ccsds_header.h create mode 100644 src/fsfw/tmtcservices/TmStoreHelper.cpp create mode 100644 src/fsfw/tmtcservices/TmStoreHelper.h diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.cpp b/src/fsfw/datalinklayer/MapPacketExtraction.cpp index 1467f2aa..feb1cc91 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.cpp +++ b/src/fsfw/datalinklayer/MapPacketExtraction.cpp @@ -6,7 +6,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/tmtcpacket/SpacePacketReader.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/TmTcMessage.h" diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index f784acf4..87549808 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -5,33 +5,25 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h" -Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId) - : PusServiceBase(objectId, apid, serviceId), packetSubCounter(0) {} +Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId, + StorageManagerIF* tmStore, StorageManagerIF* ipcStore, + InternalErrorReporterIF* errReporter) + : PusServiceBase(objectId, apid, serviceId, ipcStore), + helper(tmStore, MessageQueueIF::NO_QUEUE, MessageQueueIF::NO_QUEUE, errReporter), + packetSubCounter(0) {} -Service17Test::~Service17Test() {} +Service17Test::~Service17Test() = default; ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { switch (subservice) { case Subservice::CONNECTION_TEST: { -#if FSFW_USE_PUS_C_TELEMETRY == 0 - TmPacketStoredPusA connectionPacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT, - packetSubCounter++); -#else - TmPacketStoredPusC connectionPacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT, - packetSubCounter++); -#endif - connectionPacket.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); + helper.preparePacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter); + helper.sendPacket(); return HasReturnvaluesIF::RETURN_OK; } case Subservice::EVENT_TRIGGER_TEST: { -#if FSFW_USE_PUS_C_TELEMETRY == 0 - TmPacketStoredPusA connectionPacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT, - packetSubCounter++); -#else - TmPacketStoredPusC connectionPacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT, - packetSubCounter++); -#endif - connectionPacket.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); + helper.preparePacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter++); + helper.sendPacket(); triggerEvent(TEST, 1234, 5678); return RETURN_OK; } @@ -41,3 +33,12 @@ ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { } ReturnValue_t Service17Test::performService() { return HasReturnvaluesIF::RETURN_OK; } + +ReturnValue_t Service17Test::initialize() { + ReturnValue_t result = PusServiceBase::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + helper.setMsgDestination(requestQueue->getDefaultDestination()); + helper.setMsgSource(requestQueue->getId()); + if (tm) } diff --git a/src/fsfw/pus/Service17Test.h b/src/fsfw/pus/Service17Test.h index c2248020..0f690ea4 100644 --- a/src/fsfw/pus/Service17Test.h +++ b/src/fsfw/pus/Service17Test.h @@ -3,6 +3,7 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tmtcservices/PusServiceBase.h" +#include "fsfw/tmtcservices/TmStoreHelper.h" /** * @brief Test Service @@ -32,12 +33,16 @@ class Service17Test : public PusServiceBase { EVENT_TRIGGER_TEST = 128, }; - Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId); - virtual ~Service17Test(); - virtual ReturnValue_t handleRequest(uint8_t subservice) override; - virtual ReturnValue_t performService() override; + Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId, + InternalErrorReporterIF* errReporter, StorageManagerIF* tmStore = nullptr, + StorageManagerIF* ipcStore = nullptr); + ~Service17Test() override; + ReturnValue_t handleRequest(uint8_t subservice) override; + ReturnValue_t performService() override; + ReturnValue_t initialize() override; protected: + TmStoreHelper helper; uint16_t packetSubCounter = 0; }; diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index f18e55de..9601825c 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -2,7 +2,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tmtcpacket/SpacePacketReader.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" #define CCSDS_DISTRIBUTOR_DEBUGGING 0 diff --git a/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp b/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp index 8c97f646..e1b6337f 100644 --- a/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp +++ b/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp @@ -1,7 +1,7 @@ #include "CcsdsPacketCheckerBase.h" #include "fsfw/tcdistribution/definitions.h" -#include "fsfw/tmtcpacket/SpacePacketReader.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" CcsdsPacketCheckerBase::CcsdsPacketCheckerBase(uint16_t apid, ccsds::PacketType packetType_, uint8_t ccsdsVersion_) diff --git a/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h b/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h index f5a9b317..0f7f7e14 100644 --- a/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h +++ b/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h @@ -2,7 +2,7 @@ #define FSFW_TESTS_CCSDSPACKETCHECKERBASE_H #include "CcsdsPacketCheckIF.h" -#include "fsfw/tmtcpacket/SpacePacketIF.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" class CcsdsPacketCheckerBase : public CcsdsPacketCheckIF, public HasReturnvaluesIF { public: diff --git a/src/fsfw/tmtcpacket/CMakeLists.txt b/src/fsfw/tmtcpacket/CMakeLists.txt index 69b3cc48..8c70d351 100644 --- a/src/fsfw/tmtcpacket/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/CMakeLists.txt @@ -1,7 +1,6 @@ -target_sources( - ${LIB_FSFW_NAME} PRIVATE SpacePacketReader.cpp SpacePacketCreator.cpp - PacketStorageHelper.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE PacketStorageHelper.cpp) +add_subdirectory(ccsds) +add_subdirectory(pus) add_subdirectory(cfdp) add_subdirectory(packetmatcher) -add_subdirectory(pus) diff --git a/src/fsfw/tmtcpacket/ReadablePacketIF.h b/src/fsfw/tmtcpacket/ReadablePacketIF.h index c1287e81..01478273 100644 --- a/src/fsfw/tmtcpacket/ReadablePacketIF.h +++ b/src/fsfw/tmtcpacket/ReadablePacketIF.h @@ -1,7 +1,7 @@ #ifndef FSFW_TMTCPACKET_SPACEPACKETREADERIF_H #define FSFW_TMTCPACKET_SPACEPACKETREADERIF_H -#include "SpacePacketIF.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" class ReadablePacketIF { public: diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.h b/src/fsfw/tmtcpacket/SpacePacketCreator.h deleted file mode 100644 index 9c74046b..00000000 --- a/src/fsfw/tmtcpacket/SpacePacketCreator.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef FSFW_TMTCPACKET_SPACEPACKETCREATOR_H -#define FSFW_TMTCPACKET_SPACEPACKETCREATOR_H - -#include "SpacePacketIF.h" -#include "fsfw/serialize/SerializeIF.h" - -struct PacketId { - public: - /** - * Simple wrapper for Space Packet IDs. Does not check the APID for validity - * @param packetType_ - * @param secHeaderFlag_ - * @param apid_ - */ - PacketId(ccsds::PacketType packetType_, bool secHeaderFlag_, uint16_t apid_) - : packetType(packetType_), secHeaderFlag(secHeaderFlag_), apid(apid_) {} - - /** - * NOTE: If the APID has an invalid value, the invalid bits will be cut off - * @return - */ - [[nodiscard]] uint16_t raw() const { - return (static_cast(packetType) << 12) | - (static_cast(secHeaderFlag) << 11) | (apid & 0x7ff); - } - - ccsds::PacketType packetType; - bool secHeaderFlag; - uint16_t apid; -}; - -struct PacketSeqCtrl { - public: - PacketSeqCtrl(ccsds::SequenceFlags seqFlags, uint16_t seqCount) - : seqFlags(seqFlags), seqCount(seqCount) {} - - /** - * NOTE: If the sequence control has an invalid value, the invalid bits will be cut off - * @return - */ - [[nodiscard]] uint16_t raw() const { - return (static_cast(seqFlags) << 14) | (seqCount & 0x3FFF); - } - ccsds::SequenceFlags seqFlags; - uint16_t seqCount; -}; - -struct SpacePacketParams { - PacketId packetId; - PacketSeqCtrl packetSeqCtrl; - uint16_t dataLen; - uint8_t version = 0b000; -}; - -class SpacePacketCreator : public SpacePacketIF, public SerializeIF { - public: - /* - SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid, - ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen, - uint8_t version = 0); - */ - explicit SpacePacketCreator(SpacePacketParams ¶ms); - [[nodiscard]] bool isValid() const; - [[nodiscard]] uint16_t getPacketId() const override; - [[nodiscard]] uint16_t getPacketSeqCtrl() const override; - [[nodiscard]] uint16_t getPacketDataLen() const override; - - void setApid(uint16_t apid); - void setSeqCount(uint16_t seqCount); - void setSeqFlags(ccsds::SequenceFlags flags); - void setDataLen(uint16_t dataLen); - - ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const; - ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const override; - - [[nodiscard]] size_t getSerializedSize() const override; - ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, - Endianness streamEndianness) override; - - private: - void checkFieldValidity(); - - bool valid{}; - SpacePacketParams params; -}; -#endif // FSFW_TMTCPACKET_SPACEPACKETCREATOR_H diff --git a/src/fsfw/tmtcpacket/ccsds/CMakeLists.txt b/src/fsfw/tmtcpacket/ccsds/CMakeLists.txt new file mode 100644 index 00000000..68efe09c --- /dev/null +++ b/src/fsfw/tmtcpacket/ccsds/CMakeLists.txt @@ -0,0 +1,2 @@ +target_sources(${LIB_FSFW_NAME} PRIVATE SpacePacketReader.cpp + SpacePacketCreator.cpp header.cpp) diff --git a/src/fsfw/tmtcpacket/ccsds/PacketId.h b/src/fsfw/tmtcpacket/ccsds/PacketId.h new file mode 100644 index 00000000..49587483 --- /dev/null +++ b/src/fsfw/tmtcpacket/ccsds/PacketId.h @@ -0,0 +1,68 @@ +#ifndef FSFW_TMTCPACKET_PACKETID_H +#define FSFW_TMTCPACKET_PACKETID_H + +#include + +#include "defs.h" +#include "fsfw/serialize/SerializeAdapter.h" +#include "fsfw/serialize/SerializeIF.h" + +struct PacketId : public SerializeIF { + public: + PacketId() = default; + /** + * Simple wrapper for Space Packet IDs. Does not check the APID for validity + * @param packetType_ + * @param secHeaderFlag_ + * @param apid_ + */ + PacketId(ccsds::PacketType packetType_, bool secHeaderFlag_, uint16_t apid_) + : packetType(packetType_), secHeaderFlag(secHeaderFlag_), apid(apid_) {} + + /** + * NOTE: If the APID has an invalid value, the invalid bits will be cut off + * @return + */ + [[nodiscard]] uint16_t raw() const { + return (static_cast(packetType) << 12) | + (static_cast(secHeaderFlag) << 11) | (apid & 0x7ff); + } + + static PacketId fromRaw(uint16_t raw) { + uint8_t highByte = (raw >> 8) & 0xff; + uint8_t lowByte = raw & 0xff; + return {static_cast((highByte >> 4) & 0b1), + static_cast((highByte >> 3) & 0b1), + static_cast((highByte & 0b111) << 8 | lowByte)}; + } + + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override { + uint16_t pscRaw = raw(); + return SerializeAdapter::serialize(&pscRaw, buffer, size, maxSize, streamEndianness); + } + + [[nodiscard]] size_t getSerializedSize() const override { return 2; } + + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override { + if (*size < 2) { + return SerializeIF::STREAM_TOO_SHORT; + } + uint8_t highByte = **buffer; + *buffer += 1; + uint8_t lowByte = **buffer; + *buffer += 1; + *size -= 2; + packetType = static_cast((highByte >> 4) & 0b1); + secHeaderFlag = (highByte >> 3) & 0b1; + apid = static_cast((highByte & 0b111) << 8 | lowByte); + return HasReturnvaluesIF::RETURN_OK; + } + + ccsds::PacketType packetType = ccsds::PacketType::TM; + bool secHeaderFlag = false; + uint16_t apid = 0; +}; + +#endif // FSFW_TMTCPACKET_PACKETID_H diff --git a/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h b/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h new file mode 100644 index 00000000..830a6fa2 --- /dev/null +++ b/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h @@ -0,0 +1,56 @@ +#ifndef FSFW_TMTCPACKET_PACKETSEQCTRL_H +#define FSFW_TMTCPACKET_PACKETSEQCTRL_H + +#include "defs.h" +#include "fsfw/serialize/SerializeAdapter.h" +#include "fsfw/serialize/SerializeIF.h" + +struct PacketSeqCtrl : public SerializeIF { + public: + PacketSeqCtrl() = default; + + PacketSeqCtrl(ccsds::SequenceFlags seqFlags, uint16_t seqCount) + : seqFlags(seqFlags), seqCount(seqCount) {} + + /** + * NOTE: If the sequence control has an invalid value, the invalid bits will be cut off + * @return + */ + [[nodiscard]] uint16_t raw() const { + return (static_cast(seqFlags) << 14) | (seqCount & 0x3FFF); + } + + static PacketSeqCtrl fromRaw(uint16_t raw) { + uint8_t highByte = (raw >> 8) & 0xff; + uint8_t lowByte = raw & 0xff; + return {static_cast((highByte >> 6) & 0b11), + static_cast(((highByte << 8) | lowByte) & 0x3FFF)}; + } + + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override { + uint16_t packetIdRaw = raw(); + return SerializeAdapter::serialize(&packetIdRaw, buffer, size, maxSize, streamEndianness); + } + [[nodiscard]] size_t getSerializedSize() const override { return 2; } + + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override { + if (*size < 2) { + return SerializeIF::STREAM_TOO_SHORT; + } + uint8_t highByte = **buffer; + *buffer += 1; + uint8_t lowByte = **buffer; + *buffer += 1; + *size -= 2; + seqFlags = static_cast((highByte >> 6) & 0b11); + seqCount = ((highByte << 8) | lowByte) & 0x3FFF; + return HasReturnvaluesIF::RETURN_OK; + } + + ccsds::SequenceFlags seqFlags = ccsds::SequenceFlags::CONTINUATION; + uint16_t seqCount = 0; +}; + +#endif // FSFW_TMTCPACKET_PACKETSEQCTRL_H diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp similarity index 75% rename from src/fsfw/tmtcpacket/SpacePacketCreator.cpp rename to src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp index ff131059..ce1852ab 100644 --- a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp @@ -1,13 +1,23 @@ #include "SpacePacketCreator.h" +#include + #include "fsfw/serialize/SerializeAdapter.h" -SpacePacketCreator::SpacePacketCreator(SpacePacketParams ¶ms_) : params(params_) { +SpacePacketCreator::SpacePacketCreator(SpacePacketParams params_) : params(std::move(params_)) { checkFieldValidity(); } -uint16_t SpacePacketCreator::getPacketId() const { return params.packetId.raw(); } -uint16_t SpacePacketCreator::getPacketSeqCtrl() const { return params.packetSeqCtrl.raw(); } +SpacePacketCreator::SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, + uint16_t apid, ccsds::SequenceFlags seqFlags, + uint16_t seqCount, uint16_t dataLen, uint8_t version) + : params(SpacePacketParams(PacketId(packetType, secHeaderFlag, apid), + PacketSeqCtrl(seqFlags, seqCount), dataLen)) { + params.version = version; +} + +uint16_t SpacePacketCreator::getPacketIdRaw() const { return params.packetId.raw(); } +uint16_t SpacePacketCreator::getPacketSeqCtrlRaw() const { return params.packetSeqCtrl.raw(); } uint16_t SpacePacketCreator::getPacketDataLen() const { return params.dataLen; } ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h new file mode 100644 index 00000000..5e2888c0 --- /dev/null +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h @@ -0,0 +1,53 @@ +#ifndef FSFW_TMTCPACKET_SPACEPACKETCREATOR_H +#define FSFW_TMTCPACKET_SPACEPACKETCREATOR_H + +#include + +#include "PacketId.h" +#include "PacketSeqCtrl.h" +#include "SpacePacketIF.h" +#include "fsfw/serialize/SerializeIF.h" + +struct SpacePacketParams { + SpacePacketParams(PacketId packetId, PacketSeqCtrl psc, uint16_t dataLen) + : packetId(std::move(packetId)), packetSeqCtrl(std::move(psc)), dataLen(dataLen) {} + + PacketId packetId{}; + PacketSeqCtrl packetSeqCtrl{}; + uint16_t dataLen = 0; + uint8_t version = 0b000; +}; + +class SpacePacketCreator : public SpacePacketIF, public SerializeIF { + public: + explicit SpacePacketCreator(SpacePacketParams params); + SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid, + ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen, + uint8_t version = 0); + + [[nodiscard]] bool isValid() const; + [[nodiscard]] uint16_t getPacketIdRaw() const override; + [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; + [[nodiscard]] uint16_t getPacketDataLen() const override; + + void setApid(uint16_t apid); + void setSeqCount(uint16_t seqCount); + void setSeqFlags(ccsds::SequenceFlags flags); + void setDataLen(uint16_t dataLen); + + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const; + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override; + + [[nodiscard]] size_t getSerializedSize() const override; + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override; + + private: + void checkFieldValidity(); + + SpacePacketCreator() = default; + bool valid{}; + SpacePacketParams params; +}; +#endif // FSFW_TMTCPACKET_SPACEPACKETCREATOR_H diff --git a/src/fsfw/tmtcpacket/SpacePacketIF.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h similarity index 56% rename from src/fsfw/tmtcpacket/SpacePacketIF.h rename to src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h index 21ee4c32..5db7b254 100644 --- a/src/fsfw/tmtcpacket/SpacePacketIF.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h @@ -4,37 +4,10 @@ #include #include -#include "ccsds_header.h" - -namespace ccsds { - -enum PacketType : uint8_t { TM = 0, TC = 1 }; - -enum SequenceFlags : uint8_t { - CONTINUATION = 0b00, - FIRST_SEGMENT = 0b01, - LAST_SEGMENT = 0b10, - UNSEGMENTED = 0b11 -}; - -static const uint16_t LIMIT_APID = 2048; // 2^11 -static const uint16_t LIMIT_SEQUENCE_COUNT = 16384; // 2^14 -static const uint16_t APID_IDLE_PACKET = 0x7FF; - -constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid, - bool secondaryHeaderFlag = true) { - return ((isTc << 4) | (secondaryHeaderFlag << 3) | ((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff); -} - -constexpr uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { - return getSpacePacketIdFromApid(true, apid, secondaryHeaderFlag); -} - -constexpr uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { - return getSpacePacketIdFromApid(false, apid, secondaryHeaderFlag); -} - -} // namespace ccsds +#include "PacketId.h" +#include "PacketSeqCtrl.h" +#include "fsfw/tmtcpacket/ccsds/defs.h" +#include "header.h" class SpacePacketIF { public: @@ -45,7 +18,7 @@ class SpacePacketIF { /** * This is the minimum size of a SpacePacket. */ - static const uint16_t MINIMUM_SIZE = sizeof(CCSDSPrimaryHeader) + CRC_SIZE; + static const uint16_t MINIMUM_SIZE = sizeof(ccsds::PrimaryHeader) + CRC_SIZE; virtual ~SpacePacketIF() = default; @@ -54,21 +27,25 @@ class SpacePacketIF { * the CCSDS packet ID * @return The CCSDS packet ID */ - [[nodiscard]] virtual uint16_t getPacketId() const = 0; + [[nodiscard]] virtual uint16_t getPacketIdRaw() const = 0; /** * Returns the third and the fourth byte of the CCSDS header which are the packet sequence * control field * @return */ - [[nodiscard]] virtual uint16_t getPacketSeqCtrl() const = 0; + [[nodiscard]] virtual uint16_t getPacketSeqCtrlRaw() const = 0; /** * Returns the fifth and the sixth byte of the CCSDS header which is the packet length field * @return */ [[nodiscard]] virtual uint16_t getPacketDataLen() const = 0; + virtual PacketId getPacketId() { return PacketId::fromRaw(getPacketIdRaw()); } + + virtual PacketSeqCtrl getPacketSeqCtrl() { return PacketSeqCtrl::fromRaw(getPacketSeqCtrlRaw()); } + [[nodiscard]] virtual uint16_t getApid() const { - uint16_t packetId = getPacketId(); + uint16_t packetId = getPacketIdRaw(); // Uppermost 11 bits of packet ID return ((packetId >> 8) & 0b111) | (packetId & 0xFF); } @@ -78,12 +55,12 @@ class SpacePacketIF { * @return */ [[nodiscard]] virtual uint8_t getVersion() const { - uint16_t packetId = getPacketId(); + uint16_t packetId = getPacketIdRaw(); return (packetId >> 13) & 0b111; } [[nodiscard]] virtual ccsds::PacketType getPacketType() const { - return static_cast((getPacketId() >> 12) & 0b1); + return static_cast((getPacketIdRaw() >> 12) & 0b1); } [[nodiscard]] virtual bool isTc() const { return getPacketType() == ccsds::PacketType::TC; } @@ -95,20 +72,20 @@ class SpacePacketIF { * which is checked with this method. * @return Returns true if the bit is set and false if not. */ - [[nodiscard]] virtual bool hasSecHeader() const { return (getPacketId() >> 11) & 0b1; } + [[nodiscard]] virtual bool hasSecHeader() const { return (getPacketIdRaw() >> 11) & 0b1; } [[nodiscard]] virtual ccsds::SequenceFlags getSequenceFlags() const { - return static_cast(getPacketSeqCtrl() >> 14 & 0b11); + return static_cast(getPacketSeqCtrlRaw() >> 14 & 0b11); } - [[nodiscard]] virtual uint16_t getSequenceCount() const { return getPacketSeqCtrl() & 0x3FFF; } + [[nodiscard]] virtual uint16_t getSequenceCount() const { return getPacketSeqCtrlRaw() & 0x3FFF; } /** * Returns the full packet length based of the packet data length field * @return */ [[nodiscard]] virtual size_t getFullPacketLen() const { - return sizeof(CCSDSPrimaryHeader) + getPacketDataLen() + 1; + return ccsds::HEADER_LEN + getPacketDataLen() + 1; } }; diff --git a/src/fsfw/tmtcpacket/SpacePacketReader.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp similarity index 62% rename from src/fsfw/tmtcpacket/SpacePacketReader.cpp rename to src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp index 2d7d2eda..a0ad5328 100644 --- a/src/fsfw/tmtcpacket/SpacePacketReader.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp @@ -1,4 +1,4 @@ -#include "fsfw/tmtcpacket/SpacePacketReader.h" +#include "SpacePacketReader.h" #include @@ -18,27 +18,24 @@ ReturnValue_t SpacePacketReader::checkLength() const { SpacePacketReader::~SpacePacketReader() = default; -inline uint16_t SpacePacketReader::getPacketId() const { - return ((spHeader->packetIdHAndVersion) << 8) + spHeader->packetIdL; -} +inline uint16_t SpacePacketReader::getPacketIdRaw() const { return ccsds::getPacketId(*spHeader); } const uint8_t* SpacePacketReader::getPacketData() { return packetDataField; } ReturnValue_t SpacePacketReader::setData(uint8_t* pData, size_t maxSize_, void* args) { setInternalFields(pData, maxSize_); + return HasReturnvaluesIF::RETURN_OK; } -uint16_t SpacePacketReader::getPacketSeqCtrl() const { - return (spHeader->packetSeqCtrlH << 8) + spHeader->packetSeqCtrlL; +uint16_t SpacePacketReader::getPacketSeqCtrlRaw() const { + return ccsds::getPacketSeqCtrl(*spHeader); } -uint16_t SpacePacketReader::getPacketDataLen() const { - return (spHeader->packetLenH << 8) | spHeader->packetIdL; -} +uint16_t SpacePacketReader::getPacketDataLen() const { return ccsds::getPacketLen(*spHeader); } void SpacePacketReader::setInternalFields(const uint8_t* data, size_t maxSize_) { maxSize = maxSize_; - spHeader = reinterpret_cast(data); - packetDataField = data + sizeof(CCSDSPrimaryHeader); + spHeader = reinterpret_cast(data); + packetDataField = data + ccsds::HEADER_LEN; } const uint8_t* SpacePacketReader::getFullData() { return reinterpret_cast(spHeader); diff --git a/src/fsfw/tmtcpacket/SpacePacketReader.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h similarity index 88% rename from src/fsfw/tmtcpacket/SpacePacketReader.h rename to src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h index eb1d5c93..43119146 100644 --- a/src/fsfw/tmtcpacket/SpacePacketReader.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h @@ -1,13 +1,12 @@ #ifndef FSFW_TMTCPACKET_SPACEPACKETBASE_H_ #define FSFW_TMTCPACKET_SPACEPACKETBASE_H_ -#include - #include -#include "ReadablePacketIF.h" -#include "ccsds_header.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tmtcpacket/ReadablePacketIF.h" +#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" +#include "fsfw/tmtcpacket/ccsds/defs.h" /** * @defgroup tmtcpackets Space Packets @@ -46,8 +45,8 @@ class SpacePacketReader : public SpacePacketIF, */ ~SpacePacketReader() override; - [[nodiscard]] uint16_t getPacketId() const override; - [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketIdRaw() const override; + [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; const uint8_t* getFullData() override; @@ -70,7 +69,7 @@ class SpacePacketReader : public SpacePacketIF, * the packet header. * To be hardware-safe, all elements are of byte size. */ - const CCSDSPrimaryHeader* spHeader{}; + const ccsds::PrimaryHeader* spHeader{}; const uint8_t* packetDataField{}; size_t maxSize = 0; diff --git a/src/fsfw/tmtcpacket/ccsds/defs.h b/src/fsfw/tmtcpacket/ccsds/defs.h new file mode 100644 index 00000000..1c7de540 --- /dev/null +++ b/src/fsfw/tmtcpacket/ccsds/defs.h @@ -0,0 +1,36 @@ +#ifndef CCSDS_HEADER_H_ +#define CCSDS_HEADER_H_ + +#include + +namespace ccsds { + +enum PacketType : uint8_t { TM = 0, TC = 1 }; + +enum SequenceFlags : uint8_t { + CONTINUATION = 0b00, + FIRST_SEGMENT = 0b01, + LAST_SEGMENT = 0b10, + UNSEGMENTED = 0b11 +}; + +static const uint16_t LIMIT_APID = 2048; // 2^11 +static const uint16_t LIMIT_SEQUENCE_COUNT = 16384; // 2^14 +static const uint16_t APID_IDLE_PACKET = 0x7FF; + +constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid, + bool secondaryHeaderFlag = true) { + return ((isTc << 4) | (secondaryHeaderFlag << 3) | ((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff); +} + +constexpr uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { + return getSpacePacketIdFromApid(true, apid, secondaryHeaderFlag); +} + +constexpr uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { + return getSpacePacketIdFromApid(false, apid, secondaryHeaderFlag); +} + +} // namespace ccsds + +#endif /* CCSDS_HEADER_H_ */ diff --git a/src/fsfw/tmtcpacket/ccsds/header.cpp b/src/fsfw/tmtcpacket/ccsds/header.cpp new file mode 100644 index 00000000..b7aa270e --- /dev/null +++ b/src/fsfw/tmtcpacket/ccsds/header.cpp @@ -0,0 +1,29 @@ +#include "header.h" + +uint16_t ccsds::getPacketId(const PrimaryHeader &header) { + return ((header.packetIdHAndVersion & 0x1F00) << 8) + header.packetIdL; +} + +uint16_t ccsds::getPacketSeqCtrl(const PrimaryHeader &header) { + return (header.packetSeqCtrlH << 8) | header.packetSeqCtrlL; +} + +uint8_t ccsds::getVersion(const PrimaryHeader &header) { + return (header.packetIdHAndVersion >> 5) & 0b111; +} + +uint16_t ccsds::getPacketLen(const PrimaryHeader &header) { + return (header.packetLenH << 8) | header.packetLenL; +} + +void ccsds::setPacketId(PrimaryHeader &header, uint16_t packetId) { + header.packetIdHAndVersion = (packetId >> 8) & 0x1F; + header.packetIdL = packetId & 0xff; +} + +void ccsds::setApid(PrimaryHeader &header, uint16_t apid) { + uint16_t packetIdRaw = getPacketId(header); + packetIdRaw &= ~0x7FF; + packetIdRaw |= apid & 0x7FF; + setPacketId(header, packetIdRaw); +} diff --git a/src/fsfw/tmtcpacket/ccsds/header.h b/src/fsfw/tmtcpacket/ccsds/header.h new file mode 100644 index 00000000..d416f697 --- /dev/null +++ b/src/fsfw/tmtcpacket/ccsds/header.h @@ -0,0 +1,30 @@ +#ifndef FSFW_TMTCPACKET_HEADER_H +#define FSFW_TMTCPACKET_HEADER_H + +#include +#include + +namespace ccsds { + +static constexpr size_t HEADER_LEN = 6; + +struct PrimaryHeader { + uint8_t packetIdHAndVersion; + uint8_t packetIdL; + uint8_t packetSeqCtrlH; + uint8_t packetSeqCtrlL; + uint8_t packetLenH; + uint8_t packetLenL; +}; + +uint16_t getPacketId(const PrimaryHeader& header); +uint16_t getPacketSeqCtrl(const PrimaryHeader& header); +uint8_t getVersion(const PrimaryHeader& header); +uint16_t getPacketLen(const PrimaryHeader& header); + +void setPacketId(PrimaryHeader& header, uint16_t packetId); +void setApid(PrimaryHeader& header, uint16_t apid); + +} // namespace ccsds + +#endif // FSFW_TMTCPACKET_HEADER_H diff --git a/src/fsfw/tmtcpacket/ccsds_header.h b/src/fsfw/tmtcpacket/ccsds_header.h deleted file mode 100644 index c0db194e..00000000 --- a/src/fsfw/tmtcpacket/ccsds_header.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef CCSDS_HEADER_H_ -#define CCSDS_HEADER_H_ - -#include - -struct CCSDSPrimaryHeader { - uint8_t packetIdHAndVersion; - uint8_t packetIdL; - uint8_t packetSeqCtrlH; - uint8_t packetSeqCtrlL; - uint8_t packetLenH; - uint8_t packetLenL; -}; - -#endif /* CCSDS_HEADER_H_ */ diff --git a/src/fsfw/tmtcpacket/cfdp/CfdpPacket.h b/src/fsfw/tmtcpacket/cfdp/CfdpPacket.h index e47d3b6f..e391202f 100644 --- a/src/fsfw/tmtcpacket/cfdp/CfdpPacket.h +++ b/src/fsfw/tmtcpacket/cfdp/CfdpPacket.h @@ -1,7 +1,7 @@ #ifndef FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_ #define FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_ -#include "fsfw/tmtcpacket/SpacePacketReader.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" class CfdpReader : public SpacePacketReader { public: diff --git a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp index 1ab8729b..c1f6665a 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp +++ b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp @@ -32,8 +32,8 @@ PacketMatchTree::~PacketMatchTree() = default; ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t subtype) { // We assume adding APID is always requested. PusTmMinimal::TmPacketMinimalPointer data{}; - data.secHeader.service_type = type; - data.secHeader.service_subtype = subtype; + data.secHeader.service = type; + data.secHeader.subservice = subtype; PusTmMinimal testPacket((uint8_t*)&data); testPacket.setApid(apid); @@ -122,13 +122,13 @@ ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test, } ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type, uint8_t subtype) { - PusTmMinimal::TmPacketMinimalPointer data; - data.secHeader.service_type = type; - data.secHeader.service_subtype = subtype; + PusTmMinimal::TmPacketMinimalPointer data{}; + data.secHeader.service = type; + data.secHeader.subservice = subtype; PusTmMinimal testPacket((uint8_t*)&data); testPacket.setApid(apid); iterator foundElement = findMatch(begin(), &testPacket); - if (foundElement == this->end()) { + if (foundElement == PacketMatchTree::end()) { return NO_MATCH; } if (type == 0) { diff --git a/src/fsfw/tmtcpacket/pus/PusIF.h b/src/fsfw/tmtcpacket/pus/PusIF.h index 61d4fcff..5eeae04d 100644 --- a/src/fsfw/tmtcpacket/pus/PusIF.h +++ b/src/fsfw/tmtcpacket/pus/PusIF.h @@ -3,7 +3,7 @@ #include -#include "fsfw/tmtcpacket/SpacePacketIF.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" class PusIF : public SpacePacketIF { public: diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index cbd6da53..7de759c8 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -51,9 +51,9 @@ ReturnValue_t PusTcCreator::deSerialize(const uint8_t **buffer, size_t *size, return HasReturnvaluesIF::RETURN_FAILED; } -uint16_t PusTcCreator::getPacketId() const { return spCreator.getPacketId(); } +uint16_t PusTcCreator::getPacketIdRaw() const { return spCreator.getPacketIdRaw(); } -uint16_t PusTcCreator::getPacketSeqCtrl() const { return spCreator.getPacketSeqCtrl(); } +uint16_t PusTcCreator::getPacketSeqCtrlRaw() const { return spCreator.getPacketSeqCtrlRaw(); } uint16_t PusTcCreator::getPacketDataLen() const { return spCreator.getPacketDataLen(); } diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index ffa2ed7c..cc220fa9 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -2,8 +2,8 @@ #define FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" -#include "fsfw/tmtcpacket/SpacePacketCreator.h" -#include "fsfw/tmtcpacket/SpacePacketIF.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" #include "fsfw/tmtcpacket/pus/definitions.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" @@ -29,8 +29,8 @@ class PusTcCreator : public PusTcIF, public SerializeIF { [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; - [[nodiscard]] uint16_t getPacketId() const override; - [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketIdRaw() const override; + [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; [[nodiscard]] uint8_t getPusVersion() const override; [[nodiscard]] uint8_t getAcknowledgeFlags() const override; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h index a8204a1f..889260c1 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h @@ -45,7 +45,7 @@ class PusTcIF : public PusIF { public: ~PusTcIF() override = default; static const size_t MIN_LEN = - (sizeof(CCSDSPrimaryHeader) + ecss::PusTcDataFieldHeader::MIN_LEN + 2); + (sizeof(ccsds::PrimaryHeader) + ecss::PusTcDataFieldHeader::MIN_LEN + 2); /** * This is a getter for the packet's Ack field, which are the lowest four diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp index 0ead9bde..43c30a46 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp @@ -21,10 +21,10 @@ ReturnValue_t PusTcReader::parseData() { } // Might become variable sized field in the future size_t secHeaderLen = ecss::PusTcDataFieldHeader::MIN_LEN; - pointers.secHeaderStart = pointers.spHeaderStart + sizeof(CCSDSPrimaryHeader); + pointers.secHeaderStart = pointers.spHeaderStart + ccsds::HEADER_LEN; // TODO: No support for spare bytes yet pointers.userDataStart = pointers.secHeaderStart + secHeaderLen; - appDataSize = size - (sizeof(CCSDSPrimaryHeader) + secHeaderLen); + appDataSize = size - (ccsds::HEADER_LEN + secHeaderLen); pointers.crcStart = pointers.userDataStart + appDataSize; return HasReturnvaluesIF::RETURN_OK; } @@ -50,8 +50,8 @@ uint16_t PusTcReader::getErrorControl() const { return pointers.crcStart[0] << 8 | pointers.crcStart[1]; } -uint16_t PusTcReader::getPacketId() const { return spReader.getPacketId(); } -uint16_t PusTcReader::getPacketSeqCtrl() const { return spReader.getPacketSeqCtrl(); } +uint16_t PusTcReader::getPacketIdRaw() const { return spReader.getPacketIdRaw(); } +uint16_t PusTcReader::getPacketSeqCtrlRaw() const { return spReader.getPacketSeqCtrlRaw(); } uint16_t PusTcReader::getPacketDataLen() const { return spReader.getPacketDataLen(); } uint8_t PusTcReader::getPusVersion() const { return spReader.getVersion(); } const uint8_t* PusTcReader::getFullData() { return pointers.spHeaderStart; } @@ -64,6 +64,7 @@ ReturnValue_t PusTcReader::setData(uint8_t* pData, size_t size_, void* args) { } ReturnValue_t PusTcReader::setData(const uint8_t* data, size_t size_) { setData(const_cast(data), size_, nullptr); + return HasReturnvaluesIF::RETURN_OK; } /* diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h index 85623980..b2045761 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h @@ -5,7 +5,7 @@ #include "PusTcIF.h" #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" -#include "fsfw/tmtcpacket/SpacePacketReader.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" /** * This class is the basic data handler for any ECSS PUS Telecommand packet. @@ -40,8 +40,8 @@ class PusTcReader : public PusTcIF, public ReadablePacketIF, public Redirectable * to the screen. */ // void print(); - [[nodiscard]] uint16_t getPacketId() const override; - [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketIdRaw() const override; + [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; [[nodiscard]] uint8_t getPusVersion() const override; [[nodiscard]] uint8_t getAcknowledgeFlags() const override; diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h index bb2b3642..fe976673 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h @@ -6,7 +6,7 @@ #include "../definitions.h" #include "PusTcReader.h" #include "fsfw/FSFW.h" -#include "fsfw/tmtcpacket/ccsds_header.h" +#include "fsfw/tmtcpacket/ccsds/defs.h" /** * This struct defines the data structure of a PUS Telecommand A packet when diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 5a1f4144..acf0435d 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -1,10 +1,12 @@ #include "PusTmCreator.h" -PusTmCreator::PusTmCreator(PusTmParams params_) : params(params_){}; +PusTmCreator::PusTmCreator(PusTmParams& params_) : params(params_){}; -uint16_t PusTmCreator::getPacketId() const { return 0; } -uint16_t PusTmCreator::getPacketSeqCtrl() const { return 0; } +uint16_t PusTmCreator::getPacketIdRaw() const { return 0; } +uint16_t PusTmCreator::getPacketSeqCtrlRaw() const { return 0; } uint16_t PusTmCreator::getPacketDataLen() const { return 0; } uint8_t PusTmCreator::getPusVersion() const { return 0; } uint8_t PusTmCreator::getService() const { return 0; } uint8_t PusTmCreator::getSubService() const { return 0; } +const uint8_t* PusTmCreator::getUserData(size_t& appDataLen) const { return nullptr; } +uint16_t PusTmCreator::getUserDataSize() const { return 0; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index fbdeb7d9..4a45e904 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -16,16 +16,18 @@ struct PusTmParams { class PusTmCreator : public PusIF { public: ~PusTmCreator() override = default; - explicit PusTmCreator(PusTmParams params); + explicit PusTmCreator(PusTmParams& params); - [[nodiscard]] uint16_t getPacketId() const override; - [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketIdRaw() const override; + [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; [[nodiscard]] uint8_t getPusVersion() const override; [[nodiscard]] uint8_t getService() const override; [[nodiscard]] uint8_t getSubService() const override; + const uint8_t* getUserData(size_t& appDataLen) const override; + [[nodiscard]] uint16_t getUserDataSize() const override; private: - PusTmParams params; + PusTmParams& params; }; #endif // FSFW_TMTCPACKET_TMPACKETCREATOR_H diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp index 4042528a..f2cc7fcc 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp @@ -5,8 +5,9 @@ #include "fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h" +PusTmMinimal::PusTmMinimal(mintm::MinimalPusTm* data) { tmData = data; } PusTmMinimal::PusTmMinimal(uint8_t* data) { - this->tmData = reinterpret_cast(data); + this->tmData = reinterpret_cast(data); } PusTmMinimal::~PusTmMinimal() = default; @@ -27,8 +28,8 @@ void PusTmMinimal::setInterpretTimestampObject(PacketTimestampInterpreterIF* int PacketTimestampInterpreterIF* PusTmMinimal::timestampInterpreter = nullptr; // TODO: Implement all of this ReturnValue_t PusTmMinimal::setData(uint8_t* dataPtr, size_t size, void* args) { return 0; } -uint16_t PusTmMinimal::getPacketId() const { return 0; } -uint16_t PusTmMinimal::getPacketSeqCtrl() const { return 0; } +uint16_t PusTmMinimal::getPacketIdRaw() const { return 0; } +uint16_t PusTmMinimal::getPacketSeqCtrlRaw() const { return 0; } uint16_t PusTmMinimal::getPacketDataLen() const { return 0; } uint8_t PusTmMinimal::getPusVersion() const { return 0; } uint8_t PusTmMinimal::getService() const { return tmData->secHeader.service; } @@ -36,7 +37,9 @@ uint8_t PusTmMinimal::getSubService() const { return tmData->secHeader.subservic const uint8_t* PusTmMinimal::getUserData(size_t& appDataLen) const { return nullptr; } uint16_t PusTmMinimal::getUserDataSize() const { return 0; } uint8_t PusTmMinimal::getScTimeRefStatus() { return 0; } -uint16_t PusTmMinimal::getMessageTypeCounter() { return tmData->secHeader.messageTypeCounter; } +uint16_t PusTmMinimal::getMessageTypeCounter() { + return (tmData->secHeader.messageTypeH << 8) | tmData->secHeader.messageTypeL; +} uint16_t PusTmMinimal::getDestId() { return 0; } const uint8_t* PusTmMinimal::getTimestamp(size_t& timeStampLen) { return nullptr; } size_t PusTmMinimal::getTimestampLen() { return 0; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h index a09523fb..b9146def 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h @@ -3,10 +3,39 @@ #include "PusTmIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/tmtcpacket/SpacePacketReader.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" struct timeval; + class PacketTimestampInterpreterIF; + +namespace mintm { + +// NOTE: Only PUS C compatible! +struct PusTmMinimalSecHeader { + uint8_t versionAndScTimeRefStatus; + uint8_t service; + uint8_t subservice; + uint8_t messageTypeH; + uint8_t messageTypeL; +}; + +/** + * This struct defines the data structure of a PUS Telecommand Packet when + * accessed via a pointer. + * @ingroup tmtcpackets + */ +struct MinimalPusTm { + ccsds::PrimaryHeader primary; + PusTmMinimalSecHeader secHeader; + uint8_t rest; +}; + +// Must include a checksum and is therefore at least one larger than the above struct. +static const uint16_t MINIMUM_SIZE = sizeof(MinimalPusTm) + 1; + +} // namespace mintm + /** * This is a minimal version of a PUS TmPacket without any variable field, or, * in other words with Service Type, Subtype and subcounter only. @@ -15,6 +44,7 @@ class PacketTimestampInterpreterIF; */ class PusTmMinimal : public PusTmIF, public RedirectableDataPointerIF { public: + explicit PusTmMinimal(mintm::MinimalPusTm* data); /** * This is the default constructor. * It sets its internal data pointer to the address passed and also @@ -33,8 +63,8 @@ class PusTmMinimal : public PusTmIF, public RedirectableDataPointerIF { static void setInterpretTimestampObject(PacketTimestampInterpreterIF* interpreter); ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override; - [[nodiscard]] uint16_t getPacketId() const override; - [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketIdRaw() const override; + [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; [[nodiscard]] uint8_t getPusVersion() const override; [[nodiscard]] uint8_t getService() const override; @@ -47,27 +77,6 @@ class PusTmMinimal : public PusTmIF, public RedirectableDataPointerIF { const uint8_t* getTimestamp(size_t& timeStampLen) override; size_t getTimestampLen() override; - // NOTE: Only PUS C compatible! - struct PusTmMinimalSecHeader { - uint8_t versionAndScTimeRefStatus; - uint8_t service; - uint8_t subservice; - uint16_t messageTypeCounter; - }; - - /** - * This struct defines the data structure of a PUS Telecommand Packet when - * accessed via a pointer. - * @ingroup tmtcpackets - */ - struct TmPacketMinimalPointer { - CCSDSPrimaryHeader primary; - PusTmMinimalSecHeader secHeader; - uint8_t rest; - }; - // Must include a checksum and is therefore at least one larger than the above struct. - static const uint16_t MINIMUM_SIZE = sizeof(TmPacketMinimalPointer) + 1; - protected: /** * A pointer to a structure which defines the data structure of @@ -75,7 +84,7 @@ class PusTmMinimal : public PusTmIF, public RedirectableDataPointerIF { * * To be hardware-safe, all elements are of byte size. */ - TmPacketMinimalPointer* tmData; + mintm::MinimalPusTm* tmData; static PacketTimestampInterpreterIF* timestampInterpreter; }; diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h index e1622466..fe7619cf 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h @@ -4,7 +4,7 @@ #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/timemanager/Clock.h" #include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/SpacePacketReader.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" namespace Factory { diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h index bf9de122..7d1eb255 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h @@ -5,7 +5,7 @@ #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/timemanager/Clock.h" #include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/SpacePacketReader.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" namespace Factory { void setStaticFrameworkObjectIds(); @@ -35,7 +35,7 @@ struct PUSTmDataFieldHeaderPusC { * @ingroup tmtcpackets */ struct TmPacketPointerPusC { - CCSDSPrimaryHeader primary; + ccsds::PrimaryHeader primary; PUSTmDataFieldHeaderPusC dataField; uint8_t data; }; @@ -52,7 +52,7 @@ class TmPacketPusC : public TmPacketBase { * This constant defines the minimum size of a valid PUS Telemetry Packet. */ static const uint32_t TM_PACKET_MIN_SIZE = - (sizeof(CCSDSPrimaryHeader) + sizeof(PUSTmDataFieldHeaderPusC) + 2); + ccsds::HEADER_LEN + sizeof(PUSTmDataFieldHeaderPusC) + 2; //! Maximum size of a TM Packet in this mission. static const uint32_t MISSION_TM_PACKET_MAX_SIZE = fsfwconfig::FSFW_MAX_TM_PACKET_SIZE; diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h index fe65e2ca..2a1f645f 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h @@ -1,72 +1,73 @@ -#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ -#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ - -#include "TmPacketPusC.h" -#include "TmPacketStoredBase.h" - -/** - * This class generates a ECSS PUS C Telemetry packet within a given - * intermediate storage. - * As most packets are passed between tasks with the help of a storage - * anyway, it seems logical to create a Packet-In-Storage access class - * which saves the user almost all storage handling operation. - * Packets can both be newly created with the class and be "linked" to - * packets in a store with the help of a storeAddress. - * @ingroup tmtcpackets - */ -class TmPacketStoredPusC : public TmPacketStoredBase, public TmPacketPusC { - public: - /** - * This is a default constructor which does not set the data pointer. - * However, it does try to set the packet store. - */ - TmPacketStoredPusC(store_address_t setAddress); - /** - * With this constructor, new space is allocated in the packet store and - * a new PUS Telemetry Packet is created there. - * Packet Application Data passed in data is copied into the packet. - * The Application data is passed in two parts, first a header, then a - * data field. This allows building a Telemetry Packet from two separate - * data sources. - * @param apid Sets the packet's APID field. - * @param service Sets the packet's Service ID field. - * This specifies the source service. - * @param subservice Sets the packet's Service Subtype field. - * This specifies the source sub-service. - * @param packet_counter Sets the Packet counter field of this packet - * @param data The payload data to be copied to the - * Application Data Field - * @param size The amount of data to be copied. - * @param headerData The header Data of the Application field, - * will be copied in front of data - * @param headerSize The size of the headerDataF - * @param destinationId Destination ID containing the application process ID as specified - * by PUS C - * @param timeRefField 4 bit time reference field as specified by PUS C - */ - TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice, uint16_t packetCounter = 0, - const uint8_t* data = nullptr, uint32_t size = 0, - const uint8_t* headerData = nullptr, uint32_t headerSize = 0, - uint16_t destinationId = 0, uint8_t timeRefField = 0); - /** - * Another ctor to directly pass structured content and header data to the - * packet to avoid additional buffers. - */ - TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice, uint16_t packetCounter, - SerializeIF* content, SerializeIF* header = nullptr, - uint16_t destinationId = 0, uint8_t timeRefField = 0); - - uint8_t* getAllTmData() override; - - private: - /** - * Implementation required by base class - * @param newPointer - * @param maxSize - * @param args - * @return - */ - ReturnValue_t setData(uint8_t* newPointer, size_t maxSize, void* args) override; -}; - -#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ */ +//#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ +//#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ +// +//#include "TmPacketPusC.h" +//#include "TmPacketStoredBase.h" +// +///** +// * This class generates a ECSS PUS C Telemetry packet within a given +// * intermediate storage. +// * As most packets are passed between tasks with the help of a storage +// * anyway, it seems logical to create a Packet-In-Storage access class +// * which saves the user almost all storage handling operation. +// * Packets can both be newly created with the class and be "linked" to +// * packets in a store with the help of a storeAddress. +// * @ingroup tmtcpackets +// */ +// class TmPacketStoredPusC : public TmPacketStoredBase, public TmPacketPusC { +// public: +// /** +// * This is a default constructor which does not set the data pointer. +// * However, it does try to set the packet store. +// */ +// TmPacketStoredPusC(store_address_t setAddress); +// /** +// * With this constructor, new space is allocated in the packet store and +// * a new PUS Telemetry Packet is created there. +// * Packet Application Data passed in data is copied into the packet. +// * The Application data is passed in two parts, first a header, then a +// * data field. This allows building a Telemetry Packet from two separate +// * data sources. +// * @param apid Sets the packet's APID field. +// * @param service Sets the packet's Service ID field. +// * This specifies the source service. +// * @param subservice Sets the packet's Service Subtype field. +// * This specifies the source sub-service. +// * @param packet_counter Sets the Packet counter field of this packet +// * @param data The payload data to be copied to the +// * Application Data Field +// * @param size The amount of data to be copied. +// * @param headerData The header Data of the Application field, +// * will be copied in front of data +// * @param headerSize The size of the headerDataF +// * @param destinationId Destination ID containing the application process ID as specified +// * by PUS C +// * @param timeRefField 4 bit time reference field as specified by PUS C +// */ +// TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice, uint16_t packetCounter = +// 0, +// const uint8_t* data = nullptr, uint32_t size = 0, +// const uint8_t* headerData = nullptr, uint32_t headerSize = 0, +// uint16_t destinationId = 0, uint8_t timeRefField = 0); +// /** +// * Another ctor to directly pass structured content and header data to the +// * packet to avoid additional buffers. +// */ +// TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice, uint16_t packetCounter, +// SerializeIF* content, SerializeIF* header = nullptr, +// uint16_t destinationId = 0, uint8_t timeRefField = 0); +// +// uint8_t* getAllTmData() override; +// +// private: +// /** +// * Implementation required by base class +// * @param newPointer +// * @param maxSize +// * @param args +// * @return +// */ +// ReturnValue_t setData(uint8_t* newPointer, size_t maxSize, void* args) override; +//}; +// +//#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ */ diff --git a/src/fsfw/tmtcservices/CMakeLists.txt b/src/fsfw/tmtcservices/CMakeLists.txt index d2a3f4ed..fcbcb49d 100644 --- a/src/fsfw/tmtcservices/CMakeLists.txt +++ b/src/fsfw/tmtcservices/CMakeLists.txt @@ -6,4 +6,5 @@ target_sources( TmTcBridge.cpp TmTcMessage.cpp VerificationReporter.cpp - SpacePacketParser.cpp) + SpacePacketParser.cpp + TmStoreHelper.cpp) diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index f0cdb61b..b18a736b 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -12,8 +12,8 @@ object_id_t PusServiceBase::packetSource = 0; object_id_t PusServiceBase::packetDestination = 0; PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId, - StorageManagerIF* store_) - : SystemObject(setObjectId), apid(setApid), serviceId(setServiceId), store(store_) { + StorageManagerIF* ipcStore_) + : SystemObject(setObjectId), apid(setApid), serviceId(setServiceId), ipcStore(ipcStore_) { requestQueue = QueueFactory::instance()->createMessageQueue(PUS_SERVICE_MAX_RECEPTION); } @@ -52,7 +52,7 @@ void PusServiceBase::handleRequestQueue() { if (status == RETURN_OK) { const uint8_t* dataPtr; size_t dataLen = 0; - result = store->getData(message.getStorageId(), &dataPtr, &dataLen); + result = ipcStore->getData(message.getStorageId(), &dataPtr, &dataLen); if (result != HasReturnvaluesIF::RETURN_OK) { // TODO: Warning? } @@ -73,7 +73,7 @@ void PusServiceBase::handleRequestQueue() { &this->currentPacket, result, 0, errorParameter1, errorParameter2); } - store->deleteData(message.getStorageId()); + ipcStore->deleteData(message.getStorageId()); errorParameter1 = 0; errorParameter2 = 0; } else if (status == MessageQueueIF::EMPTY) { @@ -112,6 +112,12 @@ ReturnValue_t PusServiceBase::initialize() { } this->requestQueue->setDefaultDestination(destService->getReportReceptionQueue()); distributor->registerService(this); + if (ipcStore == nullptr) { + ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); + if (ipcStore == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + } return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 57547ace..d487c6c6 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -52,7 +52,7 @@ class PusServiceBase : public ExecutableObjectIF, * The Service Identifier as specified in ECSS PUS. */ PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId, - StorageManagerIF* store); + StorageManagerIF* ipcStore); /** * The destructor is empty. */ @@ -144,7 +144,7 @@ class PusServiceBase : public ExecutableObjectIF, * It is deleted after handleRequest was executed. */ // TcPacketStoredPus currentPacket; - StorageManagerIF* store; + StorageManagerIF* ipcStore; PusTcReader currentPacket; static object_id_t packetSource; diff --git a/src/fsfw/tmtcservices/SourceSequenceCounter.h b/src/fsfw/tmtcservices/SourceSequenceCounter.h index 836ac5e9..da96dc4e 100644 --- a/src/fsfw/tmtcservices/SourceSequenceCounter.h +++ b/src/fsfw/tmtcservices/SourceSequenceCounter.h @@ -1,7 +1,7 @@ #ifndef FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ #define FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ -#include "../tmtcpacket/SpacePacketReader.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" class SourceSequenceCounter { private: diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp new file mode 100644 index 00000000..54e6ffc8 --- /dev/null +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -0,0 +1,43 @@ +#include "TmStoreHelper.h" + +#include "TmTcMessage.h" +#include "fsfw/ipc/MessageQueueSenderIF.h" + +TmStoreHelper::TmStoreHelper(StorageManagerIF *tmStore, MessageQueueId_t tmtcMsgDest, + MessageQueueId_t tmtcMsgSrc, InternalErrorReporterIF *reporter) + : creator(params), + tmtcMsgDest(tmtcMsgDest), + tmtcMsgSrc(tmtcMsgSrc), + errReporter(reporter), + tmStore(tmStore) {} + +void TmStoreHelper::preparePacket(uint16_t apid, uint8_t service, uint8_t subservice, + uint16_t counter) { + // TODO: Implement + // creator.setApid(apid); + params.service = service; + params.subservice = subservice; + params.messageTypeCounter = counter; + // TODO: Implement serialize and then serialize into the store +} + +ReturnValue_t TmStoreHelper::sendPacket() { + TmTcMessage tmMessage(currentAddr); + ReturnValue_t result = MessageQueueSenderIF::sendMessage(tmtcMsgDest, &tmMessage, tmtcMsgSrc); + if (result != HasReturnvaluesIF::RETURN_OK) { + tmStore->deleteData(currentAddr); + if (errReporter != nullptr) { + errReporter->lostTm(); + } + return result; + } + return HasReturnvaluesIF::RETURN_OK; +} + +void TmStoreHelper::setMsgDestination(MessageQueueId_t msgDest) { tmtcMsgDest = msgDest; } + +void TmStoreHelper::setMsgSource(MessageQueueId_t msgSrc) { tmtcMsgSrc = msgSrc; } + +void TmStoreHelper::setInternalErrorReporter(InternalErrorReporterIF *reporter) { + errReporter = reporter; +} diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h new file mode 100644 index 00000000..bada3b7d --- /dev/null +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -0,0 +1,33 @@ +#ifndef FSFW_TMTCSERVICES_STOREHELPER_H +#define FSFW_TMTCSERVICES_STOREHELPER_H + +#include "fsfw/internalerror/InternalErrorReporterIF.h" +#include "fsfw/ipc/MessageQueueMessageIF.h" +#include "fsfw/storagemanager/StorageManagerIF.h" +#include "fsfw/tmtcpacket/pus/tm/PusTmCreator.h" + +// TODO: Serializing a packet into a store and sending the message are two different tasks +// Move them into separate classes +class TmStoreHelper { + public: + TmStoreHelper(StorageManagerIF* tmStore, MessageQueueId_t tmtcMsgDest, + MessageQueueId_t tmtcMsgSrc, InternalErrorReporterIF* reporter); + + void setInternalErrorReporter(InternalErrorReporterIF* reporter); + void setMsgDestination(MessageQueueId_t msgDest); + void setMsgSource(MessageQueueId_t msgSrc); + void preparePacket(uint16_t apid, uint8_t service, uint8_t subservice, uint16_t counter); + ReturnValue_t sendPacket(); + + private: + PusTmParams params{}; + PusTmCreator creator; + + bool doErrorReporting = true; + MessageQueueId_t tmtcMsgDest; + MessageQueueId_t tmtcMsgSrc; + InternalErrorReporterIF* errReporter; + store_address_t currentAddr{}; + StorageManagerIF* tmStore; +}; +#endif // FSFW_TMTCSERVICES_STOREHELPER_H diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index bf33d1c4..04b42934 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -22,8 +22,8 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, PusTcReader* return; } PusVerificationMessage message(set_report_id, currentPacket->getAcknowledgeFlags(), - currentPacket->getPacketId(), currentPacket->getPacketSeqCtrl(), 0, - set_step); + currentPacket->getPacketIdRaw(), + currentPacket->getPacketSeqCtrlRaw(), 0, set_step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -59,9 +59,9 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, PusTcReader* cur if (currentPacket == nullptr) { return; } - PusVerificationMessage message(report_id, currentPacket->getAcknowledgeFlags(), - currentPacket->getPacketId(), currentPacket->getPacketSeqCtrl(), - error_code, step, parameter1, parameter2); + PusVerificationMessage message( + report_id, currentPacket->getAcknowledgeFlags(), currentPacket->getPacketIdRaw(), + currentPacket->getPacketSeqCtrlRaw(), error_code, step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/unittests/tmtcpacket/testCcsdsCreator.cpp b/unittests/tmtcpacket/testCcsdsCreator.cpp index d56669a7..2043d6a6 100644 --- a/unittests/tmtcpacket/testCcsdsCreator.cpp +++ b/unittests/tmtcpacket/testCcsdsCreator.cpp @@ -2,11 +2,12 @@ #include #include -#include "fsfw/tmtcpacket/SpacePacketCreator.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" TEST_CASE("CCSDS Creator", "[ccsds-creator]") { - SpacePacketCreator base = SpacePacketCreator(ccsds::PacketType::TC, true, 0x02, - ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); + auto params = SpacePacketParams(PacketId(ccsds::PacketType::TC, true, 0x02), + PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16); + SpacePacketCreator base = SpacePacketCreator(params); std::array buf{}; uint8_t* bufPtr = buf.data(); size_t serLen = 0; @@ -27,7 +28,7 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { REQUIRE(base.getSequenceCount() == 0x34); REQUIRE(base.getPacketDataLen() == 0x16); REQUIRE(base.getPacketType() == ccsds::PacketType::TC); - REQUIRE(base.getPacketId() == 0x1802); + REQUIRE(base.getPacketIdRaw() == 0x1802); REQUIRE(base.getSerializedSize() == 6); } @@ -71,17 +72,15 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { } SECTION("Invalid APID") { - SpacePacketCreator invalid = - SpacePacketCreator(PacketId(ccsds::PacketType::TC, true, 0xFFFF), - PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16); + SpacePacketCreator invalid = SpacePacketCreator( + ccsds::PacketType::TC, true, 0xFFFF, ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); REQUIRE(not invalid.isValid()); REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); } SECTION("Invalid Seq Count") { - SpacePacketCreator invalid = - SpacePacketCreator(PacketId(ccsds::PacketType::TC, true, 0x02), - PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0xFFFF), 0x16); + SpacePacketCreator invalid = SpacePacketCreator( + ccsds::PacketType::TC, true, 0x02, ccsds::SequenceFlags::FIRST_SEGMENT, 0xFFFF, 0x16); REQUIRE(not invalid.isValid()); REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); } diff --git a/unittests/tmtcpacket/testCcsdsReader.cpp b/unittests/tmtcpacket/testCcsdsReader.cpp index b8a6f3dd..89ee5a46 100644 --- a/unittests/tmtcpacket/testCcsdsReader.cpp +++ b/unittests/tmtcpacket/testCcsdsReader.cpp @@ -1,5 +1,5 @@ #include -#include "fsfw/tmtcpacket/SpacePacketReader.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" TEST_CASE("CCSDS Reader", "[ccsds-reader]") {} \ No newline at end of file From 9860061fc6909f2a4b57465c2268ce6b49792949 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 20 Jul 2022 11:45:50 +0200 Subject: [PATCH 058/532] create new TmSendHelper --- src/fsfw/tmtcservices/TmStoreHelper.h | 31 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index bada3b7d..61ef93f4 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -6,27 +6,34 @@ #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/tmtcpacket/pus/tm/PusTmCreator.h" +class TmStoreAndSendWrapper { + +}; + +class TmSendHelper { + public: + TmSendHelper(MessageQueueId_t tmtcMsgDest, + MessageQueueId_t tmtcMsgSrc, InternalErrorReporterIF* reporter); + void setMsgDestination(MessageQueueId_t msgDest); + void setMsgSource(MessageQueueId_t msgSrc); + void setInternalErrorReporter(InternalErrorReporterIF* reporter); + ReturnValue_t sendPacket(); + private: + MessageQueueId_t tmtcMsgDest; + MessageQueueId_t tmtcMsgSrc; + InternalErrorReporterIF* errReporter; +}; + // TODO: Serializing a packet into a store and sending the message are two different tasks // Move them into separate classes class TmStoreHelper { public: - TmStoreHelper(StorageManagerIF* tmStore, MessageQueueId_t tmtcMsgDest, - MessageQueueId_t tmtcMsgSrc, InternalErrorReporterIF* reporter); + TmStoreHelper(StorageManagerIF* tmStore); - void setInternalErrorReporter(InternalErrorReporterIF* reporter); - void setMsgDestination(MessageQueueId_t msgDest); - void setMsgSource(MessageQueueId_t msgSrc); void preparePacket(uint16_t apid, uint8_t service, uint8_t subservice, uint16_t counter); - ReturnValue_t sendPacket(); - private: PusTmParams params{}; PusTmCreator creator; - - bool doErrorReporting = true; - MessageQueueId_t tmtcMsgDest; - MessageQueueId_t tmtcMsgSrc; - InternalErrorReporterIF* errReporter; store_address_t currentAddr{}; StorageManagerIF* tmStore; }; From be35bd53a6b4434b5a51233d34eef95aa2e9b9fe Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 20 Jul 2022 22:21:15 +0200 Subject: [PATCH 059/532] switched to new tmtc stack API --- .../monitoring/MonitoringMessageContent.h | 6 +- src/fsfw/osal/host/MessageQueue.cpp | 2 +- src/fsfw/pus/Service17Test.cpp | 40 ++-- src/fsfw/pus/Service17Test.h | 11 +- .../pus/Service1TelecommandVerification.cpp | 36 ++-- .../pus/Service1TelecommandVerification.h | 11 +- src/fsfw/pus/Service20ParameterManagement.cpp | 4 +- src/fsfw/pus/Service2DeviceAccess.cpp | 10 +- src/fsfw/pus/Service3Housekeeping.cpp | 5 +- src/fsfw/pus/Service5EventReporting.cpp | 25 +-- src/fsfw/pus/Service5EventReporting.h | 4 +- src/fsfw/pus/Service8FunctionManagement.cpp | 6 +- src/fsfw/pus/Service9TimeManagement.cpp | 6 +- src/fsfw/pus/servicepackets/Service9Packets.h | 6 +- src/fsfw/storagemanager/StorageManagerIF.h | 8 +- src/fsfw/tcdistribution/PusDistributor.cpp | 2 +- .../{TimeStamper.h => CdsShortTimeStamper.h} | 13 +- src/fsfw/timemanager/TimeStamper.cpp | 32 +++- src/fsfw/timemanager/TimeStamperIF.h | 17 +- .../tmtcpacket/ccsds/SpacePacketCreator.cpp | 4 + .../tmtcpacket/ccsds/SpacePacketCreator.h | 9 +- src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h | 2 +- .../packetmatcher/PacketMatchTree.cpp | 4 +- src/fsfw/tmtcpacket/pus/CreatorDataIF.h | 10 + src/fsfw/tmtcpacket/pus/PusIF.h | 18 -- src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h | 12 ++ src/fsfw/tmtcpacket/pus/definitions.h | 28 +++ src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 36 ++-- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 9 +- src/fsfw/tmtcpacket/pus/tc/PusTcIF.h | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp | 16 +- src/fsfw/tmtcpacket/pus/tc/PusTcReader.h | 11 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 93 +++++++++- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 51 +++-- src/fsfw/tmtcpacket/pus/tm/PusTmIF.h | 14 +- src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp | 9 +- src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h | 14 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h | 2 +- src/fsfw/tmtcservices/CMakeLists.txt | 3 +- .../tmtcservices/CommandingServiceBase.cpp | 174 +++++++++--------- src/fsfw/tmtcservices/CommandingServiceBase.h | 54 +++--- src/fsfw/tmtcservices/PusServiceBase.cpp | 43 +++-- src/fsfw/tmtcservices/PusServiceBase.h | 17 +- src/fsfw/tmtcservices/TmSendHelper.cpp | 29 +++ src/fsfw/tmtcservices/TmSendHelper.h | 26 +++ src/fsfw/tmtcservices/TmStoreHelper.cpp | 77 ++++---- src/fsfw/tmtcservices/TmStoreHelper.h | 38 ++-- .../tmtcservices/VerificationReporter.cpp | 18 +- src/fsfw/tmtcservices/VerificationReporter.h | 4 +- src/fsfw/tmtcservices/sendAndStoreHelper.h | 54 ++++++ unittests/CatchFactory.cpp | 2 - 51 files changed, 753 insertions(+), 374 deletions(-) rename src/fsfw/timemanager/{TimeStamper.h => CdsShortTimeStamper.h} (60%) create mode 100644 src/fsfw/tmtcpacket/pus/CreatorDataIF.h create mode 100644 src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h create mode 100644 src/fsfw/tmtcservices/TmSendHelper.cpp create mode 100644 src/fsfw/tmtcservices/TmSendHelper.h create mode 100644 src/fsfw/tmtcservices/sendAndStoreHelper.h diff --git a/src/fsfw/monitoring/MonitoringMessageContent.h b/src/fsfw/monitoring/MonitoringMessageContent.h index fb3ace3d..aeadacdf 100644 --- a/src/fsfw/monitoring/MonitoringMessageContent.h +++ b/src/fsfw/monitoring/MonitoringMessageContent.h @@ -34,7 +34,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter { SerializeElement limitValue; SerializeElement oldState; SerializeElement newState; - uint8_t rawTimestamp[TimeStamperIF::MISSION_TIMESTAMP_SIZE] = {}; + uint8_t rawTimestamp[TimeStamperIF::MAXIMUM_TIMESTAMP_LEN] = {}; SerializeElement> timestampSerializer; TimeStamperIF* timeStamper; MonitoringReportContent() @@ -47,7 +47,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter { oldState(0), newState(0), timestampSerializer(rawTimestamp, sizeof(rawTimestamp)), - timeStamper(NULL) { + timeStamper(nullptr) { setAllNext(); } MonitoringReportContent(gp_id_t globalPoolId, T value, T limitValue, ReturnValue_t oldState, @@ -61,7 +61,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter { oldState(oldState), newState(newState), timestampSerializer(rawTimestamp, sizeof(rawTimestamp)), - timeStamper(NULL) { + timeStamper(nullptr) { setAllNext(); if (checkAndSetStamper()) { timeStamper->addTimeStamp(rawTimestamp, sizeof(rawTimestamp)); diff --git a/src/fsfw/osal/host/MessageQueue.cpp b/src/fsfw/osal/host/MessageQueue.cpp index d0a12850..5eb0c99a 100644 --- a/src/fsfw/osal/host/MessageQueue.cpp +++ b/src/fsfw/osal/host/MessageQueue.cpp @@ -84,7 +84,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, message->getMaximumMessageSize()); } else { if (not ignoreFault) { - InternalErrorReporterIF* internalErrorReporter = + auto* internalErrorReporter = ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); if (internalErrorReporter != nullptr) { internalErrorReporter->queueMessageNotSent(); diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index 87549808..7d13af06 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -1,15 +1,14 @@ #include "fsfw/pus/Service17Test.h" #include "fsfw/FSFW.h" +#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h" +#include "fsfw/tmtcservices/sendAndStoreHelper.h" -Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId, - StorageManagerIF* tmStore, StorageManagerIF* ipcStore, - InternalErrorReporterIF* errReporter) - : PusServiceBase(objectId, apid, serviceId, ipcStore), - helper(tmStore, MessageQueueIF::NO_QUEUE, MessageQueueIF::NO_QUEUE, errReporter), +Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId) + : PusServiceBase(objectId, apid, serviceId), + storeHelper(apid, nullptr), + sendHelper(nullptr), packetSubCounter(0) {} Service17Test::~Service17Test() = default; @@ -17,15 +16,13 @@ Service17Test::~Service17Test() = default; ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { switch (subservice) { case Subservice::CONNECTION_TEST: { - helper.preparePacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter); - helper.sendPacket(); - return HasReturnvaluesIF::RETURN_OK; + storeHelper.preparePacket(serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter); + return tm::storeAndSendTmPacket(storeHelper, sendHelper); } case Subservice::EVENT_TRIGGER_TEST: { - helper.preparePacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter++); - helper.sendPacket(); + storeHelper.preparePacket(serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter++); triggerEvent(TEST, 1234, 5678); - return RETURN_OK; + return tm::storeAndSendTmPacket(storeHelper, sendHelper); } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; @@ -39,6 +36,17 @@ ReturnValue_t Service17Test::initialize() { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - helper.setMsgDestination(requestQueue->getDefaultDestination()); - helper.setMsgSource(requestQueue->getId()); - if (tm) } + initializeTmHelpers(sendHelper, storeHelper); + if (storeHelper.getTmStore() == nullptr) { + auto* tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (tmStore == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + storeHelper.setTmStore(tmStore); + } + return result; +} + +void Service17Test::setCustomTmStore(StorageManagerIF* tmStore_) { + storeHelper.setTmStore(tmStore_); +} diff --git a/src/fsfw/pus/Service17Test.h b/src/fsfw/pus/Service17Test.h index 0f690ea4..a5bfa974 100644 --- a/src/fsfw/pus/Service17Test.h +++ b/src/fsfw/pus/Service17Test.h @@ -33,16 +33,19 @@ class Service17Test : public PusServiceBase { EVENT_TRIGGER_TEST = 128, }; - Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId, - InternalErrorReporterIF* errReporter, StorageManagerIF* tmStore = nullptr, - StorageManagerIF* ipcStore = nullptr); + Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId); + + void setCustomTmStore(StorageManagerIF* tmStore); + ~Service17Test() override; ReturnValue_t handleRequest(uint8_t subservice) override; ReturnValue_t performService() override; ReturnValue_t initialize() override; protected: - TmStoreHelper helper; + TmStoreHelper storeHelper; + TmSendHelper sendHelper; + uint16_t packetSubCounter = 0; }; diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 13d6a1c4..5c49111e 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -3,10 +3,10 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/pus/servicepackets/Service1Packets.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" +#include "fsfw/tmtcservices/sendAndStoreHelper.h" Service1TelecommandVerification::Service1TelecommandVerification(object_id_t objectId, uint16_t apid, uint8_t serviceId, @@ -15,7 +15,9 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t obj : SystemObject(objectId), apid(apid), serviceId(serviceId), - targetDestination(targetDestination) { + targetDestination(targetDestination), + sendHelper(nullptr), + storeHelper(apid, nullptr) { tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); } @@ -67,32 +69,23 @@ ReturnValue_t Service1TelecommandVerification::generateFailureReport( FailureReport report(message->getReportId(), message->getTcPacketId(), message->getTcSequenceControl(), message->getStep(), message->getErrorCode(), message->getParameter1(), message->getParameter2()); -#if FSFW_USE_PUS_C_TELEMETRY == 0 - TmPacketStoredPusA tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report); -#else - TmPacketStoredPusC tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report); -#endif - ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(), tmQueue->getId()); - return result; + storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); + storeHelper.setSourceDataSerializable(&report); + return tm::storeAndSendTmPacket(storeHelper, sendHelper); } ReturnValue_t Service1TelecommandVerification::generateSuccessReport( PusVerificationMessage* message) { SuccessReport report(message->getReportId(), message->getTcPacketId(), message->getTcSequenceControl(), message->getStep()); -#if FSFW_USE_PUS_C_TELEMETRY == 0 - TmPacketStoredPusA tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report); -#else - TmPacketStoredPusC tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report); -#endif - ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(), tmQueue->getId()); - return result; + storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); + storeHelper.setSourceDataSerializable(&report); + return tm::storeAndSendTmPacket(storeHelper, sendHelper); } ReturnValue_t Service1TelecommandVerification::initialize() { // Get target object for TC verification messages - AcceptsTelemetryIF* funnel = - ObjectManager::instance()->get(targetDestination); + auto* funnel = ObjectManager::instance()->get(targetDestination); if (funnel == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service1TelecommandVerification::initialize: Specified" @@ -103,5 +96,12 @@ ReturnValue_t Service1TelecommandVerification::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } tmQueue->setDefaultDestination(funnel->getReportReceptionQueue()); + if (tmStore == nullptr) { + tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (tmStore == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + storeHelper.setTmStore(tmStore); + } return SystemObject::initialize(); } diff --git a/src/fsfw/pus/Service1TelecommandVerification.h b/src/fsfw/pus/Service1TelecommandVerification.h index 10d2da0e..a87acdfe 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.h +++ b/src/fsfw/pus/Service1TelecommandVerification.h @@ -7,6 +7,8 @@ #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" +#include "fsfw/tmtcservices/TmSendHelper.h" +#include "fsfw/tmtcservices/TmStoreHelper.h" /** * @brief Verify TC acceptance, start, progress and execution. @@ -45,13 +47,13 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, Service1TelecommandVerification(object_id_t objectId, uint16_t apid, uint8_t serviceId, object_id_t targetDestination, uint16_t messageQueueDepth); - virtual ~Service1TelecommandVerification(); + ~Service1TelecommandVerification() override; /** * * @return ID of Verification Queue */ - virtual MessageQueueId_t getVerificationQueue() override; + MessageQueueId_t getVerificationQueue() override; /** * Performs the service periodically as specified in init_mission(). @@ -59,7 +61,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, * @param operationCode * @return */ - ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t performOperation(uint8_t operationCode) override; /** * Initializes the destination for TC verification messages and initializes @@ -80,6 +82,9 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, uint16_t packetSubCounter = 0; + TmSendHelper sendHelper; + TmStoreHelper storeHelper; + StorageManagerIF* tmStore = nullptr; MessageQueueIF* tmQueue = nullptr; enum class Subservice : uint8_t { diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index 61e29412..9354c80d 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -137,7 +137,7 @@ ReturnValue_t Service20ParameterManagement::prepareLoadCommand(CommandMessage* m if (parameterDataLen == 0) { return CommandingServiceBase::INVALID_TC; } - ReturnValue_t result = IPCStore->getFreeElement(&storeAddress, parameterDataLen, &storePointer); + ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, parameterDataLen, &storePointer); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -169,7 +169,7 @@ ReturnValue_t Service20ParameterManagement::handleReply(const CommandMessage* re switch (replyId) { case ParameterMessage::REPLY_PARAMETER_DUMP: { - ConstAccessorPair parameterData = IPCStore->getData(ParameterMessage::getStoreId(reply)); + ConstAccessorPair parameterData = ipcStore->getData(ParameterMessage::getStoreId(reply)); if (parameterData.first != HasReturnvaluesIF::RETURN_OK) { return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index 3430271e..8060b2b6 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -75,7 +75,7 @@ ReturnValue_t Service2DeviceAccess::prepareRawCommand(CommandMessage* messageToS // store command into the Inter Process Communication Store store_address_t storeAddress; ReturnValue_t result = - IPCStore->addData(&storeAddress, RawCommand.getCommand(), RawCommand.getCommandSize()); + ipcStore->addData(&storeAddress, RawCommand.getCommand(), RawCommand.getCommandSize()); DeviceHandlerMessage::setDeviceHandlerRawCommandMessage(messageToSet, storeAddress); return result; } @@ -135,7 +135,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs store_address_t storeAddress = DeviceHandlerMessage::getStoreAddress(reply); const uint8_t* data = nullptr; size_t size = 0; - ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size); + ReturnValue_t result = ipcStore->getData(storeAddress, &data, &size); if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in " @@ -147,10 +147,8 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs // Init our dummy packet and correct endianness of object ID before // sending it back. - WiretappingPacket TmPacket(DeviceHandlerMessage::getDeviceObjectId(reply), data); - TmPacket.objectId = EndianConverter::convertBigEndian(TmPacket.objectId); - sendTmPacket(subservice, TmPacket.data, size, reinterpret_cast(&TmPacket.objectId), - sizeof(TmPacket.objectId)); + WiretappingPacket tmPacket(DeviceHandlerMessage::getDeviceObjectId(reply), data); + sendTmPacket(subservice, tmPacket.objectId, tmPacket.data, size); } MessageQueueId_t Service2DeviceAccess::getDeviceQueue() { return commandQueue->getId(); } diff --git a/src/fsfw/pus/Service3Housekeeping.cpp b/src/fsfw/pus/Service3Housekeeping.cpp index 07574783..7ef5636d 100644 --- a/src/fsfw/pus/Service3Housekeeping.cpp +++ b/src/fsfw/pus/Service3Housekeeping.cpp @@ -284,14 +284,13 @@ ReturnValue_t Service3Housekeeping::generateHkReply(const CommandMessage* hkMess store_address_t storeId; sid_t sid = HousekeepingMessage::getHkDataReply(hkMessage, &storeId); - auto resultPair = IPCStore->getData(storeId); + auto resultPair = ipcStore->getData(storeId); if (resultPair.first != HasReturnvaluesIF::RETURN_OK) { return resultPair.first; } HkPacket hkPacket(sid, resultPair.second.data(), resultPair.second.size()); - return sendTmPacket(static_cast(subserviceId), hkPacket.hkData, hkPacket.hkSize, nullptr, - 0); + return sendTmPacket(static_cast(subserviceId), hkPacket.hkData, hkPacket.hkSize); } sid_t Service3Housekeeping::buildSid(object_id_t objectId, const uint8_t** tcData, diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index 987217dc..4d0dcf1d 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -6,11 +6,14 @@ #include "fsfw/pus/servicepackets/Service5Packets.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h" +#include "fsfw/tmtcservices/sendAndStoreHelper.h" Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t apid, uint8_t serviceId, size_t maxNumberReportsPerCycle, uint32_t messageQueueDepth) : PusServiceBase(objectId, apid, serviceId), + sendHelper(nullptr), + storeHelper(apid, nullptr), maxNumberReportsPerCycle(maxNumberReportsPerCycle) { eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); } @@ -45,15 +48,9 @@ ReturnValue_t Service5EventReporting::performService() { ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) { EventReport report(message.getEventId(), message.getReporter(), message.getParameter1(), message.getParameter2()); -#if FSFW_USE_PUS_C_TELEMETRY == 0 - TmPacketStoredPusA tmPacket(PusServiceBase::apid, PusServiceBase::serviceId, - message.getSeverity(), packetSubCounter++, &report); -#else - TmPacketStoredPusC tmPacket(PusServiceBase::apid, PusServiceBase::serviceId, - message.getSeverity(), packetSubCounter++, &report); -#endif - ReturnValue_t result = - tmPacket.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); + storeHelper.preparePacket(serviceId, message.getSeverity(), packetSubCounter); + storeHelper.setSourceDataSerializable(&report); + ReturnValue_t result = tm::storeAndSendTmPacket(storeHelper, sendHelper); if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service5EventReporting::generateEventReport: " @@ -64,6 +61,8 @@ ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) "Service5EventReporting::generateEventReport: " "Could not send TM packet\n"); #endif + } else { + packetSubCounter++; } return result; } @@ -86,14 +85,18 @@ ReturnValue_t Service5EventReporting::handleRequest(uint8_t subservice) { // In addition to the default PUSServiceBase initialization, this service needs // to be registered to the event manager to listen for events. ReturnValue_t Service5EventReporting::initialize() { + ReturnValue_t result = PusServiceBase::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } auto* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (manager == nullptr) { return RETURN_FAILED; } // register Service 5 as listener for events - ReturnValue_t result = manager->registerListener(eventQueue->getId(), true); + result = manager->registerListener(eventQueue->getId(), true); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - return PusServiceBase::initialize(); + initializeTmHelpers(sendHelper, storeHelper); } diff --git a/src/fsfw/pus/Service5EventReporting.h b/src/fsfw/pus/Service5EventReporting.h index 74264130..a357e5fc 100644 --- a/src/fsfw/pus/Service5EventReporting.h +++ b/src/fsfw/pus/Service5EventReporting.h @@ -42,7 +42,7 @@ class Service5EventReporting : public PusServiceBase { public: Service5EventReporting(object_id_t objectId, uint16_t apid, uint8_t serviceId, size_t maxNumberReportsPerCycle = 10, uint32_t messageQueueDepth = 10); - virtual ~Service5EventReporting(); + ~Service5EventReporting() override; /*** * Check for events and generate event reports if required. @@ -77,6 +77,8 @@ class Service5EventReporting : public PusServiceBase { uint16_t packetSubCounter = 0; MessageQueueIF* eventQueue = nullptr; bool enableEventReport = true; + TmSendHelper sendHelper; + TmStoreHelper storeHelper; const uint8_t maxNumberReportsPerCycle; ReturnValue_t generateEventReport(EventMessage message); diff --git a/src/fsfw/pus/Service8FunctionManagement.cpp b/src/fsfw/pus/Service8FunctionManagement.cpp index be8d9058..0b3784be 100644 --- a/src/fsfw/pus/Service8FunctionManagement.cpp +++ b/src/fsfw/pus/Service8FunctionManagement.cpp @@ -78,7 +78,7 @@ ReturnValue_t Service8FunctionManagement::prepareDirectCommand(CommandMessage* m // store additional parameters into the IPC Store store_address_t parameterAddress; ReturnValue_t result = - IPCStore->addData(¶meterAddress, command.getParameters(), command.getParametersSize()); + ipcStore->addData(¶meterAddress, command.getParameters(), command.getParametersSize()); // setCommand expects a Command Message, an Action ID and a store adress // pointing to additional parameters @@ -130,7 +130,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* store_address_t storeId = ActionMessage::getStoreId(reply); size_t size = 0; const uint8_t* buffer = nullptr; - ReturnValue_t result = IPCStore->getData(storeId, &buffer, &size); + ReturnValue_t result = ipcStore->getData(storeId, &buffer, &size); if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service 8: Could not retrieve data for data reply" << std::endl; @@ -140,7 +140,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* DataReply dataReply(objectId, actionId, buffer, size); result = sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), &dataReply); - auto deletionResult = IPCStore->deleteData(storeId); + auto deletionResult = ipcStore->deleteData(storeId); if (deletionResult != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service8FunctionManagement::handleReply: Deletion" diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 6cd46f3a..99b447c1 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -9,7 +9,7 @@ Service9TimeManagement::Service9TimeManagement(object_id_t objectId, uint16_t ap uint8_t serviceId) : PusServiceBase(objectId, apid, serviceId) {} -Service9TimeManagement::~Service9TimeManagement() {} +Service9TimeManagement::~Service9TimeManagement() = default; ReturnValue_t Service9TimeManagement::performService() { return RETURN_OK; } @@ -25,7 +25,9 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { ReturnValue_t Service9TimeManagement::setTime() { Clock::TimeOfDay_t timeToSet; - TimePacket timePacket(currentPacket.getUserData(), currentPacket.getUserDataSize()); + size_t userDataLen = 0; + const uint8_t* timeData = currentPacket.getUserData(userDataLen); + TimePacket timePacket(timeData, userDataLen); ReturnValue_t result = CCSDSTime::convertFromCcsds(&timeToSet, timePacket.getTime(), timePacket.getTimeSize()); if (result != RETURN_OK) { diff --git a/src/fsfw/pus/servicepackets/Service9Packets.h b/src/fsfw/pus/servicepackets/Service9Packets.h index 076536e8..082a65fa 100644 --- a/src/fsfw/pus/servicepackets/Service9Packets.h +++ b/src/fsfw/pus/servicepackets/Service9Packets.h @@ -1,7 +1,7 @@ #ifndef FSFW_PUS_SERVICEPACKETS_SERVICE9PACKETS_H_ #define FSFW_PUS_SERVICEPACKETS_SERVICE9PACKETS_H_ -#include "../../serialize/SerialLinkedListAdapter.h" +#include "fsfw/serialize/SerialLinkedListAdapter.h" /** * @brief Subservice 128 @@ -11,16 +11,16 @@ */ class TimePacket : SerialLinkedListAdapter { //!< [EXPORT] : [SUBSERVICE] 128 public: + TimePacket(const TimePacket& command) = delete; TimePacket(const uint8_t* timeBuffer_, uint32_t timeSize_) { timeBuffer = timeBuffer_; timeSize = timeSize_; } const uint8_t* getTime() { return timeBuffer; } - uint32_t getTimeSize() const { return timeSize; } + [[nodiscard]] uint32_t getTimeSize() const { return timeSize; } private: - TimePacket(const TimePacket& command); const uint8_t* timeBuffer; uint32_t timeSize; //!< [EXPORT] : [IGNORE] }; diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index 375fc7cc..a8313344 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -55,7 +55,7 @@ class StorageManagerIF : public HasReturnvaluesIF { /** * @brief This is the empty virtual destructor as required for C++ interfaces. */ - virtual ~StorageManagerIF(){}; + ~StorageManagerIF() override = default; /** * @brief With addData, a free storage position is allocated and data * stored there. @@ -160,8 +160,8 @@ class StorageManagerIF : public HasReturnvaluesIF { * @li RETURN_FAILED if data could not be added. * storageId is unchanged then. */ - virtual ReturnValue_t getFreeElement(store_address_t* storageId, const size_t size, - uint8_t** p_data, bool ignoreFault = false) = 0; + virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** p_data, + bool ignoreFault = false) = 0; /** * Clears the whole store. @@ -192,7 +192,7 @@ class StorageManagerIF : public HasReturnvaluesIF { * Get number of pools. * @return */ - virtual max_subpools_t getNumberOfSubPools() const = 0; + [[nodiscard]] virtual max_subpools_t getNumberOfSubPools() const = 0; }; #endif /* FSFW_STORAGEMANAGER_STORAGEMANAGERIF_H_ */ diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 5975a7f2..687c5f00 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -36,7 +36,7 @@ PusDistributor::TcMqMapIter PusDistributor::selectDestination() { HasReturnvaluesIF::RETURN_OK) { return queueMapIt; } - reader.setData(packetPtr, packetLen); + reader.setReadOnlyData(packetPtr, packetLen); // this->currentPacket->setStoreAddress(this->currentMessage.getStorageId(), currentPacket); if (reader.getFullData() != nullptr) { tcStatus = diff --git a/src/fsfw/timemanager/TimeStamper.h b/src/fsfw/timemanager/CdsShortTimeStamper.h similarity index 60% rename from src/fsfw/timemanager/TimeStamper.h rename to src/fsfw/timemanager/CdsShortTimeStamper.h index aa311ec4..1e9abfa8 100644 --- a/src/fsfw/timemanager/TimeStamper.h +++ b/src/fsfw/timemanager/CdsShortTimeStamper.h @@ -14,14 +14,15 @@ * overriding the #addTimeStamp function. * @ingroup utility */ -class TimeStamper : public TimeStamperIF, public SystemObject { +class CdsShortTimeStamper : public TimeStamperIF, public SystemObject { public: + static constexpr size_t TIMESTAMP_LEN = 7; /** * @brief Default constructor which also registers the time stamper as a * system object so it can be found with the #objectManager. * @param objectId */ - TimeStamper(object_id_t objectId); + explicit CdsShortTimeStamper(object_id_t objectId); /** * Adds a CCSDS CDC short 8 byte timestamp to the given buffer. @@ -30,7 +31,13 @@ class TimeStamper : public TimeStamperIF, public SystemObject { * @param maxSize * @return */ - virtual ReturnValue_t addTimeStamp(uint8_t* buffer, const uint8_t maxSize); + ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override; + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override; + size_t getSerializedSize() const override; + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override; + size_t getTimestampSize() const override; }; #endif /* FSFW_TIMEMANAGER_TIMESTAMPER_H_ */ diff --git a/src/fsfw/timemanager/TimeStamper.cpp b/src/fsfw/timemanager/TimeStamper.cpp index 9b4ad3d3..7096d95f 100644 --- a/src/fsfw/timemanager/TimeStamper.cpp +++ b/src/fsfw/timemanager/TimeStamper.cpp @@ -1,23 +1,35 @@ -#include "fsfw/timemanager/TimeStamper.h" - #include +#include "fsfw/timemanager/CdsShortTimeStamper.h" #include "fsfw/timemanager/Clock.h" -TimeStamper::TimeStamper(object_id_t objectId) : SystemObject(objectId) {} +CdsShortTimeStamper::CdsShortTimeStamper(object_id_t objectId) : SystemObject(objectId) {} -ReturnValue_t TimeStamper::addTimeStamp(uint8_t* buffer, const uint8_t maxSize) { - if (maxSize < TimeStamperIF::MISSION_TIMESTAMP_SIZE) { - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t CdsShortTimeStamper::addTimeStamp(uint8_t *buffer, const uint8_t maxSize) { + size_t serLen = 0; + return serialize(&buffer, &serLen, maxSize, SerializeIF::Endianness::NETWORK); +} + +ReturnValue_t CdsShortTimeStamper::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const { + if (*size + getSerializedSize() > maxSize) { + return SerializeIF::BUFFER_TOO_SHORT; } - - timeval now; + timeval now{}; Clock::getClock_timeval(&now); - CCSDSTime::CDS_short cds; + CCSDSTime::CDS_short cds{}; ReturnValue_t result = CCSDSTime::convertToCcsds(&cds, &now); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - std::memcpy(buffer, &cds, sizeof(cds)); + std::memcpy(*buffer, &cds, sizeof(cds)); + *buffer += getSerializedSize(); + *size += getSerializedSize(); return result; } +size_t CdsShortTimeStamper::getSerializedSize() const { return getTimestampSize(); } +ReturnValue_t CdsShortTimeStamper::deSerialize(const uint8_t **buffer, size_t *size, + SerializeIF::Endianness streamEndianness) { + return HasReturnvaluesIF::RETURN_FAILED; +} +size_t CdsShortTimeStamper::getTimestampSize() const { return TIMESTAMP_LEN; } diff --git a/src/fsfw/timemanager/TimeStamperIF.h b/src/fsfw/timemanager/TimeStamperIF.h index 5c3880ea..404dd10a 100644 --- a/src/fsfw/timemanager/TimeStamperIF.h +++ b/src/fsfw/timemanager/TimeStamperIF.h @@ -1,9 +1,8 @@ #ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ #define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ -#include - -#include "../returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/serialize/SerializeIF.h" /** * A class implementing this IF provides facilities to add a time stamp to the @@ -11,17 +10,21 @@ * Implementors need to ensure that calling the method is thread-safe, i.e. * addTimeStamp may be called in parallel from a different context. */ -class TimeStamperIF { +class TimeStamperIF : public SerializeIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::TIME_STAMPER_IF; static const ReturnValue_t BAD_TIMESTAMP = MAKE_RETURN_CODE(1); + // I am going to assume there are no larger timestamps + static constexpr size_t MAXIMUM_TIMESTAMP_LEN = 16; + //! This is a mission-specific constant and determines the total //! size reserved for timestamps. - static const uint8_t MISSION_TIMESTAMP_SIZE = fsfwconfig::FSFW_MISSION_TIMESTAMP_SIZE; + // static const uint8_t MISSION_TIMESTAMP_SIZE = fsfwconfig::FSFW_MISSION_TIMESTAMP_SIZE; - virtual ReturnValue_t addTimeStamp(uint8_t* buffer, const uint8_t maxSize) = 0; - virtual ~TimeStamperIF() {} + [[nodiscard]] virtual size_t getTimestampSize() const = 0; + virtual ReturnValue_t addTimeStamp(uint8_t* buffer, uint8_t maxSize) = 0; + ~TimeStamperIF() override = default; }; #endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */ diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp index ce1852ab..94cf45f4 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp @@ -75,3 +75,7 @@ void SpacePacketCreator::checkFieldValidity() { valid = false; } } + +void SpacePacketCreator::setParams(SpacePacketParams params_) { params = std::move(params_); } + +SpacePacketParams &SpacePacketCreator::getParams() { return params; } diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h index 5e2888c0..dd5edbd5 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h @@ -9,6 +9,8 @@ #include "fsfw/serialize/SerializeIF.h" struct SpacePacketParams { + SpacePacketParams() = default; + SpacePacketParams(PacketId packetId, PacketSeqCtrl psc, uint16_t dataLen) : packetId(std::move(packetId)), packetSeqCtrl(std::move(psc)), dataLen(dataLen) {} @@ -20,6 +22,7 @@ struct SpacePacketParams { class SpacePacketCreator : public SpacePacketIF, public SerializeIF { public: + SpacePacketCreator() = default; explicit SpacePacketCreator(SpacePacketParams params); SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid, ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen, @@ -30,6 +33,8 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF { [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; + SpacePacketParams &getParams(); + void setParams(SpacePacketParams params); void setApid(uint16_t apid); void setSeqCount(uint16_t seqCount); void setSeqFlags(ccsds::SequenceFlags flags); @@ -45,9 +50,7 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF { private: void checkFieldValidity(); - - SpacePacketCreator() = default; bool valid{}; - SpacePacketParams params; + SpacePacketParams params{}; }; #endif // FSFW_TMTCPACKET_SPACEPACKETCREATOR_H diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h index 5db7b254..068e04d9 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h @@ -18,7 +18,7 @@ class SpacePacketIF { /** * This is the minimum size of a SpacePacket. */ - static const uint16_t MINIMUM_SIZE = sizeof(ccsds::PrimaryHeader) + CRC_SIZE; + static const uint16_t MIN_CCSDS_SIZE = sizeof(ccsds::PrimaryHeader) + CRC_SIZE; virtual ~SpacePacketIF() = default; diff --git a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp index c1f6665a..fe0e1f69 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp +++ b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp @@ -31,7 +31,7 @@ PacketMatchTree::~PacketMatchTree() = default; ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t subtype) { // We assume adding APID is always requested. - PusTmMinimal::TmPacketMinimalPointer data{}; + mintm::MinimalPusTm data{}; data.secHeader.service = type; data.secHeader.subservice = subtype; PusTmMinimal testPacket((uint8_t*)&data); @@ -122,7 +122,7 @@ ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test, } ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type, uint8_t subtype) { - PusTmMinimal::TmPacketMinimalPointer data{}; + mintm::MinimalPusTm data{}; data.secHeader.service = type; data.secHeader.subservice = subtype; PusTmMinimal testPacket((uint8_t*)&data); diff --git a/src/fsfw/tmtcpacket/pus/CreatorDataIF.h b/src/fsfw/tmtcpacket/pus/CreatorDataIF.h new file mode 100644 index 00000000..7d5d1d18 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/CreatorDataIF.h @@ -0,0 +1,10 @@ +#ifndef FSFW_TMTCPACKET_CREATORDATAIF_H +#define FSFW_TMTCPACKET_CREATORDATAIF_H + +#include "definitions.h" + +class CreatorDataIF { + public: + virtual ecss::DataWrapper& getDataWrapper() = 0; +}; +#endif // FSFW_TMTCPACKET_CREATORDATAIF_H diff --git a/src/fsfw/tmtcpacket/pus/PusIF.h b/src/fsfw/tmtcpacket/pus/PusIF.h index 5eeae04d..eb0e35f8 100644 --- a/src/fsfw/tmtcpacket/pus/PusIF.h +++ b/src/fsfw/tmtcpacket/pus/PusIF.h @@ -29,24 +29,6 @@ class PusIF : public SpacePacketIF { * @return The packet's PUS Service Subtype. */ [[nodiscard]] virtual uint8_t getSubService() const = 0; - - /** - * This is a getter for a pointer to the packet's Application data. - * - * These are the bytes that follow after the Data Field Header. They form - * the packet's application data. - * @return A pointer to the PUS Application Data. - */ - [[nodiscard]] virtual const uint8_t* getUserData(size_t& appDataLen) const = 0; - /** - * This method calculates the size of the PUS Application data field. - * - * It takes the information stored in the CCSDS Packet Data Length field - * and subtracts the Data Field Header size and the CRC size. - * @return The size of the PUS Application Data (without Error Control - * field) - */ - [[nodiscard]] virtual uint16_t getUserDataSize() const = 0; }; #endif // FSFW_TMTCPACKET_PUSIF_H diff --git a/src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h b/src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h new file mode 100644 index 00000000..170ac824 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h @@ -0,0 +1,12 @@ +#ifndef FSFW_TMTCPACKET_RAWDATAIF_H +#define FSFW_TMTCPACKET_RAWDATAIF_H + +#include +#include + +class RawUserDataReaderIF { + public: + virtual const uint8_t* getUserData(size_t& userDataLen) = 0; +}; + +#endif // FSFW_TMTCPACKET_RAWDATAIF_H diff --git a/src/fsfw/tmtcpacket/pus/definitions.h b/src/fsfw/tmtcpacket/pus/definitions.h index 369f869a..6a5c10eb 100644 --- a/src/fsfw/tmtcpacket/pus/definitions.h +++ b/src/fsfw/tmtcpacket/pus/definitions.h @@ -3,11 +3,39 @@ #include +#include "fsfw/serialize/SerializeIF.h" + namespace ecss { //! Version numbers according to ECSS-E-ST-70-41C p.439 enum PusVersion : uint8_t { PUS_A = 1, PUS_C = 2 }; +struct RawData { + const uint8_t* data; + size_t len; +}; + +enum DataTypes { RAW, SERIALIZABLE }; + +union DataUnion { + RawData raw; + SerializeIF* serializable; +}; + +struct DataWrapper { + DataTypes type; + DataUnion dataUnion; + + [[nodiscard]] size_t getLength() const { + if (type == DataTypes::RAW) { + return dataUnion.raw.len; + } else if (type == DataTypes::SERIALIZABLE and dataUnion.serializable != nullptr) { + return dataUnion.serializable->getSerializedSize(); + } + return 0; + } +}; + } // namespace ecss #endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TM_DEFINITIONS_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 7de759c8..8f8cc8e6 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -1,17 +1,20 @@ #include "PusTcCreator.h" +#include + #include "PusTcIF.h" #include "fsfw/globalfunctions/CRC.h" #include "fsfw/serialize/SerializeAdapter.h" PusTcCreator::PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams) - : spCreator(spParams), pusParams(pusParams) { + : spCreator(std::move(spParams)), pusParams(pusParams) { updateSpLengthField(); } ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { - if (*size + PusTcIF::MIN_LEN + pusParams.appDataLen > maxSize) { + size_t userDataLen = pusParams.dataWrapper.getLength(); + if (*size + PusTcIF::MIN_LEN + userDataLen > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } ReturnValue_t result = spCreator.serialize(buffer, size, maxSize, streamEndianness); @@ -33,15 +36,28 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - std::memcpy(*buffer, pusParams.appData, pusParams.appDataLen); - *buffer += pusParams.appDataLen; - *size += pusParams.appDataLen; + if (pusParams.dataWrapper.type == ecss::DataTypes::RAW) { + const uint8_t *data = pusParams.dataWrapper.dataUnion.raw.data; + if (data != nullptr and userDataLen > 0) { + std::memcpy(*buffer, data, userDataLen); + *buffer += userDataLen; + *size += userDataLen; + } + } else if (pusParams.dataWrapper.type == ecss::DataTypes::SERIALIZABLE and + pusParams.dataWrapper.dataUnion.serializable != nullptr) { + result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, + streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + } + uint16_t crc16 = CRC::crc16ccitt(*buffer, getFullPacketLen() - 2); return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness); } void PusTcCreator::updateSpLengthField() { - spCreator.setDataLen(ecss::PusTcDataFieldHeader::MIN_LEN + pusParams.appDataLen + 1); + spCreator.setDataLen(ecss::PusTcDataFieldHeader::MIN_LEN + pusParams.dataWrapper.getLength() + 1); } size_t PusTcCreator::getSerializedSize() const { return spCreator.getFullPacketLen(); } @@ -66,10 +82,4 @@ uint8_t PusTcCreator::getService() const { return pusParams.service; } uint8_t PusTcCreator::getSubService() const { return pusParams.subservice; } uint16_t PusTcCreator::getSourceId() const { return pusParams.sourceId; } - -const uint8_t *PusTcCreator::getUserData(size_t &appDataLen) const { - appDataLen = getUserDataSize(); - return pusParams.appData; -} - -uint16_t PusTcCreator::getUserDataSize() const { return pusParams.appDataLen; } +ecss::DataWrapper &PusTcCreator::getDataWrapper() { return pusParams.dataWrapper; } diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index cc220fa9..956a2505 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -4,6 +4,7 @@ #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" +#include "fsfw/tmtcpacket/pus/CreatorDataIF.h" #include "fsfw/tmtcpacket/pus/definitions.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" @@ -14,12 +15,11 @@ struct PusTcParams { uint8_t subservice; uint8_t ackFlags = ecss::ACK_ALL; uint16_t sourceId = 0; - uint8_t *appData = nullptr; - size_t appDataLen = 0; + ecss::DataWrapper dataWrapper{}; uint8_t pusVersion = ecss::PusVersion::PUS_C; }; -class PusTcCreator : public PusTcIF, public SerializeIF { +class PusTcCreator : public PusTcIF, public SerializeIF, public CreatorDataIF { public: PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams); @@ -37,8 +37,7 @@ class PusTcCreator : public PusTcIF, public SerializeIF { [[nodiscard]] uint8_t getService() const override; [[nodiscard]] uint8_t getSubService() const override; [[nodiscard]] uint16_t getSourceId() const override; - const uint8_t *getUserData(size_t &appDataLen) const override; - [[nodiscard]] uint16_t getUserDataSize() const override; + ecss::DataWrapper &getDataWrapper() override; private: SpacePacketCreator spCreator; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h index 889260c1..61b29660 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h @@ -23,7 +23,7 @@ enum AckField { static constexpr uint8_t ACK_ALL = ACK_ACCEPTANCE | ACK_START | ACK_STEP | ACK_COMPLETION; /** - * This struct defines a byte-wise structured PUS C ata Field Header. + * This struct defines a byte-wise structured PUS C data Field Header. * Any optional fields in the header must be added or removed here. * Currently, the Source Id field is present with one byte. * No spare byte support for now. diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp index 43c30a46..bf4ec181 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp @@ -7,7 +7,7 @@ #include "fsfw/serialize.h" #include "fsfw/serviceinterface/ServiceInterface.h" -PusTcReader::PusTcReader(const uint8_t* data, size_t size) { setData(data, size); } +PusTcReader::PusTcReader(const uint8_t* data, size_t size) { setReadOnlyData(data, size); } PusTcReader::~PusTcReader() = default; @@ -39,12 +39,6 @@ uint8_t PusTcReader::getSubService() const { return pointers.secHeaderStart[2]; uint16_t PusTcReader::getSourceId() const { return (pointers.secHeaderStart[3] << 8) | pointers.secHeaderStart[4]; } -const uint8_t* PusTcReader::getUserData(size_t& appDataLen) const { - appDataLen = appDataSize; - return pointers.userDataStart; -} - -uint16_t PusTcReader::getUserDataSize() const { return appDataSize; } uint16_t PusTcReader::getErrorControl() const { return pointers.crcStart[0] << 8 | pointers.crcStart[1]; @@ -62,11 +56,17 @@ ReturnValue_t PusTcReader::setData(uint8_t* pData, size_t size_, void* args) { spReader.setData(pData, size_, args); return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PusTcReader::setData(const uint8_t* data, size_t size_) { + +ReturnValue_t PusTcReader::setReadOnlyData(const uint8_t* data, size_t size_) { setData(const_cast(data), size_, nullptr); return HasReturnvaluesIF::RETURN_OK; } +const uint8_t* PusTcReader::getUserData(size_t& userDataLen) { + userDataLen = appDataSize; + return pointers.userDataStart; +} + /* void PusTcReader::print() { #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h index b2045761..0cf18496 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h @@ -6,6 +6,7 @@ #include "PusTcIF.h" #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" +#include "fsfw/tmtcpacket/pus/RawUserDataReaderIF.h" /** * This class is the basic data handler for any ECSS PUS Telecommand packet. @@ -18,7 +19,10 @@ * check can be performed by making use of the getWholeData method. * @ingroup tmtcpackets */ -class PusTcReader : public PusTcIF, public ReadablePacketIF, public RedirectableDataPointerIF { +class PusTcReader : public PusTcIF, + public RawUserDataReaderIF, + public ReadablePacketIF, + public RedirectableDataPointerIF { public: PusTcReader() = default; /** @@ -48,12 +52,11 @@ class PusTcReader : public PusTcIF, public ReadablePacketIF, public Redirectable [[nodiscard]] uint8_t getService() const override; [[nodiscard]] uint8_t getSubService() const override; [[nodiscard]] uint16_t getSourceId() const override; - [[nodiscard]] const uint8_t* getUserData(size_t& appDataLen) const override; - [[nodiscard]] uint16_t getUserDataSize() const override; [[nodiscard]] uint16_t getErrorControl() const; const uint8_t* getFullData() override; - ReturnValue_t setData(const uint8_t* data, size_t size); + ReturnValue_t setReadOnlyData(const uint8_t* data, size_t size); + const uint8_t* getUserData(size_t& userDataLen) override; protected: /** diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index acf0435d..e80eddd1 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -1,6 +1,19 @@ #include "PusTmCreator.h" -PusTmCreator::PusTmCreator(PusTmParams& params_) : params(params_){}; +#include + +#include "fsfw/globalfunctions/CRC.h" +#include "fsfw/timemanager/TimeStamperIF.h" + +PusTmCreator::PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams, + TimeStamperIF* timeStamper) + : pusParams(initPusParams), spCreator(std::move(initSpParams)){}; + +PusTmCreator::PusTmCreator(TimeStamperIF* timeStamper_) { + pusParams.secHeader.timeStamper = timeStamper_; +}; + +PusTmCreator::PusTmCreator() = default; uint16_t PusTmCreator::getPacketIdRaw() const { return 0; } uint16_t PusTmCreator::getPacketSeqCtrlRaw() const { return 0; } @@ -8,5 +21,79 @@ uint16_t PusTmCreator::getPacketDataLen() const { return 0; } uint8_t PusTmCreator::getPusVersion() const { return 0; } uint8_t PusTmCreator::getService() const { return 0; } uint8_t PusTmCreator::getSubService() const { return 0; } -const uint8_t* PusTmCreator::getUserData(size_t& appDataLen) const { return nullptr; } -uint16_t PusTmCreator::getUserDataSize() const { return 0; } +PusTmParams& PusTmCreator::getParams() { return pusParams; } +void PusTmCreator::setTimeStamper(TimeStamperIF* timeStamper_) { + pusParams.secHeader.timeStamper = timeStamper_; +} +uint8_t PusTmCreator::getScTimeRefStatus() { return 0; } +uint16_t PusTmCreator::getMessageTypeCounter() { return 0; } +uint16_t PusTmCreator::getDestId() { return 0; } + +ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const { + if (*size + getSerializedSize() > maxSize) { + return SerializeIF::BUFFER_TOO_SHORT; + } + ReturnValue_t result = spCreator.serialize(buffer, size, maxSize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + size_t userDataLen = pusParams.dataWrapper.getLength(); + **buffer = + ((pusParams.secHeader.pusVersion << 4) & 0xF0) | (pusParams.secHeader.scTimeRefStatus & 0x0F); + *buffer += 1; + **buffer = pusParams.secHeader.service; + *buffer += 1; + **buffer = pusParams.secHeader.subservice; + *buffer += 1; + *size += 3; + result = SerializeAdapter::serialize(&pusParams.secHeader.messageTypeCounter, buffer, size, + maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = SerializeAdapter::serialize(&pusParams.secHeader.destId, buffer, size, maxSize, + streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = pusParams.secHeader.timeStamper->serialize(buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (pusParams.dataWrapper.type == ecss::DataTypes::RAW and + pusParams.dataWrapper.dataUnion.raw.data != nullptr) { + std::memcpy(*buffer, pusParams.dataWrapper.dataUnion.raw.data, userDataLen); + *buffer += userDataLen; + *size += userDataLen; + } else if (pusParams.dataWrapper.type == ecss::DataTypes::SERIALIZABLE and + pusParams.dataWrapper.dataUnion.serializable != nullptr) { + result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, + streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + } + uint16_t crc16 = CRC::crc16ccitt(*buffer, getFullPacketLen() - 2); + return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness); +} + +size_t PusTmCreator::getSerializedSize() const { return getFullPacketLen(); } +ReturnValue_t PusTmCreator::deSerialize(const uint8_t** buffer, size_t* size, + SerializeIF::Endianness streamEndianness) { + return HasReturnvaluesIF::RETURN_FAILED; +} + +ecss::DataWrapper& PusTmCreator::getDataWrapper() { return pusParams.dataWrapper; } +TimeStamperIF* PusTmCreator::getTimestamper() { return pusParams.secHeader.timeStamper; } +SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } + +void PusTmCreator::updateSpLengthField() { + size_t headerLen = PusTmIF::MIN_TM_SIZE; + if (pusParams.secHeader.timeStamper != nullptr) { + headerLen += pusParams.secHeader.timeStamper->getSerializedSize(); + } + spCreator.setDataLen(headerLen + pusParams.dataWrapper.getLength() + 1); +} + +void PusTmCreator::setApid(uint16_t apid) { spCreator.setApid(apid); }; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 4a45e904..5269bd0f 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -1,33 +1,62 @@ #ifndef FSFW_TMTCPACKET_TMPACKETCREATOR_H #define FSFW_TMTCPACKET_TMPACKETCREATOR_H -#include "fsfw/tmtcpacket/pus/PusIF.h" +#include "PusTmIF.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" +#include "fsfw/tmtcpacket/pus/CreatorDataIF.h" -struct PusTmParams { +struct PusTmSecHeader { uint8_t pusVersion; uint8_t scTimeRefStatus; uint8_t service; uint8_t subservice; uint16_t messageTypeCounter; uint16_t destId; - uint8_t* timestamp; - size_t timestampLen; + TimeStamperIF* timeStamper; }; -class PusTmCreator : public PusIF { - public: - ~PusTmCreator() override = default; - explicit PusTmCreator(PusTmParams& params); +struct PusTmParams { + PusTmSecHeader secHeader; + ecss::DataWrapper dataWrapper; +}; + +class TimeStamperIF; + +class PusTmCreator : public SerializeIF, public PusTmIF, public CreatorDataIF { + public: + PusTmCreator(); + + explicit PusTmCreator(TimeStamperIF* timeStamper); + PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams, + TimeStamperIF* timeStamper); + ~PusTmCreator() override = default; + + void setTimeStamper(TimeStamperIF* timeStamper); + SpacePacketParams& getSpParams(); + void setApid(uint16_t apid); + PusTmParams& getParams(); + void updateSpLengthField(); [[nodiscard]] uint16_t getPacketIdRaw() const override; [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; [[nodiscard]] uint8_t getPusVersion() const override; [[nodiscard]] uint8_t getService() const override; [[nodiscard]] uint8_t getSubService() const override; - const uint8_t* getUserData(size_t& appDataLen) const override; - [[nodiscard]] uint16_t getUserDataSize() const override; + uint8_t getScTimeRefStatus() override; + uint16_t getMessageTypeCounter() override; + uint16_t getDestId() override; + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const override; + [[nodiscard]] size_t getSerializedSize() const override; + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override; + TimeStamperIF* getTimestamper() override; private: - PusTmParams& params; + ecss::DataWrapper& getDataWrapper() override; + + private: + PusTmParams pusParams{}; + SpacePacketCreator spCreator; }; #endif // FSFW_TMTCPACKET_TMPACKETCREATOR_H diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h b/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h index b22bdf3d..94d41467 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h @@ -4,17 +4,27 @@ #include #include +#include "fsfw/timemanager/TimeStamperIF.h" #include "fsfw/tmtcpacket/pus/PusIF.h" +#include "fsfw/tmtcpacket/pus/definitions.h" class PusTmIF : public PusIF { public: ~PusTmIF() override = default; + /** + * Minimum length without timestamp + */ + static constexpr size_t MIN_SEC_HEADER_LEN = 7; + /** + * 2 bytes for CRC16 + */ + static constexpr size_t MIN_TM_SIZE = sizeof(ccsds::PrimaryHeader) + MIN_SEC_HEADER_LEN + 2; + virtual uint8_t getScTimeRefStatus() = 0; virtual uint16_t getMessageTypeCounter() = 0; virtual uint16_t getDestId() = 0; - virtual const uint8_t* getTimestamp(size_t& timeStampLen) = 0; - virtual size_t getTimestampLen() = 0; + virtual TimeStamperIF* getTimestamper() = 0; }; #endif // FSFW_TMTCPACKET_PUSTMIF_H diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp index f2cc7fcc..f36cfc2a 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp @@ -34,15 +34,16 @@ uint16_t PusTmMinimal::getPacketDataLen() const { return 0; } uint8_t PusTmMinimal::getPusVersion() const { return 0; } uint8_t PusTmMinimal::getService() const { return tmData->secHeader.service; } uint8_t PusTmMinimal::getSubService() const { return tmData->secHeader.subservice; } -const uint8_t* PusTmMinimal::getUserData(size_t& appDataLen) const { return nullptr; } -uint16_t PusTmMinimal::getUserDataSize() const { return 0; } uint8_t PusTmMinimal::getScTimeRefStatus() { return 0; } uint16_t PusTmMinimal::getMessageTypeCounter() { return (tmData->secHeader.messageTypeH << 8) | tmData->secHeader.messageTypeL; } uint16_t PusTmMinimal::getDestId() { return 0; } -const uint8_t* PusTmMinimal::getTimestamp(size_t& timeStampLen) { return nullptr; } -size_t PusTmMinimal::getTimestampLen() { return 0; } void PusTmMinimal::setApid(uint16_t apid) { /* TODO: Implement. Maybe provide low level function to do this */ } +const uint8_t* PusTmMinimal::getUserData(size_t& userDataLen_) { + userDataLen_ = userDataLen; + return reinterpret_cast(&tmData->rest); +} +TimeStamperIF* PusTmMinimal::getTimestamper() { return nullptr; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h index b9146def..06ed4aff 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h @@ -4,6 +4,7 @@ #include "PusTmIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" +#include "fsfw/tmtcpacket/pus/RawUserDataReaderIF.h" struct timeval; @@ -12,7 +13,7 @@ class PacketTimestampInterpreterIF; namespace mintm { // NOTE: Only PUS C compatible! -struct PusTmMinimalSecHeader { +struct PusTmMinimalSecHeaderPacked { uint8_t versionAndScTimeRefStatus; uint8_t service; uint8_t subservice; @@ -27,7 +28,7 @@ struct PusTmMinimalSecHeader { */ struct MinimalPusTm { ccsds::PrimaryHeader primary; - PusTmMinimalSecHeader secHeader; + PusTmMinimalSecHeaderPacked secHeader; uint8_t rest; }; @@ -42,7 +43,7 @@ static const uint16_t MINIMUM_SIZE = sizeof(MinimalPusTm) + 1; * This is required for handling TM packets with different APIDs with different * secondary headers. */ -class PusTmMinimal : public PusTmIF, public RedirectableDataPointerIF { +class PusTmMinimal : public PusTmIF, public RawUserDataReaderIF, public RedirectableDataPointerIF { public: explicit PusTmMinimal(mintm::MinimalPusTm* data); /** @@ -69,13 +70,11 @@ class PusTmMinimal : public PusTmIF, public RedirectableDataPointerIF { [[nodiscard]] uint8_t getPusVersion() const override; [[nodiscard]] uint8_t getService() const override; [[nodiscard]] uint8_t getSubService() const override; - const uint8_t* getUserData(size_t& appDataLen) const override; - [[nodiscard]] uint16_t getUserDataSize() const override; uint8_t getScTimeRefStatus() override; uint16_t getMessageTypeCounter() override; uint16_t getDestId() override; - const uint8_t* getTimestamp(size_t& timeStampLen) override; - size_t getTimestampLen() override; + const uint8_t* getUserData(size_t& userDataLen) override; + TimeStamperIF* getTimestamper() override; protected: /** @@ -84,6 +83,7 @@ class PusTmMinimal : public PusTmIF, public RedirectableDataPointerIF { * * To be hardware-safe, all elements are of byte size. */ + size_t userDataLen = 0; mintm::MinimalPusTm* tmData; static PacketTimestampInterpreterIF* timestampInterpreter; diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h index 7d1eb255..c68deadd 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h @@ -26,7 +26,7 @@ struct PUSTmDataFieldHeaderPusC { uint8_t subcounterLsb; uint8_t destinationIdMsb; uint8_t destinationIdLsb; - uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE]; + // uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE]; }; /** diff --git a/src/fsfw/tmtcservices/CMakeLists.txt b/src/fsfw/tmtcservices/CMakeLists.txt index fcbcb49d..a26faf7f 100644 --- a/src/fsfw/tmtcservices/CMakeLists.txt +++ b/src/fsfw/tmtcservices/CMakeLists.txt @@ -7,4 +7,5 @@ target_sources( TmTcMessage.cpp VerificationReporter.cpp SpacePacketParser.cpp - TmStoreHelper.cpp) + TmStoreHelper.cpp + TmSendHelper.cpp) diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 37232c49..8aa5dbce 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -8,6 +8,7 @@ #include "fsfw/tmtcpacket/pus/tm.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/TmTcMessage.h" +#include "fsfw/tmtcservices/sendAndStoreHelper.h" object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; object_id_t CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; @@ -19,17 +20,19 @@ CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t a apid(apid), service(service), timeoutSeconds(commandTimeoutSeconds), + tmStoreHelper(apid, nullptr), + tmSendHelper(nullptr), commandMap(numberOfParallelCommands) { commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth); } -void CommandingServiceBase::setPacketSource(object_id_t packetSource) { - this->packetSource = packetSource; +void CommandingServiceBase::setPacketSource(object_id_t packetSource_) { + packetSource = packetSource_; } -void CommandingServiceBase::setPacketDestination(object_id_t packetDestination) { - this->packetDestination = packetDestination; +void CommandingServiceBase::setPacketDestination(object_id_t packetDestination_) { + packetDestination = packetDestination_; } CommandingServiceBase::~CommandingServiceBase() { @@ -58,13 +61,12 @@ ReturnValue_t CommandingServiceBase::initialize() { if (packetDestination == objects::NO_OBJECT) { packetDestination = defaultPacketDestination; } - AcceptsTelemetryIF* packetForwarding = - ObjectManager::instance()->get(packetDestination); + auto* packetForwarding = ObjectManager::instance()->get(packetDestination); if (packetSource == objects::NO_OBJECT) { packetSource = defaultPacketSource; } - PUSDistributorIF* distributor = ObjectManager::instance()->get(packetSource); + auto* distributor = ObjectManager::instance()->get(packetSource); if (packetForwarding == nullptr or distributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -78,10 +80,10 @@ ReturnValue_t CommandingServiceBase::initialize() { distributor->registerService(this); requestQueue->setDefaultDestination(packetForwarding->getReportReceptionQueue()); - IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); - TCStore = ObjectManager::instance()->get(objects::TC_STORE); + ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); + tcStore = ObjectManager::instance()->get(objects::TC_STORE); - if (IPCStore == nullptr or TCStore == nullptr) { + if (ipcStore == nullptr or tcStore == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CommandingServiceBase::intialize: IPC store or TC store " "not initialized yet!" @@ -89,7 +91,20 @@ ReturnValue_t CommandingServiceBase::initialize() { #endif return ObjectManagerIF::CHILD_INIT_FAILED; } - + if (tmStoreHelper.getTmStore() == nullptr) { + auto* tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (tmStore == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + tmStoreHelper.setTmStore(tmStore); + } + if (errReporter == nullptr) { + errReporter = + ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); + if (errReporter != nullptr) { + tmSendHelper.setInternalErrorReporter(errReporter); + } + } return RETURN_OK; } @@ -226,23 +241,31 @@ void CommandingServiceBase::handleRequestQueue() { TmTcMessage message; ReturnValue_t result; store_address_t address; - TcPacketStoredPus packet; MessageQueueId_t queue; object_id_t objectId; for (result = requestQueue->receiveMessage(&message); result == RETURN_OK; result = requestQueue->receiveMessage(&message)) { address = message.getStorageId(); - packet.setStoreAddress(address, &packet); + const uint8_t* dataPtr; + size_t dataLen = 0; + result = tcStore->getData(message.getStorageId(), &dataPtr, &dataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + // TODO: Warning? + } + tcReader.setReadOnlyData(dataPtr, dataLen); - if ((packet.getSubService() == 0) or (isValidSubservice(packet.getSubService()) != RETURN_OK)) { - rejectPacket(tc_verification::START_FAILURE, &packet, INVALID_SUBSERVICE); + if ((tcReader.getSubService() == 0) or + (isValidSubservice(tcReader.getSubService()) != RETURN_OK)) { + rejectPacket(tc_verification::START_FAILURE, address, &tcReader, INVALID_SUBSERVICE); continue; } - result = getMessageQueueAndObject(packet.getSubService(), packet.getApplicationData(), - packet.getApplicationDataSize(), &queue, &objectId); + size_t appDataLen = 0; + const uint8_t* appData = tcReader.getUserData(appDataLen); + result = + getMessageQueueAndObject(tcReader.getSubService(), appData, appDataLen, &queue, &objectId); if (result != HasReturnvaluesIF::RETURN_OK) { - rejectPacket(tc_verification::START_FAILURE, &packet, result); + rejectPacket(tc_verification::START_FAILURE, address, &tcReader, result); continue; } @@ -253,33 +276,26 @@ void CommandingServiceBase::handleRequestQueue() { if (iter != commandMap.end()) { result = iter->second.fifo.insert(address); if (result != RETURN_OK) { - rejectPacket(tc_verification::START_FAILURE, &packet, OBJECT_BUSY); + rejectPacket(tc_verification::START_FAILURE, address, &tcReader, OBJECT_BUSY); } } else { CommandInfo newInfo; // Info will be set by startExecution if neccessary newInfo.objectId = objectId; result = commandMap.insert(queue, newInfo, &iter); if (result != RETURN_OK) { - rejectPacket(tc_verification::START_FAILURE, &packet, BUSY); + rejectPacket(tc_verification::START_FAILURE, address, &tcReader, BUSY); } else { - startExecution(&packet, iter); + startExecution(address, &tcReader, iter); } } } } -ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, const uint8_t* data, - size_t dataLen, const uint8_t* headerData, - size_t headerSize) { -#if FSFW_USE_PUS_C_TELEMETRY == 0 - TmPacketStoredPusA tmPacketStored(this->apid, this->service, subservice, this->tmPacketCounter, - data, dataLen, headerData, headerSize); -#else - TmPacketStoredPusC tmPacketStored(this->apid, this->service, subservice, this->tmPacketCounter, - data, dataLen, headerData, headerSize); -#endif - ReturnValue_t result = - tmPacketStored.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); +ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, const uint8_t* sourceData, + size_t sourceDataLen) { + tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); + tmStoreHelper.setSourceDataRaw(sourceData, sourceDataLen); + ReturnValue_t result = tm::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); if (result == HasReturnvaluesIF::RETURN_OK) { this->tmPacketCounter++; } @@ -288,54 +304,38 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, const uint ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_t objectId, const uint8_t* data, size_t dataLen) { - uint8_t buffer[sizeof(object_id_t)]; - uint8_t* pBuffer = buffer; - size_t size = 0; - SerializeAdapter::serialize(&objectId, &pBuffer, &size, sizeof(object_id_t), - SerializeIF::Endianness::BIG); -#if FSFW_USE_PUS_C_TELEMETRY == 0 - TmPacketStoredPusA tmPacketStored(this->apid, this->service, subservice, this->tmPacketCounter, - data, dataLen, buffer, size); -#else - TmPacketStoredPusC tmPacketStored(this->apid, this->service, subservice, this->tmPacketCounter, - data, dataLen, buffer, size); -#endif - ReturnValue_t result = - tmPacketStored.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); + tm::SourceDataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); + tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); + tmStoreHelper.setSourceDataSerializable(&dataWithObjId); + ReturnValue_t result = tm::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); if (result == HasReturnvaluesIF::RETURN_OK) { this->tmPacketCounter++; } return result; } -ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeIF* content, - SerializeIF* header) { -#if FSFW_USE_PUS_C_TELEMETRY == 0 - TmPacketStoredPusA tmPacketStored(this->apid, this->service, subservice, this->tmPacketCounter, - content, header); -#else - TmPacketStoredPusC tmPacketStored(this->apid, this->service, subservice, this->tmPacketCounter, - content, header); -#endif - ReturnValue_t result = - tmPacketStored.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); +ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeIF* sourceData) { + tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); + tmStoreHelper.setSourceDataSerializable(sourceData); + ReturnValue_t result = tm::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); if (result == HasReturnvaluesIF::RETURN_OK) { this->tmPacketCounter++; } return result; } -void CommandingServiceBase::startExecution(TcPacketStoredPus* storedPacket, CommandMapIter iter) { +void CommandingServiceBase::startExecution(store_address_t storeId, PusTcReader* storedPacket, + CommandMapIter iter) { ReturnValue_t result = RETURN_OK; CommandMessage command; - // TcPacketPusBase* tcPacketBase = storedPacket->getPacketBase(); if (storedPacket == nullptr) { return; } iter->second.subservice = storedPacket->getSubService(); - result = prepareCommand(&command, iter->second.subservice, storedPacket->getApplicationData(), - storedPacket->getApplicationDataSize(), &iter->second.state, - iter->second.objectId); + size_t appDataLen = 0; + const uint8_t* appData = storedPacket->getUserData(appDataLen); + result = prepareCommand(&command, iter->second.subservice, appData, appDataLen, + &iter->second.state, iter->second.objectId); ReturnValue_t sendResult = RETURN_OK; switch (result) { @@ -349,12 +349,12 @@ void CommandingServiceBase::startExecution(TcPacketStoredPus* storedPacket, Comm iter->second.subservice = storedPacket->getSubService(); iter->second.command = command.getCommand(); iter->second.tcInfo.ackFlags = storedPacket->getAcknowledgeFlags(); - iter->second.tcInfo.tcPacketId = storedPacket->getPacketId(); - iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSeqCtrl(); - acceptPacket(tc_verification::START_SUCCESS, storedPacket); + iter->second.tcInfo.tcPacketId = storedPacket->getPacketIdRaw(); + iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSeqCtrlRaw(); + acceptPacket(tc_verification::START_SUCCESS, storeId, storedPacket); } else { command.clearCommandMessage(); - rejectPacket(tc_verification::START_FAILURE, storedPacket, sendResult); + rejectPacket(tc_verification::START_FAILURE, storeId, storedPacket, sendResult); checkAndExecuteFifo(iter); } break; @@ -364,33 +364,32 @@ void CommandingServiceBase::startExecution(TcPacketStoredPus* storedPacket, Comm sendResult = commandQueue->sendMessage(iter.value->first, &command); } if (sendResult == RETURN_OK) { - verificationReporter.sendSuccessReport(tc_verification::START_SUCCESS, - storedPacket->getPacketBase()); - acceptPacket(tc_verification::COMPLETION_SUCCESS, storedPacket); + verificationReporter.sendSuccessReport(tc_verification::START_SUCCESS, storedPacket); + acceptPacket(tc_verification::COMPLETION_SUCCESS, storeId, storedPacket); checkAndExecuteFifo(iter); } else { command.clearCommandMessage(); - rejectPacket(tc_verification::START_FAILURE, storedPacket, sendResult); + rejectPacket(tc_verification::START_FAILURE, storeId, storedPacket, sendResult); checkAndExecuteFifo(iter); } break; default: - rejectPacket(tc_verification::START_FAILURE, storedPacket, result); + rejectPacket(tc_verification::START_FAILURE, storeId, storedPacket, result); checkAndExecuteFifo(iter); break; } } -void CommandingServiceBase::rejectPacket(uint8_t reportId, TcPacketStoredPus* packet, - ReturnValue_t errorCode) { - verificationReporter.sendFailureReport(reportId, dynamic_cast(packet), - errorCode); - packet->deletePacket(); +void CommandingServiceBase::rejectPacket(uint8_t reportId, store_address_t tcStoreId, + PusTcReader* correspondingTc, ReturnValue_t errorCode) { + verificationReporter.sendFailureReport(reportId, correspondingTc, errorCode); + tcStore->deleteData(tcStoreId); } -void CommandingServiceBase::acceptPacket(uint8_t reportId, TcPacketStoredPus* packet) { - verificationReporter.sendSuccessReport(reportId, dynamic_cast(packet)); - packet->deletePacket(); +void CommandingServiceBase::acceptPacket(uint8_t reportId, store_address_t tcStoreId, + PusTcReader* packet) { + verificationReporter.sendSuccessReport(reportId, packet); + tcStore->deleteData(tcStoreId); } void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) { @@ -398,8 +397,15 @@ void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) { if (iter->second.fifo.retrieve(&address) != RETURN_OK) { commandMap.erase(&iter); } else { - TcPacketStoredPus newPacket(address); - startExecution(&newPacket, iter); + const uint8_t* dataPtr; + size_t dataLen = 0; + ReturnValue_t result = tcStore->getData(address, &dataPtr, &dataLen); + if (result == HasReturnvaluesIF::RETURN_OK) { + tcReader.setReadOnlyData(dataPtr, dataLen); + startExecution(address, &tcReader, iter); + } else { + // TODO: Warning? + } } } @@ -426,3 +432,7 @@ void CommandingServiceBase::checkTimeout() { } void CommandingServiceBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; } + +void CommandingServiceBase::setCustomTmStore(StorageManagerIF* store) { + tmStoreHelper.setTmStore(store); +} diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 4dcad024..a392fb95 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -2,6 +2,8 @@ #define FSFW_TMTCSERVICES_COMMANDINGSERVICEBASE_H_ #include "AcceptsTelecommandsIF.h" +#include "TmSendHelper.h" +#include "TmStoreHelper.h" #include "VerificationReporter.h" #include "fsfw/FSFW.h" #include "fsfw/container/FIFO.h" @@ -69,8 +71,9 @@ class CommandingServiceBase : public SystemObject, CommandingServiceBase(object_id_t setObjectId, uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands, uint16_t commandTimeoutSeconds, size_t queueDepth = 20); - virtual ~CommandingServiceBase(); + ~CommandingServiceBase() override; + void setCustomTmStore(StorageManagerIF* store); /** * This setter can be used to set the packet source individually instead * of using the default static framework ID set in the factory. @@ -93,9 +96,9 @@ class CommandingServiceBase : public SystemObject, * @param opCode is unused here at the moment * @return RETURN_OK */ - virtual ReturnValue_t performOperation(uint8_t opCode) override; + ReturnValue_t performOperation(uint8_t opCode) override; - virtual uint16_t getIdentifier() override; + uint16_t getIdentifier() override; /** * Returns the requestQueue MessageQueueId_t @@ -104,7 +107,7 @@ class CommandingServiceBase : public SystemObject, * * @return requestQueue messageQueueId_t */ - virtual MessageQueueId_t getRequestQueue() override; + MessageQueueId_t getRequestQueue() override; /** * Returns the commandQueue MessageQueueId_t @@ -114,7 +117,7 @@ class CommandingServiceBase : public SystemObject, */ virtual MessageQueueId_t getCommandQueue(); - virtual ReturnValue_t initialize() override; + ReturnValue_t initialize() override; /** * Implementation of ExecutableObjectIF function @@ -122,7 +125,7 @@ class CommandingServiceBase : public SystemObject, * Used to setup the reference of the task, that executes this component * @param task Pointer to the taskIF of this task */ - virtual void setTaskIF(PeriodicTaskIF* task) override; + void setTaskIF(PeriodicTaskIF* task) override; protected: /** @@ -230,15 +233,15 @@ class CommandingServiceBase : public SystemObject, object_id_t objectId; FIFO fifo; - 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 { return HasReturnvaluesIF::RETURN_FAILED; }; - virtual size_t getSerializedSize() const override { return 0; }; + [[nodiscard]] size_t getSerializedSize() const override { return 0; }; - 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 { return HasReturnvaluesIF::RETURN_FAILED; }; }; @@ -253,9 +256,13 @@ class CommandingServiceBase : public SystemObject, uint8_t tmPacketCounter = 0; - StorageManagerIF* IPCStore = nullptr; + StorageManagerIF* ipcStore = nullptr; - StorageManagerIF* TCStore = nullptr; + PusTcReader tcReader; + TmStoreHelper tmStoreHelper; + TmSendHelper tmSendHelper; + + StorageManagerIF* tcStore = nullptr; MessageQueueIF* commandQueue = nullptr; @@ -263,6 +270,8 @@ class CommandingServiceBase : public SystemObject, VerificationReporter verificationReporter; + InternalErrorReporterIF* errReporter = nullptr; + FixedMap commandMap; /* May be set be children to return a more precise failure condition. */ @@ -284,13 +293,10 @@ class CommandingServiceBase : public SystemObject, * @brief Send TM data from pointer to data. * If a header is supplied it is added before data * @param subservice Number of subservice - * @param data Pointer to the data in the Packet - * @param dataLen Lenght of data in the Packet - * @param headerData HeaderData will be placed before data - * @param headerSize Size of HeaderData + * @param sourceData Custom source data + * @param sourceDataLen Lenght of data in the Packet */ - ReturnValue_t sendTmPacket(uint8_t subservice, const uint8_t* data, size_t dataLen, - const uint8_t* headerData = nullptr, size_t headerSize = 0); + ReturnValue_t sendTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen); /** * @brief To send TM packets of objects that still need to be serialized @@ -310,8 +316,7 @@ class CommandingServiceBase : public SystemObject, * @param content This is a pointer to the serialized packet * @param header Serialize IF header which will be placed before content */ - ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF* content, - SerializeIF* header = nullptr); + ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF* sourceData); void checkAndExecuteFifo(CommandMapIter& iter); @@ -345,11 +350,12 @@ class CommandingServiceBase : public SystemObject, */ void handleRequestQueue(); - void rejectPacket(uint8_t reportId, TcPacketStoredPus* packet, ReturnValue_t errorCode); + void rejectPacket(uint8_t reportId, store_address_t tcStoreId, PusTcReader* tcPacket, + ReturnValue_t errorCode); - void acceptPacket(uint8_t reportId, TcPacketStoredPus* packet); + void acceptPacket(uint8_t reportId, store_address_t tcStoreId, PusTcReader* tcPacket); - void startExecution(TcPacketStoredPus* storedPacket, CommandMapIter iter); + void startExecution(store_address_t storeId, PusTcReader* storedPacket, CommandMapIter iter); void handleCommandMessage(CommandMessage* reply); void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter, diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index b18a736b..e924ba67 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -11,9 +11,8 @@ object_id_t PusServiceBase::packetSource = 0; object_id_t PusServiceBase::packetDestination = 0; -PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId, - StorageManagerIF* ipcStore_) - : SystemObject(setObjectId), apid(setApid), serviceId(setServiceId), ipcStore(ipcStore_) { +PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId) + : SystemObject(setObjectId), apid(setApid), serviceId(setServiceId) { requestQueue = QueueFactory::instance()->createMessageQueue(PUS_SERVICE_MAX_RECEPTION); } @@ -36,7 +35,7 @@ void PusServiceBase::setTaskIF(PeriodicTaskIF* taskHandle_) { this->taskHandle = void PusServiceBase::handleRequestQueue() { TmTcMessage message; - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result; for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) { ReturnValue_t status = this->requestQueue->receiveMessage(&message); // if(status != MessageQueueIF::EMPTY) { @@ -57,14 +56,9 @@ void PusServiceBase::handleRequestQueue() { // TODO: Warning? } - currentPacket.setData(dataPtr, dataLen); - // info << "Service " << (uint16_t) this->serviceId << - // ": new packet!" << std::endl; + currentPacket.setReadOnlyData(dataPtr, dataLen); result = this->handleRequest(currentPacket.getSubService()); - - // debug << "Service " << (uint16_t)this->serviceId << - // ": handleRequest returned: " << (int)return_code << std::endl; if (result == RETURN_OK) { this->verifyReporter.sendSuccessReport(tc_verification::COMPLETION_SUCCESS, &this->currentPacket); @@ -78,8 +72,6 @@ void PusServiceBase::handleRequestQueue() { errorParameter2 = 0; } else if (status == MessageQueueIF::EMPTY) { status = RETURN_OK; - // debug << "PusService " << (uint16_t)this->serviceId << - // ": no new packet." << std::endl; break; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -127,3 +119,30 @@ ReturnValue_t PusServiceBase::initializeAfterTaskCreation() { // be used to get those parameters. return HasReturnvaluesIF::RETURN_OK; } + +void PusServiceBase::setCustomIpcStore(StorageManagerIF* ipcStore_) { ipcStore = ipcStore_; } + +void PusServiceBase::setCustomErrorReporter(InternalErrorReporterIF* errReporter_) { + errReporter = errReporter_; +} + +void PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper) { + initializeTmSendHelper(tmSendHelper); + initializeTmStoreHelper(tmStoreHelper); +} + +void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { + tmSendHelper.setMsgSource(requestQueue->getId()); + tmSendHelper.setMsgDestination(requestQueue->getDefaultDestination()); + if (errReporter == nullptr) { + errReporter = + ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); + if (errReporter != nullptr) { + tmSendHelper.setInternalErrorReporter(errReporter); + } + } +} + +void PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { + tmStoreHelper.setApid(apid); +} diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index d487c6c6..58f83540 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -2,6 +2,8 @@ #define FSFW_TMTCSERVICES_PUSSERVICEBASE_H_ #include "AcceptsTelecommandsIF.h" +#include "TmSendHelper.h" +#include "TmStoreHelper.h" #include "VerificationCodes.h" #include "VerificationReporter.h" #include "fsfw/ipc/MessageQueueIF.h" @@ -51,12 +53,18 @@ class PusServiceBase : public ExecutableObjectIF, * @param setServiceId * The Service Identifier as specified in ECSS PUS. */ - PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId, - StorageManagerIF* ipcStore); + PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId); /** * The destructor is empty. */ ~PusServiceBase() override; + + void setCustomIpcStore(StorageManagerIF* ipcStore); + void setCustomErrorReporter(InternalErrorReporterIF* errReporter); + + void initializeTmSendHelper(TmSendHelper& tmSendHelper); + void initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const; + void initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper); /** * @brief The handleRequest method shall handle any kind of Telecommand * Request immediately. @@ -139,13 +147,14 @@ class PusServiceBase : public ExecutableObjectIF, * sending any kind of verification message to the TC Verification Service. */ VerificationReporter verifyReporter; + /** * The current Telecommand to be processed. * It is deleted after handleRequest was executed. */ - // TcPacketStoredPus currentPacket; - StorageManagerIF* ipcStore; PusTcReader currentPacket; + StorageManagerIF* ipcStore = nullptr; + InternalErrorReporterIF* errReporter = nullptr; static object_id_t packetSource; diff --git a/src/fsfw/tmtcservices/TmSendHelper.cpp b/src/fsfw/tmtcservices/TmSendHelper.cpp new file mode 100644 index 00000000..76591ca2 --- /dev/null +++ b/src/fsfw/tmtcservices/TmSendHelper.cpp @@ -0,0 +1,29 @@ +#include "TmSendHelper.h" + +#include "fsfw/ipc/MessageQueueSenderIF.h" + +TmSendHelper::TmSendHelper(MessageQueueId_t tmtcMsgDest, MessageQueueId_t tmtcMsgSrc, + InternalErrorReporterIF *reporter) + : tmtcMsgDest(tmtcMsgDest), tmtcMsgSrc(tmtcMsgSrc), errReporter(reporter) {} + +TmSendHelper::TmSendHelper(InternalErrorReporterIF *reporter) : errReporter(reporter) {} + +ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) { + TmTcMessage message(storeId); + ReturnValue_t result = MessageQueueSenderIF::sendMessage(tmtcMsgDest, &message, tmtcMsgSrc); + if (result != HasReturnvaluesIF::RETURN_OK) { + if (errReporter != nullptr) { + errReporter->lostTm(); + } + return result; + } + return HasReturnvaluesIF::RETURN_OK; +} + +void TmSendHelper::setMsgDestination(MessageQueueId_t msgDest) { tmtcMsgDest = msgDest; } + +void TmSendHelper::setMsgSource(MessageQueueId_t msgSrc) { tmtcMsgSrc = msgSrc; } + +void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF *reporter) { + errReporter = reporter; +} diff --git a/src/fsfw/tmtcservices/TmSendHelper.h b/src/fsfw/tmtcservices/TmSendHelper.h new file mode 100644 index 00000000..f7acb237 --- /dev/null +++ b/src/fsfw/tmtcservices/TmSendHelper.h @@ -0,0 +1,26 @@ +#ifndef FSFW_TMTCPACKET_TMSENDHELPER_H +#define FSFW_TMTCPACKET_TMSENDHELPER_H + +#include "TmTcMessage.h" +#include "fsfw/internalerror/InternalErrorReporterIF.h" +#include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/ipc/messageQueueDefinitions.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +class TmSendHelper { + public: + explicit TmSendHelper(InternalErrorReporterIF* reporter); + TmSendHelper(MessageQueueId_t tmtcMsgDest, MessageQueueId_t tmtcMsgSrc, + InternalErrorReporterIF* reporter); + void setMsgDestination(MessageQueueId_t msgDest); + void setMsgSource(MessageQueueId_t msgSrc); + void setInternalErrorReporter(InternalErrorReporterIF* reporter); + ReturnValue_t sendPacket(const store_address_t& storeId); + + private: + MessageQueueId_t tmtcMsgDest = MessageQueueIF::NO_QUEUE; + MessageQueueId_t tmtcMsgSrc = MessageQueueIF::NO_QUEUE; + InternalErrorReporterIF* errReporter; +}; + +#endif // FSFW_TMTCPACKET_TMSENDHELPER_H diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index 54e6ffc8..661ee3a0 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -1,43 +1,58 @@ #include "TmStoreHelper.h" #include "TmTcMessage.h" -#include "fsfw/ipc/MessageQueueSenderIF.h" -TmStoreHelper::TmStoreHelper(StorageManagerIF *tmStore, MessageQueueId_t tmtcMsgDest, - MessageQueueId_t tmtcMsgSrc, InternalErrorReporterIF *reporter) - : creator(params), - tmtcMsgDest(tmtcMsgDest), - tmtcMsgSrc(tmtcMsgSrc), - errReporter(reporter), - tmStore(tmStore) {} - -void TmStoreHelper::preparePacket(uint16_t apid, uint8_t service, uint8_t subservice, - uint16_t counter) { - // TODO: Implement - // creator.setApid(apid); - params.service = service; - params.subservice = subservice; - params.messageTypeCounter = counter; - // TODO: Implement serialize and then serialize into the store +TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore, + TimeStamperIF* timeStamper) + : creator(timeStamper), tmStore(tmStore) { + creator.setApid(defaultApid); } -ReturnValue_t TmStoreHelper::sendPacket() { - TmTcMessage tmMessage(currentAddr); - ReturnValue_t result = MessageQueueSenderIF::sendMessage(tmtcMsgDest, &tmMessage, tmtcMsgSrc); - if (result != HasReturnvaluesIF::RETURN_OK) { - tmStore->deleteData(currentAddr); - if (errReporter != nullptr) { - errReporter->lostTm(); - } - return result; - } +TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore) + : creator(nullptr), tmStore(tmStore) { + creator.setApid(defaultApid); +} + +ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, uint16_t counter) { + // TODO: Implement + // creator.setApid(apid); + PusTmParams& params = creator.getParams(); + params.secHeader.service = service; + params.secHeader.subservice = subservice; + params.secHeader.messageTypeCounter = counter; + // TODO: Implement serialize and then serialize into the store return HasReturnvaluesIF::RETURN_OK; } -void TmStoreHelper::setMsgDestination(MessageQueueId_t msgDest) { tmtcMsgDest = msgDest; } +StorageManagerIF* TmStoreHelper::getTmStore() { return tmStore; } -void TmStoreHelper::setMsgSource(MessageQueueId_t msgSrc) { tmtcMsgSrc = msgSrc; } +void TmStoreHelper::setTmStore(StorageManagerIF* store) { tmStore = store; } +const store_address_t& TmStoreHelper::getCurrentAddr() const { return currentAddr; } +ReturnValue_t TmStoreHelper::deletePacket() { return tmStore->deleteData(currentAddr); } -void TmStoreHelper::setInternalErrorReporter(InternalErrorReporterIF *reporter) { - errReporter = reporter; +void TmStoreHelper::setSourceDataRaw(const uint8_t* data, size_t len) { + PusTmParams& params = creator.getParams(); + params.dataWrapper.type = ecss::DataTypes::RAW; + params.dataWrapper.dataUnion.raw.data = data; + params.dataWrapper.dataUnion.raw.len = len; } + +void TmStoreHelper::setSourceDataSerializable(SerializeIF* serializable) { + PusTmParams& params = creator.getParams(); + params.dataWrapper.type = ecss::DataTypes::SERIALIZABLE; + params.dataWrapper.dataUnion.serializable = serializable; +} + +ReturnValue_t TmStoreHelper::addPacketToStore() { + creator.updateSpLengthField(); + uint8_t* dataPtr; + tmStore->getFreeElement(¤tAddr, creator.getSerializedSize(), &dataPtr); + size_t serLen = 0; + return creator.serialize(&dataPtr, &serLen, creator.getSerializedSize(), + SerializeIF::Endianness::NETWORK); +} + +void TmStoreHelper::setTimeStamper(TimeStamperIF* timeStamper_) { + creator.setTimeStamper(timeStamper_); +} +void TmStoreHelper::setApid(uint16_t apid) { creator.setApid(apid); } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index 61ef93f4..43f7e787 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -4,35 +4,27 @@ #include "fsfw/internalerror/InternalErrorReporterIF.h" #include "fsfw/ipc/MessageQueueMessageIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" +#include "fsfw/timemanager/TimeStamperIF.h" #include "fsfw/tmtcpacket/pus/tm/PusTmCreator.h" -class TmStoreAndSendWrapper { - -}; - -class TmSendHelper { - public: - TmSendHelper(MessageQueueId_t tmtcMsgDest, - MessageQueueId_t tmtcMsgSrc, InternalErrorReporterIF* reporter); - void setMsgDestination(MessageQueueId_t msgDest); - void setMsgSource(MessageQueueId_t msgSrc); - void setInternalErrorReporter(InternalErrorReporterIF* reporter); - ReturnValue_t sendPacket(); - private: - MessageQueueId_t tmtcMsgDest; - MessageQueueId_t tmtcMsgSrc; - InternalErrorReporterIF* errReporter; -}; - -// TODO: Serializing a packet into a store and sending the message are two different tasks -// Move them into separate classes class TmStoreHelper { public: - TmStoreHelper(StorageManagerIF* tmStore); + explicit TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore); + TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore, TimeStamperIF* timeStamper); + + ReturnValue_t preparePacket(uint8_t service, uint8_t subservice, uint16_t counter); + + void setTimeStamper(TimeStamperIF* timeStamper); + [[nodiscard]] const store_address_t& getCurrentAddr() const; + void setSourceDataRaw(const uint8_t* data, size_t len); + void setSourceDataSerializable(SerializeIF* serializable); + void setApid(uint16_t apid); + StorageManagerIF* getTmStore(); + void setTmStore(StorageManagerIF* store); + ReturnValue_t addPacketToStore(); + ReturnValue_t deletePacket(); - void preparePacket(uint16_t apid, uint8_t service, uint8_t subservice, uint16_t counter); private: - PusTmParams params{}; PusTmCreator creator; store_address_t currentAddr{}; StorageManagerIF* tmStore; diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 04b42934..67b2af37 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -13,17 +13,17 @@ VerificationReporter::VerificationReporter() : acknowledgeQueue(MessageQueueIF:: VerificationReporter::~VerificationReporter() = default; -void VerificationReporter::sendSuccessReport(uint8_t set_report_id, PusTcReader* currentPacket, +void VerificationReporter::sendSuccessReport(uint8_t set_report_id, PusTcReader* correspondingTc, uint8_t set_step) { if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) { this->initialize(); } - if (currentPacket == nullptr) { + if (correspondingTc == nullptr) { return; } - PusVerificationMessage message(set_report_id, currentPacket->getAcknowledgeFlags(), - currentPacket->getPacketIdRaw(), - currentPacket->getPacketSeqCtrlRaw(), 0, set_step); + PusVerificationMessage message(set_report_id, correspondingTc->getAcknowledgeFlags(), + correspondingTc->getPacketIdRaw(), + correspondingTc->getPacketSeqCtrlRaw(), 0, set_step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -50,18 +50,18 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, uint8_t ackF } } -void VerificationReporter::sendFailureReport(uint8_t report_id, PusTcReader* currentPacket, +void VerificationReporter::sendFailureReport(uint8_t report_id, PusTcReader* correspondingTc, ReturnValue_t error_code, uint8_t step, uint32_t parameter1, uint32_t parameter2) { if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) { this->initialize(); } - if (currentPacket == nullptr) { + if (correspondingTc == nullptr) { return; } PusVerificationMessage message( - report_id, currentPacket->getAcknowledgeFlags(), currentPacket->getPacketIdRaw(), - currentPacket->getPacketSeqCtrlRaw(), error_code, step, parameter1, parameter2); + report_id, correspondingTc->getAcknowledgeFlags(), correspondingTc->getPacketIdRaw(), + correspondingTc->getPacketSeqCtrlRaw(), error_code, step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/tmtcservices/VerificationReporter.h b/src/fsfw/tmtcservices/VerificationReporter.h index 5b4dbe0a..d668c502 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.h +++ b/src/fsfw/tmtcservices/VerificationReporter.h @@ -27,11 +27,11 @@ class VerificationReporter { VerificationReporter(); virtual ~VerificationReporter(); - void sendSuccessReport(uint8_t set_report_id, PusTcReader* current_packet, uint8_t set_step = 0); + void sendSuccessReport(uint8_t set_report_id, PusTcReader* correspondingTc, uint8_t set_step = 0); void sendSuccessReport(uint8_t set_report_id, uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl, uint8_t set_step = 0); - void sendFailureReport(uint8_t report_id, PusTcReader* current_packet, + void sendFailureReport(uint8_t report_id, PusTcReader* correspondingTc, ReturnValue_t error_code = 0, uint8_t step = 0, uint32_t parameter1 = 0, uint32_t parameter2 = 0); void sendFailureReport(uint8_t report_id, uint8_t ackFlags, uint16_t tcPacketId, diff --git a/src/fsfw/tmtcservices/sendAndStoreHelper.h b/src/fsfw/tmtcservices/sendAndStoreHelper.h new file mode 100644 index 00000000..d07456f6 --- /dev/null +++ b/src/fsfw/tmtcservices/sendAndStoreHelper.h @@ -0,0 +1,54 @@ +#ifndef FSFW_TMTCSERVICES_SENDANDSTOREHELPER_H +#define FSFW_TMTCSERVICES_SENDANDSTOREHELPER_H + +#include "TmSendHelper.h" +#include "TmStoreHelper.h" + +namespace tm { + +ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper) { + storeHelper.addPacketToStore(); + ReturnValue_t result = sendHelper.sendPacket(storeHelper.getCurrentAddr()); + if (result != HasReturnvaluesIF::RETURN_OK) { + storeHelper.deletePacket(); + } + return result; +} + +class SourceDataWithObjectIdPrefix : public SerializeIF { + public: + SourceDataWithObjectIdPrefix(object_id_t objectId, const uint8_t* srcData, size_t srcDataLen) + : objectId(objectId), srcData(srcData), srcDataLen(srcDataLen) {} + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const override { + if (*size + getSerializedSize() > maxSize) { + return SerializeIF::BUFFER_TOO_SHORT; + } + ReturnValue_t result = + SerializeAdapter::serialize(&objectId, buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + std::memcpy(*buffer, srcData, srcDataLen); + *buffer += srcDataLen; + *size += srcDataLen; + return HasReturnvaluesIF::RETURN_OK; + } + + [[nodiscard]] size_t getSerializedSize() const override { return sizeof(objectId) + srcDataLen; } + + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override { + // TODO: Implement + return HasReturnvaluesIF::RETURN_FAILED; + } + + private: + object_id_t objectId; + const uint8_t* srcData; + size_t srcDataLen; +}; + +} // namespace tm + +#endif // FSFW_TMTCSERVICES_SENDANDSTOREHELPER_H diff --git a/unittests/CatchFactory.cpp b/unittests/CatchFactory.cpp index 860a9bed..25ced1ba 100644 --- a/unittests/CatchFactory.cpp +++ b/unittests/CatchFactory.cpp @@ -70,8 +70,6 @@ void Factory::setStaticFrameworkObjectIds() { LocalDataPoolManager::defaultHkDestination = objects::HK_RECEIVER_MOCK; DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT; - - TmPacketBase::timeStamperId = objects::NO_OBJECT; } #endif From d8b6cb39acfe7601338de02ee3ec37387991ef31 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 21 Jul 2022 11:34:11 +0200 Subject: [PATCH 060/532] various bugfixes and improvements --- src/fsfw/ipc/MessageQueueSenderIF.h | 9 +- src/fsfw/pus/Service5EventReporting.cpp | 1 + src/fsfw/pus/Service9TimeManagement.cpp | 4 +- src/fsfw/returnvalues/FwClassIds.h | 3 +- src/fsfw/tcdistribution/PusPacketChecker.h | 2 +- src/fsfw/timemanager/CCSDSTime.cpp | 2 +- src/fsfw/timemanager/CMakeLists.txt | 5 +- src/fsfw/timemanager/CcsdsTimeStampReader.cpp | 14 +++ src/fsfw/timemanager/CcsdsTimeStampReader.h | 19 ++++ ...imeStamper.cpp => CdsShortTimeStamper.cpp} | 6 +- src/fsfw/timemanager/CdsShortTimeStamper.h | 6 +- src/fsfw/timemanager/TimeReaderIF.h | 19 ++++ src/fsfw/timemanager/TimeStamperIF.h | 1 + .../tmtcpacket/ccsds/SpacePacketReader.cpp | 27 +++--- src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h | 51 ++++++++--- src/fsfw/tmtcpacket/pus/CreatorDataIF.h | 2 +- src/fsfw/tmtcpacket/pus/PusIF.h | 5 ++ src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h | 3 +- .../tmtcpacket/pus/{definitions.h => defs.h} | 14 +++ src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 10 ++- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 4 +- src/fsfw/tmtcpacket/pus/tc/PusTcIF.h | 6 +- src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp | 35 ++++---- src/fsfw/tmtcpacket/pus/tc/PusTcReader.h | 33 +++---- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 20 ++--- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmIF.h | 5 +- src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp | 6 +- src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h | 4 +- src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp | 86 ++++++++++++++++++- src/fsfw/tmtcpacket/pus/tm/PusTmReader.h | 42 ++++++++- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp | 2 +- .../tmtcservices/CommandingServiceBase.cpp | 36 +++++--- src/fsfw/tmtcservices/PusServiceBase.cpp | 62 +++++++------ 35 files changed, 401 insertions(+), 147 deletions(-) create mode 100644 src/fsfw/timemanager/CcsdsTimeStampReader.cpp create mode 100644 src/fsfw/timemanager/CcsdsTimeStampReader.h rename src/fsfw/timemanager/{TimeStamper.cpp => CdsShortTimeStamper.cpp} (99%) create mode 100644 src/fsfw/timemanager/TimeReaderIF.h rename src/fsfw/tmtcpacket/pus/{definitions.h => defs.h} (74%) diff --git a/src/fsfw/ipc/MessageQueueSenderIF.h b/src/fsfw/ipc/MessageQueueSenderIF.h index a98862f6..83c7223a 100644 --- a/src/fsfw/ipc/MessageQueueSenderIF.h +++ b/src/fsfw/ipc/MessageQueueSenderIF.h @@ -1,14 +1,14 @@ #ifndef FSFW_IPC_MESSAGEQUEUESENDERIF_H_ #define FSFW_IPC_MESSAGEQUEUESENDERIF_H_ -#include "../objectmanager/ObjectManagerIF.h" #include "MessageQueueIF.h" #include "MessageQueueMessageIF.h" +#include "fsfw/objectmanager/ObjectManagerIF.h" class MessageQueueSenderIF { public: - virtual ~MessageQueueSenderIF() {} - + virtual ~MessageQueueSenderIF() = default; + MessageQueueSenderIF() = delete; /** * Allows sending messages without actually "owning" a message queue. * Not sure whether this is actually a good idea. @@ -16,9 +16,6 @@ class MessageQueueSenderIF { static ReturnValue_t sendMessage(MessageQueueId_t sendTo, MessageQueueMessageIF* message, MessageQueueId_t sentFrom = MessageQueueIF::NO_QUEUE, bool ignoreFault = false); - - private: - MessageQueueSenderIF() {} }; #endif /* FSFW_IPC_MESSAGEQUEUESENDERIF_H_ */ diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index 4d0dcf1d..d88e58b8 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -99,4 +99,5 @@ ReturnValue_t Service5EventReporting::initialize() { return result; } initializeTmHelpers(sendHelper, storeHelper); + return result; } diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 99b447c1..4abbd5d2 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -25,9 +25,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { ReturnValue_t Service9TimeManagement::setTime() { Clock::TimeOfDay_t timeToSet; - size_t userDataLen = 0; - const uint8_t* timeData = currentPacket.getUserData(userDataLen); - TimePacket timePacket(timeData, userDataLen); + TimePacket timePacket(currentPacket.getUserData(), currentPacket.getUserDataLen()); ReturnValue_t result = CCSDSTime::convertFromCcsds(&timeToSet, timePacket.getTime(), timePacket.getTimeSize()); if (result != RETURN_OK) { diff --git a/src/fsfw/returnvalues/FwClassIds.h b/src/fsfw/returnvalues/FwClassIds.h index 50efd9c5..1dfe1cc8 100644 --- a/src/fsfw/returnvalues/FwClassIds.h +++ b/src/fsfw/returnvalues/FwClassIds.h @@ -36,7 +36,8 @@ enum : uint8_t { TRIPLE_REDUNDACY_CHECK, // TRC PACKET_CHECK, // TCC PACKET_DISTRIBUTION, // TCD - ACCEPTS_TELECOMMANDS_IF, // PUS + ACCEPTS_TELECOMMANDS_IF, // ATC + PUS_IF, // PUS DEVICE_SERVICE_BASE, // DSB COMMAND_SERVICE_BASE, // CSB TM_STORE_BACKEND_IF, // TMB diff --git a/src/fsfw/tcdistribution/PusPacketChecker.h b/src/fsfw/tcdistribution/PusPacketChecker.h index fe341378..431ee5a8 100644 --- a/src/fsfw/tcdistribution/PusPacketChecker.h +++ b/src/fsfw/tcdistribution/PusPacketChecker.h @@ -5,7 +5,7 @@ #include "CcsdsPacketCheckerBase.h" #include "fsfw/FSFW.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/tmtcpacket/pus/definitions.h" +#include "fsfw/tmtcpacket/pus/defs.h" #include "fsfw/tmtcservices/PusVerificationReport.h" class PacketCheckIF : public ReadablePacketIF, public PusIF {}; diff --git a/src/fsfw/timemanager/CCSDSTime.cpp b/src/fsfw/timemanager/CCSDSTime.cpp index 1f84dd03..4d5de9b3 100644 --- a/src/fsfw/timemanager/CCSDSTime.cpp +++ b/src/fsfw/timemanager/CCSDSTime.cpp @@ -504,7 +504,7 @@ ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from, size_t } else if ((pField & 0b11) == 0b10) { expectedLength += 4; } - if (foundLength != NULL) { + if (foundLength != nullptr) { *foundLength = expectedLength; } if (expectedLength > maxLength) { diff --git a/src/fsfw/timemanager/CMakeLists.txt b/src/fsfw/timemanager/CMakeLists.txt index c4f77395..7e38cc6a 100644 --- a/src/fsfw/timemanager/CMakeLists.txt +++ b/src/fsfw/timemanager/CMakeLists.txt @@ -1,3 +1,4 @@ target_sources( - ${LIB_FSFW_NAME} PRIVATE CCSDSTime.cpp Countdown.cpp Stopwatch.cpp - TimeMessage.cpp TimeStamper.cpp ClockCommon.cpp) + ${LIB_FSFW_NAME} + PRIVATE CCSDSTime.cpp Countdown.cpp Stopwatch.cpp TimeMessage.cpp + CdsShortTimeStamper.cpp ClockCommon.cpp) diff --git a/src/fsfw/timemanager/CcsdsTimeStampReader.cpp b/src/fsfw/timemanager/CcsdsTimeStampReader.cpp new file mode 100644 index 00000000..d23d0387 --- /dev/null +++ b/src/fsfw/timemanager/CcsdsTimeStampReader.cpp @@ -0,0 +1,14 @@ +#include "CcsdsTimeStampReader.h" + +#include "CCSDSTime.h" + +ReturnValue_t CcsdsTimestampReader::readTimeStamp(const uint8_t* buffer, uint8_t maxSize) { + ReturnValue_t result = CCSDSTime::convertFromCcsds(&time, buffer, ×tampLen, maxSize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return result; +} + +timeval& CcsdsTimestampReader::getTime() { return time; } +size_t CcsdsTimestampReader::getTimestampLen() { return timestampLen; } diff --git a/src/fsfw/timemanager/CcsdsTimeStampReader.h b/src/fsfw/timemanager/CcsdsTimeStampReader.h new file mode 100644 index 00000000..f323c87e --- /dev/null +++ b/src/fsfw/timemanager/CcsdsTimeStampReader.h @@ -0,0 +1,19 @@ +#ifndef FSFW_TIMEMANAGER_CCSDSTIMESTAMPREADER_H +#define FSFW_TIMEMANAGER_CCSDSTIMESTAMPREADER_H + +#include + +#include "TimeReaderIF.h" + +class CcsdsTimestampReader : public TimeReaderIF { + public: + ReturnValue_t readTimeStamp(const uint8_t* buffer, uint8_t maxSize) override; + size_t getTimestampLen() override; + timeval& getTime() override; + + private: + timeval time{}; + size_t timestampLen = 0; +}; + +#endif // FSFW_TIMEMANAGER_CCSDSTIMESTAMPREADER_H diff --git a/src/fsfw/timemanager/TimeStamper.cpp b/src/fsfw/timemanager/CdsShortTimeStamper.cpp similarity index 99% rename from src/fsfw/timemanager/TimeStamper.cpp rename to src/fsfw/timemanager/CdsShortTimeStamper.cpp index 7096d95f..af0344e3 100644 --- a/src/fsfw/timemanager/TimeStamper.cpp +++ b/src/fsfw/timemanager/CdsShortTimeStamper.cpp @@ -1,6 +1,7 @@ +#include "fsfw/timemanager/CdsShortTimeStamper.h" + #include -#include "fsfw/timemanager/CdsShortTimeStamper.h" #include "fsfw/timemanager/Clock.h" CdsShortTimeStamper::CdsShortTimeStamper(object_id_t objectId) : SystemObject(objectId) {} @@ -27,9 +28,12 @@ ReturnValue_t CdsShortTimeStamper::serialize(uint8_t **buffer, size_t *size, siz *size += getSerializedSize(); return result; } + size_t CdsShortTimeStamper::getSerializedSize() const { return getTimestampSize(); } + ReturnValue_t CdsShortTimeStamper::deSerialize(const uint8_t **buffer, size_t *size, SerializeIF::Endianness streamEndianness) { return HasReturnvaluesIF::RETURN_FAILED; } + size_t CdsShortTimeStamper::getTimestampSize() const { return TIMESTAMP_LEN; } diff --git a/src/fsfw/timemanager/CdsShortTimeStamper.h b/src/fsfw/timemanager/CdsShortTimeStamper.h index 1e9abfa8..d392c1a6 100644 --- a/src/fsfw/timemanager/CdsShortTimeStamper.h +++ b/src/fsfw/timemanager/CdsShortTimeStamper.h @@ -1,9 +1,9 @@ #ifndef FSFW_TIMEMANAGER_TIMESTAMPER_H_ #define FSFW_TIMEMANAGER_TIMESTAMPER_H_ -#include "../objectmanager/SystemObject.h" #include "CCSDSTime.h" #include "TimeStamperIF.h" +#include "fsfw/objectmanager/SystemObject.h" /** * @brief Time stamper which can be used to add any timestamp to a @@ -34,10 +34,10 @@ class CdsShortTimeStamper : public TimeStamperIF, public SystemObject { ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override; ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; - size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; - size_t getTimestampSize() const override; + [[nodiscard]] size_t getTimestampSize() const override; }; #endif /* FSFW_TIMEMANAGER_TIMESTAMPER_H_ */ diff --git a/src/fsfw/timemanager/TimeReaderIF.h b/src/fsfw/timemanager/TimeReaderIF.h new file mode 100644 index 00000000..388f7d71 --- /dev/null +++ b/src/fsfw/timemanager/TimeReaderIF.h @@ -0,0 +1,19 @@ +#ifndef FSFW_TIMEMANAGER_TIMEREADERIF_H +#define FSFW_TIMEMANAGER_TIMEREADERIF_H + +#include + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +class TimeReaderIF { + public: + virtual ~TimeReaderIF() = default; + virtual ReturnValue_t readTimeStamp(const uint8_t* buffer, uint8_t maxSize) = 0; + // Would be nice to have this, but the clock backend needs to be redesigned + // virtual ReturnValue_t readTimestampLen(const uint8_t* buffer, uint8_t maxSize, size_t& + // timestampLen) = 0; + virtual size_t getTimestampLen() = 0; + virtual timeval& getTime() = 0; +}; + +#endif // FSFW_TIMEMANAGER_TIMEREADERIF_H diff --git a/src/fsfw/timemanager/TimeStamperIF.h b/src/fsfw/timemanager/TimeStamperIF.h index 404dd10a..2f0e8021 100644 --- a/src/fsfw/timemanager/TimeStamperIF.h +++ b/src/fsfw/timemanager/TimeStamperIF.h @@ -24,6 +24,7 @@ class TimeStamperIF : public SerializeIF { [[nodiscard]] virtual size_t getTimestampSize() const = 0; virtual ReturnValue_t addTimeStamp(uint8_t* buffer, uint8_t maxSize) = 0; + ~TimeStamperIF() override = default; }; diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp index a0ad5328..c528d0a7 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp @@ -1,7 +1,5 @@ #include "SpacePacketReader.h" -#include - #include "fsfw/serialize/SerializeIF.h" #include "fsfw/serviceinterface/ServiceInterface.h" @@ -9,8 +7,8 @@ SpacePacketReader::SpacePacketReader(const uint8_t* setAddress, size_t maxSize_) setInternalFields(setAddress, maxSize_); } -ReturnValue_t SpacePacketReader::checkLength() const { - if (getFullPacketLen() > maxSize) { +ReturnValue_t SpacePacketReader::checkSize() const { + if (getFullPacketLen() > bufSize) { return SerializeIF::STREAM_TOO_SHORT; } return HasReturnvaluesIF::RETURN_OK; @@ -22,9 +20,8 @@ inline uint16_t SpacePacketReader::getPacketIdRaw() const { return ccsds::getPac const uint8_t* SpacePacketReader::getPacketData() { return packetDataField; } -ReturnValue_t SpacePacketReader::setData(uint8_t* pData, size_t maxSize_, void* args) { - setInternalFields(pData, maxSize_); - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t SpacePacketReader::setData(uint8_t* data, size_t maxSize_, void* args) { + return setInternalFields(data, maxSize_); } uint16_t SpacePacketReader::getPacketSeqCtrlRaw() const { @@ -32,11 +29,21 @@ uint16_t SpacePacketReader::getPacketSeqCtrlRaw() const { } uint16_t SpacePacketReader::getPacketDataLen() const { return ccsds::getPacketLen(*spHeader); } -void SpacePacketReader::setInternalFields(const uint8_t* data, size_t maxSize_) { - maxSize = maxSize_; + +ReturnValue_t SpacePacketReader::setInternalFields(const uint8_t* data, size_t maxSize_) { + bufSize = maxSize_; spHeader = reinterpret_cast(data); packetDataField = data + ccsds::HEADER_LEN; + return checkSize(); } + const uint8_t* SpacePacketReader::getFullData() { return reinterpret_cast(spHeader); -}; +} +size_t SpacePacketReader::getBufSize() const { return bufSize; } + +bool SpacePacketReader::isNull() const { return spHeader == nullptr; } + +ReturnValue_t SpacePacketReader::setReadOnlyData(const uint8_t* data, size_t maxSize) { + return setData(const_cast(data), maxSize, nullptr); +} diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h index 43119146..b35b813b 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h @@ -22,17 +22,21 @@ * This class is the basic data handler for any CCSDS Space Packet * compatible Telecommand and Telemetry packet. * It does not contain the packet data itself but a pointer to the - * data must be set on instantiation. An invalid pointer may cause - * damage, as no getter method checks data validity. Anyway, a NULL - * check can be performed by making use of the getWholeData method. - * Remark: All bit numbers in this documentation are counted from - * the most significant bit (from left). + * data must be set on instantiation or with the @setData or @setReadOnlyData call. + * The @isNull and @checkSize methods can be used to check the validity of the data pointed to. + * + * This is a zero-copy reader class. It does not contain the packet data itself but a pointer to + * the data. Calling any accessor methods without pointing the object to valid data first will + * cause undefined behaviour. * @ingroup tmtcpackets */ class SpacePacketReader : public SpacePacketIF, public ReadablePacketIF, public RedirectableDataPointerIF { public: + /** + * Initialize an empty space packet reader which points to no data + */ SpacePacketReader() = default; /** * This is the default constructor. @@ -45,6 +49,24 @@ class SpacePacketReader : public SpacePacketIF, */ ~SpacePacketReader() override; + /** + * Check whether any data is set for the reader object + * @return + */ + [[nodiscard]] bool isNull() const; + /** + * Get size of the buffer. This is the size which is passed to the constructor or to the + * @setData call. It is not the content of the CCSDS data length field and it is not necessarily + * equal to the full packet length of the space packet. + * @return + */ + [[nodiscard]] size_t getBufSize() const; + + /** + * CCSDS header always has 6 bytes + * @return + */ + static constexpr size_t getHeaderLen() { return ccsds::HEADER_LEN; } [[nodiscard]] uint16_t getPacketIdRaw() const override; [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; @@ -52,16 +74,11 @@ class SpacePacketReader : public SpacePacketIF, const uint8_t* getFullData() override; // Helper methods: - [[nodiscard]] ReturnValue_t checkLength() const; + [[nodiscard]] ReturnValue_t checkSize() const; const uint8_t* getPacketData(); - /** - * With this method, the packet data pointer can be redirected to another - * location. - * @param p_Data A pointer to another raw Space Packet. - */ - ReturnValue_t setData(uint8_t* p_Data, size_t maxSize, void* args) override; + ReturnValue_t setReadOnlyData(const uint8_t* data, size_t maxSize); protected: /** @@ -71,9 +88,15 @@ class SpacePacketReader : public SpacePacketIF, */ const ccsds::PrimaryHeader* spHeader{}; const uint8_t* packetDataField{}; - size_t maxSize = 0; + size_t bufSize = 0; + /** + * With this method, the packet data pointer can be redirected to another + * location. + * @param data A pointer to another raw Space Packet. + */ + ReturnValue_t setData(uint8_t* data, size_t maxSize, void* args) override; - void setInternalFields(const uint8_t* data, size_t maxSize); + ReturnValue_t setInternalFields(const uint8_t* data, size_t maxSize); }; #endif /* FSFW_TMTCPACKET_SPACEPACKETBASE_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/CreatorDataIF.h b/src/fsfw/tmtcpacket/pus/CreatorDataIF.h index 7d5d1d18..f66ca567 100644 --- a/src/fsfw/tmtcpacket/pus/CreatorDataIF.h +++ b/src/fsfw/tmtcpacket/pus/CreatorDataIF.h @@ -1,7 +1,7 @@ #ifndef FSFW_TMTCPACKET_CREATORDATAIF_H #define FSFW_TMTCPACKET_CREATORDATAIF_H -#include "definitions.h" +#include "defs.h" class CreatorDataIF { public: diff --git a/src/fsfw/tmtcpacket/pus/PusIF.h b/src/fsfw/tmtcpacket/pus/PusIF.h index eb0e35f8..8a15f01e 100644 --- a/src/fsfw/tmtcpacket/pus/PusIF.h +++ b/src/fsfw/tmtcpacket/pus/PusIF.h @@ -3,10 +3,15 @@ #include +#include "fsfw/returnvalues/FwClassIds.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" class PusIF : public SpacePacketIF { public: + static constexpr uint8_t INTERFACE_ID = CLASS_ID::PUS_IF; + static constexpr ReturnValue_t INVALID_CRC_16 = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); + ~PusIF() override = default; /** * This command returns the TC Packet PUS Version Number. diff --git a/src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h b/src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h index 170ac824..e4e515f8 100644 --- a/src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h +++ b/src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h @@ -6,7 +6,8 @@ class RawUserDataReaderIF { public: - virtual const uint8_t* getUserData(size_t& userDataLen) = 0; + virtual const uint8_t* getUserData() const = 0; + virtual size_t getUserDataLen() const = 0; }; #endif // FSFW_TMTCPACKET_RAWDATAIF_H diff --git a/src/fsfw/tmtcpacket/pus/definitions.h b/src/fsfw/tmtcpacket/pus/defs.h similarity index 74% rename from src/fsfw/tmtcpacket/pus/definitions.h rename to src/fsfw/tmtcpacket/pus/defs.h index 6a5c10eb..027ff37c 100644 --- a/src/fsfw/tmtcpacket/pus/definitions.h +++ b/src/fsfw/tmtcpacket/pus/defs.h @@ -7,6 +7,8 @@ namespace ecss { +using PusChecksumT = uint16_t; + //! Version numbers according to ECSS-E-ST-70-41C p.439 enum PusVersion : uint8_t { PUS_A = 1, PUS_C = 2 }; @@ -36,6 +38,18 @@ struct DataWrapper { } }; +/** + * This struct defines the data structure of a Space Packet when accessed + * via a pointer. + * @ingroup tmtcpackets + */ +struct PusPointers { + const uint8_t* spHeaderStart; + const uint8_t* secHeaderStart; + const uint8_t* userDataStart; + const uint8_t* crcStart; +}; + } // namespace ecss #endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TM_DEFINITIONS_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 8f8cc8e6..bd824d24 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -14,7 +14,7 @@ PusTcCreator::PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams) ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { size_t userDataLen = pusParams.dataWrapper.getLength(); - if (*size + PusTcIF::MIN_LEN + userDataLen > maxSize) { + if (*size + PusTcIF::MIN_SIZE + userDataLen > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } ReturnValue_t result = spCreator.serialize(buffer, size, maxSize, streamEndianness); @@ -57,7 +57,8 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max } void PusTcCreator::updateSpLengthField() { - spCreator.setDataLen(ecss::PusTcDataFieldHeader::MIN_LEN + pusParams.dataWrapper.getLength() + 1); + spCreator.setDataLen(ecss::PusTcDataFieldHeader::MIN_SIZE + pusParams.dataWrapper.getLength() + + 1); } size_t PusTcCreator::getSerializedSize() const { return spCreator.getFullPacketLen(); } @@ -82,4 +83,9 @@ uint8_t PusTcCreator::getService() const { return pusParams.service; } uint8_t PusTcCreator::getSubService() const { return pusParams.subservice; } uint16_t PusTcCreator::getSourceId() const { return pusParams.sourceId; } + ecss::DataWrapper &PusTcCreator::getDataWrapper() { return pusParams.dataWrapper; } + +PusTcParams &PusTcCreator::getPusParams() { return pusParams; } + +SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 956a2505..1f6e8acb 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -5,7 +5,7 @@ #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" #include "fsfw/tmtcpacket/pus/CreatorDataIF.h" -#include "fsfw/tmtcpacket/pus/definitions.h" +#include "fsfw/tmtcpacket/pus/defs.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" struct PusTcParams { @@ -24,6 +24,8 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CreatorDataIF { PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams); void updateSpLengthField(); + PusTcParams &getPusParams(); + SpacePacketParams &getSpParams(); ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h index 61b29660..43e9aab0 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h @@ -31,7 +31,7 @@ static constexpr uint8_t ACK_ALL = ACK_ACCEPTANCE | ACK_START | ACK_STEP | ACK_C */ struct PusTcDataFieldHeader { // Version and ACK byte, Service Byte, Subservice Byte, 2 byte Source ID - static constexpr size_t MIN_LEN = 5; + static constexpr size_t MIN_SIZE = 5; uint8_t pusVersion; uint8_t ackFlags; uint8_t serviceType; @@ -44,8 +44,8 @@ struct PusTcDataFieldHeader { class PusTcIF : public PusIF { public: ~PusTcIF() override = default; - static const size_t MIN_LEN = - (sizeof(ccsds::PrimaryHeader) + ecss::PusTcDataFieldHeader::MIN_LEN + 2); + static const size_t MIN_SIZE = + (sizeof(ccsds::PrimaryHeader) + ecss::PusTcDataFieldHeader::MIN_SIZE + 2); /** * This is a getter for the packet's Ack field, which are the lowest four diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp index bf4ec181..b9e5e00f 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp @@ -12,20 +12,30 @@ PusTcReader::PusTcReader(const uint8_t* data, size_t size) { setReadOnlyData(dat PusTcReader::~PusTcReader() = default; ReturnValue_t PusTcReader::parseData() { - ReturnValue_t result = spReader.checkLength(); + if (pointers.spHeaderStart == nullptr or spReader.isNull()) { + return HasReturnvaluesIF::RETURN_FAILED; + } + ReturnValue_t result = spReader.checkSize(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - if (size < PusTcIF::MIN_LEN) { + if (spReader.getBufSize() < PusTcIF::MIN_SIZE) { return SerializeIF::STREAM_TOO_SHORT; } + + size_t currentOffset = SpacePacketReader::getHeaderLen(); + pointers.secHeaderStart = pointers.spHeaderStart + currentOffset; // Might become variable sized field in the future - size_t secHeaderLen = ecss::PusTcDataFieldHeader::MIN_LEN; - pointers.secHeaderStart = pointers.spHeaderStart + ccsds::HEADER_LEN; // TODO: No support for spare bytes yet - pointers.userDataStart = pointers.secHeaderStart + secHeaderLen; - appDataSize = size - (ccsds::HEADER_LEN + secHeaderLen); + currentOffset += ecss::PusTcDataFieldHeader::MIN_SIZE; + pointers.userDataStart = pointers.spHeaderStart + currentOffset; + appDataSize = spReader.getFullPacketLen() - currentOffset - sizeof(ecss::PusChecksumT); pointers.crcStart = pointers.userDataStart + appDataSize; + uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen()); + if (crc16 != 0) { + // Checksum failure + return PusIF::INVALID_CRC_16; + } return HasReturnvaluesIF::RETURN_OK; } @@ -51,21 +61,16 @@ uint8_t PusTcReader::getPusVersion() const { return spReader.getVersion(); } const uint8_t* PusTcReader::getFullData() { return pointers.spHeaderStart; } ReturnValue_t PusTcReader::setData(uint8_t* pData, size_t size_, void* args) { - size = size_; pointers.spHeaderStart = pData; - spReader.setData(pData, size_, args); - return HasReturnvaluesIF::RETURN_OK; + return spReader.setReadOnlyData(pData, size_); } ReturnValue_t PusTcReader::setReadOnlyData(const uint8_t* data, size_t size_) { - setData(const_cast(data), size_, nullptr); - return HasReturnvaluesIF::RETURN_OK; + return setData(const_cast(data), size_, nullptr); } -const uint8_t* PusTcReader::getUserData(size_t& userDataLen) { - userDataLen = appDataSize; - return pointers.userDataStart; -} +const uint8_t* PusTcReader::getUserData() const { return pointers.userDataStart; } +size_t PusTcReader::getUserDataLen() const { return appDataSize; } /* void PusTcReader::print() { diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h index 0cf18496..e79f8b61 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h @@ -7,16 +7,17 @@ #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" #include "fsfw/tmtcpacket/pus/RawUserDataReaderIF.h" +#include "fsfw/tmtcpacket/pus/defs.h" /** - * This class is the basic data handler for any ECSS PUS Telecommand packet. + * This class is the basic reader class to read ECSS PUS C Telecommand packets. * - * In addition to #SpacePacketBase, the class provides methods to handle - * the standardized entries of the PUS TC Packet Data Field Header. - * It does not contain the packet data itself but a pointer to the - * data must be set on instantiation. An invalid pointer may cause - * damage, as no getter method checks data validity. Anyway, a NULL - * check can be performed by making use of the getWholeData method. + * 1. Implements the @SpacePacketIF to provide accessor methods for the contained space packet. + * 2. Implements the @PusTcIF to provide accessor methods for generic PUS C fields + * + * This is a zero-copy reader class. It does not contain the packet data itself but a pointer to + * the data. Calling any accessor methods without pointing the object to valid data first will + * cause undefined behaviour. * @ingroup tmtcpackets */ class PusTcReader : public PusTcIF, @@ -56,7 +57,8 @@ class PusTcReader : public PusTcIF, const uint8_t* getFullData() override; ReturnValue_t setReadOnlyData(const uint8_t* data, size_t size); - const uint8_t* getUserData(size_t& userDataLen) override; + [[nodiscard]] const uint8_t* getUserData() const override; + size_t getUserDataLen() const override; protected: /** @@ -70,20 +72,7 @@ class PusTcReader : public PusTcIF, ReturnValue_t setData(uint8_t* pData, size_t size, void* args) override; SpacePacketReader spReader; - /** - * This struct defines the data structure of a Space Packet when accessed - * via a pointer. - * @ingroup tmtcpackets - */ - struct PusTcPointers { - const uint8_t* spHeaderStart; - const uint8_t* secHeaderStart; - const uint8_t* userDataStart; - const uint8_t* crcStart; - }; - - PusTcPointers pointers{}; - size_t size = 0; + ecss::PusPointers pointers{}; size_t appDataSize = 0; }; diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h index fe976673..8af6125a 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h @@ -3,7 +3,7 @@ #include -#include "../definitions.h" +#include "../defs.h" #include "PusTcReader.h" #include "fsfw/FSFW.h" #include "fsfw/tmtcpacket/ccsds/defs.h" diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index e80eddd1..927ec072 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -7,20 +7,20 @@ PusTmCreator::PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams, TimeStamperIF* timeStamper) - : pusParams(initPusParams), spCreator(std::move(initSpParams)){}; + : pusParams(initPusParams), spCreator(std::move(initSpParams)) {} PusTmCreator::PusTmCreator(TimeStamperIF* timeStamper_) { pusParams.secHeader.timeStamper = timeStamper_; -}; +} PusTmCreator::PusTmCreator() = default; -uint16_t PusTmCreator::getPacketIdRaw() const { return 0; } -uint16_t PusTmCreator::getPacketSeqCtrlRaw() const { return 0; } -uint16_t PusTmCreator::getPacketDataLen() const { return 0; } -uint8_t PusTmCreator::getPusVersion() const { return 0; } -uint8_t PusTmCreator::getService() const { return 0; } -uint8_t PusTmCreator::getSubService() const { return 0; } +uint16_t PusTmCreator::getPacketIdRaw() const { return spCreator.getPacketIdRaw(); } +uint16_t PusTmCreator::getPacketSeqCtrlRaw() const { return spCreator.getPacketSeqCtrlRaw(); } +uint16_t PusTmCreator::getPacketDataLen() const { return spCreator.getPacketDataLen(); } +uint8_t PusTmCreator::getPusVersion() const { return pusParams.secHeader.pusVersion; } +uint8_t PusTmCreator::getService() const { return pusParams.secHeader.service; } +uint8_t PusTmCreator::getSubService() const { return pusParams.secHeader.subservice; } PusTmParams& PusTmCreator::getParams() { return pusParams; } void PusTmCreator::setTimeStamper(TimeStamperIF* timeStamper_) { pusParams.secHeader.timeStamper = timeStamper_; @@ -89,11 +89,11 @@ TimeStamperIF* PusTmCreator::getTimestamper() { return pusParams.secHeader.timeS SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } void PusTmCreator::updateSpLengthField() { - size_t headerLen = PusTmIF::MIN_TM_SIZE; + size_t headerLen = PusTmIF::MIN_SIZE; if (pusParams.secHeader.timeStamper != nullptr) { headerLen += pusParams.secHeader.timeStamper->getSerializedSize(); } spCreator.setDataLen(headerLen + pusParams.dataWrapper.getLength() + 1); } -void PusTmCreator::setApid(uint16_t apid) { spCreator.setApid(apid); }; +void PusTmCreator::setApid(uint16_t apid) { spCreator.setApid(apid); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 5269bd0f..9ac79d16 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -50,7 +50,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CreatorDataIF { [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override; - TimeStamperIF* getTimestamper() override; + TimeStamperIF* getTimestamper(); private: ecss::DataWrapper& getDataWrapper() override; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h b/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h index 94d41467..356cf20b 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h @@ -6,7 +6,7 @@ #include "fsfw/timemanager/TimeStamperIF.h" #include "fsfw/tmtcpacket/pus/PusIF.h" -#include "fsfw/tmtcpacket/pus/definitions.h" +#include "fsfw/tmtcpacket/pus/defs.h" class PusTmIF : public PusIF { public: @@ -19,12 +19,11 @@ class PusTmIF : public PusIF { /** * 2 bytes for CRC16 */ - static constexpr size_t MIN_TM_SIZE = sizeof(ccsds::PrimaryHeader) + MIN_SEC_HEADER_LEN + 2; + static constexpr size_t MIN_SIZE = sizeof(ccsds::PrimaryHeader) + MIN_SEC_HEADER_LEN + 2; virtual uint8_t getScTimeRefStatus() = 0; virtual uint16_t getMessageTypeCounter() = 0; virtual uint16_t getDestId() = 0; - virtual TimeStamperIF* getTimestamper() = 0; }; #endif // FSFW_TMTCPACKET_PUSTMIF_H diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp index f36cfc2a..a389551c 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp @@ -42,8 +42,8 @@ uint16_t PusTmMinimal::getDestId() { return 0; } void PusTmMinimal::setApid(uint16_t apid) { /* TODO: Implement. Maybe provide low level function to do this */ } -const uint8_t* PusTmMinimal::getUserData(size_t& userDataLen_) { - userDataLen_ = userDataLen; +size_t PusTmMinimal::getUserDataLen() const { return userDataLen; } + +const uint8_t* PusTmMinimal::getUserData() const { return reinterpret_cast(&tmData->rest); } -TimeStamperIF* PusTmMinimal::getTimestamper() { return nullptr; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h index 06ed4aff..7bfae4f2 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h @@ -73,8 +73,8 @@ class PusTmMinimal : public PusTmIF, public RawUserDataReaderIF, public Redirect uint8_t getScTimeRefStatus() override; uint16_t getMessageTypeCounter() override; uint16_t getDestId() override; - const uint8_t* getUserData(size_t& userDataLen) override; - TimeStamperIF* getTimestamper() override; + const uint8_t* getUserData() const override; + size_t getUserDataLen() const override; protected: /** diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp index d010512a..cb30de05 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp @@ -1,3 +1,83 @@ -// -// Created by rmueller on 7/19/22. -// +#include "PusTmReader.h" + +#include "fsfw/globalfunctions/CRC.h" + +PusTmReader::PusTmReader(TimeReaderIF *timeReader) : timeReader(timeReader) {} + +PusTmReader::PusTmReader(const uint8_t *data, size_t size) { setReadOnlyData(data, size); } + +PusTmReader::PusTmReader(TimeReaderIF *timeReader, const uint8_t *data, size_t size) + : PusTmReader(timeReader) { + setReadOnlyData(data, size); +} + +ReturnValue_t PusTmReader::parseData() { + // Time reader is required to read the time stamp length at run-time + if (pointers.spHeaderStart == nullptr or spReader.isNull() or timeReader == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + ReturnValue_t result = spReader.checkSize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (spReader.getBufSize() < PusTmIF::MIN_SIZE) { + return SerializeIF::STREAM_TOO_SHORT; + } + + size_t currentOffset = SpacePacketReader::getHeaderLen(); + pointers.secHeaderStart = pointers.spHeaderStart + currentOffset; + currentOffset += PusTmIF::MIN_SEC_HEADER_LEN; + size_t minTimestampLen = spReader.getBufSize() - currentOffset; + result = timeReader->readTimeStamp(pointers.secHeaderStart + PusTmIF::MIN_SEC_HEADER_LEN, + minTimestampLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + size_t timestampLen = timeReader->getTimestampLen(); + if (currentOffset + timestampLen > spReader.getBufSize()) { + return SerializeIF::STREAM_TOO_SHORT; + } + currentOffset += timestampLen; + pointers.userDataStart = pointers.spHeaderStart + currentOffset; + sourceDataLen = spReader.getFullPacketLen() - currentOffset - sizeof(ecss::PusChecksumT); + currentOffset += sourceDataLen; + pointers.crcStart = pointers.spHeaderStart + currentOffset; + uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen()); + if (crc16 != 0) { + // Checksum failure + return PusIF::INVALID_CRC_16; + } + return HasReturnvaluesIF::RETURN_OK; +} +const uint8_t *PusTmReader::getFullData() { return spReader.getFullData(); } + +ReturnValue_t PusTmReader::setReadOnlyData(const uint8_t *data, size_t size) { + return setData(const_cast(data), size, nullptr); +} + +ReturnValue_t PusTmReader::setData(uint8_t *dataPtr, size_t size, void *args) { + pointers.spHeaderStart = dataPtr; + return spReader.setReadOnlyData(dataPtr, size); +} + +uint16_t PusTmReader::getPacketIdRaw() const { return spReader.getPacketIdRaw(); } +uint16_t PusTmReader::getPacketSeqCtrlRaw() const { return spReader.getPacketSeqCtrlRaw(); } +uint16_t PusTmReader::getPacketDataLen() const { return spReader.getPacketDataLen(); } +uint8_t PusTmReader::getPusVersion() const { return (pointers.secHeaderStart[0] >> 4) & 0b1111; } +uint8_t PusTmReader::getScTimeRefStatus() { return pointers.secHeaderStart[0] & 0b1111; } +uint8_t PusTmReader::getService() const { return pointers.secHeaderStart[1]; } +uint8_t PusTmReader::getSubService() const { return pointers.secHeaderStart[2]; } +const uint8_t *PusTmReader::getUserData() const { return pointers.userDataStart; } +size_t PusTmReader::getUserDataLen() const { return sourceDataLen; } + +uint16_t PusTmReader::getMessageTypeCounter() { + return (pointers.secHeaderStart[3] << 8) | pointers.secHeaderStart[4]; +} + +uint16_t PusTmReader::getDestId() { + return (pointers.secHeaderStart[5] << 8) | pointers.secHeaderStart[6]; +} + +void PusTmReader::setTimeReader(TimeReaderIF *timeReader_) { timeReader = timeReader_; } + +TimeReaderIF *PusTmReader::getTimeReader() { return timeReader; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h index 47eff293..6eda4e51 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h @@ -1,7 +1,47 @@ #ifndef FSFW_TMTCPACKET_PUSTMREADER_H #define FSFW_TMTCPACKET_PUSTMREADER_H +#include "fsfw/timemanager/TimeReaderIF.h" +#include "fsfw/tmtcpacket/ReadablePacketIF.h" +#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" +#include "fsfw/tmtcpacket/pus/RawUserDataReaderIF.h" #include "fsfw/tmtcpacket/pus/tm/PusTmIF.h" -class PusTmReader : public PusTmIF {}; +class PusTmReader : public PusTmIF, + public RawUserDataReaderIF, + public ReadablePacketIF, + public RedirectableDataPointerIF { + public: + explicit PusTmReader(TimeReaderIF* timeReader); + PusTmReader(const uint8_t* data, size_t size); + PusTmReader(TimeReaderIF* timeReader, const uint8_t* data, size_t size); + + ReturnValue_t parseData(); + const uint8_t* getFullData() override; + + void setTimeReader(TimeReaderIF* timeReader); + TimeReaderIF* getTimeReader(); + ReturnValue_t setReadOnlyData(const uint8_t* data, size_t size); + [[nodiscard]] uint16_t getPacketIdRaw() const override; + [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; + [[nodiscard]] uint16_t getPacketDataLen() const override; + [[nodiscard]] uint8_t getPusVersion() const override; + [[nodiscard]] uint8_t getService() const override; + [[nodiscard]] uint8_t getSubService() const override; + const uint8_t* getUserData() const override; + size_t getUserDataLen() const override; + uint8_t getScTimeRefStatus() override; + uint16_t getMessageTypeCounter() override; + uint16_t getDestId() override; + + private: + ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override; + + SpacePacketReader spReader{}; + size_t sourceDataLen = 0; + TimeReaderIF* timeReader{}; + ecss::PusPointers pointers{}; +}; + #endif // FSFW_TMTCPACKET_PUSTMREADER_H diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp index 7ae6de82..5c35c540 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp @@ -2,7 +2,7 @@ #include -#include "../definitions.h" +#include "../defs.h" #include "TmPacketBase.h" #include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/arrayprinter.h" diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 8aa5dbce..d8ac88e7 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -251,8 +251,18 @@ void CommandingServiceBase::handleRequestQueue() { result = tcStore->getData(message.getStorageId(), &dataPtr, &dataLen); if (result != HasReturnvaluesIF::RETURN_OK) { // TODO: Warning? + continue; + } + result = tcReader.setReadOnlyData(dataPtr, dataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + // TODO: Warning? + continue; + } + result = tcReader.parseData(); + if (result != HasReturnvaluesIF::RETURN_OK) { + // TODO: Warning? + continue; } - tcReader.setReadOnlyData(dataPtr, dataLen); if ((tcReader.getSubService() == 0) or (isValidSubservice(tcReader.getSubService()) != RETURN_OK)) { @@ -260,10 +270,8 @@ void CommandingServiceBase::handleRequestQueue() { continue; } - size_t appDataLen = 0; - const uint8_t* appData = tcReader.getUserData(appDataLen); - result = - getMessageQueueAndObject(tcReader.getSubService(), appData, appDataLen, &queue, &objectId); + result = getMessageQueueAndObject(tcReader.getSubService(), tcReader.getUserData(), + tcReader.getUserDataLen(), &queue, &objectId); if (result != HasReturnvaluesIF::RETURN_OK) { rejectPacket(tc_verification::START_FAILURE, address, &tcReader, result); continue; @@ -332,10 +340,9 @@ void CommandingServiceBase::startExecution(store_address_t storeId, PusTcReader* return; } iter->second.subservice = storedPacket->getSubService(); - size_t appDataLen = 0; - const uint8_t* appData = storedPacket->getUserData(appDataLen); - result = prepareCommand(&command, iter->second.subservice, appData, appDataLen, - &iter->second.state, iter->second.objectId); + result = + prepareCommand(&command, iter->second.subservice, storedPacket->getUserData(), + storedPacket->getUserDataLen(), &iter->second.state, iter->second.objectId); ReturnValue_t sendResult = RETURN_OK; switch (result) { @@ -401,7 +408,16 @@ void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) { size_t dataLen = 0; ReturnValue_t result = tcStore->getData(address, &dataPtr, &dataLen); if (result == HasReturnvaluesIF::RETURN_OK) { - tcReader.setReadOnlyData(dataPtr, dataLen); + result = tcReader.setReadOnlyData(dataPtr, dataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + // TODO: Warning? + return; + } + result = tcReader.parseData(); + if (result != HasReturnvaluesIF::RETURN_OK) { + // TODO: Warning? + return; + } startExecution(address, &tcReader, iter); } else { // TODO: Warning? diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index e924ba67..5b985ad6 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -47,39 +47,51 @@ void PusServiceBase::handleRequestQueue() { // << std::endl; #endif // } - - if (status == RETURN_OK) { - const uint8_t* dataPtr; - size_t dataLen = 0; - result = ipcStore->getData(message.getStorageId(), &dataPtr, &dataLen); - if (result != HasReturnvaluesIF::RETURN_OK) { - // TODO: Warning? - } - - currentPacket.setReadOnlyData(dataPtr, dataLen); - - result = this->handleRequest(currentPacket.getSubService()); - if (result == RETURN_OK) { - this->verifyReporter.sendSuccessReport(tc_verification::COMPLETION_SUCCESS, - &this->currentPacket); - } else { - this->verifyReporter.sendFailureReport(tc_verification::COMPLETION_FAILURE, - &this->currentPacket, result, 0, errorParameter1, - errorParameter2); - } - ipcStore->deleteData(message.getStorageId()); - errorParameter1 = 0; - errorParameter2 = 0; - } else if (status == MessageQueueIF::EMPTY) { + if (status == MessageQueueIF::EMPTY) { status = RETURN_OK; break; - } else { + } else if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PusServiceBase::performOperation: Service " << this->serviceId << ": Error receiving packet. Code: " << std::hex << status << std::dec << std::endl; +#else + sif::printError( + "PusServiceBase::performOperation: Service %d. Error receiving packet. Code: %04x\n", + serviceId, status); #endif + break; } + const uint8_t* dataPtr; + size_t dataLen = 0; + result = ipcStore->getData(message.getStorageId(), &dataPtr, &dataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + // TODO: Warning? + continue; + } + + result = currentPacket.setReadOnlyData(dataPtr, dataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + // TODO: Warning? + continue; + } + result = currentPacket.parseData(); + if (result != HasReturnvaluesIF::RETURN_OK) { + // TODO: Warning? + continue; + } + result = this->handleRequest(currentPacket.getSubService()); + if (result == RETURN_OK) { + this->verifyReporter.sendSuccessReport(tc_verification::COMPLETION_SUCCESS, + &this->currentPacket); + } else { + this->verifyReporter.sendFailureReport(tc_verification::COMPLETION_FAILURE, + &this->currentPacket, result, 0, errorParameter1, + errorParameter2); + } + ipcStore->deleteData(message.getStorageId()); + errorParameter1 = 0; + errorParameter2 = 0; } } From e5ee96259d0e605a16472c25fa9ea96d0605e2ec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 21 Jul 2022 13:48:58 +0200 Subject: [PATCH 061/532] some fixes --- src/fsfw/pus/Service17Test.cpp | 2 +- .../pus/Service1TelecommandVerification.cpp | 2 +- src/fsfw/pus/Service5EventReporting.cpp | 2 +- src/fsfw/pus/servicepackets/Service1Packets.h | 8 +- src/fsfw/tcdistribution/PusDistributor.cpp | 4 +- src/fsfw/tmtcpacket/pus/tc.h | 3 +- src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp | 16 ++- src/fsfw/tmtcpacket/pus/tc/PusTcReader.h | 5 +- src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp | 81 ++++++------ src/fsfw/tmtcpacket/pus/tm/PusTmReader.h | 5 +- src/fsfw/tmtcservices/CMakeLists.txt | 4 +- .../tmtcservices/CommandingServiceBase.cpp | 116 +++++++----------- src/fsfw/tmtcservices/CommandingServiceBase.h | 4 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 37 ++---- src/fsfw/tmtcservices/PusServiceBase.h | 4 +- src/fsfw/tmtcservices/VerificationCodes.h | 10 +- .../tmtcservices/VerificationReporter.cpp | 4 +- src/fsfw/tmtcservices/VerificationReporter.h | 6 +- src/fsfw/tmtcservices/tcHelpers.cpp | 16 +++ src/fsfw/tmtcservices/tcHelpers.h | 15 +++ src/fsfw/tmtcservices/tmHelpers.cpp | 10 ++ .../{sendAndStoreHelper.h => tmHelpers.h} | 15 +-- 22 files changed, 195 insertions(+), 174 deletions(-) create mode 100644 src/fsfw/tmtcservices/tcHelpers.cpp create mode 100644 src/fsfw/tmtcservices/tcHelpers.h create mode 100644 src/fsfw/tmtcservices/tmHelpers.cpp rename src/fsfw/tmtcservices/{sendAndStoreHelper.h => tmHelpers.h} (77%) diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index 7d13af06..52319de1 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -3,7 +3,7 @@ #include "fsfw/FSFW.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/tmtcservices/sendAndStoreHelper.h" +#include "fsfw/tmtcservices/tmHelpers.h" Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId) : PusServiceBase(objectId, apid, serviceId), diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 5c49111e..4b326096 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -6,7 +6,7 @@ #include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" -#include "fsfw/tmtcservices/sendAndStoreHelper.h" +#include "fsfw/tmtcservices/tmHelpers.h" Service1TelecommandVerification::Service1TelecommandVerification(object_id_t objectId, uint16_t apid, uint8_t serviceId, diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index d88e58b8..a0cbc316 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -6,7 +6,7 @@ #include "fsfw/pus/servicepackets/Service5Packets.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h" -#include "fsfw/tmtcservices/sendAndStoreHelper.h" +#include "fsfw/tmtcservices/tmHelpers.h" Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t apid, uint8_t serviceId, size_t maxNumberReportsPerCycle, diff --git a/src/fsfw/pus/servicepackets/Service1Packets.h b/src/fsfw/pus/servicepackets/Service1Packets.h index df70f670..dce7657a 100644 --- a/src/fsfw/pus/servicepackets/Service1Packets.h +++ b/src/fsfw/pus/servicepackets/Service1Packets.h @@ -50,7 +50,7 @@ class FailureReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6 if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - if (failureSubtype == tc_verification::PROGRESS_FAILURE) { + if (failureSubtype == tcverif::PROGRESS_FAILURE) { result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -73,7 +73,7 @@ class FailureReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6 size_t size = 0; size += SerializeAdapter::getSerializedSize(&packetId); size += sizeof(packetSequenceControl); - if (failureSubtype == tc_verification::PROGRESS_FAILURE) { + if (failureSubtype == tcverif::PROGRESS_FAILURE) { size += SerializeAdapter::getSerializedSize(&stepNumber); } size += SerializeAdapter::getSerializedSize(&errorCode); @@ -130,7 +130,7 @@ class SuccessReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5 if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - if (subtype == tc_verification::PROGRESS_SUCCESS) { + if (subtype == tcverif::PROGRESS_SUCCESS) { result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -143,7 +143,7 @@ class SuccessReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5 size_t size = 0; size += SerializeAdapter::getSerializedSize(&packetId); size += sizeof(packetSequenceControl); - if (subtype == tc_verification::PROGRESS_SUCCESS) { + if (subtype == tcverif::PROGRESS_SUCCESS) { size += SerializeAdapter::getSerializedSize(&stepNumber); } return size; diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 687c5f00..bac932d5 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -121,13 +121,13 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { tcStatus = queueStatus; } if (tcStatus != RETURN_OK) { - this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, &reader, tcStatus); + this->verifyChannel.sendFailureReport(tcverif::ACCEPTANCE_FAILURE, &reader, tcStatus); // A failed packet is deleted immediately after reporting, // otherwise it will block memory. store->deleteData(currentMessage.getStorageId()); return RETURN_FAILED; } else { - this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, &reader); + this->verifyChannel.sendSuccessReport(tcverif::ACCEPTANCE_SUCCESS, &reader); return RETURN_OK; } } diff --git a/src/fsfw/tmtcpacket/pus/tc.h b/src/fsfw/tmtcpacket/pus/tc.h index 33c6352f..e5e5f9f7 100644 --- a/src/fsfw/tmtcpacket/pus/tc.h +++ b/src/fsfw/tmtcpacket/pus/tc.h @@ -1,6 +1,7 @@ #ifndef FSFW_TMTCPACKET_PUS_TC_H_ #define FSFW_TMTCPACKET_PUS_TC_H_ -#include "tc/TcPacketPus.h" +#include "tc/PusTcCreator.h" +#include "tc/PusTcReader.h" #endif /* FSFW_TMTCPACKET_PUS_TC_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp index b9e5e00f..c96bed65 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp @@ -11,7 +11,11 @@ PusTcReader::PusTcReader(const uint8_t* data, size_t size) { setReadOnlyData(dat PusTcReader::~PusTcReader() = default; -ReturnValue_t PusTcReader::parseData() { +ReturnValue_t PusTcReader::parseDataWithCrcCheck() { return parseData(true); } + +ReturnValue_t PusTcReader::parseDataWithoutCrcCheck() { return parseData(false); } + +ReturnValue_t PusTcReader::parseData(bool withCrc) { if (pointers.spHeaderStart == nullptr or spReader.isNull()) { return HasReturnvaluesIF::RETURN_FAILED; } @@ -31,10 +35,12 @@ ReturnValue_t PusTcReader::parseData() { pointers.userDataStart = pointers.spHeaderStart + currentOffset; appDataSize = spReader.getFullPacketLen() - currentOffset - sizeof(ecss::PusChecksumT); pointers.crcStart = pointers.userDataStart + appDataSize; - uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen()); - if (crc16 != 0) { - // Checksum failure - return PusIF::INVALID_CRC_16; + if (withCrc) { + uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen()); + if (crc16 != 0) { + // Checksum failure + return PusIF::INVALID_CRC_16; + } } return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h index e79f8b61..528e0ca5 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h @@ -34,7 +34,9 @@ class PusTcReader : public PusTcIF, */ PusTcReader(const uint8_t* setData, size_t size); - ReturnValue_t parseData(); + ReturnValue_t parseDataWithCrcCheck(); + ReturnValue_t parseDataWithoutCrcCheck(); + /** * This is the empty default destructor. */ @@ -70,6 +72,7 @@ class PusTcReader : public PusTcIF, * @param p_data A pointer to another PUS Telecommand Packet. */ ReturnValue_t setData(uint8_t* pData, size_t size, void* args) override; + ReturnValue_t parseData(bool withCrc); SpacePacketReader spReader; ecss::PusPointers pointers{}; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp index cb30de05..024d6ac8 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp @@ -11,44 +11,10 @@ PusTmReader::PusTmReader(TimeReaderIF *timeReader, const uint8_t *data, size_t s setReadOnlyData(data, size); } -ReturnValue_t PusTmReader::parseData() { - // Time reader is required to read the time stamp length at run-time - if (pointers.spHeaderStart == nullptr or spReader.isNull() or timeReader == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - ReturnValue_t result = spReader.checkSize(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - if (spReader.getBufSize() < PusTmIF::MIN_SIZE) { - return SerializeIF::STREAM_TOO_SHORT; - } +ReturnValue_t PusTmReader::parseDataWithCrcCheck() { return parseData(true); } + +ReturnValue_t PusTmReader::parseDataWithoutCrcCheck() { return parseData(false); } - size_t currentOffset = SpacePacketReader::getHeaderLen(); - pointers.secHeaderStart = pointers.spHeaderStart + currentOffset; - currentOffset += PusTmIF::MIN_SEC_HEADER_LEN; - size_t minTimestampLen = spReader.getBufSize() - currentOffset; - result = timeReader->readTimeStamp(pointers.secHeaderStart + PusTmIF::MIN_SEC_HEADER_LEN, - minTimestampLen); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - size_t timestampLen = timeReader->getTimestampLen(); - if (currentOffset + timestampLen > spReader.getBufSize()) { - return SerializeIF::STREAM_TOO_SHORT; - } - currentOffset += timestampLen; - pointers.userDataStart = pointers.spHeaderStart + currentOffset; - sourceDataLen = spReader.getFullPacketLen() - currentOffset - sizeof(ecss::PusChecksumT); - currentOffset += sourceDataLen; - pointers.crcStart = pointers.spHeaderStart + currentOffset; - uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen()); - if (crc16 != 0) { - // Checksum failure - return PusIF::INVALID_CRC_16; - } - return HasReturnvaluesIF::RETURN_OK; -} const uint8_t *PusTmReader::getFullData() { return spReader.getFullData(); } ReturnValue_t PusTmReader::setReadOnlyData(const uint8_t *data, size_t size) { @@ -81,3 +47,44 @@ uint16_t PusTmReader::getDestId() { void PusTmReader::setTimeReader(TimeReaderIF *timeReader_) { timeReader = timeReader_; } TimeReaderIF *PusTmReader::getTimeReader() { return timeReader; } + +ReturnValue_t PusTmReader::parseData(bool crcCheck) { + // Time reader is required to read the time stamp length at run-time + if (pointers.spHeaderStart == nullptr or spReader.isNull() or timeReader == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + ReturnValue_t result = spReader.checkSize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (spReader.getBufSize() < PusTmIF::MIN_SIZE) { + return SerializeIF::STREAM_TOO_SHORT; + } + + size_t currentOffset = SpacePacketReader::getHeaderLen(); + pointers.secHeaderStart = pointers.spHeaderStart + currentOffset; + currentOffset += PusTmIF::MIN_SEC_HEADER_LEN; + size_t minTimestampLen = spReader.getBufSize() - currentOffset; + result = timeReader->readTimeStamp(pointers.secHeaderStart + PusTmIF::MIN_SEC_HEADER_LEN, + minTimestampLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + size_t timestampLen = timeReader->getTimestampLen(); + if (currentOffset + timestampLen > spReader.getBufSize()) { + return SerializeIF::STREAM_TOO_SHORT; + } + currentOffset += timestampLen; + pointers.userDataStart = pointers.spHeaderStart + currentOffset; + sourceDataLen = spReader.getFullPacketLen() - currentOffset - sizeof(ecss::PusChecksumT); + currentOffset += sourceDataLen; + pointers.crcStart = pointers.spHeaderStart + currentOffset; + if (crcCheck) { + uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen()); + if (crc16 != 0) { + // Checksum failure + return PusIF::INVALID_CRC_16; + } + } + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h index 6eda4e51..1d91eb95 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h @@ -17,7 +17,8 @@ class PusTmReader : public PusTmIF, PusTmReader(const uint8_t* data, size_t size); PusTmReader(TimeReaderIF* timeReader, const uint8_t* data, size_t size); - ReturnValue_t parseData(); + ReturnValue_t parseDataWithoutCrcCheck(); + ReturnValue_t parseDataWithCrcCheck(); const uint8_t* getFullData() override; void setTimeReader(TimeReaderIF* timeReader); @@ -37,7 +38,7 @@ class PusTmReader : public PusTmIF, private: ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override; - + ReturnValue_t parseData(bool crcCheck); SpacePacketReader spReader{}; size_t sourceDataLen = 0; TimeReaderIF* timeReader{}; diff --git a/src/fsfw/tmtcservices/CMakeLists.txt b/src/fsfw/tmtcservices/CMakeLists.txt index a26faf7f..42ac6128 100644 --- a/src/fsfw/tmtcservices/CMakeLists.txt +++ b/src/fsfw/tmtcservices/CMakeLists.txt @@ -8,4 +8,6 @@ target_sources( VerificationReporter.cpp SpacePacketParser.cpp TmStoreHelper.cpp - TmSendHelper.cpp) + TmSendHelper.cpp + tcHelpers.cpp + tmHelpers.cpp) diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index d8ac88e7..897dd962 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -8,7 +8,8 @@ #include "fsfw/tmtcpacket/pus/tm.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/TmTcMessage.h" -#include "fsfw/tmtcservices/sendAndStoreHelper.h" +#include "fsfw/tmtcservices/tcHelpers.h" +#include "fsfw/tmtcservices/tmHelpers.h" object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; object_id_t CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; @@ -176,12 +177,12 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) { default: if (isStep) { verificationReporter.sendFailureReport( - tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, - iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, result, - ++iter->second.step, failureParameter1, failureParameter2); + tcverif::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, + iter->second.tcInfo.tcSequenceControl, result, ++iter->second.step, failureParameter1, + failureParameter2); } else { verificationReporter.sendFailureReport( - tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, + tcverif::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, result, 0, failureParameter1, failureParameter2); } @@ -208,28 +209,27 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, Comma if (sendResult == RETURN_OK) { if (isStep and result != NO_STEP_MESSAGE) { verificationReporter.sendSuccessReport( - tc_verification::PROGRESS_SUCCESS, iter->second.tcInfo.ackFlags, - iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, - ++iter->second.step); + tcverif::PROGRESS_SUCCESS, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, + iter->second.tcInfo.tcSequenceControl, ++iter->second.step); } else { verificationReporter.sendSuccessReport( - tc_verification::COMPLETION_SUCCESS, iter->second.tcInfo.ackFlags, - iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, 0); + tcverif::COMPLETION_SUCCESS, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, + iter->second.tcInfo.tcSequenceControl, 0); checkAndExecuteFifo(iter); } } else { if (isStep) { nextCommand->clearCommandMessage(); verificationReporter.sendFailureReport( - tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, - iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, sendResult, - ++iter->second.step, failureParameter1, failureParameter2); + tcverif::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, + iter->second.tcInfo.tcSequenceControl, sendResult, ++iter->second.step, failureParameter1, + failureParameter2); } else { nextCommand->clearCommandMessage(); verificationReporter.sendFailureReport( - tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, - iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, sendResult, 0, - failureParameter1, failureParameter2); + tcverif::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, + iter->second.tcInfo.tcSequenceControl, sendResult, 0, failureParameter1, + failureParameter2); } failureParameter1 = 0; failureParameter2 = 0; @@ -245,35 +245,22 @@ void CommandingServiceBase::handleRequestQueue() { object_id_t objectId; for (result = requestQueue->receiveMessage(&message); result == RETURN_OK; result = requestQueue->receiveMessage(&message)) { - address = message.getStorageId(); - const uint8_t* dataPtr; - size_t dataLen = 0; - result = tcStore->getData(message.getStorageId(), &dataPtr, &dataLen); + result = setUpTcReader(message.getStorageId()); if (result != HasReturnvaluesIF::RETURN_OK) { // TODO: Warning? + rejectPacket(tcverif::START_FAILURE, address, &tcReader, result); continue; } - result = tcReader.setReadOnlyData(dataPtr, dataLen); - if (result != HasReturnvaluesIF::RETURN_OK) { - // TODO: Warning? - continue; - } - result = tcReader.parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { - // TODO: Warning? - continue; - } - if ((tcReader.getSubService() == 0) or (isValidSubservice(tcReader.getSubService()) != RETURN_OK)) { - rejectPacket(tc_verification::START_FAILURE, address, &tcReader, INVALID_SUBSERVICE); + rejectPacket(tcverif::START_FAILURE, address, &tcReader, INVALID_SUBSERVICE); continue; } result = getMessageQueueAndObject(tcReader.getSubService(), tcReader.getUserData(), tcReader.getUserDataLen(), &queue, &objectId); if (result != HasReturnvaluesIF::RETURN_OK) { - rejectPacket(tc_verification::START_FAILURE, address, &tcReader, result); + rejectPacket(tcverif::START_FAILURE, address, &tcReader, result); continue; } @@ -284,16 +271,16 @@ void CommandingServiceBase::handleRequestQueue() { if (iter != commandMap.end()) { result = iter->second.fifo.insert(address); if (result != RETURN_OK) { - rejectPacket(tc_verification::START_FAILURE, address, &tcReader, OBJECT_BUSY); + rejectPacket(tcverif::START_FAILURE, address, &tcReader, OBJECT_BUSY); } } else { CommandInfo newInfo; // Info will be set by startExecution if neccessary newInfo.objectId = objectId; result = commandMap.insert(queue, newInfo, &iter); if (result != RETURN_OK) { - rejectPacket(tc_verification::START_FAILURE, address, &tcReader, BUSY); + rejectPacket(tcverif::START_FAILURE, address, &tcReader, BUSY); } else { - startExecution(address, &tcReader, iter); + startExecution(address, iter); } } } @@ -332,17 +319,12 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeI return result; } -void CommandingServiceBase::startExecution(store_address_t storeId, PusTcReader* storedPacket, - CommandMapIter iter) { +void CommandingServiceBase::startExecution(store_address_t storeId, CommandMapIter iter) { ReturnValue_t result = RETURN_OK; CommandMessage command; - if (storedPacket == nullptr) { - return; - } - iter->second.subservice = storedPacket->getSubService(); - result = - prepareCommand(&command, iter->second.subservice, storedPacket->getUserData(), - storedPacket->getUserDataLen(), &iter->second.state, iter->second.objectId); + iter->second.subservice = tcReader.getSubService(); + result = prepareCommand(&command, iter->second.subservice, tcReader.getUserData(), + tcReader.getUserDataLen(), &iter->second.state, iter->second.objectId); ReturnValue_t sendResult = RETURN_OK; switch (result) { @@ -353,15 +335,15 @@ void CommandingServiceBase::startExecution(store_address_t storeId, PusTcReader* if (sendResult == RETURN_OK) { Clock::getUptime(&iter->second.uptimeOfStart); iter->second.step = 0; - iter->second.subservice = storedPacket->getSubService(); + iter->second.subservice = tcReader.getSubService(); iter->second.command = command.getCommand(); - iter->second.tcInfo.ackFlags = storedPacket->getAcknowledgeFlags(); - iter->second.tcInfo.tcPacketId = storedPacket->getPacketIdRaw(); - iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSeqCtrlRaw(); - acceptPacket(tc_verification::START_SUCCESS, storeId, storedPacket); + iter->second.tcInfo.ackFlags = tcReader.getAcknowledgeFlags(); + iter->second.tcInfo.tcPacketId = tcReader.getPacketIdRaw(); + iter->second.tcInfo.tcSequenceControl = tcReader.getPacketSeqCtrlRaw(); + acceptPacket(tcverif::START_SUCCESS, storeId, &tcReader); } else { command.clearCommandMessage(); - rejectPacket(tc_verification::START_FAILURE, storeId, storedPacket, sendResult); + rejectPacket(tcverif::START_FAILURE, storeId, &tcReader, sendResult); checkAndExecuteFifo(iter); } break; @@ -371,17 +353,17 @@ void CommandingServiceBase::startExecution(store_address_t storeId, PusTcReader* sendResult = commandQueue->sendMessage(iter.value->first, &command); } if (sendResult == RETURN_OK) { - verificationReporter.sendSuccessReport(tc_verification::START_SUCCESS, storedPacket); - acceptPacket(tc_verification::COMPLETION_SUCCESS, storeId, storedPacket); + verificationReporter.sendSuccessReport(tcverif::START_SUCCESS, &tcReader); + acceptPacket(tcverif::COMPLETION_SUCCESS, storeId, &tcReader); checkAndExecuteFifo(iter); } else { command.clearCommandMessage(); - rejectPacket(tc_verification::START_FAILURE, storeId, storedPacket, sendResult); + rejectPacket(tcverif::START_FAILURE, storeId, &tcReader, sendResult); checkAndExecuteFifo(iter); } break; default: - rejectPacket(tc_verification::START_FAILURE, storeId, storedPacket, result); + rejectPacket(tcverif::START_FAILURE, storeId, &tcReader, result); checkAndExecuteFifo(iter); break; } @@ -404,23 +386,12 @@ void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) { if (iter->second.fifo.retrieve(&address) != RETURN_OK) { commandMap.erase(&iter); } else { - const uint8_t* dataPtr; - size_t dataLen = 0; - ReturnValue_t result = tcStore->getData(address, &dataPtr, &dataLen); + ReturnValue_t result = setUpTcReader(address); if (result == HasReturnvaluesIF::RETURN_OK) { - result = tcReader.setReadOnlyData(dataPtr, dataLen); - if (result != HasReturnvaluesIF::RETURN_OK) { - // TODO: Warning? - return; - } - result = tcReader.parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { - // TODO: Warning? - return; - } - startExecution(address, &tcReader, iter); + startExecution(address, iter); } else { // TODO: Warning? + rejectPacket(tcverif::START_FAILURE, address, &tcReader, result); } } } @@ -440,8 +411,8 @@ void CommandingServiceBase::checkTimeout() { for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) { if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) { verificationReporter.sendFailureReport( - tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, - iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, TIMEOUT); + tcverif::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, + iter->second.tcInfo.tcSequenceControl, TIMEOUT); checkAndExecuteFifo(iter); } } @@ -452,3 +423,6 @@ void CommandingServiceBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = t void CommandingServiceBase::setCustomTmStore(StorageManagerIF* store) { tmStoreHelper.setTmStore(store); } +ReturnValue_t CommandingServiceBase::setUpTcReader(store_address_t storeId) { + return tc::prepareTcReader(tcStore, storeId, tcReader); +} diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index a392fb95..a58a1a93 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -350,12 +350,14 @@ class CommandingServiceBase : public SystemObject, */ void handleRequestQueue(); + ReturnValue_t setUpTcReader(store_address_t storeId); + void rejectPacket(uint8_t reportId, store_address_t tcStoreId, PusTcReader* tcPacket, ReturnValue_t errorCode); void acceptPacket(uint8_t reportId, store_address_t tcStoreId, PusTcReader* tcPacket); - void startExecution(store_address_t storeId, PusTcReader* storedPacket, CommandMapIter iter); + void startExecution(store_address_t storeId, CommandMapIter iter); void handleCommandMessage(CommandMessage* reply); void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter, diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 5b985ad6..e7a0e5b9 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -7,6 +7,7 @@ #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" #include "fsfw/tmtcservices/TmTcMessage.h" +#include "fsfw/tmtcservices/tcHelpers.h" object_id_t PusServiceBase::packetSource = 0; object_id_t PusServiceBase::packetDestination = 0; @@ -62,34 +63,20 @@ void PusServiceBase::handleRequestQueue() { #endif break; } - const uint8_t* dataPtr; - size_t dataLen = 0; - result = ipcStore->getData(message.getStorageId(), &dataPtr, &dataLen); + result = tc::prepareTcReader(tcStore, message.getStorageId(), currentPacket); if (result != HasReturnvaluesIF::RETURN_OK) { - // TODO: Warning? - continue; - } - - result = currentPacket.setReadOnlyData(dataPtr, dataLen); - if (result != HasReturnvaluesIF::RETURN_OK) { - // TODO: Warning? - continue; - } - result = currentPacket.parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { - // TODO: Warning? + this->verifyReporter.sendFailureReport(tcverif::START_FAILURE, &this->currentPacket, result, + 0, errorParameter1, errorParameter2); continue; } result = this->handleRequest(currentPacket.getSubService()); if (result == RETURN_OK) { - this->verifyReporter.sendSuccessReport(tc_verification::COMPLETION_SUCCESS, - &this->currentPacket); + this->verifyReporter.sendSuccessReport(tcverif::COMPLETION_SUCCESS, &this->currentPacket); } else { - this->verifyReporter.sendFailureReport(tc_verification::COMPLETION_FAILURE, - &this->currentPacket, result, 0, errorParameter1, - errorParameter2); + this->verifyReporter.sendFailureReport(tcverif::COMPLETION_FAILURE, &this->currentPacket, + result, 0, errorParameter1, errorParameter2); } - ipcStore->deleteData(message.getStorageId()); + tcStore->deleteData(message.getStorageId()); errorParameter1 = 0; errorParameter2 = 0; } @@ -116,9 +103,9 @@ ReturnValue_t PusServiceBase::initialize() { } this->requestQueue->setDefaultDestination(destService->getReportReceptionQueue()); distributor->registerService(this); - if (ipcStore == nullptr) { - ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); - if (ipcStore == nullptr) { + if (tcStore == nullptr) { + tcStore = ObjectManager::instance()->get(objects::IPC_STORE); + if (tcStore == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } } @@ -132,7 +119,7 @@ ReturnValue_t PusServiceBase::initializeAfterTaskCreation() { return HasReturnvaluesIF::RETURN_OK; } -void PusServiceBase::setCustomIpcStore(StorageManagerIF* ipcStore_) { ipcStore = ipcStore_; } +void PusServiceBase::setCustomTcStore(StorageManagerIF* tcStore_) { tcStore = tcStore_; } void PusServiceBase::setCustomErrorReporter(InternalErrorReporterIF* errReporter_) { errReporter = errReporter_; diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 58f83540..7df563d0 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -59,7 +59,7 @@ class PusServiceBase : public ExecutableObjectIF, */ ~PusServiceBase() override; - void setCustomIpcStore(StorageManagerIF* ipcStore); + void setCustomTcStore(StorageManagerIF* tcStore); void setCustomErrorReporter(InternalErrorReporterIF* errReporter); void initializeTmSendHelper(TmSendHelper& tmSendHelper); @@ -153,7 +153,7 @@ class PusServiceBase : public ExecutableObjectIF, * It is deleted after handleRequest was executed. */ PusTcReader currentPacket; - StorageManagerIF* ipcStore = nullptr; + StorageManagerIF* tcStore = nullptr; InternalErrorReporterIF* errReporter = nullptr; static object_id_t packetSource; diff --git a/src/fsfw/tmtcservices/VerificationCodes.h b/src/fsfw/tmtcservices/VerificationCodes.h index 73edbc1d..91b76bde 100644 --- a/src/fsfw/tmtcservices/VerificationCodes.h +++ b/src/fsfw/tmtcservices/VerificationCodes.h @@ -1,9 +1,11 @@ #ifndef VERIFICATIONCODES_H_ #define VERIFICATIONCODES_H_ -namespace tc_verification { +#include -enum verification_flags { +namespace tcverif { + +enum VerifFlags : uint8_t { NONE = 0b0000, ACCEPTANCE = 0b0001, START = 0b0010, @@ -11,7 +13,7 @@ enum verification_flags { COMPLETION = 0b1000 }; -enum subservice_ids { +enum Subservices : uint8_t { NOTHING_TO_REPORT = 0, ACCEPTANCE_SUCCESS = 1, ACCEPTANCE_FAILURE = 2, @@ -23,6 +25,6 @@ enum subservice_ids { COMPLETION_FAILURE = 8, }; -} // namespace tc_verification +} // namespace tcverif #endif /* VERIFICATIONCODES_H_ */ diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 67b2af37..a9b6dd47 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -51,7 +51,7 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, uint8_t ackF } void VerificationReporter::sendFailureReport(uint8_t report_id, PusTcReader* correspondingTc, - ReturnValue_t error_code, uint8_t step, + ReturnValue_t errorCode, uint8_t step, uint32_t parameter1, uint32_t parameter2) { if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) { this->initialize(); @@ -61,7 +61,7 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, PusTcReader* cor } PusVerificationMessage message( report_id, correspondingTc->getAcknowledgeFlags(), correspondingTc->getPacketIdRaw(), - correspondingTc->getPacketSeqCtrlRaw(), error_code, step, parameter1, parameter2); + correspondingTc->getPacketSeqCtrlRaw(), errorCode, step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/tmtcservices/VerificationReporter.h b/src/fsfw/tmtcservices/VerificationReporter.h index d668c502..1d64fd48 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.h +++ b/src/fsfw/tmtcservices/VerificationReporter.h @@ -27,15 +27,17 @@ class VerificationReporter { VerificationReporter(); virtual ~VerificationReporter(); + // TODO: The API is a little bit bloated. It might be better to group all the parameters + // into a dedicated struct void sendSuccessReport(uint8_t set_report_id, PusTcReader* correspondingTc, uint8_t set_step = 0); void sendSuccessReport(uint8_t set_report_id, uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl, uint8_t set_step = 0); void sendFailureReport(uint8_t report_id, PusTcReader* correspondingTc, - ReturnValue_t error_code = 0, uint8_t step = 0, uint32_t parameter1 = 0, + ReturnValue_t errorCode = 0, uint8_t step = 0, uint32_t parameter1 = 0, uint32_t parameter2 = 0); void sendFailureReport(uint8_t report_id, uint8_t ackFlags, uint16_t tcPacketId, - uint16_t tcSequenceControl, ReturnValue_t error_code = 0, uint8_t step = 0, + uint16_t tcSequenceControl, ReturnValue_t errorCode = 0, uint8_t step = 0, uint32_t parameter1 = 0, uint32_t parameter2 = 0); void initialize(); diff --git a/src/fsfw/tmtcservices/tcHelpers.cpp b/src/fsfw/tmtcservices/tcHelpers.cpp new file mode 100644 index 00000000..91f6e3be --- /dev/null +++ b/src/fsfw/tmtcservices/tcHelpers.cpp @@ -0,0 +1,16 @@ +#include "tcHelpers.h" + +ReturnValue_t tc::prepareTcReader(StorageManagerIF *tcStore, store_address_t storeId, + PusTcReader &tcReader) { + const uint8_t *dataPtr; + size_t dataLen = 0; + ReturnValue_t result = tcStore->getData(storeId, &dataPtr, &dataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = tcReader.setReadOnlyData(dataPtr, dataLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return tcReader.parseDataWithoutCrcCheck(); +} diff --git a/src/fsfw/tmtcservices/tcHelpers.h b/src/fsfw/tmtcservices/tcHelpers.h new file mode 100644 index 00000000..fc19ae33 --- /dev/null +++ b/src/fsfw/tmtcservices/tcHelpers.h @@ -0,0 +1,15 @@ +#ifndef FSFW_TMTCSERVICES_TCHELPERS_H +#define FSFW_TMTCSERVICES_TCHELPERS_H + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/storagemanager/StorageManagerIF.h" +#include "fsfw/tmtcpacket/pus/tc.h" + +namespace tc { + +ReturnValue_t prepareTcReader(StorageManagerIF* tcStore, store_address_t storeId, + PusTcReader& tcReader); + +} // namespace tc + +#endif // FSFW_TMTCSERVICES_TCHELPERS_H diff --git a/src/fsfw/tmtcservices/tmHelpers.cpp b/src/fsfw/tmtcservices/tmHelpers.cpp new file mode 100644 index 00000000..91026d6c --- /dev/null +++ b/src/fsfw/tmtcservices/tmHelpers.cpp @@ -0,0 +1,10 @@ +#include "tmHelpers.h" + +ReturnValue_t tm::storeAndSendTmPacket(TmStoreHelper &storeHelper, TmSendHelper &sendHelper) { + storeHelper.addPacketToStore(); + ReturnValue_t result = sendHelper.sendPacket(storeHelper.getCurrentAddr()); + if (result != HasReturnvaluesIF::RETURN_OK) { + storeHelper.deletePacket(); + } + return result; +} diff --git a/src/fsfw/tmtcservices/sendAndStoreHelper.h b/src/fsfw/tmtcservices/tmHelpers.h similarity index 77% rename from src/fsfw/tmtcservices/sendAndStoreHelper.h rename to src/fsfw/tmtcservices/tmHelpers.h index d07456f6..871a7f1a 100644 --- a/src/fsfw/tmtcservices/sendAndStoreHelper.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -1,19 +1,12 @@ -#ifndef FSFW_TMTCSERVICES_SENDANDSTOREHELPER_H -#define FSFW_TMTCSERVICES_SENDANDSTOREHELPER_H +#ifndef FSFW_TMTCSERVICES_TMHELPERS_H_ +#define FSFW_TMTCSERVICES_TMHELPERS_H_ #include "TmSendHelper.h" #include "TmStoreHelper.h" namespace tm { -ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper) { - storeHelper.addPacketToStore(); - ReturnValue_t result = sendHelper.sendPacket(storeHelper.getCurrentAddr()); - if (result != HasReturnvaluesIF::RETURN_OK) { - storeHelper.deletePacket(); - } - return result; -} +ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper); class SourceDataWithObjectIdPrefix : public SerializeIF { public: @@ -51,4 +44,4 @@ class SourceDataWithObjectIdPrefix : public SerializeIF { } // namespace tm -#endif // FSFW_TMTCSERVICES_SENDANDSTOREHELPER_H +#endif // FSFW_TMTCSERVICES_TMHELPERS_H_ From 23f264096cb9f3a191617beb562119e838c5c7b1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 21 Jul 2022 14:05:31 +0200 Subject: [PATCH 062/532] delete a few old classes --- src/fsfw/tcdistribution/PusDistributor.cpp | 1 - src/fsfw/tmtcpacket/CMakeLists.txt | 2 - src/fsfw/tmtcpacket/PacketStorageHelper.cpp | 25 -------- src/fsfw/tmtcpacket/PacketStorageHelper.h | 63 ------------------- src/fsfw/tmtcpacket/pus/tc/TcPacketStored.cpp | 1 - src/fsfw/tmtcpacket/pus/tc/TcPacketStored.h | 10 --- 6 files changed, 102 deletions(-) delete mode 100644 src/fsfw/tmtcpacket/PacketStorageHelper.cpp delete mode 100644 src/fsfw/tmtcpacket/PacketStorageHelper.h delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketStored.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketStored.h diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index bac932d5..3a7fdf34 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -3,7 +3,6 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tcdistribution/CCSDSDistributorIF.h" -#include "fsfw/tmtcpacket/PacketStorageHelper.h" #include "fsfw/tmtcservices/PusVerificationReport.h" #define PUS_DISTRIBUTOR_DEBUGGING 0 diff --git a/src/fsfw/tmtcpacket/CMakeLists.txt b/src/fsfw/tmtcpacket/CMakeLists.txt index 8c70d351..e1b54efe 100644 --- a/src/fsfw/tmtcpacket/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/CMakeLists.txt @@ -1,5 +1,3 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE PacketStorageHelper.cpp) - add_subdirectory(ccsds) add_subdirectory(pus) add_subdirectory(cfdp) diff --git a/src/fsfw/tmtcpacket/PacketStorageHelper.cpp b/src/fsfw/tmtcpacket/PacketStorageHelper.cpp deleted file mode 100644 index 89184251..00000000 --- a/src/fsfw/tmtcpacket/PacketStorageHelper.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "PacketStorageHelper.h" - -#include - -#include "fsfw/serialize.h" -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/storagemanager/StorageManagerIF.h" - -PacketStorageHelper::PacketStorageHelper(StorageManagerIF* store_, - SerializeIF::Endianness endianness_) - : store(store_), endianness(endianness_) {} - -ReturnValue_t PacketStorageHelper::addPacket(SerializeIF* packet, store_address_t& storeId) { - uint8_t* ptr = nullptr; - size_t serLen = 0; - ReturnValue_t result = store->getFreeElement(&storeId, packet->getSerializedSize(), &ptr); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - return packet->serialize(&ptr, &serLen, packet->getSerializedSize(), endianness); -} - -ReturnValue_t PacketStorageHelper::deletePacket(store_address_t storeId) { - return store->deleteData(storeId); -} diff --git a/src/fsfw/tmtcpacket/PacketStorageHelper.h b/src/fsfw/tmtcpacket/PacketStorageHelper.h deleted file mode 100644 index 1be75b23..00000000 --- a/src/fsfw/tmtcpacket/PacketStorageHelper.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_ -#define FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_ - -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/serialize.h" -#include "fsfw/storagemanager/storeAddress.h" - -class StorageManagerIF; - -class PacketStorageHelper { - public: - explicit PacketStorageHelper(StorageManagerIF* store, SerializeIF::Endianness endianness); - - ReturnValue_t addPacket(SerializeIF* packet, store_address_t& storeId); - ReturnValue_t deletePacket(store_address_t storeId); - - private: - StorageManagerIF* store; - SerializeIF::Endianness endianness; -}; -// class TcPacketStoredPus : public TcPacketStoredBase, public TcPacketPus { -// public: -// /** -// * With this constructor, new space is allocated in the packet store and -// * a new PUS Telecommand Packet is created there. -// * Packet Application Data passed in data is copied into the packet. -// * @param apid Sets the packet's APID field. -// * @param service Sets the packet's Service ID field. -// * This specifies the destination service. -// * @param subservice Sets the packet's Service Subtype field. -// * This specifies the destination sub-service. -// * @param sequence_count Sets the packet's Source Sequence Count field. -// * @param data The data to be copied to the Application Data Field. -// * @param size The amount of data to be copied. -// * @param ack Set's the packet's Ack field, which specifies -// * number of verification packets returned -// * for this command. -// */ -// TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t subservice, uint8_t sequence_count = -// 0, -// const uint8_t* data = nullptr, size_t size = 0, -// uint8_t ack = TcPacketPusBase::ACK_ALL); -// /** -// * Create stored packet with existing data. -// * @param data -// * @param size -// */ -// TcPacketStoredPus(const uint8_t* data, size_t size); -// /** -// * Create stored packet from existing packet in store -// * @param setAddress -// */ -// TcPacketStoredPus(store_address_t setAddress); -// TcPacketStoredPus(); -// -// ReturnValue_t deletePacket() override; -// TcPacketPusBase* getPacketBase(); -// -// private: -// bool isSizeCorrect() override; -// }; - -#endif /* FSFW_TMTCPACKET_PUS_TCPACKETSTOREDPUSA_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.cpp deleted file mode 100644 index 89ebe75a..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "TcPacketStored.h" diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.h deleted file mode 100644 index ddd51303..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStored.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef FSFW_TMTCPACKET_TCPACKETSTORED_H -#define FSFW_TMTCPACKET_TCPACKETSTORED_H - -#include "fsfw/tmtcpacket/PacketStorageHelper.h" - -class TcPacketStored : public PacketStorageHelper { - TcPacketStored(StorageManagerIF* store); -}; - -#endif // FSFW_TMTCPACKET_TCPACKETSTORED_H From 08e0b0f1a0eafcc0c5facb26631f8b3cff6ddeb9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 21 Jul 2022 14:40:00 +0200 Subject: [PATCH 063/532] added sp reader unittests --- src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h | 6 +++ .../tmtcpacket/ccsds/SpacePacketReader.cpp | 7 ++- src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h | 5 -- src/fsfw/tmtcpacket/ccsds/header.cpp | 2 +- unittests/tmtcpacket/testCcsdsReader.cpp | 51 ++++++++++++++++++- 5 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h index 068e04d9..de01e819 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h @@ -22,6 +22,12 @@ class SpacePacketIF { virtual ~SpacePacketIF() = default; + /** + * CCSDS header always has 6 bytes + * @return + */ + static constexpr size_t getHeaderLen() { return ccsds::HEADER_LEN; } + /** * Returns the complete first two bytes of the packet, which together form * the CCSDS packet ID diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp index c528d0a7..76f92107 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp @@ -8,6 +8,9 @@ SpacePacketReader::SpacePacketReader(const uint8_t* setAddress, size_t maxSize_) } ReturnValue_t SpacePacketReader::checkSize() const { + if (isNull()) { + return HasReturnvaluesIF::RETURN_FAILED; + } if (getFullPacketLen() > bufSize) { return SerializeIF::STREAM_TOO_SHORT; } @@ -33,7 +36,9 @@ uint16_t SpacePacketReader::getPacketDataLen() const { return ccsds::getPacketLe ReturnValue_t SpacePacketReader::setInternalFields(const uint8_t* data, size_t maxSize_) { bufSize = maxSize_; spHeader = reinterpret_cast(data); - packetDataField = data + ccsds::HEADER_LEN; + if (maxSize_ > 6) { + packetDataField = data + ccsds::HEADER_LEN; + } return checkSize(); } diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h index b35b813b..0d075bae 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h @@ -62,11 +62,6 @@ class SpacePacketReader : public SpacePacketIF, */ [[nodiscard]] size_t getBufSize() const; - /** - * CCSDS header always has 6 bytes - * @return - */ - static constexpr size_t getHeaderLen() { return ccsds::HEADER_LEN; } [[nodiscard]] uint16_t getPacketIdRaw() const override; [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; diff --git a/src/fsfw/tmtcpacket/ccsds/header.cpp b/src/fsfw/tmtcpacket/ccsds/header.cpp index b7aa270e..b87ab5b3 100644 --- a/src/fsfw/tmtcpacket/ccsds/header.cpp +++ b/src/fsfw/tmtcpacket/ccsds/header.cpp @@ -1,7 +1,7 @@ #include "header.h" uint16_t ccsds::getPacketId(const PrimaryHeader &header) { - return ((header.packetIdHAndVersion & 0x1F00) << 8) + header.packetIdL; + return ((header.packetIdHAndVersion & 0x1F) << 8) + header.packetIdL; } uint16_t ccsds::getPacketSeqCtrl(const PrimaryHeader &header) { diff --git a/unittests/tmtcpacket/testCcsdsReader.cpp b/unittests/tmtcpacket/testCcsdsReader.cpp index 89ee5a46..655c34e2 100644 --- a/unittests/tmtcpacket/testCcsdsReader.cpp +++ b/unittests/tmtcpacket/testCcsdsReader.cpp @@ -1,5 +1,54 @@ +#include #include +#include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" -TEST_CASE("CCSDS Reader", "[ccsds-reader]") {} \ No newline at end of file +TEST_CASE("CCSDS Reader", "[ccsds-reader]") { + auto params = SpacePacketParams(PacketId(ccsds::PacketType::TC, true, 0x02), + PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16); + SpacePacketCreator base = SpacePacketCreator(params); + // This is enough to hold 0x16 (22) bytes + 6 (SP header length) + 1 as defined as the full packet + // length derived from the length field + std::array buf{}; + uint8_t* bufPtr = buf.data(); + size_t serLen = 0; + SpacePacketReader reader; + SECTION("Empty Reader") { + REQUIRE(reader.isNull()); + REQUIRE(reader.checkSize() == HasReturnvaluesIF::RETURN_FAILED); + } + + SECTION("Basic Read") { + REQUIRE(base.serialize(&bufPtr, &serLen, buf.size(), SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); + reader.setReadOnlyData(buf.data(), SpacePacketIF::getHeaderLen()); + REQUIRE(reader.getPacketDataLen() == 0x16); + REQUIRE(reader.getFullData() == buf.data()); + REQUIRE(reader.getFullPacketLen() == 0x16 + SpacePacketReader::getHeaderLen() + 1); + REQUIRE(reader.getPacketIdRaw() == 0x1802); + REQUIRE(reader.getSequenceFlags() == ccsds::SequenceFlags::FIRST_SEGMENT); + REQUIRE(reader.getSequenceCount() == 0x34); + REQUIRE(reader.getPacketSeqCtrlRaw() == 0x4034); + REQUIRE(reader.hasSecHeader()); + REQUIRE(reader.getApid() == 0x02); + REQUIRE(not reader.isNull()); + // We only serialized the 6 bytes of the header, so the packer data should be invalid + REQUIRE(reader.getPacketData() == nullptr); + } + + SECTION("Read with additional data") { + REQUIRE(base.serialize(&bufPtr, &serLen, buf.size(), SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.setReadOnlyData(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.getPacketData() == buf.data() + SpacePacketIF::getHeaderLen()); + } + + SECTION("Invalid Size") { + for (size_t i = 0; i < 5; i++) { + REQUIRE(reader.setReadOnlyData(buf.data(), i) == SerializeIF::STREAM_TOO_SHORT); + REQUIRE(not reader.isNull()); + REQUIRE(reader.getPacketData() == nullptr); + } + } +} \ No newline at end of file From 5af3138e81df3bfee27436a48206851f1d5a0b26 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 21 Jul 2022 17:48:11 +0200 Subject: [PATCH 064/532] fnished PUS TC creator unittests --- src/fsfw/tmtcpacket/ccsds/PacketId.h | 4 + .../tmtcpacket/ccsds/SpacePacketCreator.cpp | 4 + .../tmtcpacket/ccsds/SpacePacketCreator.h | 1 + src/fsfw/tmtcpacket/pus/PusIF.h | 4 +- src/fsfw/tmtcpacket/pus/defs.h | 13 ++ src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 18 ++- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 14 +- unittests/devicehandler/CMakeLists.txt | 4 - .../devicehandler/TestDeviceHandlerBase.cpp | 8 +- unittests/mocks/CMakeLists.txt | 4 + .../{devicehandler => mocks}/ComIFMock.cpp | 0 .../{devicehandler => mocks}/ComIFMock.h | 0 .../{devicehandler => mocks}/CookieIFMock.cpp | 0 .../{devicehandler => mocks}/CookieIFMock.h | 0 .../DeviceFdirMock.cpp | 4 +- .../{devicehandler => mocks}/DeviceFdirMock.h | 0 .../DeviceHandlerMock.cpp | 0 .../DeviceHandlerMock.h | 0 unittests/mocks/SimpleSerializable.h | 35 +++++ unittests/tmtcpacket/CMakeLists.txt | 1 + unittests/tmtcpacket/testCcsdsReader.cpp | 35 +++-- unittests/tmtcpacket/testPusTcCreator.cpp | 120 ++++++++++++++++++ 22 files changed, 239 insertions(+), 30 deletions(-) rename unittests/{devicehandler => mocks}/ComIFMock.cpp (100%) rename unittests/{devicehandler => mocks}/ComIFMock.h (100%) rename unittests/{devicehandler => mocks}/CookieIFMock.cpp (100%) rename unittests/{devicehandler => mocks}/CookieIFMock.h (100%) rename unittests/{devicehandler => mocks}/DeviceFdirMock.cpp (86%) rename unittests/{devicehandler => mocks}/DeviceFdirMock.h (100%) rename unittests/{devicehandler => mocks}/DeviceHandlerMock.cpp (100%) rename unittests/{devicehandler => mocks}/DeviceHandlerMock.h (100%) create mode 100644 unittests/mocks/SimpleSerializable.h create mode 100644 unittests/tmtcpacket/testPusTcCreator.cpp diff --git a/src/fsfw/tmtcpacket/ccsds/PacketId.h b/src/fsfw/tmtcpacket/ccsds/PacketId.h index 49587483..29b82f13 100644 --- a/src/fsfw/tmtcpacket/ccsds/PacketId.h +++ b/src/fsfw/tmtcpacket/ccsds/PacketId.h @@ -19,6 +19,10 @@ struct PacketId : public SerializeIF { PacketId(ccsds::PacketType packetType_, bool secHeaderFlag_, uint16_t apid_) : packetType(packetType_), secHeaderFlag(secHeaderFlag_), apid(apid_) {} + bool operator==(const PacketId &other) const { + return packetType == other.packetType and secHeaderFlag == other.secHeaderFlag and + apid == other.apid; + } /** * NOTE: If the APID has an invalid value, the invalid bits will be cut off * @return diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp index 94cf45f4..7ae8656f 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp @@ -79,3 +79,7 @@ void SpacePacketCreator::checkFieldValidity() { void SpacePacketCreator::setParams(SpacePacketParams params_) { params = std::move(params_); } SpacePacketParams &SpacePacketCreator::getParams() { return params; } + +void SpacePacketCreator::setPacketType(ccsds::PacketType type) { + params.packetId.packetType = type; +} diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h index dd5edbd5..de62283f 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h @@ -35,6 +35,7 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF { SpacePacketParams &getParams(); void setParams(SpacePacketParams params); + void setPacketType(ccsds::PacketType type); void setApid(uint16_t apid); void setSeqCount(uint16_t seqCount); void setSeqFlags(ccsds::SequenceFlags flags); diff --git a/src/fsfw/tmtcpacket/pus/PusIF.h b/src/fsfw/tmtcpacket/pus/PusIF.h index 8a15f01e..8c346b1d 100644 --- a/src/fsfw/tmtcpacket/pus/PusIF.h +++ b/src/fsfw/tmtcpacket/pus/PusIF.h @@ -9,8 +9,10 @@ class PusIF : public SpacePacketIF { public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::PUS_IF; - static constexpr ReturnValue_t INVALID_CRC_16 = + static constexpr ReturnValue_t INVALID_PUS_VERSION = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); + static constexpr ReturnValue_t INVALID_CRC_16 = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); ~PusIF() override = default; /** diff --git a/src/fsfw/tmtcpacket/pus/defs.h b/src/fsfw/tmtcpacket/pus/defs.h index 027ff37c..83502ed3 100644 --- a/src/fsfw/tmtcpacket/pus/defs.h +++ b/src/fsfw/tmtcpacket/pus/defs.h @@ -2,6 +2,7 @@ #define FSFW_SRC_FSFW_TMTCPACKET_PUS_TM_DEFINITIONS_H_ #include +#include #include "fsfw/serialize/SerializeIF.h" @@ -27,6 +28,7 @@ union DataUnion { struct DataWrapper { DataTypes type; DataUnion dataUnion; + using BufPairT = std::pair; [[nodiscard]] size_t getLength() const { if (type == DataTypes::RAW) { @@ -36,6 +38,17 @@ struct DataWrapper { } return 0; } + + void setRawData(BufPairT bufPair) { + type = DataTypes::RAW; + dataUnion.raw.data = bufPair.first; + dataUnion.raw.len = bufPair.second; + } + + void setSerializable(SerializeIF* serializable) { + type = DataTypes::SERIALIZABLE; + dataUnion.serializable = serializable; + } }; /** diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index bd824d24..2ff82d25 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -8,29 +8,31 @@ PusTcCreator::PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams) : spCreator(std::move(spParams)), pusParams(pusParams) { + spCreator.setPacketType(ccsds::PacketType::TC); updateSpLengthField(); } ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { + const uint8_t *start = *buffer; size_t userDataLen = pusParams.dataWrapper.getLength(); - if (*size + PusTcIF::MIN_SIZE + userDataLen > maxSize) { + if (*size + getFullPacketLen() > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } + if (pusParams.pusVersion != ecss::PusVersion::PUS_C) { + return PusIF::INVALID_PUS_VERSION; + } ReturnValue_t result = spCreator.serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - if (pusParams.pusVersion != ecss::PusVersion::PUS_C) { - // TODO: Dedicated returnvalue - return HasReturnvaluesIF::RETURN_FAILED; - } **buffer = pusParams.pusVersion << 4 | pusParams.ackFlags; *buffer += 1; **buffer = pusParams.service; *buffer += 1; **buffer = pusParams.subservice; *buffer += 1; + *size += 3; result = SerializeAdapter::serialize(&pusParams.sourceId, buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { @@ -52,7 +54,7 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max } } - uint16_t crc16 = CRC::crc16ccitt(*buffer, getFullPacketLen() - 2); + uint16_t crc16 = CRC::crc16ccitt(start, getFullPacketLen() - 2); return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness); } @@ -89,3 +91,7 @@ ecss::DataWrapper &PusTcCreator::getDataWrapper() { return pusParams.dataWrapper PusTcParams &PusTcCreator::getPusParams() { return pusParams; } SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } + +ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize) { + return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); +} diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 1f6e8acb..c09a7238 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -21,13 +21,19 @@ struct PusTcParams { class PusTcCreator : public PusTcIF, public SerializeIF, public CreatorDataIF { public: - PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams); + PusTcCreator(SpacePacketParams initSpParams, PusTcParams initPusParams); + /** + * If the parameter structure is changed in a way which changes the resulting serialized packet + * size, this function should be called to set the data length field in the space packet + * header. This fields is the primary source of information for length information. + * + * The only case for a telecommand where this size changes would be if user data is set. + */ void updateSpLengthField(); PusTcParams &getPusParams(); SpacePacketParams &getSpParams(); - 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); [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; @@ -42,6 +48,8 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CreatorDataIF { ecss::DataWrapper &getDataWrapper() override; private: + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override; SpacePacketCreator spCreator; PusTcParams pusParams; }; diff --git a/unittests/devicehandler/CMakeLists.txt b/unittests/devicehandler/CMakeLists.txt index 7ad5d316..5d4d9b06 100644 --- a/unittests/devicehandler/CMakeLists.txt +++ b/unittests/devicehandler/CMakeLists.txt @@ -1,8 +1,4 @@ target_sources(${FSFW_TEST_TGT} PRIVATE - CookieIFMock.cpp - ComIFMock.cpp DeviceHandlerCommander.cpp - DeviceHandlerMock.cpp - DeviceFdirMock.cpp TestDeviceHandlerBase.cpp ) diff --git a/unittests/devicehandler/TestDeviceHandlerBase.cpp b/unittests/devicehandler/TestDeviceHandlerBase.cpp index e8fdd17b..0a1b18fa 100644 --- a/unittests/devicehandler/TestDeviceHandlerBase.cpp +++ b/unittests/devicehandler/TestDeviceHandlerBase.cpp @@ -1,10 +1,10 @@ #include -#include "ComIFMock.h" -#include "DeviceFdirMock.h" #include "DeviceHandlerCommander.h" -#include "DeviceHandlerMock.h" -#include "devicehandler/CookieIFMock.h" +#include "mocks/ComIFMock.h" +#include "mocks/CookieIFMock.h" +#include "mocks/DeviceFdirMock.h" +#include "mocks/DeviceHandlerMock.h" #include "objects/systemObjectList.h" TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 1b86547c..50a34ce8 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -1,3 +1,7 @@ target_sources(${FSFW_TEST_TGT} PRIVATE PowerSwitcherMock.cpp + DeviceHandlerMock.cpp + DeviceFdirMock.cpp + CookieIFMock.cpp + ComIFMock.cpp ) diff --git a/unittests/devicehandler/ComIFMock.cpp b/unittests/mocks/ComIFMock.cpp similarity index 100% rename from unittests/devicehandler/ComIFMock.cpp rename to unittests/mocks/ComIFMock.cpp diff --git a/unittests/devicehandler/ComIFMock.h b/unittests/mocks/ComIFMock.h similarity index 100% rename from unittests/devicehandler/ComIFMock.h rename to unittests/mocks/ComIFMock.h diff --git a/unittests/devicehandler/CookieIFMock.cpp b/unittests/mocks/CookieIFMock.cpp similarity index 100% rename from unittests/devicehandler/CookieIFMock.cpp rename to unittests/mocks/CookieIFMock.cpp diff --git a/unittests/devicehandler/CookieIFMock.h b/unittests/mocks/CookieIFMock.h similarity index 100% rename from unittests/devicehandler/CookieIFMock.h rename to unittests/mocks/CookieIFMock.h diff --git a/unittests/devicehandler/DeviceFdirMock.cpp b/unittests/mocks/DeviceFdirMock.cpp similarity index 86% rename from unittests/devicehandler/DeviceFdirMock.cpp rename to unittests/mocks/DeviceFdirMock.cpp index e3ac39ac..5dcd985d 100644 --- a/unittests/devicehandler/DeviceFdirMock.cpp +++ b/unittests/mocks/DeviceFdirMock.cpp @@ -1,11 +1,9 @@ #include "DeviceFdirMock.h" -#include "devicehandler/DeviceFdirMock.h" - DeviceFdirMock::DeviceFdirMock(object_id_t owner, object_id_t parent) : DeviceHandlerFailureIsolation(owner, parent) {} -DeviceFdirMock::~DeviceFdirMock() {} +DeviceFdirMock::~DeviceFdirMock() = default; uint32_t DeviceFdirMock::getMissedReplyCount() { ParameterWrapper parameterWrapper; diff --git a/unittests/devicehandler/DeviceFdirMock.h b/unittests/mocks/DeviceFdirMock.h similarity index 100% rename from unittests/devicehandler/DeviceFdirMock.h rename to unittests/mocks/DeviceFdirMock.h diff --git a/unittests/devicehandler/DeviceHandlerMock.cpp b/unittests/mocks/DeviceHandlerMock.cpp similarity index 100% rename from unittests/devicehandler/DeviceHandlerMock.cpp rename to unittests/mocks/DeviceHandlerMock.cpp diff --git a/unittests/devicehandler/DeviceHandlerMock.h b/unittests/mocks/DeviceHandlerMock.h similarity index 100% rename from unittests/devicehandler/DeviceHandlerMock.h rename to unittests/mocks/DeviceHandlerMock.h diff --git a/unittests/mocks/SimpleSerializable.h b/unittests/mocks/SimpleSerializable.h new file mode 100644 index 00000000..399e2826 --- /dev/null +++ b/unittests/mocks/SimpleSerializable.h @@ -0,0 +1,35 @@ +#ifndef FSFW_TESTS_SIMPLESERIALIZABLE_H +#define FSFW_TESTS_SIMPLESERIALIZABLE_H + +#include "fsfw/serialize.h" + +class SimpleSerializable : public SerializeIF { + public: + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override { + if (*size + getSerializedSize() > maxSize) { + return SerializeIF::BUFFER_TOO_SHORT; + } + **buffer = someU8; + *buffer += 1; + *size += 1; + return SerializeAdapter::serialize(&someU16, buffer, size, maxSize, streamEndianness); + } + + [[nodiscard]] size_t getSerializedSize() const override { return 3; } + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override { + if (*size < getSerializedSize()) { + return SerializeIF::STREAM_TOO_SHORT; + } + someU8 = **buffer; + *size -= 1; + return SerializeAdapter::deSerialize(&someU16, buffer, size, streamEndianness); + } + + private: + uint8_t someU8 = 1; + uint16_t someU16 = 0x0203; +}; + +#endif // FSFW_TESTS_SIMPLESERIALIZABLE_H diff --git a/unittests/tmtcpacket/CMakeLists.txt b/unittests/tmtcpacket/CMakeLists.txt index 9a08868e..67d8858c 100644 --- a/unittests/tmtcpacket/CMakeLists.txt +++ b/unittests/tmtcpacket/CMakeLists.txt @@ -1,4 +1,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testCcsdsCreator.cpp testCcsdsReader.cpp + testPusTcCreator.cpp ) diff --git a/unittests/tmtcpacket/testCcsdsReader.cpp b/unittests/tmtcpacket/testCcsdsReader.cpp index 655c34e2..75b4af87 100644 --- a/unittests/tmtcpacket/testCcsdsReader.cpp +++ b/unittests/tmtcpacket/testCcsdsReader.cpp @@ -4,26 +4,22 @@ #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" +#define FULL_PACKET_LEN 29 + TEST_CASE("CCSDS Reader", "[ccsds-reader]") { auto params = SpacePacketParams(PacketId(ccsds::PacketType::TC, true, 0x02), PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16); SpacePacketCreator base = SpacePacketCreator(params); // This is enough to hold 0x16 (22) bytes + 6 (SP header length) + 1 as defined as the full packet // length derived from the length field - std::array buf{}; + std::array buf{}; uint8_t* bufPtr = buf.data(); size_t serLen = 0; SpacePacketReader reader; - SECTION("Empty Reader") { - REQUIRE(reader.isNull()); - REQUIRE(reader.checkSize() == HasReturnvaluesIF::RETURN_FAILED); - } - SECTION("Basic Read") { - REQUIRE(base.serialize(&bufPtr, &serLen, buf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); - reader.setReadOnlyData(buf.data(), SpacePacketIF::getHeaderLen()); + auto checkReader = [&](SpacePacketReader& reader) { REQUIRE(reader.getPacketDataLen() == 0x16); + REQUIRE(reader.getBufSize() == SpacePacketIF::getHeaderLen()); REQUIRE(reader.getFullData() == buf.data()); REQUIRE(reader.getFullPacketLen() == 0x16 + SpacePacketReader::getHeaderLen() + 1); REQUIRE(reader.getPacketIdRaw() == 0x1802); @@ -35,12 +31,33 @@ TEST_CASE("CCSDS Reader", "[ccsds-reader]") { REQUIRE(not reader.isNull()); // We only serialized the 6 bytes of the header, so the packer data should be invalid REQUIRE(reader.getPacketData() == nullptr); + }; + + SECTION("Empty Reader") { + REQUIRE(SpacePacketIF::getHeaderLen() == 6); + REQUIRE(reader.isNull()); + REQUIRE(reader.checkSize() == HasReturnvaluesIF::RETURN_FAILED); + } + + SECTION("Basic Read") { + REQUIRE(base.serialize(&bufPtr, &serLen, buf.size(), SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); + SECTION("Setter") { + reader.setReadOnlyData(buf.data(), SpacePacketIF::getHeaderLen()); + checkReader(reader); + } + SECTION("Direct Construction") { + SpacePacketReader secondReader(buf.data(), serLen); + checkReader(secondReader); + } } SECTION("Read with additional data") { REQUIRE(base.serialize(&bufPtr, &serLen, buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.setReadOnlyData(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.getBufSize() == buf.size()); + REQUIRE(reader.getFullPacketLen() == FULL_PACKET_LEN); REQUIRE(reader.getPacketData() == buf.data() + SpacePacketIF::getHeaderLen()); } diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp new file mode 100644 index 00000000..f6c15b78 --- /dev/null +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -0,0 +1,120 @@ +#include +#include + +#include "fsfw/globalfunctions/CRC.h" +#include "fsfw/tmtcpacket/pus/tc.h" +#include "mocks/SimpleSerializable.h" + +TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { + auto packetId = PacketId(ccsds::PacketType::TC, true, 0x02); + auto spParams = + SpacePacketParams(packetId, PacketSeqCtrl(ccsds::SequenceFlags::UNSEGMENTED, 0x34), 0x00); + auto pusParams = PusTcParams(17, 1); + PusTcCreator creator(spParams, pusParams); + std::array buf{}; + uint8_t* dataPtr = buf.data(); + size_t serLen = 0; + + SECTION("State") { + REQUIRE(creator.getService() == 17); + REQUIRE(creator.getSubService() == 1); + REQUIRE(creator.getApid() == 0x02); + REQUIRE(creator.getPusVersion() == 2); + REQUIRE(creator.getAcknowledgeFlags() == 0b1111); + REQUIRE(creator.getSourceId() == 0x00); + REQUIRE(creator.getPacketSeqCtrlRaw() == 0xc034); + // bytes CCSDS header, 5 bytes secondary header, 2 bytes CRC, 3 bytes app data + REQUIRE(creator.getFullPacketLen() == 13); + // The data length field is the full packet length minus the primary header minus 1 + REQUIRE(creator.getPacketDataLen() == 6); + auto& paramsLocal = creator.getSpParams(); + REQUIRE(paramsLocal.packetId == packetId); + } + + SECTION("Serialized") { + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(serLen == 13); + REQUIRE(buf[0] == 0x18); + REQUIRE(buf[1] == 0x02); + // Unsegmented, first 2 bits 11 + REQUIRE(buf[2] == 0xc0); + // Packet Sequence count only occupies lower byte of packet sequence control + REQUIRE(buf[3] == 0x34); + // Data length packed big endian + REQUIRE(buf[4] == 0x00); + REQUIRE(buf[5] == 0x06); + // PUS Version C (2) + REQUIRE(((buf[6] >> 4) & 0b1111) == 2); + // All Ack Fields is default + REQUIRE((buf[6] & 0b1111) == 0b1111); + // Service and subservice + REQUIRE(buf[7] == 17); + REQUIRE(buf[8] == 1); + // Source ID is 0 + REQUIRE(((buf[9] << 8) | buf[10]) == 0); + // CRC16 check + REQUIRE(CRC::crc16ccitt(buf.data(), serLen) == 0); + } + + SECTION("Custom Source ID") { + auto& params = creator.getPusParams(); + params.sourceId = 0x5ff; + REQUIRE(creator.getSourceId() == 0x5ff); + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(((buf[9] << 8) | buf[10]) == 0x5ff); + } + + SECTION("Test with Application Data Raw") { + auto& params = creator.getPusParams(); + std::array data{1, 2, 3}; + params.dataWrapper.setRawData({data.data(), data.size()}); + // To get correct size information, the SP length field needs to be updated automatically + REQUIRE(creator.getSerializedSize() == 13); + creator.updateSpLengthField(); + REQUIRE(creator.getSerializedSize() == 16); + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(serLen == 16); + REQUIRE(buf[11] == 1); + REQUIRE(buf[12] == 2); + REQUIRE(buf[13] == 3); + } + + SECTION("Test with Application Data Serializable") { + auto& params = creator.getPusParams(); + auto simpleSer = SimpleSerializable(); + params.dataWrapper.setSerializable(&simpleSer); + auto& dataWrapper = creator.getDataWrapper(); + REQUIRE(dataWrapper.type == ecss::DataTypes::SERIALIZABLE); + REQUIRE(dataWrapper.dataUnion.serializable == &simpleSer); + REQUIRE(creator.getSerializedSize() == 13); + creator.updateSpLengthField(); + REQUIRE(creator.getSerializedSize() == 16); + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(serLen == 16); + REQUIRE(buf[11] == 1); + REQUIRE(buf[12] == 2); + REQUIRE(buf[13] == 3); + } + + SECTION("Deserialization Fails") { + size_t deserLen = buf.size(); + const uint8_t* roPtr = buf.data(); + REQUIRE(creator.deSerialize(&roPtr, &deserLen, SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_FAILED); + } + + SECTION("Serialize with invalid buffer length") { + size_t reqSize = creator.getSerializedSize(); + for (size_t maxSize = 0; maxSize < reqSize; maxSize++) { + dataPtr = buf.data(); + serLen = 0; + REQUIRE(creator.serialize(&dataPtr, &serLen, maxSize) == SerializeIF::BUFFER_TOO_SHORT); + } + } + + SECTION("Invalid PUS Version") { + auto& params = creator.getPusParams(); + params.pusVersion = 0; + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == PusIF::INVALID_PUS_VERSION); + } +} \ No newline at end of file From 61bc867bede37c2f537c338142b4855adeea1a5c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 21 Jul 2022 17:57:31 +0200 Subject: [PATCH 065/532] delete code which is not used anymore --- .../pus/Service1TelecommandVerification.cpp | 1 - src/fsfw/pus/Service5EventReporting.cpp | 1 - src/fsfw/tmtcpacket/cfdp/CfdpPacketStored.h | 2 +- src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt | 2 - src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp | 99 ------------- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h | 69 --------- .../tmtcpacket/pus/tc/TcPacketStoredBase.cpp | 64 --------- .../tmtcpacket/pus/tc/TcPacketStoredBase.h | 84 ----------- src/fsfw/tmtcpacket/pus/tm.h | 13 +- src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp | 63 -------- src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h | 135 ------------------ src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp | 79 ---------- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h | 126 ---------------- src/fsfw/tmtcpacket/pus/tm/TmPacketStored.h | 12 -- .../tmtcpacket/pus/tm/TmPacketStoredBase.cpp | 121 ---------------- .../tmtcpacket/pus/tm/TmPacketStoredBase.h | 86 ----------- .../tmtcpacket/pus/tm/TmPacketStoredPusC.cpp | 76 ---------- .../tmtcpacket/pus/tm/TmPacketStoredPusC.h | 73 ---------- unittests/CatchFactory.cpp | 1 - 19 files changed, 3 insertions(+), 1104 deletions(-) delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketStored.h delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.h delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 4b326096..35957ba0 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -3,7 +3,6 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/pus/servicepackets/Service1Packets.h" -#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" #include "fsfw/tmtcservices/tmHelpers.h" diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index a0cbc316..31cc72f5 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -5,7 +5,6 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/pus/servicepackets/Service5Packets.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h" #include "fsfw/tmtcservices/tmHelpers.h" Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t apid, diff --git a/src/fsfw/tmtcpacket/cfdp/CfdpPacketStored.h b/src/fsfw/tmtcpacket/cfdp/CfdpPacketStored.h index 54f8e5be..60a9524f 100644 --- a/src/fsfw/tmtcpacket/cfdp/CfdpPacketStored.h +++ b/src/fsfw/tmtcpacket/cfdp/CfdpPacketStored.h @@ -1,8 +1,8 @@ #ifndef FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_ #define FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_ -#include "../pus/tc/TcPacketStoredBase.h" #include "CfdpPacket.h" +#include "fsfw/storagemanager/storeAddress.h" class CfdpPacketStored : public CfdpReader { public: diff --git a/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt b/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt index d2e30586..adf7f34d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/pus/tc/CMakeLists.txt @@ -1,4 +1,2 @@ target_sources(${LIB_FSFW_NAME} PRIVATE PusTcReader.cpp PusTcReader.cpp PusTcCreator.cpp) - -# TcPacketPus.cpp diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp deleted file mode 100644 index 06f980b7..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "TcPacketPus.h" - -#include - -#include "fsfw/globalfunctions/CRC.h" - -TcPacketPus::TcPacketPus(const uint8_t *setData) : TcPacketPusBase(setData) { - tcData = reinterpret_cast(const_cast(setData)); -} - -void TcPacketPus::initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack, - uint8_t service, uint8_t subservice, - ecss::PusVersion pusVersion, uint16_t sourceId) { - initSpacePacketHeader(true, true, apid, sequenceCount); - std::memset(&tcData->dataField, 0, sizeof(tcData->dataField)); - setPacketDataLength(sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1); - // Data Field Header. For PUS A, the first bit (CCSDS Secondary Header Flag) is zero - tcData->dataField.versionTypeAck = pusVersion << 4 | (ack & 0x0F); - tcData->dataField.serviceType = service; - tcData->dataField.serviceSubtype = subservice; -#if FSFW_USE_PUS_C_TELECOMMANDS == 1 - tcData->dataField.sourceIdH = (sourceId >> 8) | 0xff; - tcData->dataField.sourceIdL = sourceId & 0xff; -#else - tcData->dataField.sourceId = sourceId; -#endif -} - -uint8_t TcPacketPus::getService() const { return tcData->dataField.serviceType; } - -uint8_t TcPacketPus::getSubService() const { return tcData->dataField.serviceSubtype; } - -uint8_t TcPacketPus::getAcknowledgeFlags() const { - return tcData->dataField.versionTypeAck & 0b00001111; -} - -const uint8_t *TcPacketPus::getApplicationData() const { return &tcData->appData; } - -uint16_t TcPacketPus::getApplicationDataSize() const { - return SpacePacketReader::getPacketDataLen() - sizeof(tcData->dataField) - CRC_SIZE + 1; -} - -uint16_t TcPacketPus::getErrorControl() const { - uint16_t size = getApplicationDataSize() + CRC_SIZE; - uint8_t *p_to_buffer = &tcData->appData; - return (p_to_buffer[size - 2] << 8) + p_to_buffer[size - 1]; -} - -void TcPacketPus::setErrorControl() { - uint32_t full_size = getFullSize(); - uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE); - uint32_t size = getApplicationDataSize(); - (&tcData->appData)[size] = (crc & 0XFF00) >> 8; // CRCH - (&tcData->appData)[size + 1] = (crc)&0X00FF; // CRCL -} - -uint8_t TcPacketPus::getSecondaryHeaderFlag() const { -#if FSFW_USE_PUS_C_TELECOMMANDS == 1 - // Does not exist for PUS C - return 0; -#else - return (tcData->dataField.versionTypeAck & 0b10000000) >> 7; -#endif -} - -uint8_t TcPacketPus::getPusVersionNumber() const { -#if FSFW_USE_PUS_C_TELECOMMANDS == 1 - return (tcData->dataField.versionTypeAck & 0b11110000) >> 4; -#else - return (tcData->dataField.versionTypeAck & 0b01110000) >> 4; -#endif -} - -uint16_t TcPacketPus::getSourceId() const { -#if FSFW_USE_PUS_C_TELECOMMANDS == 1 - return (tcData->dataField.sourceIdH << 8) | tcData->dataField.sourceIdL; -#else - return tcData->dataField.sourceId; -#endif -} - -size_t TcPacketPus::calculateFullPacketLength(size_t appDataLen) const { - return sizeof(CCSDSPrimaryHeader) + sizeof(PUSTcDataFieldHeader) + appDataLen + - TcPacketPusBase::CRC_SIZE; -} - -ReturnValue_t TcPacketPus::setData(uint8_t *dataPtr, size_t maxSize, void *args) { - ReturnValue_t result = SpacePacketReader::setData(dataPtr, maxSize, args); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - if (maxSize < sizeof(TcPacketPointer)) { - return HasReturnvaluesIF::RETURN_FAILED; - } - // This function is const-correct, but it was decided to keep the pointer non-const - // for convenience. Therefore, cast away constness here and then cast to packet type. - tcData = reinterpret_cast(const_cast(dataPtr)); - return HasReturnvaluesIF::RETURN_OK; -} diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h deleted file mode 100644 index 8af6125a..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_ -#define FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_ - -#include - -#include "../defs.h" -#include "PusTcReader.h" -#include "fsfw/FSFW.h" -#include "fsfw/tmtcpacket/ccsds/defs.h" - -/** - * This struct defines the data structure of a PUS Telecommand A packet when - * accessed via a pointer. - * @ingroup tmtcpackets - */ -/* -struct TcPacketPointer { - CCSDSPrimaryHeader primary; - PusTcDataFieldHeader dataField; - uint8_t appData; -}; - */ - -// class TcPacketPus : public TcPacketPusBase { -// public: -// /** -// * Initialize a PUS A telecommand packet which already exists. You can also -// * create an empty (invalid) object by passing nullptr as the data pointer -// * @param setData -// */ -// TcPacketPus(const uint8_t* setData); -// -// // Base class overrides -// uint8_t getSecondaryHeaderFlag() const override; -// uint8_t getPusVersionNumber() const override; -// uint8_t getAcknowledgeFlags() const override; -// uint8_t getService() const override; -// uint8_t getSubService() const override; -// uint16_t getSourceId() const override; -// const uint8_t* getApplicationData() const override; -// uint16_t getApplicationDataSize() const override; -// uint16_t getErrorControl() const override; -// void setErrorControl() override; -// size_t calculateFullPacketLength(size_t appDataLen) const override; -// -// protected: -// ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) override; -// -// /** -// * Initializes the Tc Packet header. -// * @param apid APID used. -// * @param sequenceCount Sequence Count in the primary header. -// * @param ack Which acknowledeges are expected from the receiver. -// * @param service PUS Service -// * @param subservice PUS Subservice -// */ -// void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack, uint8_t service, -// uint8_t subservice, pus::PusVersion pusVersion, uint16_t sourceId = 0); -// -// /** -// * A pointer to a structure which defines the data structure of -// * the packet's data. -// * -// * To be hardware-safe, all elements are of byte size. -// */ -// TcPacketPointer* tcData = nullptr; -// }; - -#endif /* FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp deleted file mode 100644 index 88964bfb..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h" - -#include - -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/objectmanager/frameworkObjects.h" -#include "fsfw/serviceinterface/ServiceInterface.h" - -// StorageManagerIF* TcPacketStoredBase::STORE = nullptr; -// -// TcPacketStoredBase::TcPacketStoredBase() { -// this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; -// TcPacketStoredBase::checkAndSetStore(); -// } -// -// TcPacketStoredBase::~TcPacketStoredBase() = default; -// -// ReturnValue_t TcPacketStoredBase::getData(const uint8_t** dataPtr, size_t* dataSize) { -// auto result = TcPacketStoredBase::STORE->getData(storeAddress, dataPtr, dataSize); -// if (result != HasReturnvaluesIF::RETURN_OK) { -//#if FSFW_CPP_OSTREAM_ENABLED == 1 -// sif::warning << "TcPacketStoredBase: Could not get data" << std::endl; -//#else -// sif::printWarning("TcPacketStoredBase: Could not get data!\n"); -//#endif -// } -// return result; -// } -// -// bool TcPacketStoredBase::checkAndSetStore() { -// if (TcPacketStoredBase::STORE == nullptr) { -// TcPacketStoredBase::STORE = -// ObjectManager::instance()->get(objects::TC_STORE); if -// (TcPacketStoredBase::STORE == nullptr) { -//#if FSFW_CPP_OSTREAM_ENABLED == 1 -// sif::error << "TcPacketStoredBase::TcPacketStoredBase: TC Store not found" << std::endl; -//#else -// sif::printError("TcPacketStoredBase::TcPacketStoredBase: TC Store not found\n"); -//#endif -// return false; -// } -// } -// return true; -// } -// -// void TcPacketStoredBase::setStoreAddress(store_address_t setAddress, -// RedirectableDataPointerIF* packet) { -// this->storeAddress = setAddress; -// const uint8_t* tempData = nullptr; -// size_t tempSize; -// ReturnValue_t status = StorageManagerIF::RETURN_FAILED; -// if (this->checkAndSetStore()) { -// status = TcPacketStoredBase::STORE->getData(this->storeAddress, &tempData, &tempSize); -// } -// -// if (status == StorageManagerIF::RETURN_OK) { -// packet->setData(const_cast(tempData), tempSize); -// } else { -// packet->setData(nullptr, -1); -// this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; -// } -// } -// -// store_address_t TcPacketStoredBase::getStoreAddress() { return this->storeAddress; } diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h deleted file mode 100644 index 8291ac6c..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef TMTCPACKET_PUS_TCPACKETSTORED_H_ -#define TMTCPACKET_PUS_TCPACKETSTORED_H_ - -#include "PusTcReader.h" -#include "TcPacketStoredIF.h" -#include "fsfw/storagemanager/StorageManagerIF.h" - -///** -// * Base class for telecommand packets like CFDP or PUS packets. -// * @ingroup tmtcpackets -// */ -// class TcPacketStoredBase : public TcPacketStoredIF { -// public: -// /** -// * This is a default constructor which does not set the data pointer to initialize -// * with an empty cached store address -// */ -// TcPacketStoredBase(); -// /** -// * Constructor to set to an existing store address. -// * @param setAddress -// */ -// explicit TcPacketStoredBase(store_address_t setAddress); -// /** -// * Another constructor to create a TcPacket from a raw packet stream. -// * Takes the data and adds it unchecked to the TcStore. -// * @param data Pointer to the complete TC Space Packet. -// * @param Size size of the packet. -// */ -// TcPacketStoredBase(const uint8_t* data, uint32_t size); -// -// virtual ~TcPacketStoredBase(); -// -// /** -// * Getter function for the raw data. -// * @param dataPtr [out] Pointer to the data pointer to set -// * @param dataSize [out] Address of size to set. -// * @return -@c RETURN_OK if data was retrieved successfully. -// */ -// ReturnValue_t getData(const uint8_t** dataPtr, size_t* dataSize) override; -// -// void setStoreAddress(store_address_t setAddress, RedirectableDataPointerIF* packet) override; -// store_address_t getStoreAddress() override; -// -// /** -// * With this call, the packet is deleted. -// * It removes itself from the store and sets its data pointer to NULL. -// * @return returncode from deleting the data. -// */ -// virtual ReturnValue_t deletePacket() = 0; -// -// /** -// * This method performs a size check. -// * It reads the stored size and compares it with the size entered in the -// * packet header. This class is the optimal place for such a check as it -// * has access to both the header data and the store. -// * @return true if size is correct, false if packet is not registered in -// * store or size is incorrect. -// */ -// virtual bool isSizeCorrect() = 0; -// -// protected: -// /** -// * This is a pointer to the store all instances of the class use. -// * If the store is not yet set (i.e. @c store is NULL), every constructor -// * call tries to set it and throws an error message in case of failures. -// * The default store is objects::TC_STORE. -// */ -// static StorageManagerIF* STORE; -// /** -// * The address where the packet data of the object instance is stored. -// */ -// store_address_t storeAddress; -// /** -// * A helper method to check if a store is assigned to the class. -// * If not, the method tries to retrieve the store from the global -// * ObjectManager. -// * @return @li @c true if the store is linked or could be created. -// * @li @c false otherwise. -// */ -// static bool checkAndSetStore(); -//}; - -#endif /* TMTCPACKET_PUS_TCPACKETSTORED_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tm.h b/src/fsfw/tmtcpacket/pus/tm.h index 657790f4..619f9e01 100644 --- a/src/fsfw/tmtcpacket/pus/tm.h +++ b/src/fsfw/tmtcpacket/pus/tm.h @@ -1,16 +1,7 @@ #ifndef FSFW_TMTCPACKET_PUS_TM_H_ #define FSFW_TMTCPACKET_PUS_TM_H_ -#include "fsfw/FSFW.h" - -#if FSFW_USE_PUS_C_TELEMETRY == 1 -#include "tm/TmPacketPusC.h" -#include "tm/TmPacketStoredPusC.h" -#else -#include "tm/TmPacketPusA.h" -#include "tm/TmPacketStoredPusA.h" -#endif - -#include "tm/PusTmMinimal.h" +#include "tm/PusTmCreator.h" +#include "tm/PusTmReader.h" #endif /* FSFW_TMTCPACKET_PUS_TM_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp deleted file mode 100644 index c81c2d4d..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "fsfw/tmtcpacket/pus/tm/TmPacketBase.h" - -#include - -#include "fsfw/globalfunctions/CRC.h" -#include "fsfw/globalfunctions/arrayprinter.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/timemanager/CCSDSTime.h" - -TimeStamperIF* TmPacketBase::timeStamper = nullptr; -object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT; - -TmPacketBase::TmPacketBase(uint8_t* setData) : SpacePacketReader(setData) {} - -TmPacketBase::~TmPacketBase() = default; - -uint16_t TmPacketBase::getSourceDataSize() { - return SpacePacketReader::getPacketDataLen() - getDataFieldSize() - CRC_SIZE + 1; -} - -uint16_t TmPacketBase::getErrorControl() { - uint32_t size = getSourceDataSize() + CRC_SIZE; - uint8_t* p_to_buffer = getSourceData(); - return (p_to_buffer[size - 2] << 8) + p_to_buffer[size - 1]; -} - -void TmPacketBase::setErrorControl() { - uint32_t full_size = getFullSize(); - uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE); - uint32_t size = getSourceDataSize(); - getSourceData()[size] = (crc & 0XFF00) >> 8; // CRCH - getSourceData()[size + 1] = (crc)&0X00FF; // CRCL -} - -ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const { - size_t tempSize = 0; - return CCSDSTime::convertFromCcsds(timestamp, getPacketTimeRaw(), &tempSize, getTimestampSize()); -} - -bool TmPacketBase::checkAndSetStamper() { - if (timeStamper == nullptr) { - timeStamper = ObjectManager::instance()->get(timeStamperId); - if (timeStamper == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TmPacketBase::checkAndSetStamper: Stamper not found!" << std::endl; -#else - sif::printWarning("TmPacketBase::checkAndSetStamper: Stamper not found!\n"); -#endif - return false; - } - } - return true; -} - -void TmPacketBase::print() { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TmPacketBase::print:" << std::endl; -#else - sif::printInfo("TmPacketBase::print:\n"); -#endif - arrayprinter::print(getWholeData(), getFullSize()); -} diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h deleted file mode 100644 index fe7619cf..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef TMTCPACKET_PUS_TMPACKETBASE_H_ -#define TMTCPACKET_PUS_TMPACKETBASE_H_ - -#include "fsfw/objectmanager/SystemObjectIF.h" -#include "fsfw/timemanager/Clock.h" -#include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" - -namespace Factory { - -void setStaticFrameworkObjectIds(); - -} - -/** - * This class is the basic data handler for any ECSS PUS Telemetry packet. - * - * In addition to #SpacePacketBase, the class provides methods to handle - * the standardized entries of the PUS TM Packet Data Field Header. - * It does not contain the packet data itself but a pointer to the - * data must be set on instantiation. An invalid pointer may cause - * damage, as no getter method checks data validity. Anyway, a NULL - * check can be performed by making use of the getWholeData method. - * @ingroup tmtcpackets - */ -class TmPacketBase : public SpacePacketReader { - friend void(Factory::setStaticFrameworkObjectIds)(); - - public: - //! Maximum size of a TM Packet in this mission. - //! TODO: Make this dependant on a config variable. - static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048; - - /** - * This is the default constructor. - * It sets its internal data pointer to the address passed and also - * forwards the data pointer to the parent SpacePacketBase class. - * @param set_address The position where the packet data lies. - */ - TmPacketBase(uint8_t* setData); - /** - * This is the empty default destructor. - */ - virtual ~TmPacketBase(); - - /** - * This is a getter for the packet's PUS Service ID, which is the second - * byte of the Data Field Header. - * @return The packet's PUS Service ID. - */ - virtual uint8_t getService() = 0; - /** - * This is a getter for the packet's PUS Service Subtype, which is the - * third byte of the Data Field Header. - * @return The packet's PUS Service Subtype. - */ - virtual uint8_t getSubService() = 0; - /** - * This is a getter for a pointer to the packet's Source data. - * - * These are the bytes that follow after the Data Field Header. They form - * the packet's source data. - * @return A pointer to the PUS Source Data. - */ - virtual uint8_t* getSourceData() = 0; - /** - * This method calculates the size of the PUS Source data field. - * - * It takes the information stored in the CCSDS Packet Data Length field - * and subtracts the Data Field Header size and the CRC size. - * @return The size of the PUS Source Data (without Error Control field) - */ - virtual uint16_t getSourceDataSize() = 0; - - /** - * Get size of data field which can differ based on implementation - * @return - */ - virtual uint16_t getDataFieldSize() = 0; - - virtual size_t getPacketMinimumSize() const = 0; - - /** - * Interprets the "time"-field in the secondary header and returns it in - * timeval format. - * @return Converted timestamp of packet. - */ - virtual ReturnValue_t getPacketTime(timeval* timestamp) const; - /** - * Returns a raw pointer to the beginning of the time field. - * @return Raw pointer to time field. - */ - virtual uint8_t* getPacketTimeRaw() const = 0; - - virtual size_t getTimestampSize() const = 0; - - /** - * This is a debugging helper method that prints the whole packet content - * to the screen. - */ - void print(); - /** - * With this method, the Error Control Field is updated to match the - * current content of the packet. This method is not protected because - * a recalculation by the user might be necessary when manipulating fields - * like the sequence count. - */ - void setErrorControl(); - /** - * This getter returns the Error Control Field of the packet. - * - * The field is placed after any possible Source Data. If no - * Source Data is present there's still an Error Control field. It is - * supposed to be a 16bit-CRC. - * @return The PUS Error Control - */ - uint16_t getErrorControl(); - - protected: - /** - * The timeStamper is responsible for adding a timestamp to the packet. - * It is initialized lazy. - */ - static TimeStamperIF* timeStamper; - //! The ID to use when looking for a time stamper. - static object_id_t timeStamperId; - - /** - * Checks if a time stamper is available and tries to set it if not. - * @return Returns false if setting failed. - */ - bool checkAndSetStamper(); -}; - -#endif /* TMTCPACKET_PUS_TMPACKETBASE_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp deleted file mode 100644 index 5c35c540..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "TmPacketPusC.h" - -#include - -#include "../defs.h" -#include "TmPacketBase.h" -#include "fsfw/globalfunctions/CRC.h" -#include "fsfw/globalfunctions/arrayprinter.h" -#include "fsfw/objectmanager/ObjectManagerIF.h" -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/timemanager/CCSDSTime.h" - -TmPacketPusC::TmPacketPusC(uint8_t* setData) : TmPacketBase(setData) { - tmData = reinterpret_cast(setData); -} - -TmPacketPusC::~TmPacketPusC() = default; - -uint8_t TmPacketPusC::getService() { return tmData->dataField.serviceType; } - -uint8_t TmPacketPusC::getSubService() { return tmData->dataField.serviceSubtype; } - -uint8_t* TmPacketPusC::getSourceData() { return &tmData->data; } - -uint16_t TmPacketPusC::getSourceDataSize() { - return SpacePacketReader::getPacketDataLen() - sizeof(tmData->dataField) - CRC_SIZE + 1; -} - -ReturnValue_t TmPacketPusC::setData(uint8_t* p_Data, size_t maxSize, void* args) { - ReturnValue_t result = SpacePacketReader::setData(p_Data, maxSize, args); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - if (maxSize < sizeof(TmPacketPointerPusC)) { - return HasReturnvaluesIF::RETURN_OK; - } - tmData = reinterpret_cast(const_cast(p_Data)); - return HasReturnvaluesIF::RETURN_OK; -} - -size_t TmPacketPusC::getPacketMinimumSize() const { return TM_PACKET_MIN_SIZE; } - -uint16_t TmPacketPusC::getDataFieldSize() { return sizeof(PUSTmDataFieldHeaderPusC); } - -uint8_t* TmPacketPusC::getPacketTimeRaw() const { return tmData->dataField.time; } - -ReturnValue_t TmPacketPusC::initializeTmPacket(uint16_t apid, uint8_t service, uint8_t subservice, - uint16_t packetSubcounter, uint16_t destinationId, - uint8_t timeRefField) { - // Set primary header: - ReturnValue_t result = initSpacePacketHeader(false, true, apid); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - // Set data Field Header: - // First, set to zero. - memset(&tmData->dataField, 0, sizeof(tmData->dataField)); - - /* Only account for last 4 bytes for time reference field */ - timeRefField &= 0b1111; - tmData->dataField.versionTimeReferenceField = (ecss::PusVersion::PUS_C << 4) | timeRefField; - tmData->dataField.serviceType = service; - tmData->dataField.serviceSubtype = subservice; - tmData->dataField.subcounterMsb = (packetSubcounter << 8) & 0xff; - tmData->dataField.subcounterLsb = packetSubcounter & 0xff; - tmData->dataField.destinationIdMsb = (destinationId << 8) & 0xff; - tmData->dataField.destinationIdLsb = destinationId & 0xff; - // Timestamp packet - if (TmPacketBase::checkAndSetStamper()) { - timeStamper->addTimeStamp(tmData->dataField.time, sizeof(tmData->dataField.time)); - } - return HasReturnvaluesIF::RETURN_OK; -} - -void TmPacketPusC::setSourceDataSize(uint16_t size) { - setPacketDataLength(size + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1); -} - -size_t TmPacketPusC::getTimestampSize() const { return sizeof(tmData->dataField.time); } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h deleted file mode 100644 index c68deadd..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef FSFW_TMTCPACKET_PUS_TMPACKETPUSC_H_ -#define FSFW_TMTCPACKET_PUS_TMPACKETPUSC_H_ - -#include "TmPacketBase.h" -#include "fsfw/objectmanager/SystemObjectIF.h" -#include "fsfw/timemanager/Clock.h" -#include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" - -namespace Factory { -void setStaticFrameworkObjectIds(); -} - -/** - * This struct defines a byte-wise structured PUS TM Data Field Header. - * Any optional fields in the header must be added or removed here. - * Currently, no Destination field is present, but an eigth-byte representation - * for a time tag. - * @ingroup tmtcpackets - */ -struct PUSTmDataFieldHeaderPusC { - uint8_t versionTimeReferenceField; - uint8_t serviceType; - uint8_t serviceSubtype; - uint8_t subcounterMsb; - uint8_t subcounterLsb; - uint8_t destinationIdMsb; - uint8_t destinationIdLsb; - // uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE]; -}; - -/** - * This struct defines the data structure of a PUS Telecommand Packet when - * accessed via a pointer. - * @ingroup tmtcpackets - */ -struct TmPacketPointerPusC { - ccsds::PrimaryHeader primary; - PUSTmDataFieldHeaderPusC dataField; - uint8_t data; -}; - -/** - * PUS A packet implementation - * @ingroup tmtcpackets - */ -class TmPacketPusC : public TmPacketBase { - friend void(Factory::setStaticFrameworkObjectIds)(); - - public: - /** - * This constant defines the minimum size of a valid PUS Telemetry Packet. - */ - static const uint32_t TM_PACKET_MIN_SIZE = - ccsds::HEADER_LEN + sizeof(PUSTmDataFieldHeaderPusC) + 2; - //! Maximum size of a TM Packet in this mission. - static const uint32_t MISSION_TM_PACKET_MAX_SIZE = fsfwconfig::FSFW_MAX_TM_PACKET_SIZE; - - /** - * This is the default constructor. - * It sets its internal data pointer to the address passed and also - * forwards the data pointer to the parent SpacePacketBase class. - * @param set_address The position where the packet data lies. - */ - TmPacketPusC(uint8_t* setData); - /** - * This is the empty default destructor. - */ - virtual ~TmPacketPusC(); - - /* TmPacketBase implementations */ - uint8_t getService() override; - uint8_t getSubService() override; - uint8_t* getSourceData() override; - uint16_t getSourceDataSize() override; - uint16_t getDataFieldSize() override; - - /** - * Returns a raw pointer to the beginning of the time field. - * @return Raw pointer to time field. - */ - uint8_t* getPacketTimeRaw() const override; - size_t getTimestampSize() const override; - - size_t getPacketMinimumSize() const override; - - protected: - /** - * A pointer to a structure which defines the data structure of - * the packet's data. - * - * To be hardware-safe, all elements are of byte size. - */ - TmPacketPointerPusC* tmData; - - /** - * Initializes the Tm Packet header. - * Does set the timestamp (to now), but not the error control field. - * @param apid APID used. - * @param service PUS Service - * @param subservice PUS Subservice - * @param packetSubcounter Additional subcounter used. - */ - ReturnValue_t initializeTmPacket(uint16_t apid, uint8_t service, uint8_t subservice, - uint16_t packetSubcounter, uint16_t destinationId = 0, - uint8_t timeRefField = 0); - - /** - * With this method, the packet data pointer can be redirected to another - * location. - * - * This call overwrites the parent's setData method to set both its - * @c tc_data pointer and the parent's @c data pointer. - * - * @param pData A pointer to another PUS Telemetry Packet. - */ - ReturnValue_t setData(uint8_t* pData, size_t maxSize, void* args) override; - - /** - * In case data was filled manually (almost never the case). - * @param size Size of source data (without CRC and data filed header!). - */ - void setSourceDataSize(uint16_t size); -}; - -#endif /* FSFW_TMTCPACKET_PUS_TMPACKETPUSC_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStored.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketStored.h deleted file mode 100644 index de10655f..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStored.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_ -#define FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_ - -#include - -#if FSFW_USE_PUS_C_TELEMETRY == 1 -#include "TmPacketStoredPusC.h" -#else -#include "TmPacketStoredPusA.h" -#endif - -#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp deleted file mode 100644 index 4d37bf46..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.h" - -#include - -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tmtcservices/TmTcMessage.h" - -StorageManagerIF *TmPacketStoredBase::store = nullptr; -InternalErrorReporterIF *TmPacketStoredBase::internalErrorReporter = nullptr; - -TmPacketStoredBase::TmPacketStoredBase(store_address_t setAddress) : storeAddress(setAddress) { - setStoreAddress(storeAddress); -} - -TmPacketStoredBase::TmPacketStoredBase() {} - -TmPacketStoredBase::~TmPacketStoredBase() {} - -store_address_t TmPacketStoredBase::getStoreAddress() { return storeAddress; } - -void TmPacketStoredBase::deletePacket() { - store->deleteData(storeAddress); - storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; - setData(nullptr, -1); -} - -void TmPacketStoredBase::setStoreAddress(store_address_t setAddress) { - storeAddress = setAddress; - const uint8_t *tempData = nullptr; - size_t tempSize; - if (not checkAndSetStore()) { - return; - } - ReturnValue_t status = store->getData(storeAddress, &tempData, &tempSize); - if (status == StorageManagerIF::RETURN_OK) { - setData(const_cast(tempData), tempSize); - } else { - setData(nullptr, -1); - storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; - } -} - -bool TmPacketStoredBase::checkAndSetStore() { - if (store == nullptr) { - store = ObjectManager::instance()->get(objects::TM_STORE); - if (store == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "TmPacketStored::TmPacketStored: TM Store not found!" << std::endl; -#endif - return false; - } - } - return true; -} - -ReturnValue_t TmPacketStoredBase::sendPacket(MessageQueueId_t destination, - MessageQueueId_t sentFrom, bool doErrorReporting) { - if (getAllTmData() == nullptr) { - // SHOULDDO: More decent code. - return HasReturnvaluesIF::RETURN_FAILED; - } - TmTcMessage tmMessage(getStoreAddress()); - ReturnValue_t result = MessageQueueSenderIF::sendMessage(destination, &tmMessage, sentFrom); - if (result != HasReturnvaluesIF::RETURN_OK) { - deletePacket(); - if (doErrorReporting) { - checkAndReportLostTm(); - } - return result; - } - // SHOULDDO: In many cases, some counter is incremented for successfully sent packets. The check - // is often not done, but just incremented. - return HasReturnvaluesIF::RETURN_OK; -} - -void TmPacketStoredBase::checkAndReportLostTm() { - if (internalErrorReporter == nullptr) { - internalErrorReporter = - ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); - } - if (internalErrorReporter != nullptr) { - internalErrorReporter->lostTm(); - } -} - -void TmPacketStoredBase::handleStoreFailure(const char *const packetType, ReturnValue_t result, - size_t sizeToReserve) { - checkAndReportLostTm(); -#if FSFW_VERBOSE_LEVEL >= 1 - switch (result) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - case (StorageManagerIF::DATA_STORAGE_FULL): { - sif::warning << "TmPacketStoredPus" << packetType << ": " - << "Store full for packet with size" << sizeToReserve << std::endl; - break; - } - case (StorageManagerIF::DATA_TOO_LARGE): { - sif::warning << "TmPacketStoredPus" << packetType << ": Data with size " << sizeToReserve - << " too large" << std::endl; - break; - } -#else - case (StorageManagerIF::DATA_STORAGE_FULL): { - sif::printWarning( - "TmPacketStoredPus%s: Store full for packet with " - "size %d\n", - packetType, sizeToReserve); - break; - } - case (StorageManagerIF::DATA_TOO_LARGE): { - sif::printWarning( - "TmPacketStoredPus%s: Data with size " - "%d too large\n", - packetType, sizeToReserve); - break; - } -#endif - } -#endif -} diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.h deleted file mode 100644 index 85363ee9..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_ -#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_ - -#include "TmPacketBase.h" -#include "TmPacketStoredBase.h" -#include "fsfw/FSFW.h" -#include "fsfw/internalerror/InternalErrorReporterIF.h" -#include "fsfw/ipc/MessageQueueSenderIF.h" -#include "fsfw/serialize/SerializeIF.h" -#include "fsfw/storagemanager/StorageManagerIF.h" - -/** - * This class generates a ECSS PUS Telemetry packet within a given - * intermediate storage. - * As most packets are passed between tasks with the help of a storage - * anyway, it seems logical to create a Packet-In-Storage access class - * which saves the user almost all storage handling operation. - * Packets can both be newly created with the class and be "linked" to - * packets in a store with the help of a storeAddress. - * @ingroup tmtcpackets - */ -class TmPacketStoredBase : virtual public RedirectableDataPointerIF { - public: - /** - * This is a default constructor which does not set the data pointer. - * However, it does try to set the packet store. - */ - TmPacketStoredBase(store_address_t setAddress); - TmPacketStoredBase(); - - virtual ~TmPacketStoredBase(); - - virtual uint8_t* getAllTmData() = 0; - - /** - * This is a getter for the current store address of the packet. - * @return The current store address. The (raw) value is - * @c StorageManagerIF::INVALID_ADDRESS if - * the packet is not linked. - */ - store_address_t getStoreAddress(); - /** - * With this call, the packet is deleted. - * It removes itself from the store and sets its data pointer to NULL. - */ - void deletePacket(); - /** - * With this call, a packet can be linked to another store. This is useful - * if the packet is a class member and used for more than one packet. - * @param setAddress The new packet id to link to. - */ - void setStoreAddress(store_address_t setAddress); - - ReturnValue_t sendPacket(MessageQueueId_t destination, MessageQueueId_t sentFrom, - bool doErrorReporting = true); - - protected: - /** - * This is a pointer to the store all instances of the class use. - * If the store is not yet set (i.e. @c store is NULL), every constructor - * call tries to set it and throws an error message in case of failures. - * The default store is objects::TM_STORE. - */ - static StorageManagerIF* store; - - static InternalErrorReporterIF* internalErrorReporter; - - /** - * The address where the packet data of the object instance is stored. - */ - store_address_t storeAddress; - /** - * A helper method to check if a store is assigned to the class. - * If not, the method tries to retrieve the store from the global - * ObjectManager. - * @return @li @c true if the store is linked or could be created. - * @li @c false otherwise. - */ - bool checkAndSetStore(); - - void checkAndReportLostTm(); - - void handleStoreFailure(const char* const packetType, ReturnValue_t result, size_t sizeToReserve); -}; - -#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp deleted file mode 100644 index 5ade4191..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h" - -#include - -#include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tmtcservices/TmTcMessage.h" - -TmPacketStoredPusC::TmPacketStoredPusC(store_address_t setAddress) - : TmPacketStoredBase(setAddress), TmPacketPusC(nullptr) {} - -TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice, - uint16_t packetSubcounter, const uint8_t *data, - uint32_t size, const uint8_t *headerData, - uint32_t headerSize, uint16_t destinationId, - uint8_t timeRefField) - : TmPacketPusC(nullptr) { - storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; - if (not TmPacketStoredBase::checkAndSetStore()) { - return; - } - uint8_t *pData = nullptr; - size_t sizeToReserve = getPacketMinimumSize() + size + headerSize; - ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData); - - if (returnValue != store->RETURN_OK) { - handleStoreFailure("C", returnValue, sizeToReserve); - return; - } - setData(pData, sizeToReserve, nullptr); - initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField); - memcpy(getSourceData(), headerData, headerSize); - memcpy(getSourceData() + headerSize, data, size); - setPacketDataLength(size + headerSize + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1); -} - -TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice, - uint16_t packetSubcounter, SerializeIF *content, - SerializeIF *header, uint16_t destinationId, - uint8_t timeRefField) - : TmPacketPusC(nullptr) { - storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; - if (not TmPacketStoredBase::checkAndSetStore()) { - return; - } - size_t sourceDataSize = 0; - if (content != nullptr) { - sourceDataSize += content->getSerializedSize(); - } - if (header != nullptr) { - sourceDataSize += header->getSerializedSize(); - } - uint8_t *pData = nullptr; - size_t sizeToReserve = getPacketMinimumSize() + sourceDataSize; - ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData); - if (returnValue != store->RETURN_OK) { - handleStoreFailure("C", returnValue, sizeToReserve); - return; - } - TmPacketPusC::setData(pData, sizeToReserve, nullptr); - initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField); - uint8_t *putDataHere = getSourceData(); - size_t size = 0; - if (header != nullptr) { - header->serialize(&putDataHere, &size, sourceDataSize, SerializeIF::Endianness::BIG); - } - if (content != nullptr) { - content->serialize(&putDataHere, &size, sourceDataSize, SerializeIF::Endianness::BIG); - } - setPacketDataLength(sourceDataSize + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1); -} - -uint8_t *TmPacketStoredPusC::getAllTmData() { return getWholeData(); } - -ReturnValue_t TmPacketStoredPusC::setData(uint8_t *newPointer, size_t maxSize, void *args) { - return TmPacketPusC::setData(newPointer, maxSize, args); -} diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h deleted file mode 100644 index 2a1f645f..00000000 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h +++ /dev/null @@ -1,73 +0,0 @@ -//#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ -//#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ -// -//#include "TmPacketPusC.h" -//#include "TmPacketStoredBase.h" -// -///** -// * This class generates a ECSS PUS C Telemetry packet within a given -// * intermediate storage. -// * As most packets are passed between tasks with the help of a storage -// * anyway, it seems logical to create a Packet-In-Storage access class -// * which saves the user almost all storage handling operation. -// * Packets can both be newly created with the class and be "linked" to -// * packets in a store with the help of a storeAddress. -// * @ingroup tmtcpackets -// */ -// class TmPacketStoredPusC : public TmPacketStoredBase, public TmPacketPusC { -// public: -// /** -// * This is a default constructor which does not set the data pointer. -// * However, it does try to set the packet store. -// */ -// TmPacketStoredPusC(store_address_t setAddress); -// /** -// * With this constructor, new space is allocated in the packet store and -// * a new PUS Telemetry Packet is created there. -// * Packet Application Data passed in data is copied into the packet. -// * The Application data is passed in two parts, first a header, then a -// * data field. This allows building a Telemetry Packet from two separate -// * data sources. -// * @param apid Sets the packet's APID field. -// * @param service Sets the packet's Service ID field. -// * This specifies the source service. -// * @param subservice Sets the packet's Service Subtype field. -// * This specifies the source sub-service. -// * @param packet_counter Sets the Packet counter field of this packet -// * @param data The payload data to be copied to the -// * Application Data Field -// * @param size The amount of data to be copied. -// * @param headerData The header Data of the Application field, -// * will be copied in front of data -// * @param headerSize The size of the headerDataF -// * @param destinationId Destination ID containing the application process ID as specified -// * by PUS C -// * @param timeRefField 4 bit time reference field as specified by PUS C -// */ -// TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice, uint16_t packetCounter = -// 0, -// const uint8_t* data = nullptr, uint32_t size = 0, -// const uint8_t* headerData = nullptr, uint32_t headerSize = 0, -// uint16_t destinationId = 0, uint8_t timeRefField = 0); -// /** -// * Another ctor to directly pass structured content and header data to the -// * packet to avoid additional buffers. -// */ -// TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice, uint16_t packetCounter, -// SerializeIF* content, SerializeIF* header = nullptr, -// uint16_t destinationId = 0, uint8_t timeRefField = 0); -// -// uint8_t* getAllTmData() override; -// -// private: -// /** -// * Implementation required by base class -// * @param newPointer -// * @param maxSize -// * @param args -// * @return -// */ -// ReturnValue_t setData(uint8_t* newPointer, size_t maxSize, void* args) override; -//}; -// -//#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ */ diff --git a/unittests/CatchFactory.cpp b/unittests/CatchFactory.cpp index 25ced1ba..5dce8372 100644 --- a/unittests/CatchFactory.cpp +++ b/unittests/CatchFactory.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include From 0981ee6f7ecabfc385424d1df3fc6d8dee1beef8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 21 Jul 2022 18:17:37 +0200 Subject: [PATCH 066/532] minor changes, virtual dtors added --- src/fsfw/tmtcpacket/ReadablePacketIF.h | 2 ++ src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h | 5 +++-- src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp | 4 +++- src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/fsfw/tmtcpacket/ReadablePacketIF.h b/src/fsfw/tmtcpacket/ReadablePacketIF.h index 01478273..bbffbe10 100644 --- a/src/fsfw/tmtcpacket/ReadablePacketIF.h +++ b/src/fsfw/tmtcpacket/ReadablePacketIF.h @@ -5,6 +5,8 @@ class ReadablePacketIF { public: + virtual ~ReadablePacketIF() = default; + /** * This method returns a raw uint8_t pointer to the readable data */ diff --git a/src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h b/src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h index e4e515f8..799b7940 100644 --- a/src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h +++ b/src/fsfw/tmtcpacket/pus/RawUserDataReaderIF.h @@ -6,8 +6,9 @@ class RawUserDataReaderIF { public: - virtual const uint8_t* getUserData() const = 0; - virtual size_t getUserDataLen() const = 0; + ~RawUserDataReaderIF() = default; + [[nodiscard]] virtual const uint8_t* getUserData() const = 0; + [[nodiscard]] virtual size_t getUserDataLen() const = 0; }; #endif // FSFW_TMTCPACKET_RAWDATAIF_H diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp index c96bed65..bac6d543 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp @@ -23,7 +23,9 @@ ReturnValue_t PusTcReader::parseData(bool withCrc) { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - if (spReader.getBufSize() < PusTcIF::MIN_SIZE) { + // We already have access to the space packet fields here, so we can perform a sanity check + // on the length field + if (spReader.getFullPacketLen() < spReader.getBufSize()) { return SerializeIF::STREAM_TOO_SHORT; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp index 024d6ac8..807dd8e0 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp @@ -57,7 +57,7 @@ ReturnValue_t PusTmReader::parseData(bool crcCheck) { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - if (spReader.getBufSize() < PusTmIF::MIN_SIZE) { + if (spReader.getFullPacketLen() < spReader.getBufSize()) { return SerializeIF::STREAM_TOO_SHORT; } From affde6bad5b52512bd444fbc09d616f25cc684e2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 21 Jul 2022 18:21:10 +0200 Subject: [PATCH 067/532] rename namespace --- src/fsfw/osal/host/Clock.cpp | 2 +- src/fsfw/osal/linux/Clock.cpp | 4 ++-- src/fsfw/pus/Service17Test.cpp | 4 ++-- src/fsfw/pus/Service1TelecommandVerification.cpp | 4 ++-- src/fsfw/pus/Service5EventReporting.cpp | 2 +- src/fsfw/tmtcservices/CommandingServiceBase.cpp | 9 ++++----- src/fsfw/tmtcservices/CommandingServiceBase.h | 3 --- src/fsfw/tmtcservices/tmHelpers.cpp | 3 ++- src/fsfw/tmtcservices/tmHelpers.h | 5 +++-- 9 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/fsfw/osal/host/Clock.cpp b/src/fsfw/osal/host/Clock.cpp index 19e120b3..2dc9d472 100644 --- a/src/fsfw/osal/host/Clock.cpp +++ b/src/fsfw/osal/host/Clock.cpp @@ -146,7 +146,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { } ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) { - struct tm time_tm; + struct tm time_tm{}; time_tm.tm_year = from->year - 1900; time_tm.tm_mon = from->month - 1; diff --git a/src/fsfw/osal/linux/Clock.cpp b/src/fsfw/osal/linux/Clock.cpp index 534e7e22..afb4ce3a 100644 --- a/src/fsfw/osal/linux/Clock.cpp +++ b/src/fsfw/osal/linux/Clock.cpp @@ -122,7 +122,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { MutexGuard helper(timeMutex); // gmtime writes its output in a global buffer which is not Thread Safe // Therefore we have to use a Mutex here - struct tm* timeInfo; + struct telemetry* timeInfo; timeInfo = gmtime(&timeUnix.tv_sec); time->year = timeInfo->tm_year + 1900; time->month = timeInfo->tm_mon + 1; @@ -136,7 +136,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { } ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) { - tm fromTm; + telemetry fromTm; // Note: Fails for years before AD fromTm.tm_year = from->year - 1900; fromTm.tm_mon = from->month - 1; diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index 52319de1..ea2c06e1 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -17,12 +17,12 @@ ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { switch (subservice) { case Subservice::CONNECTION_TEST: { storeHelper.preparePacket(serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter); - return tm::storeAndSendTmPacket(storeHelper, sendHelper); + return telemetry::storeAndSendTmPacket(storeHelper, sendHelper); } case Subservice::EVENT_TRIGGER_TEST: { storeHelper.preparePacket(serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter++); triggerEvent(TEST, 1234, 5678); - return tm::storeAndSendTmPacket(storeHelper, sendHelper); + return telemetry::storeAndSendTmPacket(storeHelper, sendHelper); } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 35957ba0..93525958 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -70,7 +70,7 @@ ReturnValue_t Service1TelecommandVerification::generateFailureReport( message->getParameter1(), message->getParameter2()); storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); storeHelper.setSourceDataSerializable(&report); - return tm::storeAndSendTmPacket(storeHelper, sendHelper); + return telemetry::storeAndSendTmPacket(storeHelper, sendHelper); } ReturnValue_t Service1TelecommandVerification::generateSuccessReport( @@ -79,7 +79,7 @@ ReturnValue_t Service1TelecommandVerification::generateSuccessReport( message->getTcSequenceControl(), message->getStep()); storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); storeHelper.setSourceDataSerializable(&report); - return tm::storeAndSendTmPacket(storeHelper, sendHelper); + return telemetry::storeAndSendTmPacket(storeHelper, sendHelper); } ReturnValue_t Service1TelecommandVerification::initialize() { diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index 31cc72f5..847f5f80 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -49,7 +49,7 @@ ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) message.getParameter2()); storeHelper.preparePacket(serviceId, message.getSeverity(), packetSubCounter); storeHelper.setSourceDataSerializable(&report); - ReturnValue_t result = tm::storeAndSendTmPacket(storeHelper, sendHelper); + ReturnValue_t result = telemetry::storeAndSendTmPacket(storeHelper, sendHelper); if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service5EventReporting::generateEventReport: " diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 897dd962..6abe625b 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -5,7 +5,6 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tcdistribution/PUSDistributorIF.h" #include "fsfw/tmtcpacket/pus/tc.h" -#include "fsfw/tmtcpacket/pus/tm.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/TmTcMessage.h" #include "fsfw/tmtcservices/tcHelpers.h" @@ -290,7 +289,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, const uint size_t sourceDataLen) { tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); tmStoreHelper.setSourceDataRaw(sourceData, sourceDataLen); - ReturnValue_t result = tm::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); + ReturnValue_t result = telemetry::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); if (result == HasReturnvaluesIF::RETURN_OK) { this->tmPacketCounter++; } @@ -299,10 +298,10 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, const uint ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_t objectId, const uint8_t* data, size_t dataLen) { - tm::SourceDataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); + telemetry::SourceDataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); tmStoreHelper.setSourceDataSerializable(&dataWithObjId); - ReturnValue_t result = tm::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); + ReturnValue_t result = telemetry::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); if (result == HasReturnvaluesIF::RETURN_OK) { this->tmPacketCounter++; } @@ -312,7 +311,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeIF* sourceData) { tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); tmStoreHelper.setSourceDataSerializable(sourceData); - ReturnValue_t result = tm::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); + ReturnValue_t result = telemetry::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); if (result == HasReturnvaluesIF::RETURN_OK) { this->tmPacketCounter++; } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index a58a1a93..9b8aa61e 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -15,9 +15,6 @@ #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" -class TcPacketStoredBase; -class TcPacketStoredPus; - namespace Factory { void setStaticFrameworkObjectIds(); } diff --git a/src/fsfw/tmtcservices/tmHelpers.cpp b/src/fsfw/tmtcservices/tmHelpers.cpp index 91026d6c..d7bc66cf 100644 --- a/src/fsfw/tmtcservices/tmHelpers.cpp +++ b/src/fsfw/tmtcservices/tmHelpers.cpp @@ -1,6 +1,7 @@ #include "tmHelpers.h" -ReturnValue_t tm::storeAndSendTmPacket(TmStoreHelper &storeHelper, TmSendHelper &sendHelper) { +ReturnValue_t telemetry::storeAndSendTmPacket(TmStoreHelper &storeHelper, + TmSendHelper &sendHelper) { storeHelper.addPacketToStore(); ReturnValue_t result = sendHelper.sendPacket(storeHelper.getCurrentAddr()); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/src/fsfw/tmtcservices/tmHelpers.h b/src/fsfw/tmtcservices/tmHelpers.h index 871a7f1a..2e783039 100644 --- a/src/fsfw/tmtcservices/tmHelpers.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -4,7 +4,8 @@ #include "TmSendHelper.h" #include "TmStoreHelper.h" -namespace tm { +// I'd prefer to use tm, but there have been nameclashes with the tm struct +namespace telemetry { ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper); @@ -42,6 +43,6 @@ class SourceDataWithObjectIdPrefix : public SerializeIF { size_t srcDataLen; }; -} // namespace tm +} // namespace telemetry #endif // FSFW_TMTCSERVICES_TMHELPERS_H_ From 0dfaba81f9a3868d64f5f88726ea91bfdb22af73 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 21 Jul 2022 19:10:15 +0200 Subject: [PATCH 068/532] finished basic TC unittests --- src/fsfw/osal/host/Clock.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 12 ++- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 3 + src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp | 38 ++++------ src/fsfw/tmtcpacket/pus/tc/PusTcReader.h | 3 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp | 4 - unittests/tmtcpacket/CMakeLists.txt | 1 + unittests/tmtcpacket/testPusTcCreator.cpp | 6 +- unittests/tmtcpacket/testPusTcReader.cpp | 81 +++++++++++++++++++++ unittests/tmtcpacket/testPusTm.cpp | 1 - 11 files changed, 118 insertions(+), 35 deletions(-) create mode 100644 unittests/tmtcpacket/testPusTcReader.cpp delete mode 100644 unittests/tmtcpacket/testPusTm.cpp diff --git a/src/fsfw/osal/host/Clock.cpp b/src/fsfw/osal/host/Clock.cpp index 2dc9d472..2f7ede89 100644 --- a/src/fsfw/osal/host/Clock.cpp +++ b/src/fsfw/osal/host/Clock.cpp @@ -146,7 +146,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { } ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) { - struct tm time_tm{}; + struct tm time_tm {}; time_tm.tm_year = from->year - 1900; time_tm.tm_mon = from->month - 1; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 2ff82d25..240e7718 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -54,7 +54,7 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max } } - uint16_t crc16 = CRC::crc16ccitt(start, getFullPacketLen() - 2); + uint16_t crc16 = CRC::crc16ccitt(start, getFullPacketLen() - sizeof(ecss::PusChecksumT)); return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness); } @@ -95,3 +95,13 @@ SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize) { return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } + +void PusTcCreator::setRawAppData(ecss::DataWrapper::BufPairT bufPair) { + pusParams.dataWrapper.setRawData(bufPair); + updateSpLengthField(); +} + +void PusTcCreator::setSerializableAppData(SerializeIF *serAppData) { + pusParams.dataWrapper.setSerializable(serAppData); + updateSpLengthField(); +} diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index c09a7238..9e6b6e6f 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -33,6 +33,9 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CreatorDataIF { void updateSpLengthField(); PusTcParams &getPusParams(); SpacePacketParams &getSpParams(); + void setRawAppData(ecss::DataWrapper::BufPairT bufPair); + void setSerializableAppData(SerializeIF *serAppData); + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize); [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp index bac6d543..f5dd143a 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp @@ -23,20 +23,18 @@ ReturnValue_t PusTcReader::parseData(bool withCrc) { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - // We already have access to the space packet fields here, so we can perform a sanity check - // on the length field - if (spReader.getFullPacketLen() < spReader.getBufSize()) { - return SerializeIF::STREAM_TOO_SHORT; - } - size_t currentOffset = SpacePacketReader::getHeaderLen(); pointers.secHeaderStart = pointers.spHeaderStart + currentOffset; // Might become variable sized field in the future // TODO: No support for spare bytes yet currentOffset += ecss::PusTcDataFieldHeader::MIN_SIZE; - pointers.userDataStart = pointers.spHeaderStart + currentOffset; appDataSize = spReader.getFullPacketLen() - currentOffset - sizeof(ecss::PusChecksumT); - pointers.crcStart = pointers.userDataStart + appDataSize; + pointers.userDataStart = nullptr; + if (appDataSize > 0) { + pointers.userDataStart = pointers.spHeaderStart + currentOffset; + } + currentOffset += appDataSize; + pointers.crcStart = pointers.spHeaderStart + currentOffset; if (withCrc) { uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen()); if (crc16 != 0) { @@ -47,25 +45,28 @@ ReturnValue_t PusTcReader::parseData(bool withCrc) { return HasReturnvaluesIF::RETURN_OK; } -uint8_t PusTcReader::getAcknowledgeFlags() const { - return (pointers.secHeaderStart[0] >> 4) & 0b1111; -} +uint8_t PusTcReader::getPusVersion() const { return (pointers.secHeaderStart[0] >> 4) & 0b1111; } + +uint8_t PusTcReader::getAcknowledgeFlags() const { return pointers.secHeaderStart[0] & 0b1111; } uint8_t PusTcReader::getService() const { return pointers.secHeaderStart[1]; } uint8_t PusTcReader::getSubService() const { return pointers.secHeaderStart[2]; } + uint16_t PusTcReader::getSourceId() const { return (pointers.secHeaderStart[3] << 8) | pointers.secHeaderStart[4]; } uint16_t PusTcReader::getErrorControl() const { - return pointers.crcStart[0] << 8 | pointers.crcStart[1]; + return (pointers.crcStart[0] << 8) | pointers.crcStart[1]; } uint16_t PusTcReader::getPacketIdRaw() const { return spReader.getPacketIdRaw(); } + uint16_t PusTcReader::getPacketSeqCtrlRaw() const { return spReader.getPacketSeqCtrlRaw(); } + uint16_t PusTcReader::getPacketDataLen() const { return spReader.getPacketDataLen(); } -uint8_t PusTcReader::getPusVersion() const { return spReader.getVersion(); } + const uint8_t* PusTcReader::getFullData() { return pointers.spHeaderStart; } ReturnValue_t PusTcReader::setData(uint8_t* pData, size_t size_, void* args) { @@ -80,13 +81,4 @@ ReturnValue_t PusTcReader::setReadOnlyData(const uint8_t* data, size_t size_) { const uint8_t* PusTcReader::getUserData() const { return pointers.userDataStart; } size_t PusTcReader::getUserDataLen() const { return appDataSize; } -/* -void PusTcReader::print() { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "TcPacketBase::print:" << std::endl; -#else - sif::printInfo("TcPacketBase::print:\n"); -#endif - arrayprinter::print(getWholeData(), getFullSize()); -} -*/ \ No newline at end of file +bool PusTcReader::isNull() const { return spReader.isNull(); } diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h index 528e0ca5..3be2e5e6 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h @@ -34,6 +34,7 @@ class PusTcReader : public PusTcIF, */ PusTcReader(const uint8_t* setData, size_t size); + [[nodiscard]] bool isNull() const; ReturnValue_t parseDataWithCrcCheck(); ReturnValue_t parseDataWithoutCrcCheck(); @@ -60,7 +61,7 @@ class PusTcReader : public PusTcIF, ReturnValue_t setReadOnlyData(const uint8_t* data, size_t size); [[nodiscard]] const uint8_t* getUserData() const override; - size_t getUserDataLen() const override; + [[nodiscard]] size_t getUserDataLen() const override; protected: /** diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 927ec072..22c998c8 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -74,7 +74,7 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max return result; } } - uint16_t crc16 = CRC::crc16ccitt(*buffer, getFullPacketLen() - 2); + uint16_t crc16 = CRC::crc16ccitt(*buffer, getFullPacketLen() - sizeof(ecss::PusChecksumT)); return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp index 807dd8e0..e700a428 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp @@ -57,10 +57,6 @@ ReturnValue_t PusTmReader::parseData(bool crcCheck) { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - if (spReader.getFullPacketLen() < spReader.getBufSize()) { - return SerializeIF::STREAM_TOO_SHORT; - } - size_t currentOffset = SpacePacketReader::getHeaderLen(); pointers.secHeaderStart = pointers.spHeaderStart + currentOffset; currentOffset += PusTmIF::MIN_SEC_HEADER_LEN; diff --git a/unittests/tmtcpacket/CMakeLists.txt b/unittests/tmtcpacket/CMakeLists.txt index 67d8858c..673c5244 100644 --- a/unittests/tmtcpacket/CMakeLists.txt +++ b/unittests/tmtcpacket/CMakeLists.txt @@ -2,4 +2,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testCcsdsCreator.cpp testCcsdsReader.cpp testPusTcCreator.cpp + testPusTcReader.cpp ) diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index f6c15b78..ca934121 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -54,6 +54,8 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { REQUIRE(((buf[9] << 8) | buf[10]) == 0); // CRC16 check REQUIRE(CRC::crc16ccitt(buf.data(), serLen) == 0); + REQUIRE(buf[11] == 0xee); + REQUIRE(buf[12] == 0x63); } SECTION("Custom Source ID") { @@ -82,12 +84,10 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { SECTION("Test with Application Data Serializable") { auto& params = creator.getPusParams(); auto simpleSer = SimpleSerializable(); - params.dataWrapper.setSerializable(&simpleSer); + creator.setSerializableAppData(&simpleSer); auto& dataWrapper = creator.getDataWrapper(); REQUIRE(dataWrapper.type == ecss::DataTypes::SERIALIZABLE); REQUIRE(dataWrapper.dataUnion.serializable == &simpleSer); - REQUIRE(creator.getSerializedSize() == 13); - creator.updateSpLengthField(); REQUIRE(creator.getSerializedSize() == 16); REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(serLen == 16); diff --git a/unittests/tmtcpacket/testPusTcReader.cpp b/unittests/tmtcpacket/testPusTcReader.cpp new file mode 100644 index 00000000..1c870f78 --- /dev/null +++ b/unittests/tmtcpacket/testPusTcReader.cpp @@ -0,0 +1,81 @@ +#include +#include + +#include "fsfw/tmtcpacket/pus/tc/PusTcCreator.h" +#include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" + +TEST_CASE("PUS TC Reader", "[pus-tc-reader]") { + auto packetId = PacketId(ccsds::PacketType::TC, true, 0x02); + auto spParams = + SpacePacketParams(packetId, PacketSeqCtrl(ccsds::SequenceFlags::UNSEGMENTED, 0x34), 0x00); + auto pusParams = PusTcParams(17, 1); + PusTcCreator creator(spParams, pusParams); + std::array buf{}; + uint8_t* dataPtr = buf.data(); + size_t serLen = 0; + PusTcReader reader; + auto checkReaderFields = [&](PusTcReader& reader) { + REQUIRE(not reader.isNull()); + REQUIRE(reader.getPacketType() == ccsds::PacketType::TC); + REQUIRE(reader.getApid() == 0x02); + REQUIRE(reader.getService() == 17); + REQUIRE(reader.getSubService() == 1); + REQUIRE(reader.getFullPacketLen() == 13); + REQUIRE(reader.getPacketDataLen() == 6); + REQUIRE(reader.getPusVersion() == 2); + REQUIRE(reader.getSequenceCount() == 0x34); + REQUIRE(reader.getUserData() == nullptr); + REQUIRE(reader.getUserDataLen() == 0); + REQUIRE(reader.getFullData() == buf.data()); + REQUIRE(reader.getSourceId() == 0x00); + REQUIRE(reader.getAcknowledgeFlags() == 0b1111); + // This value was verified to be correct + REQUIRE(reader.getErrorControl() == 0xee63); + }; + + SECTION("State") { + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.isNull()); + + SECTION("Setter") { + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + checkReaderFields(reader); + } + SECTION("Directly Constructed") { + PusTcReader secondReader(buf.data(), serLen); + REQUIRE(not secondReader.isNull()); + REQUIRE(secondReader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + checkReaderFields(secondReader); + } + } + + SECTION("Invalid CRC") { + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + buf[11] = 0x00; + REQUIRE(reader.parseDataWithCrcCheck() == PusIF::INVALID_CRC_16); + } + + SECTION("Invalid CRC but no check") { + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + buf[11] = 0x00; + REQUIRE(reader.parseDataWithoutCrcCheck() == HasReturnvaluesIF::RETURN_OK); + } + + SECTION("With application data") { + auto& params = creator.getPusParams(); + std::array data{1, 2, 3}; + creator.setRawAppData({data.data(), data.size()}); + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + const uint8_t* userDataPtr = reader.getUserData(); + REQUIRE(userDataPtr != nullptr); + REQUIRE(reader.getUserDataLen() == 3); + REQUIRE(userDataPtr[0] == 1); + REQUIRE(userDataPtr[1] == 2); + REQUIRE(userDataPtr[2] == 3); + } +} \ No newline at end of file diff --git a/unittests/tmtcpacket/testPusTm.cpp b/unittests/tmtcpacket/testPusTm.cpp deleted file mode 100644 index 8b137891..00000000 --- a/unittests/tmtcpacket/testPusTm.cpp +++ /dev/null @@ -1 +0,0 @@ - From bfee4fd90aa7c5ca3cf7e7568220729d8680fde4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 21 Jul 2022 19:16:44 +0200 Subject: [PATCH 069/532] add empty test files --- unittests/tmtcpacket/CMakeLists.txt | 2 ++ unittests/tmtcpacket/testPusTmCreator.cpp | 3 +++ unittests/tmtcpacket/testPusTmReader.cpp | 3 +++ 3 files changed, 8 insertions(+) create mode 100644 unittests/tmtcpacket/testPusTmCreator.cpp create mode 100644 unittests/tmtcpacket/testPusTmReader.cpp diff --git a/unittests/tmtcpacket/CMakeLists.txt b/unittests/tmtcpacket/CMakeLists.txt index 673c5244..f47c6370 100644 --- a/unittests/tmtcpacket/CMakeLists.txt +++ b/unittests/tmtcpacket/CMakeLists.txt @@ -3,4 +3,6 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testCcsdsReader.cpp testPusTcCreator.cpp testPusTcReader.cpp + testPusTmCreator.cpp + testPusTmReader.cpp ) diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp new file mode 100644 index 00000000..481b6a31 --- /dev/null +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -0,0 +1,3 @@ +#include + +TEST_CASE("PUS TM Creator", "[pus-tm-creator]") {} \ No newline at end of file diff --git a/unittests/tmtcpacket/testPusTmReader.cpp b/unittests/tmtcpacket/testPusTmReader.cpp new file mode 100644 index 00000000..59c01914 --- /dev/null +++ b/unittests/tmtcpacket/testPusTmReader.cpp @@ -0,0 +1,3 @@ +#include + +TEST_CASE("PUS TM Reader", "[pus-tm-reader]") {} \ No newline at end of file From 67776241de0a6bac0d0318d688d8fe8b84f8c445 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Jul 2022 16:06:31 +0200 Subject: [PATCH 070/532] verify successfull TM serialization --- src/fsfw/timemanager/TimeStamperIF.h | 4 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 30 ++++++---- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 42 +++++++++----- src/fsfw/tmtcservices/TmStoreHelper.cpp | 6 +- unittests/mocks/CdsShortTimestamperMock.h | 53 +++++++++++++++++ unittests/tmtcpacket/testPusTcCreator.cpp | 1 + unittests/tmtcpacket/testPusTmCreator.cpp | 64 ++++++++++++++++++++- 7 files changed, 170 insertions(+), 30 deletions(-) create mode 100644 unittests/mocks/CdsShortTimestamperMock.h diff --git a/src/fsfw/timemanager/TimeStamperIF.h b/src/fsfw/timemanager/TimeStamperIF.h index 2f0e8021..df680b6c 100644 --- a/src/fsfw/timemanager/TimeStamperIF.h +++ b/src/fsfw/timemanager/TimeStamperIF.h @@ -22,9 +22,9 @@ class TimeStamperIF : public SerializeIF { //! size reserved for timestamps. // static const uint8_t MISSION_TIMESTAMP_SIZE = fsfwconfig::FSFW_MISSION_TIMESTAMP_SIZE; - [[nodiscard]] virtual size_t getTimestampSize() const = 0; - virtual ReturnValue_t addTimeStamp(uint8_t* buffer, uint8_t maxSize) = 0; + [[nodiscard]] virtual size_t getTimestampSize() const { return getSerializedSize(); } + virtual ReturnValue_t addTimeStamp(uint8_t* buffer, uint8_t maxSize) = 0; ~TimeStamperIF() override = default; }; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 22c998c8..df931dfd 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -5,15 +5,12 @@ #include "fsfw/globalfunctions/CRC.h" #include "fsfw/timemanager/TimeStamperIF.h" -PusTmCreator::PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams, - TimeStamperIF* timeStamper) - : pusParams(initPusParams), spCreator(std::move(initSpParams)) {} - -PusTmCreator::PusTmCreator(TimeStamperIF* timeStamper_) { - pusParams.secHeader.timeStamper = timeStamper_; +PusTmCreator::PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams) + : pusParams(initPusParams), spCreator(std::move(initSpParams)) { + setup(); } -PusTmCreator::PusTmCreator() = default; +PusTmCreator::PusTmCreator() { setup(); } uint16_t PusTmCreator::getPacketIdRaw() const { return spCreator.getPacketIdRaw(); } uint16_t PusTmCreator::getPacketSeqCtrlRaw() const { return spCreator.getPacketSeqCtrlRaw(); } @@ -31,6 +28,7 @@ uint16_t PusTmCreator::getDestId() { return 0; } ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { + const uint8_t* start = *buffer; if (*size + getSerializedSize() > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } @@ -74,7 +72,7 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max return result; } } - uint16_t crc16 = CRC::crc16ccitt(*buffer, getFullPacketLen() - sizeof(ecss::PusChecksumT)); + uint16_t crc16 = CRC::crc16ccitt(start, getFullPacketLen() - sizeof(ecss::PusChecksumT)); return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness); } @@ -85,15 +83,25 @@ ReturnValue_t PusTmCreator::deSerialize(const uint8_t** buffer, size_t* size, } ecss::DataWrapper& PusTmCreator::getDataWrapper() { return pusParams.dataWrapper; } -TimeStamperIF* PusTmCreator::getTimestamper() { return pusParams.secHeader.timeStamper; } +TimeStamperIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader.timeStamper; } SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } void PusTmCreator::updateSpLengthField() { - size_t headerLen = PusTmIF::MIN_SIZE; + size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + pusParams.dataWrapper.getLength() + + sizeof(ecss::PusChecksumT) - 1; if (pusParams.secHeader.timeStamper != nullptr) { headerLen += pusParams.secHeader.timeStamper->getSerializedSize(); } - spCreator.setDataLen(headerLen + pusParams.dataWrapper.getLength() + 1); + spCreator.setDataLen(headerLen); } void PusTmCreator::setApid(uint16_t apid) { spCreator.setApid(apid); } + +ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize) const { + return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); +} + +void PusTmCreator::setup() { + updateSpLengthField(); + spCreator.setPacketType(ccsds::PacketType::TM); +} diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 9ac79d16..97c96391 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -6,18 +6,35 @@ #include "fsfw/tmtcpacket/pus/CreatorDataIF.h" struct PusTmSecHeader { - uint8_t pusVersion; - uint8_t scTimeRefStatus; - uint8_t service; - uint8_t subservice; - uint16_t messageTypeCounter; - uint16_t destId; - TimeStamperIF* timeStamper; + PusTmSecHeader() = default; + PusTmSecHeader(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper) + : service(service), subservice(subservice), timeStamper(timeStamper) {} + + uint8_t service = 0; + uint8_t subservice = 0; + TimeStamperIF* timeStamper = nullptr; + uint8_t pusVersion = ecss::PusVersion::PUS_C; + uint8_t scTimeRefStatus = 0; + uint16_t messageTypeCounter = 0; + uint16_t destId = 0; }; struct PusTmParams { + PusTmParams() = default; + explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader){}; + PusTmParams(PusTmSecHeader secHeader, ecss::DataWrapper dataWrapper) + : secHeader(secHeader), dataWrapper(dataWrapper) {} + + PusTmParams(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper) + : secHeader(service, subservice, timeStamper) {} + + PusTmParams(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper, + ecss::DataWrapper dataWrapper_) + : PusTmParams(service, subservice, timeStamper) { + dataWrapper = dataWrapper_; + } PusTmSecHeader secHeader; - ecss::DataWrapper dataWrapper; + ecss::DataWrapper dataWrapper{}; }; class TimeStamperIF; @@ -25,10 +42,7 @@ class TimeStamperIF; class PusTmCreator : public SerializeIF, public PusTmIF, public CreatorDataIF { public: PusTmCreator(); - - explicit PusTmCreator(TimeStamperIF* timeStamper); - PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams, - TimeStamperIF* timeStamper); + PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams); ~PusTmCreator() override = default; void setTimeStamper(TimeStamperIF* timeStamper); @@ -45,17 +59,19 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CreatorDataIF { uint8_t getScTimeRefStatus() override; uint16_t getMessageTypeCounter() override; uint16_t getDestId() override; + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize) const; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override; - TimeStamperIF* getTimestamper(); + [[nodiscard]] TimeStamperIF* getTimestamper() const; private: ecss::DataWrapper& getDataWrapper() override; private: + void setup(); PusTmParams pusParams{}; SpacePacketCreator spCreator; }; diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index 661ee3a0..44b2e6a1 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -4,12 +4,12 @@ TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore, TimeStamperIF* timeStamper) - : creator(timeStamper), tmStore(tmStore) { + : tmStore(tmStore) { creator.setApid(defaultApid); + creator.setTimeStamper(timeStamper); } -TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore) - : creator(nullptr), tmStore(tmStore) { +TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore) : tmStore(tmStore) { creator.setApid(defaultApid); } diff --git a/unittests/mocks/CdsShortTimestamperMock.h b/unittests/mocks/CdsShortTimestamperMock.h new file mode 100644 index 00000000..779859d0 --- /dev/null +++ b/unittests/mocks/CdsShortTimestamperMock.h @@ -0,0 +1,53 @@ +#ifndef FSFW_TESTS_CDSSHORTTIMESTAMPERMOCK_H +#define FSFW_TESTS_CDSSHORTTIMESTAMPERMOCK_H + +#include + +#include "fsfw/timemanager/TimeStamperIF.h" + +class CdsShortTimestamperMock : public TimeStamperIF { + public: + unsigned int serializeCallCount = 0; + ReturnValue_t lastSerializeResult = HasReturnvaluesIF::RETURN_OK; + unsigned int getSizeCallCount = 0; + std::array valueToStamp{}; + + CdsShortTimestamperMock() = default; + + explicit CdsShortTimestamperMock(std::array valueToStamp) + : valueToStamp(valueToStamp) {} + + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override { + auto &thisNonConst = const_cast(*this); + thisNonConst.serializeCallCount += 1; + if (*size + getSerializedSize() > maxSize) { + thisNonConst.lastSerializeResult = SerializeIF::BUFFER_TOO_SHORT; + return lastSerializeResult; + } + std::copy(valueToStamp.begin(), valueToStamp.end(), *buffer); + thisNonConst.lastSerializeResult = HasReturnvaluesIF::RETURN_OK; + *buffer += getSerializedSize(); + *size += getSerializedSize(); + return lastSerializeResult; + } + [[nodiscard]] size_t getSerializedSize() const override { + auto &thisNonConst = const_cast(*this); + thisNonConst.getSizeCallCount += 1; + return valueToStamp.size(); + } + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override { + return HasReturnvaluesIF::RETURN_FAILED; + } + [[nodiscard]] size_t getTimestampSize() const override { return getSerializedSize(); } + ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override { return 0; } + + void reset() { + serializeCallCount = 0; + getSizeCallCount = 0; + } + + private: +}; +#endif // FSFW_TESTS_CDSSHORTTIMESTAMPERMOCK_H diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index ca934121..28c7e555 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -16,6 +16,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { size_t serLen = 0; SECTION("State") { + REQUIRE(creator.isTc()); REQUIRE(creator.getService() == 17); REQUIRE(creator.getSubService() == 1); REQUIRE(creator.getApid() == 0x02); diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index 481b6a31..6b92b134 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -1,3 +1,65 @@ #include -TEST_CASE("PUS TM Creator", "[pus-tm-creator]") {} \ No newline at end of file +#include "fsfw/globalfunctions/arrayprinter.h" +#include "fsfw/tmtcpacket/pus/tm.h" +#include "fsfw/globalfunctions/CRC.h" +#include "mocks/CdsShortTimestamperMock.h" + +TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { + auto packetId = PacketId(ccsds::PacketType::TC, true, 0xef); + auto spParams = + SpacePacketParams(packetId, PacketSeqCtrl(ccsds::SequenceFlags::UNSEGMENTED, 22), 0x00); + auto timeStamper = CdsShortTimestamperMock(); + auto pusTmParams = PusTmParams(17, 2, &timeStamper); + timeStamper.valueToStamp = {1, 2, 3, 4, 5, 6, 7}; + PusTmCreator creator(spParams, pusTmParams); + std::array buf{}; + uint8_t* dataPtr = buf.data(); + size_t serLen = 0; + + SECTION("State") { + REQUIRE(creator.isTm()); + REQUIRE(creator.getApid() == 0xef); + REQUIRE(creator.getService() == 17); + REQUIRE(creator.getSubService() == 2); + REQUIRE(creator.getTimestamper() == &timeStamper); + REQUIRE(creator.getSequenceFlags() == ccsds::SequenceFlags::UNSEGMENTED); + REQUIRE(creator.getSequenceCount() == 22); + // 6 bytes CCSDS header, 7 bytes secondary header, 7 bytes CDS short timestamp, + // 0 bytes application data, 2 bytes CRC + REQUIRE(creator.getFullPacketLen() == 22); + // As specified in standard, the data length fields is the total size of the packet without + // the primary header minus 1 + REQUIRE(creator.getPacketDataLen() == 15); + REQUIRE(timeStamper.getSizeCallCount == 1); + } + + SECTION("Serialization") { + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(buf[0] == 0x08); + REQUIRE(buf[1] == 0xef); + // Unsegmented is the default + REQUIRE(buf[2] == 0xc0); + REQUIRE(buf[3] == 22); + REQUIRE(buf[4] == 0); + REQUIRE(buf[5] == 15); + REQUIRE(((buf[6] >> 4) & 0b1111) == ecss::PusVersion::PUS_C); + // SC time reference field + REQUIRE((buf[6] & 0b1111) == 0); + // Service and subservice field + REQUIRE(buf[7] == 17); + REQUIRE(buf[8] == 2); + // Message Sequence Count + REQUIRE(((buf[9] << 8) | buf[10]) == 0); + // Destination ID + REQUIRE(((buf[11] << 8) | buf[12]) == 0); + // Custom timestamp + for(size_t i = 1; i < 8; i++) { + REQUIRE(buf[12 + i] == i); + } + REQUIRE(serLen == 22); + REQUIRE(CRC::crc16ccitt(buf.data(), serLen) == 0); + REQUIRE(buf[20] == 0x03); + REQUIRE(buf[21] == 0x79); + } +} \ No newline at end of file From 9275ccb79bae8e836ed8ea2a221252644b67d1b9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Jul 2022 16:09:18 +0200 Subject: [PATCH 071/532] added some missing implementations --- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index df931dfd..479358b7 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -22,9 +22,9 @@ PusTmParams& PusTmCreator::getParams() { return pusParams; } void PusTmCreator::setTimeStamper(TimeStamperIF* timeStamper_) { pusParams.secHeader.timeStamper = timeStamper_; } -uint8_t PusTmCreator::getScTimeRefStatus() { return 0; } -uint16_t PusTmCreator::getMessageTypeCounter() { return 0; } -uint16_t PusTmCreator::getDestId() { return 0; } +uint8_t PusTmCreator::getScTimeRefStatus() { return pusParams.secHeader.scTimeRefStatus; } +uint16_t PusTmCreator::getMessageTypeCounter() { return pusParams.secHeader.messageTypeCounter; } +uint16_t PusTmCreator::getDestId() { return pusParams.secHeader.destId; } ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { From f28b9ea61b52cf8b7c4675b2e5bb5dc87143a61e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Jul 2022 16:41:32 +0200 Subject: [PATCH 072/532] APID getter bugfix --- src/fsfw/tcdistribution/CCSDSDistributor.h | 2 +- src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h | 3 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 31 ++++++++++++++++ src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 4 ++ unittests/tmtcpacket/testPusTmCreator.cpp | 41 +++++++++++++++++++++ 5 files changed, 78 insertions(+), 3 deletions(-) diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.h b/src/fsfw/tcdistribution/CCSDSDistributor.h index 2d9b1fbd..b5cfc5a4 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.h +++ b/src/fsfw/tcdistribution/CCSDSDistributor.h @@ -31,7 +31,7 @@ class CCSDSDistributor : public TcDistributor, /** * The destructor is empty. */ - virtual ~CCSDSDistributor(); + ~CCSDSDistributor() override; MessageQueueId_t getRequestQueue() override; ReturnValue_t registerApplication(uint16_t apid, MessageQueueId_t id) override; diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h index de01e819..41d087ad 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketIF.h @@ -51,9 +51,8 @@ class SpacePacketIF { virtual PacketSeqCtrl getPacketSeqCtrl() { return PacketSeqCtrl::fromRaw(getPacketSeqCtrlRaw()); } [[nodiscard]] virtual uint16_t getApid() const { - uint16_t packetId = getPacketIdRaw(); // Uppermost 11 bits of packet ID - return ((packetId >> 8) & 0b111) | (packetId & 0xFF); + return getPacketIdRaw() & 0x7ff; } /** diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 479358b7..9cbdeb5c 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -13,17 +13,27 @@ PusTmCreator::PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusPa PusTmCreator::PusTmCreator() { setup(); } uint16_t PusTmCreator::getPacketIdRaw() const { return spCreator.getPacketIdRaw(); } + uint16_t PusTmCreator::getPacketSeqCtrlRaw() const { return spCreator.getPacketSeqCtrlRaw(); } + uint16_t PusTmCreator::getPacketDataLen() const { return spCreator.getPacketDataLen(); } + uint8_t PusTmCreator::getPusVersion() const { return pusParams.secHeader.pusVersion; } + uint8_t PusTmCreator::getService() const { return pusParams.secHeader.service; } + uint8_t PusTmCreator::getSubService() const { return pusParams.secHeader.subservice; } + PusTmParams& PusTmCreator::getParams() { return pusParams; } + void PusTmCreator::setTimeStamper(TimeStamperIF* timeStamper_) { pusParams.secHeader.timeStamper = timeStamper_; } + uint8_t PusTmCreator::getScTimeRefStatus() { return pusParams.secHeader.scTimeRefStatus; } + uint16_t PusTmCreator::getMessageTypeCounter() { return pusParams.secHeader.messageTypeCounter; } + uint16_t PusTmCreator::getDestId() { return pusParams.secHeader.destId; } ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize, @@ -83,7 +93,9 @@ ReturnValue_t PusTmCreator::deSerialize(const uint8_t** buffer, size_t* size, } ecss::DataWrapper& PusTmCreator::getDataWrapper() { return pusParams.dataWrapper; } + TimeStamperIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader.timeStamper; } + SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } void PusTmCreator::updateSpLengthField() { @@ -105,3 +117,22 @@ void PusTmCreator::setup() { updateSpLengthField(); spCreator.setPacketType(ccsds::PacketType::TM); } + +void PusTmCreator::setMessageTypeCounter(uint16_t messageTypeCounter) { + pusParams.secHeader.messageTypeCounter = messageTypeCounter; +}; + +void PusTmCreator::setDestId(uint16_t destId) { pusParams.secHeader.destId = destId; } + +void PusTmCreator::setRawSourceData(ecss::DataWrapper::BufPairT bufPair) { + pusParams.dataWrapper.type = ecss::DataTypes::RAW; + pusParams.dataWrapper.dataUnion.raw.data = bufPair.first; + pusParams.dataWrapper.dataUnion.raw.len = bufPair.second; + updateSpLengthField(); +} + +void PusTmCreator::setSerializableSourceData(SerializeIF* serializable) { + pusParams.dataWrapper.type = ecss::DataTypes::SERIALIZABLE; + pusParams.dataWrapper.dataUnion.serializable = serializable; + updateSpLengthField(); +} diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 97c96391..c0406dc0 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -47,7 +47,11 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CreatorDataIF { void setTimeStamper(TimeStamperIF* timeStamper); SpacePacketParams& getSpParams(); + void setRawSourceData(ecss::DataWrapper::BufPairT bufPair); + void setSerializableSourceData(SerializeIF* serializable); void setApid(uint16_t apid); + void setDestId(uint16_t destId); + void setMessageTypeCounter(uint16_t messageTypeCounter); PusTmParams& getParams(); void updateSpLengthField(); [[nodiscard]] uint16_t getPacketIdRaw() const override; diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index 6b92b134..0cb1c093 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -62,4 +62,45 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { REQUIRE(buf[20] == 0x03); REQUIRE(buf[21] == 0x79); } + + SECTION("Custom Fields") { + creator.setApid(0x3ff); + SECTION("Using Params") { + auto& pusParams = creator.getParams(); + pusParams.secHeader.destId = 0xfff; + pusParams.secHeader.messageTypeCounter = 0x313; + } + SECTION("Using Setters") { + auto& pusParams = creator.getParams(); + creator.setDestId(0xfff); + creator.setMessageTypeCounter(0x313); + } + REQUIRE(creator.getApid() == 0x3ff); + REQUIRE(creator.getDestId() == 0xfff); + REQUIRE(creator.getMessageTypeCounter() == 0x313); + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + // Message Sequence Count + REQUIRE(((buf[9] << 8) | buf[10]) == 0x313); + // Destination ID + REQUIRE(((buf[11] << 8) | buf[12]) == 0xfff); + } + + SECTION("Deserialization fails") { + const uint8_t* roDataPtr = nullptr; + REQUIRE(creator.deSerialize(&roDataPtr, &serLen, SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_FAILED); + } + + SECTION("Serialize with Raw Data") { + std::array data{1, 2, 3}; + creator.setRawSourceData({data.data(), data.size()}); + REQUIRE(creator.getFullPacketLen() == 25); + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(buf[20] == 1); + REQUIRE(buf[21] == 2); + REQUIRE(buf[22] == 3); + } + + SECTION("Serialize with Serializable") { + + } } \ No newline at end of file From cecaec600753abc65d99ae09f991412b8079af74 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Jul 2022 17:09:44 +0200 Subject: [PATCH 073/532] PUS TM creator tests done --- src/fsfw/tmtcpacket/pus/CreatorDataIF.h | 10 ---- src/fsfw/tmtcpacket/pus/CustomUserDataIF.h | 12 +++++ src/fsfw/tmtcpacket/pus/defs.h | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 16 +++--- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 9 ++-- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 17 +++---- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 11 ++--- unittests/tmtcpacket/testPusTcCreator.cpp | 5 +- unittests/tmtcpacket/testPusTcReader.cpp | 55 +++++++++++---------- unittests/tmtcpacket/testPusTmCreator.cpp | 46 +++++++++++++++-- 10 files changed, 110 insertions(+), 73 deletions(-) delete mode 100644 src/fsfw/tmtcpacket/pus/CreatorDataIF.h create mode 100644 src/fsfw/tmtcpacket/pus/CustomUserDataIF.h diff --git a/src/fsfw/tmtcpacket/pus/CreatorDataIF.h b/src/fsfw/tmtcpacket/pus/CreatorDataIF.h deleted file mode 100644 index f66ca567..00000000 --- a/src/fsfw/tmtcpacket/pus/CreatorDataIF.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef FSFW_TMTCPACKET_CREATORDATAIF_H -#define FSFW_TMTCPACKET_CREATORDATAIF_H - -#include "defs.h" - -class CreatorDataIF { - public: - virtual ecss::DataWrapper& getDataWrapper() = 0; -}; -#endif // FSFW_TMTCPACKET_CREATORDATAIF_H diff --git a/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h b/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h new file mode 100644 index 00000000..ddbce9f1 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h @@ -0,0 +1,12 @@ +#ifndef FSFW_TMTCPACKET_CREATORDATAIF_H +#define FSFW_TMTCPACKET_CREATORDATAIF_H + +#include "defs.h" + +class CustomUserDataIF { + public: + virtual ~CustomUserDataIF() = default; + virtual ReturnValue_t setRawUserData(const uint8_t* data, size_t len) = 0; + virtual ReturnValue_t setSerializableUserData(SerializeIF* serializable) = 0; +}; +#endif // FSFW_TMTCPACKET_CREATORDATAIF_H diff --git a/src/fsfw/tmtcpacket/pus/defs.h b/src/fsfw/tmtcpacket/pus/defs.h index 83502ed3..72a154ff 100644 --- a/src/fsfw/tmtcpacket/pus/defs.h +++ b/src/fsfw/tmtcpacket/pus/defs.h @@ -28,7 +28,7 @@ union DataUnion { struct DataWrapper { DataTypes type; DataUnion dataUnion; - using BufPairT = std::pair; + using BufPairT = std::pair; [[nodiscard]] size_t getLength() const { if (type == DataTypes::RAW) { diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 240e7718..9ffd6eb4 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -16,7 +16,7 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max SerializeIF::Endianness streamEndianness) const { const uint8_t *start = *buffer; size_t userDataLen = pusParams.dataWrapper.getLength(); - if (*size + getFullPacketLen() > maxSize) { + if (*size + getSerializedSize() > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } if (pusParams.pusVersion != ecss::PusVersion::PUS_C) { @@ -86,8 +86,6 @@ uint8_t PusTcCreator::getSubService() const { return pusParams.subservice; } uint16_t PusTcCreator::getSourceId() const { return pusParams.sourceId; } -ecss::DataWrapper &PusTcCreator::getDataWrapper() { return pusParams.dataWrapper; } - PusTcParams &PusTcCreator::getPusParams() { return pusParams; } SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } @@ -96,12 +94,16 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } -void PusTcCreator::setRawAppData(ecss::DataWrapper::BufPairT bufPair) { - pusParams.dataWrapper.setRawData(bufPair); +ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { + // TODO: Check length field? + pusParams.dataWrapper.setRawData({data, len}); updateSpLengthField(); + return HasReturnvaluesIF::RETURN_OK; } -void PusTcCreator::setSerializableAppData(SerializeIF *serAppData) { - pusParams.dataWrapper.setSerializable(serAppData); +ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF *serializable) { + // TODO: Check length field? + pusParams.dataWrapper.setSerializable(serializable); updateSpLengthField(); + return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 9e6b6e6f..4e5951a5 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -4,7 +4,7 @@ #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" -#include "fsfw/tmtcpacket/pus/CreatorDataIF.h" +#include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" #include "fsfw/tmtcpacket/pus/defs.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" @@ -19,7 +19,7 @@ struct PusTcParams { uint8_t pusVersion = ecss::PusVersion::PUS_C; }; -class PusTcCreator : public PusTcIF, public SerializeIF, public CreatorDataIF { +class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF { public: PusTcCreator(SpacePacketParams initSpParams, PusTcParams initPusParams); @@ -33,8 +33,6 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CreatorDataIF { void updateSpLengthField(); PusTcParams &getPusParams(); SpacePacketParams &getSpParams(); - void setRawAppData(ecss::DataWrapper::BufPairT bufPair); - void setSerializableAppData(SerializeIF *serAppData); ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize); [[nodiscard]] size_t getSerializedSize() const override; @@ -48,7 +46,8 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CreatorDataIF { [[nodiscard]] uint8_t getService() const override; [[nodiscard]] uint8_t getSubService() const override; [[nodiscard]] uint16_t getSourceId() const override; - ecss::DataWrapper &getDataWrapper() override; + ReturnValue_t setRawUserData(const uint8_t *data, size_t len) override; + ReturnValue_t setSerializableUserData(SerializeIF *serializable) override; private: ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 9cbdeb5c..b8ef0852 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -28,6 +28,7 @@ PusTmParams& PusTmCreator::getParams() { return pusParams; } void PusTmCreator::setTimeStamper(TimeStamperIF* timeStamper_) { pusParams.secHeader.timeStamper = timeStamper_; + updateSpLengthField(); } uint8_t PusTmCreator::getScTimeRefStatus() { return pusParams.secHeader.scTimeRefStatus; } @@ -92,8 +93,6 @@ ReturnValue_t PusTmCreator::deSerialize(const uint8_t** buffer, size_t* size, return HasReturnvaluesIF::RETURN_FAILED; } -ecss::DataWrapper& PusTmCreator::getDataWrapper() { return pusParams.dataWrapper; } - TimeStamperIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader.timeStamper; } SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } @@ -124,15 +123,13 @@ void PusTmCreator::setMessageTypeCounter(uint16_t messageTypeCounter) { void PusTmCreator::setDestId(uint16_t destId) { pusParams.secHeader.destId = destId; } -void PusTmCreator::setRawSourceData(ecss::DataWrapper::BufPairT bufPair) { - pusParams.dataWrapper.type = ecss::DataTypes::RAW; - pusParams.dataWrapper.dataUnion.raw.data = bufPair.first; - pusParams.dataWrapper.dataUnion.raw.len = bufPair.second; +ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { + pusParams.dataWrapper.setRawData({data, len}); updateSpLengthField(); + return HasReturnvaluesIF::RETURN_OK; } - -void PusTmCreator::setSerializableSourceData(SerializeIF* serializable) { - pusParams.dataWrapper.type = ecss::DataTypes::SERIALIZABLE; - pusParams.dataWrapper.dataUnion.serializable = serializable; +ReturnValue_t PusTmCreator::setSerializableUserData(SerializeIF* serializable) { + pusParams.dataWrapper.setSerializable(serializable); updateSpLengthField(); + return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index c0406dc0..9981c39c 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -3,7 +3,7 @@ #include "PusTmIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" -#include "fsfw/tmtcpacket/pus/CreatorDataIF.h" +#include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" struct PusTmSecHeader { PusTmSecHeader() = default; @@ -39,7 +39,7 @@ struct PusTmParams { class TimeStamperIF; -class PusTmCreator : public SerializeIF, public PusTmIF, public CreatorDataIF { +class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF { public: PusTmCreator(); PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams); @@ -47,8 +47,6 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CreatorDataIF { void setTimeStamper(TimeStamperIF* timeStamper); SpacePacketParams& getSpParams(); - void setRawSourceData(ecss::DataWrapper::BufPairT bufPair); - void setSerializableSourceData(SerializeIF* serializable); void setApid(uint16_t apid); void setDestId(uint16_t destId); void setMessageTypeCounter(uint16_t messageTypeCounter); @@ -70,9 +68,8 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CreatorDataIF { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override; [[nodiscard]] TimeStamperIF* getTimestamper() const; - - private: - ecss::DataWrapper& getDataWrapper() override; + ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override; + ReturnValue_t setSerializableUserData(SerializeIF* serializable) override; private: void setup(); diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index 28c7e555..978833cd 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -85,10 +85,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { SECTION("Test with Application Data Serializable") { auto& params = creator.getPusParams(); auto simpleSer = SimpleSerializable(); - creator.setSerializableAppData(&simpleSer); - auto& dataWrapper = creator.getDataWrapper(); - REQUIRE(dataWrapper.type == ecss::DataTypes::SERIALIZABLE); - REQUIRE(dataWrapper.dataUnion.serializable == &simpleSer); + creator.setSerializableUserData(&simpleSer); REQUIRE(creator.getSerializedSize() == 16); REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(serLen == 16); diff --git a/unittests/tmtcpacket/testPusTcReader.cpp b/unittests/tmtcpacket/testPusTcReader.cpp index 1c870f78..82a88542 100644 --- a/unittests/tmtcpacket/testPusTcReader.cpp +++ b/unittests/tmtcpacket/testPusTcReader.cpp @@ -15,38 +15,43 @@ TEST_CASE("PUS TC Reader", "[pus-tc-reader]") { size_t serLen = 0; PusTcReader reader; auto checkReaderFields = [&](PusTcReader& reader) { - REQUIRE(not reader.isNull()); - REQUIRE(reader.getPacketType() == ccsds::PacketType::TC); - REQUIRE(reader.getApid() == 0x02); - REQUIRE(reader.getService() == 17); - REQUIRE(reader.getSubService() == 1); - REQUIRE(reader.getFullPacketLen() == 13); - REQUIRE(reader.getPacketDataLen() == 6); - REQUIRE(reader.getPusVersion() == 2); - REQUIRE(reader.getSequenceCount() == 0x34); - REQUIRE(reader.getUserData() == nullptr); - REQUIRE(reader.getUserDataLen() == 0); - REQUIRE(reader.getFullData() == buf.data()); - REQUIRE(reader.getSourceId() == 0x00); - REQUIRE(reader.getAcknowledgeFlags() == 0b1111); - // This value was verified to be correct - REQUIRE(reader.getErrorControl() == 0xee63); + }; SECTION("State") { REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.isNull()); - + PusTcReader* readerPtr = nullptr; + bool callDelete = false; SECTION("Setter") { - REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); - checkReaderFields(reader); + readerPtr = &reader; + REQUIRE(readerPtr->setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(readerPtr->parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); } SECTION("Directly Constructed") { - PusTcReader secondReader(buf.data(), serLen); - REQUIRE(not secondReader.isNull()); - REQUIRE(secondReader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); - checkReaderFields(secondReader); + callDelete = true; + readerPtr = new PusTcReader(buf.data(), serLen); + REQUIRE(not readerPtr->isNull()); + REQUIRE(readerPtr->parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + } + REQUIRE(not readerPtr->isNull()); + REQUIRE(readerPtr->getPacketType() == ccsds::PacketType::TC); + REQUIRE(readerPtr->getApid() == 0x02); + REQUIRE(readerPtr->getService() == 17); + REQUIRE(readerPtr->getSubService() == 1); + REQUIRE(readerPtr->getFullPacketLen() == 13); + REQUIRE(readerPtr->getPacketDataLen() == 6); + REQUIRE(readerPtr->getPusVersion() == 2); + REQUIRE(readerPtr->getSequenceCount() == 0x34); + REQUIRE(readerPtr->getUserData() == nullptr); + REQUIRE(readerPtr->getUserDataLen() == 0); + REQUIRE(readerPtr->getFullData() == buf.data()); + REQUIRE(readerPtr->getSourceId() == 0x00); + REQUIRE(readerPtr->getAcknowledgeFlags() == 0b1111); + // This value was verified to be correct + REQUIRE(readerPtr->getErrorControl() == 0xee63); + if (callDelete) { + delete readerPtr; } } @@ -67,7 +72,7 @@ TEST_CASE("PUS TC Reader", "[pus-tc-reader]") { SECTION("With application data") { auto& params = creator.getPusParams(); std::array data{1, 2, 3}; - creator.setRawAppData({data.data(), data.size()}); + creator.setRawUserData(data.data(), data.size()); REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index 0cb1c093..2b60515f 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -1,9 +1,10 @@ #include +#include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/tmtcpacket/pus/tm.h" -#include "fsfw/globalfunctions/CRC.h" #include "mocks/CdsShortTimestamperMock.h" +#include "mocks/SimpleSerializable.h" TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { auto packetId = PacketId(ccsds::PacketType::TC, true, 0xef); @@ -20,6 +21,8 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { SECTION("State") { REQUIRE(creator.isTm()); REQUIRE(creator.getApid() == 0xef); + REQUIRE(creator.getPusVersion() == 2); + REQUIRE(creator.getScTimeRefStatus() == 0); REQUIRE(creator.getService() == 17); REQUIRE(creator.getSubService() == 2); REQUIRE(creator.getTimestamper() == &timeStamper); @@ -34,6 +37,12 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { REQUIRE(timeStamper.getSizeCallCount == 1); } + SECTION("SP Params") { + auto& spParamsRef = creator.getSpParams(); + REQUIRE(spParamsRef.dataLen == 15); + REQUIRE(spParamsRef.packetId.apid == 0xef); + } + SECTION("Serialization") { REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[0] == 0x08); @@ -54,7 +63,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { // Destination ID REQUIRE(((buf[11] << 8) | buf[12]) == 0); // Custom timestamp - for(size_t i = 1; i < 8; i++) { + for (size_t i = 1; i < 8; i++) { REQUIRE(buf[12 + i] == i); } REQUIRE(serLen == 22); @@ -87,12 +96,13 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { SECTION("Deserialization fails") { const uint8_t* roDataPtr = nullptr; - REQUIRE(creator.deSerialize(&roDataPtr, &serLen, SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(creator.deSerialize(&roDataPtr, &serLen, SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_FAILED); } SECTION("Serialize with Raw Data") { std::array data{1, 2, 3}; - creator.setRawSourceData({data.data(), data.size()}); + creator.setRawUserData(data.data(), data.size()); REQUIRE(creator.getFullPacketLen() == 25); REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[20] == 1); @@ -101,6 +111,34 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { } SECTION("Serialize with Serializable") { + auto simpleSer = SimpleSerializable(); + creator.setSerializableUserData(&simpleSer); + REQUIRE(creator.getFullPacketLen() == 25); + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(buf[20] == 1); + REQUIRE(buf[21] == 2); + REQUIRE(buf[22] == 3); + } + SECTION("Empty Ctor") { + PusTmCreator creatorFromEmptyCtor; + // 6 bytes CCSDS header, 7 bytes secondary header, no timestamp (IF is null), + // 0 bytes application data, 2 bytes CRC + REQUIRE(creatorFromEmptyCtor.getFullPacketLen() == 15); + // As specified in standard, the data length fields is the total size of the packet without + // the primary header minus 1 + REQUIRE(creatorFromEmptyCtor.getPacketDataLen() == 8); + creatorFromEmptyCtor.setTimeStamper(&timeStamper); + REQUIRE(creatorFromEmptyCtor.getFullPacketLen() == 22); + REQUIRE(creatorFromEmptyCtor.getPacketDataLen() == 15); + } + + SECTION("Invalid Buffer Sizes") { + size_t reqSize = creator.getSerializedSize(); + for (size_t maxSize = 0; maxSize < reqSize; maxSize++) { + dataPtr = buf.data(); + serLen = 0; + REQUIRE(creator.serialize(&dataPtr, &serLen, maxSize) == SerializeIF::BUFFER_TOO_SHORT); + } } } \ No newline at end of file From 2dfbce6174582346c87367415b8ded3732eb44ec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Jul 2022 17:11:55 +0200 Subject: [PATCH 074/532] start TM reader unittests --- unittests/tmtcpacket/testPusTmReader.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/unittests/tmtcpacket/testPusTmReader.cpp b/unittests/tmtcpacket/testPusTmReader.cpp index 59c01914..69dc7088 100644 --- a/unittests/tmtcpacket/testPusTmReader.cpp +++ b/unittests/tmtcpacket/testPusTmReader.cpp @@ -1,3 +1,18 @@ #include -TEST_CASE("PUS TM Reader", "[pus-tm-reader]") {} \ No newline at end of file +#include "fsfw/tmtcpacket/pus/tm/PusTmCreator.h" +#include "mocks/CdsShortTimestamperMock.h" + +TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { + auto packetId = PacketId(ccsds::PacketType::TC, true, 0xef); + auto spParams = + SpacePacketParams(packetId, PacketSeqCtrl(ccsds::SequenceFlags::UNSEGMENTED, 22), 0x00); + auto timeStamper = CdsShortTimestamperMock(); + auto pusTmParams = PusTmParams(17, 2, &timeStamper); + timeStamper.valueToStamp = {1, 2, 3, 4, 5, 6, 7}; + PusTmCreator creator(spParams, pusTmParams); + + SECTION("State") { + + } +} \ No newline at end of file From b350018cad26979c3dd11a4b55e924c5d53bf49a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Jul 2022 18:22:35 +0200 Subject: [PATCH 075/532] completed basic test set --- src/fsfw/timemanager/TimeReaderIF.h | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp | 2 + src/fsfw/tmtcpacket/pus/tc/PusTcReader.h | 7 +- src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp | 8 +- src/fsfw/tmtcpacket/pus/tm/PusTmReader.h | 6 +- unittests/mocks/CdsShortTimestamperMock.h | 19 ++++- unittests/tmtcpacket/testPusTcReader.cpp | 5 +- unittests/tmtcpacket/testPusTmCreator.cpp | 1 + unittests/tmtcpacket/testPusTmReader.cpp | 86 ++++++++++++++++++++-- 9 files changed, 117 insertions(+), 19 deletions(-) diff --git a/src/fsfw/timemanager/TimeReaderIF.h b/src/fsfw/timemanager/TimeReaderIF.h index 388f7d71..cfad90ff 100644 --- a/src/fsfw/timemanager/TimeReaderIF.h +++ b/src/fsfw/timemanager/TimeReaderIF.h @@ -8,7 +8,7 @@ class TimeReaderIF { public: virtual ~TimeReaderIF() = default; - virtual ReturnValue_t readTimeStamp(const uint8_t* buffer, uint8_t maxSize) = 0; + virtual ReturnValue_t readTimeStamp(const uint8_t* buffer, size_t maxSize) = 0; // Would be nice to have this, but the clock backend needs to be redesigned // virtual ReturnValue_t readTimestampLen(const uint8_t* buffer, uint8_t maxSize, size_t& // timestampLen) = 0; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp index f5dd143a..f50affa7 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp @@ -82,3 +82,5 @@ const uint8_t* PusTcReader::getUserData() const { return pointers.userDataStart; size_t PusTcReader::getUserDataLen() const { return appDataSize; } bool PusTcReader::isNull() const { return spReader.isNull(); } + +PusTcReader::operator bool() const { return not isNull(); } diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h index 3be2e5e6..1b9eea49 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h @@ -33,16 +33,13 @@ class PusTcReader : public PusTcIF, * @param setData The position where the packet data lies. */ PusTcReader(const uint8_t* setData, size_t size); + ~PusTcReader() override; + explicit operator bool() const; [[nodiscard]] bool isNull() const; ReturnValue_t parseDataWithCrcCheck(); ReturnValue_t parseDataWithoutCrcCheck(); - /** - * This is the empty default destructor. - */ - ~PusTcReader() override; - /** * This is a debugging helper method that prints the whole packet content * to the screen. diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp index e700a428..0dfab4ce 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp @@ -71,8 +71,11 @@ ReturnValue_t PusTmReader::parseData(bool crcCheck) { return SerializeIF::STREAM_TOO_SHORT; } currentOffset += timestampLen; - pointers.userDataStart = pointers.spHeaderStart + currentOffset; sourceDataLen = spReader.getFullPacketLen() - currentOffset - sizeof(ecss::PusChecksumT); + pointers.userDataStart = nullptr; + if (sourceDataLen > 0) { + pointers.userDataStart = pointers.spHeaderStart + currentOffset; + } currentOffset += sourceDataLen; pointers.crcStart = pointers.spHeaderStart + currentOffset; if (crcCheck) { @@ -84,3 +87,6 @@ ReturnValue_t PusTmReader::parseData(bool crcCheck) { } return HasReturnvaluesIF::RETURN_OK; } +bool PusTmReader::isNull() const { return spReader.isNull(); } + +PusTmReader::operator bool() const { return not isNull(); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h index 1d91eb95..e5a61aec 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h @@ -21,6 +21,8 @@ class PusTmReader : public PusTmIF, ReturnValue_t parseDataWithCrcCheck(); const uint8_t* getFullData() override; + explicit operator bool() const; + [[nodiscard]] bool isNull() const; void setTimeReader(TimeReaderIF* timeReader); TimeReaderIF* getTimeReader(); ReturnValue_t setReadOnlyData(const uint8_t* data, size_t size); @@ -30,8 +32,8 @@ class PusTmReader : public PusTmIF, [[nodiscard]] uint8_t getPusVersion() const override; [[nodiscard]] uint8_t getService() const override; [[nodiscard]] uint8_t getSubService() const override; - const uint8_t* getUserData() const override; - size_t getUserDataLen() const override; + [[nodiscard]] const uint8_t* getUserData() const override; + [[nodiscard]] size_t getUserDataLen() const override; uint8_t getScTimeRefStatus() override; uint16_t getMessageTypeCounter() override; uint16_t getDestId() override; diff --git a/unittests/mocks/CdsShortTimestamperMock.h b/unittests/mocks/CdsShortTimestamperMock.h index 779859d0..460c98c5 100644 --- a/unittests/mocks/CdsShortTimestamperMock.h +++ b/unittests/mocks/CdsShortTimestamperMock.h @@ -5,9 +5,11 @@ #include "fsfw/timemanager/TimeStamperIF.h" -class CdsShortTimestamperMock : public TimeStamperIF { +class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { public: unsigned int serializeCallCount = 0; + unsigned int deserializeCallCount = 0; + ReturnValue_t lastDeserializeResult = HasReturnvaluesIF::RETURN_OK; ReturnValue_t lastSerializeResult = HasReturnvaluesIF::RETURN_OK; unsigned int getSizeCallCount = 0; std::array valueToStamp{}; @@ -38,8 +40,15 @@ class CdsShortTimestamperMock : public TimeStamperIF { } ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override { - return HasReturnvaluesIF::RETURN_FAILED; + deserializeCallCount += 1; + if (*size < 7) { + lastDeserializeResult = SerializeIF::STREAM_TOO_SHORT; + return lastDeserializeResult; + } + std::copy(*buffer, *buffer + getSerializedSize(), valueToStamp.begin()); + return lastDeserializeResult; } + [[nodiscard]] size_t getTimestampSize() const override { return getSerializedSize(); } ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override { return 0; } @@ -47,7 +56,13 @@ class CdsShortTimestamperMock : public TimeStamperIF { serializeCallCount = 0; getSizeCallCount = 0; } + ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override { + return deSerialize(&buffer, &maxSize, SerializeIF::Endianness::NETWORK); + } + size_t getTimestampLen() override { return getSerializedSize(); } + timeval &getTime() override { return dummyTime; } private: + timeval dummyTime{}; }; #endif // FSFW_TESTS_CDSSHORTTIMESTAMPERMOCK_H diff --git a/unittests/tmtcpacket/testPusTcReader.cpp b/unittests/tmtcpacket/testPusTcReader.cpp index 82a88542..3245218a 100644 --- a/unittests/tmtcpacket/testPusTcReader.cpp +++ b/unittests/tmtcpacket/testPusTcReader.cpp @@ -14,13 +14,11 @@ TEST_CASE("PUS TC Reader", "[pus-tc-reader]") { uint8_t* dataPtr = buf.data(); size_t serLen = 0; PusTcReader reader; - auto checkReaderFields = [&](PusTcReader& reader) { - - }; SECTION("State") { REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.isNull()); + REQUIRE(not reader); PusTcReader* readerPtr = nullptr; bool callDelete = false; SECTION("Setter") { @@ -35,6 +33,7 @@ TEST_CASE("PUS TC Reader", "[pus-tc-reader]") { REQUIRE(readerPtr->parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); } REQUIRE(not readerPtr->isNull()); + REQUIRE(*readerPtr); REQUIRE(readerPtr->getPacketType() == ccsds::PacketType::TC); REQUIRE(readerPtr->getApid() == 0x02); REQUIRE(readerPtr->getService() == 17); diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index 2b60515f..035126f0 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -70,6 +70,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { REQUIRE(CRC::crc16ccitt(buf.data(), serLen) == 0); REQUIRE(buf[20] == 0x03); REQUIRE(buf[21] == 0x79); + REQUIRE(timeStamper.serializeCallCount == 1); } SECTION("Custom Fields") { diff --git a/unittests/tmtcpacket/testPusTmReader.cpp b/unittests/tmtcpacket/testPusTmReader.cpp index 69dc7088..8540b97c 100644 --- a/unittests/tmtcpacket/testPusTmReader.cpp +++ b/unittests/tmtcpacket/testPusTmReader.cpp @@ -1,18 +1,94 @@ #include #include "fsfw/tmtcpacket/pus/tm/PusTmCreator.h" +#include "fsfw/tmtcpacket/pus/tm/PusTmReader.h" #include "mocks/CdsShortTimestamperMock.h" TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { auto packetId = PacketId(ccsds::PacketType::TC, true, 0xef); auto spParams = SpacePacketParams(packetId, PacketSeqCtrl(ccsds::SequenceFlags::UNSEGMENTED, 22), 0x00); - auto timeStamper = CdsShortTimestamperMock(); - auto pusTmParams = PusTmParams(17, 2, &timeStamper); - timeStamper.valueToStamp = {1, 2, 3, 4, 5, 6, 7}; + auto timeStamperAndReader = CdsShortTimestamperMock(); + auto pusTmParams = PusTmParams(17, 2, &timeStamperAndReader); + timeStamperAndReader.valueToStamp = {1, 2, 3, 4, 5, 6, 7}; PusTmCreator creator(spParams, pusTmParams); + PusTmReader reader(&timeStamperAndReader); + std::array buf{}; + uint8_t* dataPtr = buf.data(); + size_t serLen = 0; - SECTION("State") { - + SECTION("Basic") { + PusTmReader* readerPtr = &reader; + bool deleteReader = false; + dataPtr = buf.data(); + serLen = 0; + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(not(*readerPtr)); + REQUIRE(readerPtr->isNull()); + + SECTION("Setter") { + REQUIRE(readerPtr->setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + } + SECTION("Full Construction") { + readerPtr = new PusTmReader(&timeStamperAndReader, buf.data(), serLen); + deleteReader = true; + } + SECTION("Time Stamper set manually") { + readerPtr = new PusTmReader(buf.data(), serLen); + readerPtr->setTimeReader(&timeStamperAndReader); + deleteReader = true; + } + REQUIRE(readerPtr); + REQUIRE(not readerPtr->isNull()); + REQUIRE(readerPtr->parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(readerPtr->getService() == 17); + REQUIRE(readerPtr->getSubService() == 2); + REQUIRE(readerPtr->getApid() == 0xef); + REQUIRE(readerPtr->getSequenceFlags() == ccsds::SequenceFlags::UNSEGMENTED); + REQUIRE(readerPtr->getScTimeRefStatus() == 0); + REQUIRE(readerPtr->getDestId() == 0); + REQUIRE(readerPtr->getMessageTypeCounter() == 0); + REQUIRE(readerPtr->getTimeReader() == &timeStamperAndReader); + REQUIRE(readerPtr->getPusVersion() == 2); + REQUIRE(readerPtr->getPacketDataLen() == 15); + REQUIRE(readerPtr->getFullPacketLen() == 22); + REQUIRE(readerPtr->getUserDataLen() == 0); + REQUIRE(readerPtr->getUserData() == nullptr); + REQUIRE(readerPtr->getFullData() == buf.data()); + if (deleteReader) { + delete readerPtr; + } + } + + SECTION("Invalid CRC") { + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + buf[20] = 0; + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.parseDataWithCrcCheck() == PusIF::INVALID_CRC_16); + } + + SECTION("Set Time Reader") { + reader.setTimeReader(nullptr); + REQUIRE(reader.getTimeReader() == nullptr); + } + + SECTION("Invalid CRC ignored") { + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + buf[20] = 0; + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.parseDataWithoutCrcCheck() == HasReturnvaluesIF::RETURN_OK); + } + + SECTION("Read with source data") { + std::array data{1, 2, 3}; + creator.setRawUserData(data.data(), data.size()); + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.getUserDataLen() == 3); + const uint8_t* roData = reader.getUserData(); + REQUIRE(roData[0] == 1); + REQUIRE(roData[1] == 2); + REQUIRE(roData[2] == 3); } } \ No newline at end of file From cb05329dd946d1503432934e4560806ff4f83674 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Jul 2022 18:31:00 +0200 Subject: [PATCH 076/532] completed baseline PUS TM unittests --- unittests/mocks/CdsShortTimestamperMock.h | 18 ++++++++++++++++++ unittests/tmtcpacket/testPusTmReader.cpp | 14 ++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/unittests/mocks/CdsShortTimestamperMock.h b/unittests/mocks/CdsShortTimestamperMock.h index 460c98c5..c53c22f9 100644 --- a/unittests/mocks/CdsShortTimestamperMock.h +++ b/unittests/mocks/CdsShortTimestamperMock.h @@ -12,6 +12,10 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { ReturnValue_t lastDeserializeResult = HasReturnvaluesIF::RETURN_OK; ReturnValue_t lastSerializeResult = HasReturnvaluesIF::RETURN_OK; unsigned int getSizeCallCount = 0; + bool nextSerFails = false; + ReturnValue_t serFailRetval = HasReturnvaluesIF::RETURN_FAILED; + bool nextDeserFails = false; + ReturnValue_t deserFailRetval = HasReturnvaluesIF::RETURN_FAILED; std::array valueToStamp{}; CdsShortTimestamperMock() = default; @@ -23,6 +27,9 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { Endianness streamEndianness) const override { auto &thisNonConst = const_cast(*this); thisNonConst.serializeCallCount += 1; + if (nextSerFails) { + return serFailRetval; + } if (*size + getSerializedSize() > maxSize) { thisNonConst.lastSerializeResult = SerializeIF::BUFFER_TOO_SHORT; return lastSerializeResult; @@ -41,6 +48,9 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override { deserializeCallCount += 1; + if (nextDeserFails) { + return deserFailRetval; + } if (*size < 7) { lastDeserializeResult = SerializeIF::STREAM_TOO_SHORT; return lastDeserializeResult; @@ -55,7 +65,15 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { void reset() { serializeCallCount = 0; getSizeCallCount = 0; + deserializeCallCount = 0; + nextSerFails = false; + nextDeserFails = false; + lastSerializeResult = HasReturnvaluesIF::RETURN_OK; + lastDeserializeResult = HasReturnvaluesIF::RETURN_OK; + deserFailRetval = HasReturnvaluesIF::RETURN_FAILED; + serFailRetval = HasReturnvaluesIF::RETURN_FAILED; } + ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override { return deSerialize(&buffer, &maxSize, SerializeIF::Endianness::NETWORK); } diff --git a/unittests/tmtcpacket/testPusTmReader.cpp b/unittests/tmtcpacket/testPusTmReader.cpp index 8540b97c..7a61b731 100644 --- a/unittests/tmtcpacket/testPusTmReader.cpp +++ b/unittests/tmtcpacket/testPusTmReader.cpp @@ -91,4 +91,18 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { REQUIRE(roData[1] == 2); REQUIRE(roData[2] == 3); } + + SECTION("Invalid stream lengths") { + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + for (size_t i = 0; i < serLen - 1; i++) { + REQUIRE(reader.setReadOnlyData(buf.data(), i) == SerializeIF::STREAM_TOO_SHORT); + } + } + + SECTION("Reading timestamp fails") { + timeStamperAndReader.nextDeserFails = true; + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_FAILED); + } } \ No newline at end of file From 133894f4ba06dda17346fddaa4d448fb95a51776 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Jul 2022 18:46:58 +0200 Subject: [PATCH 077/532] add basic CCSDS tests --- CMakeLists.txt | 2 +- src/fsfw/tmtcpacket/ccsds/PacketId.h | 16 +++++++-- unittests/tmtcpacket/CMakeLists.txt | 1 + unittests/tmtcpacket/testCcsds.cpp | 53 ++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 unittests/tmtcpacket/testCcsds.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e59eb4c5..acc061fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,7 +168,7 @@ if(FSFW_BUILD_TESTS) configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h) project(${FSFW_TEST_TGT} CXX C) - add_executable(${FSFW_TEST_TGT}) + add_executable(${FSFW_TEST_TGT} unittests/tmtcpacket/testCcsds.cpp) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) diff --git a/src/fsfw/tmtcpacket/ccsds/PacketId.h b/src/fsfw/tmtcpacket/ccsds/PacketId.h index 29b82f13..2c77652c 100644 --- a/src/fsfw/tmtcpacket/ccsds/PacketId.h +++ b/src/fsfw/tmtcpacket/ccsds/PacketId.h @@ -42,8 +42,20 @@ struct PacketId : public SerializeIF { ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override { - uint16_t pscRaw = raw(); - return SerializeAdapter::serialize(&pscRaw, buffer, size, maxSize, streamEndianness); + if (*size + getSerializedSize() > maxSize) { + return SerializeIF::BUFFER_TOO_SHORT; + } + uint16_t idRaw = raw(); + // Leave the first three bits untouched, they could generally contain the CCSDS version, + // or more generally, the packet ID is a 13 bit field + **buffer &= ~0x1f; + **buffer |= (idRaw >> 8) & 0x1f; + *size += 1; + *buffer += 1; + **buffer = idRaw & 0xff; + *size += 1; + *buffer += 1; + return HasReturnvaluesIF::RETURN_OK; } [[nodiscard]] size_t getSerializedSize() const override { return 2; } diff --git a/unittests/tmtcpacket/CMakeLists.txt b/unittests/tmtcpacket/CMakeLists.txt index f47c6370..dd0100a6 100644 --- a/unittests/tmtcpacket/CMakeLists.txt +++ b/unittests/tmtcpacket/CMakeLists.txt @@ -5,4 +5,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testPusTcReader.cpp testPusTmCreator.cpp testPusTmReader.cpp + testCcsds.cpp ) diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp new file mode 100644 index 00000000..28b255e5 --- /dev/null +++ b/unittests/tmtcpacket/testCcsds.cpp @@ -0,0 +1,53 @@ +#include +#include + +#include "fsfw/tmtcpacket/ccsds/PacketId.h" +#include "fsfw/tmtcpacket/ccsds/header.h" + +TEST_CASE("CCSDS Low Level", "[ccsds-ll]") { + SECTION("Lowlevel Header Packet ID test") { + ccsds::PrimaryHeader header{}; + uint16_t packetIdRaw = 0x3ff; + ccsds::setPacketId(header, packetIdRaw); + REQUIRE(header.packetIdHAndVersion == 3); + REQUIRE(header.packetIdL == 0xff); + REQUIRE(ccsds::getPacketId(header) == 0x3ff); + header.packetIdHAndVersion |= 0b00100000; + REQUIRE(ccsds::getPacketId(header) == 0x3ff); + REQUIRE(ccsds::getVersion(header) == 0b001); + } + + SECTION("Lowlevel Header APID Test") { + ccsds::PrimaryHeader header{}; + uint16_t packetIdRaw = 0x3ff; + ccsds::setPacketId(header, packetIdRaw); + ccsds::setApid(header, 0x1ff); + REQUIRE(ccsds::getPacketId(header) == 0x1ff); + } + + SECTION("Lowlevel Packet Length Test") { + ccsds::PrimaryHeader header{}; + header.packetLenH = 0x02; + header.packetLenL = 0x03; + REQUIRE(ccsds::getPacketLen(header) == 0x0203); + } +} + +TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { + PacketId packetId; + std::array buf{}; + size_t serLen = 0; + uint8_t* ptr = buf.data(); + SECTION("Basic") { + packetId.apid = 0x1ff; + packetId.secHeaderFlag = false; + packetId.packetType = ccsds::PacketType::TM; + REQUIRE(packetId.raw() == 0x1ff); + REQUIRE(packetId.serialize(&ptr, &serLen, buf.size(), SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); + REQUIRE(buf[0] == 0x1); + REQUIRE(buf[1] == 0xff); + } +} + +TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") {} From 42a1d6cccd5af37622eef41adba0d44520fd7814 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 23 Jul 2022 10:03:42 +0200 Subject: [PATCH 078/532] default implementation of simple serialize/deserialize --- src/fsfw/serialize/SerializeIF.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index d806c161..de5abaeb 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -90,6 +90,32 @@ class SerializeIF { */ virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) = 0; + + /** + * Helper method which can be used if serialization should be performed without any additional + * pointer arithmetic on a passed buffer pointer + * @param buffer + * @param maxSize + * @param streamEndianness + * @return + */ + virtual ReturnValue_t serialize(uint8_t* buffer, size_t maxSize, Endianness streamEndianness) { + size_t tmpSize = 0; + return serialize(&buffer, &tmpSize, maxSize, streamEndianness); + } + + /** + * Helper methods which can be used if deserialization should be performed without any additional + * pointer arithmetic on a passed buffer pointer + * @param buffer + * @param maxSize + * @param streamEndianness + * @return + */ + virtual ReturnValue_t deSerialize(const uint8_t* buffer, size_t maxSize, + Endianness streamEndianness) { + return deSerialize(&buffer, &maxSize, streamEndianness); + } }; #endif /* FSFW_SERIALIZE_SERIALIZEIF_H_ */ From 99aaf7068d1a53f4e849d6280d3b48aac03ceb6d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 23 Jul 2022 10:05:57 +0200 Subject: [PATCH 079/532] some tests --- src/fsfw/serialize/SerializeIF.h | 4 ++-- unittests/tmtcpacket/testCcsds.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index de5abaeb..ad8d3730 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -66,7 +66,7 @@ class SerializeIF { * Gets the size of a object if it would be serialized in a buffer * @return Size of serialized object */ - virtual size_t getSerializedSize() const = 0; + [[nodiscard]] virtual size_t getSerializedSize() const = 0; /** * @brief @@ -99,7 +99,7 @@ class SerializeIF { * @param streamEndianness * @return */ - virtual ReturnValue_t serialize(uint8_t* buffer, size_t maxSize, Endianness streamEndianness) { + virtual ReturnValue_t serialize(uint8_t* buffer, size_t maxSize, Endianness streamEndianness) const { size_t tmpSize = 0; return serialize(&buffer, &tmpSize, maxSize, streamEndianness); } diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp index 28b255e5..a2679896 100644 --- a/unittests/tmtcpacket/testCcsds.cpp +++ b/unittests/tmtcpacket/testCcsds.cpp @@ -43,7 +43,7 @@ TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { packetId.secHeaderFlag = false; packetId.packetType = ccsds::PacketType::TM; REQUIRE(packetId.raw() == 0x1ff); - REQUIRE(packetId.serialize(&ptr, &serLen, buf.size(), SerializeIF::Endianness::NETWORK) == + REQUIRE(packetId.serialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[0] == 0x1); REQUIRE(buf[1] == 0xff); From ddad97033d6224c65fa27195da7693f7907b963b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 23 Jul 2022 10:06:42 +0200 Subject: [PATCH 080/532] expand serialize IF further --- CMakeLists.txt | 4 +-- src/fsfw/osal/linux/MessageQueue.cpp | 3 +- src/fsfw/serialize/SerializeIF.h | 9 +++--- src/fsfw_hal/CMakeLists.txt | 4 +-- src/fsfw_hal/common/gpio/CMakeLists.txt | 4 +-- src/fsfw_hal/devicehandlers/CMakeLists.txt | 8 ++--- src/fsfw_hal/linux/CMakeLists.txt | 30 ++++++++----------- src/fsfw_hal/linux/gpio/CMakeLists.txt | 18 +++++------ src/fsfw_hal/linux/i2c/CMakeLists.txt | 9 +----- src/fsfw_hal/linux/rpi/CMakeLists.txt | 4 +-- src/fsfw_hal/linux/spi/CMakeLists.txt | 9 +----- src/fsfw_hal/linux/uart/CMakeLists.txt | 5 +--- src/fsfw_hal/linux/uio/CMakeLists.txt | 4 +-- src/fsfw_hal/stm32h7/CMakeLists.txt | 4 +-- .../stm32h7/devicetest/CMakeLists.txt | 4 +-- src/fsfw_hal/stm32h7/gpio/CMakeLists.txt | 4 +-- src/fsfw_hal/stm32h7/i2c/CMakeLists.txt | 3 +- src/fsfw_hal/stm32h7/spi/CMakeLists.txt | 18 +++++------ src/fsfw_hal/stm32h7/uart/CMakeLists.txt | 3 +- src/fsfw_tests/CMakeLists.txt | 4 +-- .../integration/assemblies/CMakeLists.txt | 4 +-- .../integration/controller/CMakeLists.txt | 4 +-- .../integration/devices/CMakeLists.txt | 7 ++--- .../integration/task/CMakeLists.txt | 4 +-- src/fsfw_tests/internal/CMakeLists.txt | 8 ++--- .../internal/globalfunctions/CMakeLists.txt | 4 +-- src/fsfw_tests/internal/osal/CMakeLists.txt | 7 ++--- .../internal/serialize/CMakeLists.txt | 4 +-- 28 files changed, 68 insertions(+), 125 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae1a621e..e59eb4c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,8 +104,8 @@ if(FSFW_GENERATE_SECTIONS) option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) endif() -option(FSFW_BUILD_TESTS - "Build unittest binary in addition to static library" OFF) +option(FSFW_BUILD_TESTS "Build unittest binary in addition to static library" + OFF) option(FSFW_CICD_BUILD "Build for CI/CD. This can disable problematic test" OFF) option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF) if(FSFW_BUILD_TESTS) diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index 4ef7f756..ec212165 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -292,7 +292,8 @@ ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messag sif::error << "MessageQueue::MessageQueue: Default MQ size " << defaultMqMaxMsg << " is too small for requested message depth " << messageDepth << std::endl; sif::error << "This error can be fixed by setting the maximum " - "allowed message depth higher" << std::endl; + "allowed message depth higher" + << std::endl; #else sif::printError( "MessageQueue::MessageQueue: Default MQ size %d is too small for" diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index de5abaeb..3f4fdc38 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -34,7 +34,7 @@ class SerializeIF { static const ReturnValue_t TOO_MANY_ELEMENTS = MAKE_RETURN_CODE(3); // !< There are too many elements to be deserialized - virtual ~SerializeIF() {} + virtual ~SerializeIF() = default; /** * @brief * Function to serialize the object into a buffer with maxSize. Size represents the written @@ -66,7 +66,7 @@ class SerializeIF { * Gets the size of a object if it would be serialized in a buffer * @return Size of serialized object */ - virtual size_t getSerializedSize() const = 0; + [[nodiscard]] virtual size_t getSerializedSize() const = 0; /** * @brief @@ -99,7 +99,8 @@ class SerializeIF { * @param streamEndianness * @return */ - virtual ReturnValue_t serialize(uint8_t* buffer, size_t maxSize, Endianness streamEndianness) { + virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize, + Endianness streamEndianness) const { size_t tmpSize = 0; return serialize(&buffer, &tmpSize, maxSize, streamEndianness); } @@ -112,7 +113,7 @@ class SerializeIF { * @param streamEndianness * @return */ - virtual ReturnValue_t deSerialize(const uint8_t* buffer, size_t maxSize, + virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t maxSize, Endianness streamEndianness) { return deSerialize(&buffer, &maxSize, streamEndianness); } diff --git a/src/fsfw_hal/CMakeLists.txt b/src/fsfw_hal/CMakeLists.txt index b7559d4b..057ab3a6 100644 --- a/src/fsfw_hal/CMakeLists.txt +++ b/src/fsfw_hal/CMakeLists.txt @@ -2,9 +2,9 @@ add_subdirectory(devicehandlers) add_subdirectory(common) if(UNIX) - add_subdirectory(linux) + add_subdirectory(linux) endif() if(FSFW_HAL_ADD_STM32H7) - add_subdirectory(stm32h7) + add_subdirectory(stm32h7) endif() diff --git a/src/fsfw_hal/common/gpio/CMakeLists.txt b/src/fsfw_hal/common/gpio/CMakeLists.txt index 098c05fa..5c81d9cc 100644 --- a/src/fsfw_hal/common/gpio/CMakeLists.txt +++ b/src/fsfw_hal/common/gpio/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GpioCookie.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE GpioCookie.cpp) diff --git a/src/fsfw_hal/devicehandlers/CMakeLists.txt b/src/fsfw_hal/devicehandlers/CMakeLists.txt index 94e67c72..17139416 100644 --- a/src/fsfw_hal/devicehandlers/CMakeLists.txt +++ b/src/fsfw_hal/devicehandlers/CMakeLists.txt @@ -1,5 +1,3 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GyroL3GD20Handler.cpp - MgmRM3100Handler.cpp - MgmLIS3MDLHandler.cpp -) +target_sources( + ${LIB_FSFW_NAME} PRIVATE GyroL3GD20Handler.cpp MgmRM3100Handler.cpp + MgmLIS3MDLHandler.cpp) diff --git a/src/fsfw_hal/linux/CMakeLists.txt b/src/fsfw_hal/linux/CMakeLists.txt index f6d1a460..ffa5f5ee 100644 --- a/src/fsfw_hal/linux/CMakeLists.txt +++ b/src/fsfw_hal/linux/CMakeLists.txt @@ -1,25 +1,21 @@ if(FSFW_HAL_ADD_RASPBERRY_PI) - add_subdirectory(rpi) + add_subdirectory(rpi) endif() -target_sources(${LIB_FSFW_NAME} PRIVATE - UnixFileGuard.cpp - CommandExecutor.cpp - utility.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE UnixFileGuard.cpp CommandExecutor.cpp + utility.cpp) if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS) -if(FSFW_HAL_LINUX_ADD_LIBGPIOD) - add_subdirectory(gpio) -endif() - add_subdirectory(uart) - # Adding those does not really make sense on Apple systems which - # are generally host systems. It won't even compile as the headers - # are missing - if(NOT APPLE) - add_subdirectory(i2c) - add_subdirectory(spi) - endif() + if(FSFW_HAL_LINUX_ADD_LIBGPIOD) + add_subdirectory(gpio) + endif() + add_subdirectory(uart) + # Adding those does not really make sense on Apple systems which are generally + # host systems. It won't even compile as the headers are missing + if(NOT APPLE) + add_subdirectory(i2c) + add_subdirectory(spi) + endif() endif() add_subdirectory(uio) diff --git a/src/fsfw_hal/linux/gpio/CMakeLists.txt b/src/fsfw_hal/linux/gpio/CMakeLists.txt index b1609850..f6e7f2b0 100644 --- a/src/fsfw_hal/linux/gpio/CMakeLists.txt +++ b/src/fsfw_hal/linux/gpio/CMakeLists.txt @@ -1,16 +1,12 @@ -# This abstraction layer requires the gpiod library. You can install this library -# with "sudo apt-get install -y libgpiod-dev". If you are cross-compiling, you need -# to install the package before syncing the sysroot to your host computer. +# This abstraction layer requires the gpiod library. You can install this +# library with "sudo apt-get install -y libgpiod-dev". If you are +# cross-compiling, you need to install the package before syncing the sysroot to +# your host computer. find_library(LIB_GPIO gpiod) if(${LIB_GPIO} MATCHES LIB_GPIO-NOTFOUND) - message(STATUS "gpiod library not found, not linking against it") + message(STATUS "gpiod library not found, not linking against it") else() - target_sources(${LIB_FSFW_NAME} PRIVATE - LinuxLibgpioIF.cpp - ) - target_link_libraries(${LIB_FSFW_NAME} PRIVATE - ${LIB_GPIO} - ) + target_sources(${LIB_FSFW_NAME} PRIVATE LinuxLibgpioIF.cpp) + target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${LIB_GPIO}) endif() - diff --git a/src/fsfw_hal/linux/i2c/CMakeLists.txt b/src/fsfw_hal/linux/i2c/CMakeLists.txt index 3eb0882c..b94bdc99 100644 --- a/src/fsfw_hal/linux/i2c/CMakeLists.txt +++ b/src/fsfw_hal/linux/i2c/CMakeLists.txt @@ -1,8 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - I2cComIF.cpp - I2cCookie.cpp -) - - - - +target_sources(${LIB_FSFW_NAME} PUBLIC I2cComIF.cpp I2cCookie.cpp) diff --git a/src/fsfw_hal/linux/rpi/CMakeLists.txt b/src/fsfw_hal/linux/rpi/CMakeLists.txt index 47be218c..3a865037 100644 --- a/src/fsfw_hal/linux/rpi/CMakeLists.txt +++ b/src/fsfw_hal/linux/rpi/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GpioRPi.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE GpioRPi.cpp) diff --git a/src/fsfw_hal/linux/spi/CMakeLists.txt b/src/fsfw_hal/linux/spi/CMakeLists.txt index 404e1f47..f242bb3b 100644 --- a/src/fsfw_hal/linux/spi/CMakeLists.txt +++ b/src/fsfw_hal/linux/spi/CMakeLists.txt @@ -1,8 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - SpiComIF.cpp - SpiCookie.cpp -) - - - - +target_sources(${LIB_FSFW_NAME} PUBLIC SpiComIF.cpp SpiCookie.cpp) diff --git a/src/fsfw_hal/linux/uart/CMakeLists.txt b/src/fsfw_hal/linux/uart/CMakeLists.txt index 21ed0278..9cad62a4 100644 --- a/src/fsfw_hal/linux/uart/CMakeLists.txt +++ b/src/fsfw_hal/linux/uart/CMakeLists.txt @@ -1,4 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - UartComIF.cpp - UartCookie.cpp -) +target_sources(${LIB_FSFW_NAME} PUBLIC UartComIF.cpp UartCookie.cpp) diff --git a/src/fsfw_hal/linux/uio/CMakeLists.txt b/src/fsfw_hal/linux/uio/CMakeLists.txt index e98a0865..e3498246 100644 --- a/src/fsfw_hal/linux/uio/CMakeLists.txt +++ b/src/fsfw_hal/linux/uio/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC - UioMapper.cpp -) +target_sources(${LIB_FSFW_NAME} PUBLIC UioMapper.cpp) diff --git a/src/fsfw_hal/stm32h7/CMakeLists.txt b/src/fsfw_hal/stm32h7/CMakeLists.txt index bae3b1ac..e8843ed3 100644 --- a/src/fsfw_hal/stm32h7/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/CMakeLists.txt @@ -2,6 +2,4 @@ add_subdirectory(spi) add_subdirectory(gpio) add_subdirectory(devicetest) -target_sources(${LIB_FSFW_NAME} PRIVATE - dma.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE dma.cpp) diff --git a/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt b/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt index 7bd4c3a9..8e789ddb 100644 --- a/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/devicetest/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - GyroL3GD20H.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE GyroL3GD20H.cpp) diff --git a/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt b/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt index 35245b25..54d76b2d 100644 --- a/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/gpio/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - gpio.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE gpio.cpp) diff --git a/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt b/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt index 5ecb0990..a0d48465 100644 --- a/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/i2c/CMakeLists.txt @@ -1,2 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE -) +target_sources(${LIB_FSFW_NAME} PRIVATE) diff --git a/src/fsfw_hal/stm32h7/spi/CMakeLists.txt b/src/fsfw_hal/stm32h7/spi/CMakeLists.txt index aa5541bc..9a98f502 100644 --- a/src/fsfw_hal/stm32h7/spi/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/spi/CMakeLists.txt @@ -1,9 +1,9 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - spiCore.cpp - spiDefinitions.cpp - spiInterrupts.cpp - mspInit.cpp - SpiCookie.cpp - SpiComIF.cpp - stm32h743zi.cpp -) +target_sources( + ${LIB_FSFW_NAME} + PRIVATE spiCore.cpp + spiDefinitions.cpp + spiInterrupts.cpp + mspInit.cpp + SpiCookie.cpp + SpiComIF.cpp + stm32h743zi.cpp) diff --git a/src/fsfw_hal/stm32h7/uart/CMakeLists.txt b/src/fsfw_hal/stm32h7/uart/CMakeLists.txt index 5ecb0990..a0d48465 100644 --- a/src/fsfw_hal/stm32h7/uart/CMakeLists.txt +++ b/src/fsfw_hal/stm32h7/uart/CMakeLists.txt @@ -1,2 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE -) +target_sources(${LIB_FSFW_NAME} PRIVATE) diff --git a/src/fsfw_tests/CMakeLists.txt b/src/fsfw_tests/CMakeLists.txt index 5e16e0a7..d161699a 100644 --- a/src/fsfw_tests/CMakeLists.txt +++ b/src/fsfw_tests/CMakeLists.txt @@ -1,7 +1,7 @@ if(FSFW_ADD_INTERNAL_TESTS) - add_subdirectory(internal) + add_subdirectory(internal) endif() if(NOT FSFW_BUILD_TESTS) - add_subdirectory(integration) + add_subdirectory(integration) endif() diff --git a/src/fsfw_tests/integration/assemblies/CMakeLists.txt b/src/fsfw_tests/integration/assemblies/CMakeLists.txt index 22c06600..63a6447a 100644 --- a/src/fsfw_tests/integration/assemblies/CMakeLists.txt +++ b/src/fsfw_tests/integration/assemblies/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestAssembly.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE TestAssembly.cpp) diff --git a/src/fsfw_tests/integration/controller/CMakeLists.txt b/src/fsfw_tests/integration/controller/CMakeLists.txt index f5655b71..5eeb5c68 100644 --- a/src/fsfw_tests/integration/controller/CMakeLists.txt +++ b/src/fsfw_tests/integration/controller/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestController.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE TestController.cpp) diff --git a/src/fsfw_tests/integration/devices/CMakeLists.txt b/src/fsfw_tests/integration/devices/CMakeLists.txt index cfd238d2..d5799197 100644 --- a/src/fsfw_tests/integration/devices/CMakeLists.txt +++ b/src/fsfw_tests/integration/devices/CMakeLists.txt @@ -1,5 +1,2 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestCookie.cpp - TestDeviceHandler.cpp - TestEchoComIF.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE TestCookie.cpp TestDeviceHandler.cpp + TestEchoComIF.cpp) diff --git a/src/fsfw_tests/integration/task/CMakeLists.txt b/src/fsfw_tests/integration/task/CMakeLists.txt index 4cd481bf..62d5e8ef 100644 --- a/src/fsfw_tests/integration/task/CMakeLists.txt +++ b/src/fsfw_tests/integration/task/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestTask.cpp -) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE TestTask.cpp) diff --git a/src/fsfw_tests/internal/CMakeLists.txt b/src/fsfw_tests/internal/CMakeLists.txt index 2a144a9b..c1af5467 100644 --- a/src/fsfw_tests/internal/CMakeLists.txt +++ b/src/fsfw_tests/internal/CMakeLists.txt @@ -1,8 +1,6 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - InternalUnitTester.cpp - UnittDefinitions.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE InternalUnitTester.cpp + UnittDefinitions.cpp) add_subdirectory(osal) add_subdirectory(serialize) -add_subdirectory(globalfunctions) \ No newline at end of file +add_subdirectory(globalfunctions) diff --git a/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt b/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt index cde97734..6e7e58ad 100644 --- a/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt +++ b/src/fsfw_tests/internal/globalfunctions/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - TestArrayPrinter.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE TestArrayPrinter.cpp) diff --git a/src/fsfw_tests/internal/osal/CMakeLists.txt b/src/fsfw_tests/internal/osal/CMakeLists.txt index 8d79d759..db1031a0 100644 --- a/src/fsfw_tests/internal/osal/CMakeLists.txt +++ b/src/fsfw_tests/internal/osal/CMakeLists.txt @@ -1,5 +1,2 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - testMq.cpp - testMutex.cpp - testSemaphore.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE testMq.cpp testMutex.cpp + testSemaphore.cpp) diff --git a/src/fsfw_tests/internal/serialize/CMakeLists.txt b/src/fsfw_tests/internal/serialize/CMakeLists.txt index 47e8b538..ee264d9d 100644 --- a/src/fsfw_tests/internal/serialize/CMakeLists.txt +++ b/src/fsfw_tests/internal/serialize/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE - IntTestSerialization.cpp -) +target_sources(${LIB_FSFW_NAME} PRIVATE IntTestSerialization.cpp) From 55a238d5533e1ee7c3477d570cd4ac82683afea0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 23 Jul 2022 10:24:56 +0200 Subject: [PATCH 081/532] extended serialize if further --- src/fsfw/serialize/SerializeIF.h | 26 +++++++++++++++++++ .../tmtcpacket/ccsds/SpacePacketCreator.cpp | 4 +-- .../tmtcpacket/ccsds/SpacePacketCreator.h | 4 ++- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 2 +- unittests/tmtcpacket/testCcsds.cpp | 11 +++++--- unittests/tmtcpacket/testCcsdsCreator.cpp | 14 +++++----- 6 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 3f4fdc38..82becb26 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -62,6 +62,20 @@ class SerializeIF { virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const = 0; + /** + * Forwards to regular @serialize call with network endianness + */ + virtual ReturnValue_t serializeNe(uint8_t** buffer, size_t* size, size_t maxSize) { + return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); + } + + /** + * If endianness is not explicitly specified, use machine endianness + */ + virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) { + return serialize(buffer, size, maxSize, SerializeIF::Endianness::MACHINE); + } + /** * Gets the size of a object if it would be serialized in a buffer * @return Size of serialized object @@ -90,6 +104,18 @@ class SerializeIF { */ virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) = 0; + /** + * Forwards to regular @deSerialize call with network endianness + */ + virtual ReturnValue_t deSerializeNe(const uint8_t** buffer, size_t* size, size_t maxSize) { + return deSerialize(buffer, size, SerializeIF::Endianness::NETWORK); + } + /** + * If endianness is not explicitly specified, use machine endianness + */ + virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size, size_t maxSize) { + return deSerialize(buffer, size, SerializeIF::Endianness::MACHINE); + } /** * Helper method which can be used if serialization should be performed without any additional diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp index 7ae8656f..05da88b4 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp @@ -48,9 +48,6 @@ ReturnValue_t SpacePacketCreator::deSerialize(const uint8_t **buffer, size_t *si } bool SpacePacketCreator::isValid() const { return valid; } -ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize) const { - return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); -} void SpacePacketCreator::setApid(uint16_t apid) { if (apid < ccsds::LIMIT_APID) { params.packetId.apid = apid; @@ -83,3 +80,4 @@ SpacePacketParams &SpacePacketCreator::getParams() { return params; } void SpacePacketCreator::setPacketType(ccsds::PacketType type) { params.packetId.packetType = type; } +bool SpacePacketCreator::operator==(const SpacePacketCreator &other) const { return false; } diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h index de62283f..d30457ea 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h @@ -24,6 +24,9 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF { public: SpacePacketCreator() = default; explicit SpacePacketCreator(SpacePacketParams params); + + bool operator==(const SpacePacketCreator &other) const; + SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid, ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen, uint8_t version = 0); @@ -41,7 +44,6 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF { void setSeqFlags(ccsds::SequenceFlags flags); void setDataLen(uint16_t dataLen); - ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const; ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index b8ef0852..03cf2fbf 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -43,7 +43,7 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max if (*size + getSerializedSize() > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } - ReturnValue_t result = spCreator.serialize(buffer, size, maxSize); + ReturnValue_t result = spCreator.serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp index a2679896..7f337b6d 100644 --- a/unittests/tmtcpacket/testCcsds.cpp +++ b/unittests/tmtcpacket/testCcsds.cpp @@ -36,18 +36,23 @@ TEST_CASE("CCSDS Low Level", "[ccsds-ll]") { TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { PacketId packetId; std::array buf{}; - size_t serLen = 0; - uint8_t* ptr = buf.data(); SECTION("Basic") { packetId.apid = 0x1ff; packetId.secHeaderFlag = false; packetId.packetType = ccsds::PacketType::TM; REQUIRE(packetId.raw() == 0x1ff); - REQUIRE(packetId.serialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == + REQUIRE(packetId.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[0] == 0x1); REQUIRE(buf[1] == 0xff); } + + SECTION("From Raw") { + auto newId = PacketId(ccsds::PacketType::TC, true, 0x2ff); + uint16_t rawId = newId.raw(); + REQUIRE(rawId == 0x1aff); + REQUIRE(PacketId::fromRaw(rawId) == newId); + } } TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") {} diff --git a/unittests/tmtcpacket/testCcsdsCreator.cpp b/unittests/tmtcpacket/testCcsdsCreator.cpp index 2043d6a6..91122ef9 100644 --- a/unittests/tmtcpacket/testCcsdsCreator.cpp +++ b/unittests/tmtcpacket/testCcsdsCreator.cpp @@ -40,7 +40,7 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { } SECTION("Raw Output") { - REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(base.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); // TC, and secondary header flag is set -> 0b0001100 -> 0x18 REQUIRE(buf[0] == 0x18); // APID 0x02 @@ -62,7 +62,7 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { base.setSeqFlags(ccsds::SequenceFlags::UNSEGMENTED); base.setDataLen(static_cast(std::pow(2, 16)) - 1); REQUIRE(base.isValid()); - REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(base.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[0] == 0x1F); REQUIRE(buf[1] == 0xFF); REQUIRE(buf[2] == 0xFF); @@ -75,28 +75,28 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { SpacePacketCreator invalid = SpacePacketCreator( ccsds::PacketType::TC, true, 0xFFFF, ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); REQUIRE(not invalid.isValid()); - REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(invalid.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); } SECTION("Invalid Seq Count") { SpacePacketCreator invalid = SpacePacketCreator( ccsds::PacketType::TC, true, 0x02, ccsds::SequenceFlags::FIRST_SEGMENT, 0xFFFF, 0x16); REQUIRE(not invalid.isValid()); - REQUIRE(invalid.serialize(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(invalid.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); } SECTION("Invalid Buf Size 1") { serLen = 2; - REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(base.serializeNe(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT); } SECTION("Invalid Buf Size 2") { serLen = 4; - REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(base.serializeNe(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT); } SECTION("Invalid Buf Size 3") { serLen = 6; - REQUIRE(base.serialize(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(base.serializeNe(&bufPtr, &serLen, buf.size()) == SerializeIF::BUFFER_TOO_SHORT); } } From 8e05fc0417d7fa247bf10c65ecc559b0de1fe3bb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 23 Jul 2022 10:28:01 +0200 Subject: [PATCH 082/532] added a few more methods --- src/fsfw/serialize/SerializeIF.h | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 3f4fdc38..9fc5b731 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -61,6 +61,18 @@ class SerializeIF { */ virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const = 0; + /** + * Forwards to regular @serialize call with network endianness + */ + virtual ReturnValue_t serializeNe(uint8_t** buffer, size_t* size, size_t maxSize) { + return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); + } + /** + * If endianness is not explicitly specified, use machine endianness + */ + virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) { + return serialize(buffer, size, maxSize, SerializeIF::Endianness::MACHINE); + } /** * Gets the size of a object if it would be serialized in a buffer @@ -90,6 +102,18 @@ class SerializeIF { */ virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) = 0; + /** + * Forwards to regular @deSerialize call with network endianness + */ + virtual ReturnValue_t deSerializeNe(const uint8_t** buffer, size_t* size, size_t maxSize) { + return deSerialize(buffer, size, SerializeIF::Endianness::NETWORK); + } + /** + * If endianness is not explicitly specified, use machine endianness + */ + virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size, size_t maxSize) { + return deSerialize(buffer, size, SerializeIF::Endianness::MACHINE); + } /** * Helper method which can be used if serialization should be performed without any additional @@ -104,6 +128,18 @@ class SerializeIF { size_t tmpSize = 0; return serialize(&buffer, &tmpSize, maxSize, streamEndianness); } + /** + * Forwards to regular @serialize call with network endianness + */ + virtual ReturnValue_t serializeNe(uint8_t *buffer, size_t maxSize) const { + return serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); + } + /** + * If endianness is not explicitly specified, use machine endianness + */ + virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize) const { + return serialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); + } /** * Helper methods which can be used if deserialization should be performed without any additional @@ -117,6 +153,18 @@ class SerializeIF { Endianness streamEndianness) { return deSerialize(&buffer, &maxSize, streamEndianness); } + /** + * Forwards to regular @serialize call with network endianness + */ + virtual ReturnValue_t deSerializeNe(uint8_t *buffer, size_t maxSize) const { + return serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); + } + /** + * If endianness is not explicitly specified, use machine endianness + */ + virtual ReturnValue_t deSerialize(uint8_t *buffer, size_t maxSize) const { + return serialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); + } }; #endif /* FSFW_SERIALIZE_SERIALIZEIF_H_ */ From b66fd63cb432162ea495ecb9f5717fc3daec758f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 23 Jul 2022 10:29:19 +0200 Subject: [PATCH 083/532] remove doubly defines --- src/fsfw/serialize/SerializeIF.h | 14 -------------- unittests/tmtcpacket/testCcsds.cpp | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 0c0e4c42..9fc5b731 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -74,20 +74,6 @@ class SerializeIF { return serialize(buffer, size, maxSize, SerializeIF::Endianness::MACHINE); } - /** - * Forwards to regular @serialize call with network endianness - */ - virtual ReturnValue_t serializeNe(uint8_t** buffer, size_t* size, size_t maxSize) { - return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); - } - - /** - * If endianness is not explicitly specified, use machine endianness - */ - virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) { - return serialize(buffer, size, maxSize, SerializeIF::Endianness::MACHINE); - } - /** * Gets the size of a object if it would be serialized in a buffer * @return Size of serialized object diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp index 7f337b6d..1bae5912 100644 --- a/unittests/tmtcpacket/testCcsds.cpp +++ b/unittests/tmtcpacket/testCcsds.cpp @@ -41,7 +41,7 @@ TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { packetId.secHeaderFlag = false; packetId.packetType = ccsds::PacketType::TM; REQUIRE(packetId.raw() == 0x1ff); - REQUIRE(packetId.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == + REQUIRE(packetId.SerializeIF::serializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[0] == 0x1); REQUIRE(buf[1] == 0xff); From f2bf4b463e8bfe3219a368479ada88346528af18 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 23 Jul 2022 10:34:19 +0200 Subject: [PATCH 084/532] expand serializeIF tests --- CMakeLists.txt | 2 +- unittests/serialize/CMakeLists.txt | 7 ++++--- ...rialLinkedPacket.h => SerialLinkedListAdapterPacket.h} | 8 ++++---- ...erialBufferAdapter.cpp => testSerialBufferAdapter.cpp} | 4 ++-- ...tSerialLinkedPacket.cpp => testSerialLinkedPacket.cpp} | 3 +-- .../{TestSerialization.cpp => testSerializeAdapter.cpp} | 0 unittests/serialize/testSerializeIF.cpp | 6 ++++++ 7 files changed, 18 insertions(+), 12 deletions(-) rename unittests/serialize/{TestSerialLinkedPacket.h => SerialLinkedListAdapterPacket.h} (80%) rename unittests/serialize/{TestSerialBufferAdapter.cpp => testSerialBufferAdapter.cpp} (98%) rename unittests/serialize/{TestSerialLinkedPacket.cpp => testSerialLinkedPacket.cpp} (98%) rename unittests/serialize/{TestSerialization.cpp => testSerializeAdapter.cpp} (100%) create mode 100644 unittests/serialize/testSerializeIF.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e59eb4c5..949c9403 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,7 +168,7 @@ if(FSFW_BUILD_TESTS) configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h) project(${FSFW_TEST_TGT} CXX C) - add_executable(${FSFW_TEST_TGT}) + add_executable(${FSFW_TEST_TGT} unittests/serialize/testSerializeIF.cpp) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) diff --git a/unittests/serialize/CMakeLists.txt b/unittests/serialize/CMakeLists.txt index 96c80f4a..be4301db 100644 --- a/unittests/serialize/CMakeLists.txt +++ b/unittests/serialize/CMakeLists.txt @@ -1,5 +1,6 @@ target_sources(${FSFW_TEST_TGT} PRIVATE - TestSerialBufferAdapter.cpp - TestSerialization.cpp - TestSerialLinkedPacket.cpp + testSerialBufferAdapter.cpp + testSerializeAdapter.cpp + testSerialLinkedPacket.cpp + testSerializeIF.cpp ) diff --git a/unittests/serialize/TestSerialLinkedPacket.h b/unittests/serialize/SerialLinkedListAdapterPacket.h similarity index 80% rename from unittests/serialize/TestSerialLinkedPacket.h rename to unittests/serialize/SerialLinkedListAdapterPacket.h index 0cfdd9ff..81268d28 100644 --- a/unittests/serialize/TestSerialLinkedPacket.h +++ b/unittests/serialize/SerialLinkedListAdapterPacket.h @@ -26,13 +26,13 @@ class TestPacket : public SerialLinkedListAdapter { setLinks(); } - uint32_t getHeader() const { return header.entry; } + [[nodiscard]] uint32_t getHeader() const { return header.entry; } - const uint8_t* getBuffer() { return buffer.entry.getConstBuffer(); } + [[nodiscard]] const uint8_t* getBuffer() const { return buffer.entry.getConstBuffer(); } size_t getBufferLength() { return buffer.getSerializedSize(); } - uint16_t getTail() const { return tail.entry; } + [[nodiscard]] uint16_t getTail() const { return tail.entry; } private: void setLinks() { @@ -47,4 +47,4 @@ class TestPacket : public SerialLinkedListAdapter { SerializeElement tail = 0; }; -#endif /* UNITTEST_TESTFW_NEWTESTS_TESTTEMPLATE_H_ */ +#endif /* UNITTEST_HOSTED_TESTSERIALLINKEDPACKET_H_ */ diff --git a/unittests/serialize/TestSerialBufferAdapter.cpp b/unittests/serialize/testSerialBufferAdapter.cpp similarity index 98% rename from unittests/serialize/TestSerialBufferAdapter.cpp rename to unittests/serialize/testSerialBufferAdapter.cpp index 2aa76ec8..f9fbece1 100644 --- a/unittests/serialize/TestSerialBufferAdapter.cpp +++ b/unittests/serialize/testSerialBufferAdapter.cpp @@ -92,7 +92,7 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") { testArray[3] = 1; testArray[4] = 1; testArray[5] = 0; - std::array test_recv_array; + std::array test_recv_array{}; arrayPtr = testArray.data(); // copy testArray[1] to testArray[4] into receive buffer, skip // size field (testArray[0]) for deSerialization. @@ -116,7 +116,7 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") { testArray[3] = 1; testArray[4] = 1; testArray[5] = 0; - std::array test_recv_array; + std::array test_recv_array{}; arrayPtr = testArray.data() + 2; // copy testArray[1] to testArray[4] into receive buffer, skip // size field (testArray[0]) diff --git a/unittests/serialize/TestSerialLinkedPacket.cpp b/unittests/serialize/testSerialLinkedPacket.cpp similarity index 98% rename from unittests/serialize/TestSerialLinkedPacket.cpp rename to unittests/serialize/testSerialLinkedPacket.cpp index 2d6e476f..40910efb 100644 --- a/unittests/serialize/TestSerialLinkedPacket.cpp +++ b/unittests/serialize/testSerialLinkedPacket.cpp @@ -1,11 +1,10 @@ -#include "TestSerialLinkedPacket.h" - #include #include #include #include "CatchDefinitions.h" +#include "SerialLinkedListAdapterPacket.h" TEST_CASE("Serial Linked Packet", "[SerLinkPacket]") { // perform set-up here diff --git a/unittests/serialize/TestSerialization.cpp b/unittests/serialize/testSerializeAdapter.cpp similarity index 100% rename from unittests/serialize/TestSerialization.cpp rename to unittests/serialize/testSerializeAdapter.cpp diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp new file mode 100644 index 00000000..80bcba64 --- /dev/null +++ b/unittests/serialize/testSerializeIF.cpp @@ -0,0 +1,6 @@ + +#include + +TEST_CASE("Simple Test", "[SerSizeTest]") { + +} \ No newline at end of file From b809f90e727bb9669badc179446a91b00dbdf53d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 23 Jul 2022 11:10:44 +0200 Subject: [PATCH 085/532] added unittests for new helpers --- src/fsfw/serialize.h | 10 +- src/fsfw/serialize/EndianConverter.h | 14 +- src/fsfw/serialize/SerializeIF.h | 14 +- unittests/mocks/SimpleSerializable.h | 40 ++++++ unittests/serialize/testSerializeIF.cpp | 170 +++++++++++++++++++++++- 5 files changed, 226 insertions(+), 22 deletions(-) create mode 100644 unittests/mocks/SimpleSerializable.h diff --git a/src/fsfw/serialize.h b/src/fsfw/serialize.h index edd7c9c7..514e1e0c 100644 --- a/src/fsfw/serialize.h +++ b/src/fsfw/serialize.h @@ -1,10 +1,10 @@ #ifndef FSFW_INC_FSFW_SERIALIZE_H_ #define FSFW_INC_FSFW_SERIALIZE_H_ -#include "src/core/serialize/EndianConverter.h" -#include "src/core/serialize/SerialArrayListAdapter.h" -#include "src/core/serialize/SerialBufferAdapter.h" -#include "src/core/serialize/SerialLinkedListAdapter.h" -#include "src/core/serialize/SerializeElement.h" +#include "fsfw/serialize/EndianConverter.h" +#include "fsfw/serialize/SerialArrayListAdapter.h" +#include "fsfw/serialize/SerialBufferAdapter.h" +#include "fsfw/serialize/SerialLinkedListAdapter.h" +#include "fsfw/serialize/SerializeElement.h" #endif /* FSFW_INC_FSFW_SERIALIZE_H_ */ diff --git a/src/fsfw/serialize/EndianConverter.h b/src/fsfw/serialize/EndianConverter.h index 3beae46a..9d6c73a3 100644 --- a/src/fsfw/serialize/EndianConverter.h +++ b/src/fsfw/serialize/EndianConverter.h @@ -4,7 +4,7 @@ #include #include -#include "../osal/Endiness.h" +#include "fsfw/osal/Endiness.h" /** * Helper class to convert variables or bitstreams between machine @@ -36,7 +36,7 @@ */ class EndianConverter { private: - EndianConverter(){}; + EndianConverter() = default; public: /** @@ -49,8 +49,8 @@ class EndianConverter { #error BYTE_ORDER_SYSTEM not defined #elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN T tmp; - uint8_t *pointerOut = (uint8_t *)&tmp; - uint8_t *pointerIn = (uint8_t *)∈ + auto *pointerOut = reinterpret_cast(&tmp); + auto *pointerIn = reinterpret_cast(&in); for (size_t count = 0; count < sizeof(T); count++) { pointerOut[sizeof(T) - count - 1] = pointerIn[count]; } @@ -73,7 +73,6 @@ class EndianConverter { for (size_t count = 0; count < size; count++) { out[size - count - 1] = in[count]; } - return; #elif BYTE_ORDER_SYSTEM == BIG_ENDIAN memcpy(out, in, size); return; @@ -90,8 +89,8 @@ class EndianConverter { #error BYTE_ORDER_SYSTEM not defined #elif BYTE_ORDER_SYSTEM == BIG_ENDIAN T tmp; - uint8_t *pointerOut = (uint8_t *)&tmp; - uint8_t *pointerIn = (uint8_t *)∈ + auto *pointerOut = reinterpret_cast(&tmp); + auto *pointerIn = reinterpret_cast(&in); for (size_t count = 0; count < sizeof(T); count++) { pointerOut[sizeof(T) - count - 1] = pointerIn[count]; } @@ -116,7 +115,6 @@ class EndianConverter { return; #elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN memcpy(out, in, size); - return; #endif } }; diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 9fc5b731..54a1f4e3 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -3,7 +3,7 @@ #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" /** * @defgroup serialize Serialization @@ -105,13 +105,13 @@ class SerializeIF { /** * Forwards to regular @deSerialize call with network endianness */ - virtual ReturnValue_t deSerializeNe(const uint8_t** buffer, size_t* size, size_t maxSize) { + virtual ReturnValue_t deSerializeNe(const uint8_t** buffer, size_t* size) { return deSerialize(buffer, size, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size, size_t maxSize) { + virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size) { return deSerialize(buffer, size, SerializeIF::Endianness::MACHINE); } @@ -156,14 +156,14 @@ class SerializeIF { /** * Forwards to regular @serialize call with network endianness */ - virtual ReturnValue_t deSerializeNe(uint8_t *buffer, size_t maxSize) const { - return serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); + virtual ReturnValue_t deSerializeNe(const uint8_t *buffer, size_t maxSize) { + return deSerialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t deSerialize(uint8_t *buffer, size_t maxSize) const { - return serialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); + virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t maxSize) { + return deSerialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); } }; diff --git a/unittests/mocks/SimpleSerializable.h b/unittests/mocks/SimpleSerializable.h new file mode 100644 index 00000000..5c28a09a --- /dev/null +++ b/unittests/mocks/SimpleSerializable.h @@ -0,0 +1,40 @@ +#ifndef FSFW_TESTS_SIMPLESERIALIZABLE_H +#define FSFW_TESTS_SIMPLESERIALIZABLE_H + +#include "fsfw/serialize.h" +#include "fsfw/osal/Endiness.h" + +class SimpleSerializable : public SerializeIF { + public: + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override { + if (*size + getSerializedSize() > maxSize) { + return SerializeIF::BUFFER_TOO_SHORT; + } + **buffer = someU8; + *buffer += 1; + *size += 1; + return SerializeAdapter::serialize(&someU16, buffer, size, maxSize, streamEndianness); + } + + [[nodiscard]] size_t getSerializedSize() const override { return 3; } + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override { + if (*size < getSerializedSize()) { + return SerializeIF::STREAM_TOO_SHORT; + } + someU8 = **buffer; + *size -= 1; + *buffer += 1; + return SerializeAdapter::deSerialize(&someU16, buffer, size, streamEndianness); + } + + [[nodiscard]] uint8_t getU8() const { return someU8; } + [[nodiscard]] uint16_t getU16() const { return someU16; } + + private: + uint8_t someU8 = 1; + uint16_t someU16 = 0x0203; +}; + +#endif // FSFW_TESTS_SIMPLESERIALIZABLE_H diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index 80bcba64..2cbe6132 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -1,6 +1,172 @@ +#include #include -TEST_CASE("Simple Test", "[SerSizeTest]") { - +#include "mocks/SimpleSerializable.h" + +using namespace std; + +TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { + auto simpleSer = SimpleSerializable(); + array buf{}; + uint8_t* ptr = buf.data(); + size_t len = 0; + + SECTION("Little Endian Normal") { + REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + CHECK(buf[0] == 1); + CHECK(buf[1] == 3); + CHECK(buf[2] == 2); + // Verify pointer arithmetic and size increment + CHECK(ptr == buf.data() + 3); + CHECK(len == 3); + } + + SECTION("Little Endian Simple") { + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + CHECK(buf[0] == 1); + CHECK(buf[1] == 3); + CHECK(buf[2] == 2); + } + + SECTION("Big Endian Normal") { + SECTION("Explicit") { + REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::BIG) == + HasReturnvaluesIF::RETURN_OK); + } + SECTION("Network 0") { + REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + } + SECTION("Network 1") { + REQUIRE(simpleSer.serializeNe(&ptr, &len, buf.size()) == HasReturnvaluesIF::RETURN_OK); + } + + CHECK(buf[0] == 1); + CHECK(buf[1] == 2); + CHECK(buf[2] == 3); + // Verify pointer arithmetic and size increment + CHECK(ptr == buf.data() + 3); + CHECK(len == 3); + } + + SECTION("Big Endian Simple") { + SECTION("Explicit") { + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::BIG) == + HasReturnvaluesIF::RETURN_OK); + } + SECTION("Network 0") { + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + } + SECTION("Network 1") { + REQUIRE(simpleSer.SerializeIF::serializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + } + CHECK(buf[0] == 1); + CHECK(buf[1] == 2); + CHECK(buf[2] == 3); + } + + SECTION("Machine Endian Implicit") { + REQUIRE(simpleSer.SerializeIF::serialize(&ptr, &len, buf.size()) == + HasReturnvaluesIF::RETURN_OK); + CHECK(buf[0] == 1); +#if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN + CHECK(buf[1] == 3); + CHECK(buf[2] == 2); +#else + CHECK(buf[1] == 2); + CHECK(buf[2] == 3); +#endif + // Verify pointer arithmetic and size increment + CHECK(ptr == buf.data() + 3); + CHECK(len == 3); + } + + SECTION("Machine Endian Simple Implicit") { + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size()) == + HasReturnvaluesIF::RETURN_OK); + CHECK(buf[0] == 1); +#if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN + CHECK(buf[1] == 3); + CHECK(buf[2] == 2); +#else + CHECK(buf[1] == 2); + CHECK(buf[2] == 3); +#endif + } +} + +TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { + auto simpleSer = SimpleSerializable(); + array buf = {5, 0, 1}; + const uint8_t* ptr = buf.data(); + size_t len = buf.size(); + + SECTION("Little Endian Normal") { + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + CHECK(simpleSer.getU8() == 5); + CHECK(simpleSer.getU16() == 0x0100); + CHECK(ptr == buf.data() + 3); + CHECK(len == 0); + } + + SECTION("Little Endian Simple") { + REQUIRE(simpleSer.SerializeIF::deSerialize(ptr, len, SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + CHECK(simpleSer.getU8() == 5); + CHECK(simpleSer.getU16() == 0x0100); + } + + SECTION("Big Endian Normal") { + SECTION("Explicit") { + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == HasReturnvaluesIF::RETURN_OK); + } + SECTION("Network 0") { + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + } + SECTION("Network 1") { + REQUIRE(simpleSer.SerializeIF::deSerializeNe(&ptr, &len) == HasReturnvaluesIF::RETURN_OK); + } + CHECK(simpleSer.getU8() == 5); + CHECK(simpleSer.getU16() == 1); + CHECK(ptr == buf.data() + 3); + CHECK(len == 0); + } + + SECTION("Big Endian Simple") { + SECTION("Explicit") { + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), SerializeIF::Endianness::BIG) == + HasReturnvaluesIF::RETURN_OK); + } + SECTION("Network 0") { + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + } + SECTION("Network 1") { + REQUIRE(simpleSer.SerializeIF::deSerializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + } + CHECK(simpleSer.getU8() == 5); + CHECK(simpleSer.getU16() == 1); + } + + SECTION("Machine Endian Implicit") { + REQUIRE(simpleSer.SerializeIF::deSerialize(&ptr, &len) == HasReturnvaluesIF::RETURN_OK); + CHECK(simpleSer.getU8() == 5); +#if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN + CHECK(simpleSer.getU16() == 0x0100); +#else + CHECK(simpleSer.getU16() == 1); +#endif + // Verify pointer arithmetic and size increment + CHECK(ptr == buf.data() + 3); + CHECK(len == 0); + } + + SECTION("Machine Endian Simple Implicit") { + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size()) == + HasReturnvaluesIF::RETURN_OK); + CHECK(simpleSer.getU8() == 5); +#if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN + CHECK(simpleSer.getU16() == 0x0100); +#else + CHECK(simpleSer.getU16() == 1); +#endif + } } \ No newline at end of file From 3708df242320cc0edd5b103504a2ce926df6f078 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 23 Jul 2022 11:15:55 +0200 Subject: [PATCH 086/532] small fix --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 949c9403..e59eb4c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,7 +168,7 @@ if(FSFW_BUILD_TESTS) configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h) project(${FSFW_TEST_TGT} CXX C) - add_executable(${FSFW_TEST_TGT} unittests/serialize/testSerializeIF.cpp) + add_executable(${FSFW_TEST_TGT}) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) From d474c4a7ee1d62d640ecca1a6cedd6f7df397b73 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 23 Jul 2022 11:43:48 +0200 Subject: [PATCH 087/532] store helper --- src/fsfw/serialize/SerializeIF.h | 6 +- src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h | 4 ++ .../tmtcpacket/ccsds/SpacePacketCreator.cpp | 2 + .../tmtcpacket/ccsds/SpacePacketCreator.h | 1 + src/fsfw/tmtcservices/TmStoreHelper.cpp | 19 +++-- unittests/CMakeLists.txt | 1 + unittests/mocks/SimpleSerializable.h | 2 +- unittests/serialize/testSerializeIF.cpp | 44 ++++++++---- unittests/tmtcpacket/testCcsds.cpp | 69 +++++++++++++++++-- unittests/tmtcpacket/testCcsdsCreator.cpp | 57 ++++++++------- unittests/tmtcservices/CMakeLists.txt | 2 + unittests/tmtcservices/testStoreHelper.cpp | 3 + 12 files changed, 150 insertions(+), 60 deletions(-) create mode 100644 unittests/tmtcservices/CMakeLists.txt create mode 100644 unittests/tmtcservices/testStoreHelper.cpp diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 54a1f4e3..2b466839 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -64,7 +64,7 @@ class SerializeIF { /** * Forwards to regular @serialize call with network endianness */ - virtual ReturnValue_t serializeNe(uint8_t** buffer, size_t* size, size_t maxSize) { + virtual ReturnValue_t serializeNe(uint8_t **buffer, size_t *size, size_t maxSize) { return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } /** @@ -105,13 +105,13 @@ class SerializeIF { /** * Forwards to regular @deSerialize call with network endianness */ - virtual ReturnValue_t deSerializeNe(const uint8_t** buffer, size_t* size) { + virtual ReturnValue_t deSerializeNe(const uint8_t **buffer, size_t *size) { return deSerialize(buffer, size, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size) { + virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size) { return deSerialize(buffer, size, SerializeIF::Endianness::MACHINE); } diff --git a/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h b/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h index 830a6fa2..cd4e153e 100644 --- a/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h +++ b/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h @@ -12,6 +12,10 @@ struct PacketSeqCtrl : public SerializeIF { PacketSeqCtrl(ccsds::SequenceFlags seqFlags, uint16_t seqCount) : seqFlags(seqFlags), seqCount(seqCount) {} + bool operator==(const PacketSeqCtrl &other) const { + return seqCount == other.seqCount and seqFlags == other.seqFlags; + } + /** * NOTE: If the sequence control has an invalid value, the invalid bits will be cut off * @return diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp index 05da88b4..20c9341f 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp @@ -81,3 +81,5 @@ void SpacePacketCreator::setPacketType(ccsds::PacketType type) { params.packetId.packetType = type; } bool SpacePacketCreator::operator==(const SpacePacketCreator &other) const { return false; } + +SpacePacketCreator::operator bool() const { return isValid(); } diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h index d30457ea..9c13bd5a 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h @@ -26,6 +26,7 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF { explicit SpacePacketCreator(SpacePacketParams params); bool operator==(const SpacePacketCreator &other) const; + explicit operator bool() const; SpacePacketCreator(ccsds::PacketType packetType, bool secHeaderFlag, uint16_t apid, ccsds::SequenceFlags seqFlags, uint16_t seqCount, uint16_t dataLen, diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index 44b2e6a1..3260d4d1 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -14,13 +14,10 @@ TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore) : } ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, uint16_t counter) { - // TODO: Implement - // creator.setApid(apid); PusTmParams& params = creator.getParams(); params.secHeader.service = service; params.secHeader.subservice = subservice; params.secHeader.messageTypeCounter = counter; - // TODO: Implement serialize and then serialize into the store return HasReturnvaluesIF::RETURN_OK; } @@ -31,22 +28,21 @@ const store_address_t& TmStoreHelper::getCurrentAddr() const { return currentAdd ReturnValue_t TmStoreHelper::deletePacket() { return tmStore->deleteData(currentAddr); } void TmStoreHelper::setSourceDataRaw(const uint8_t* data, size_t len) { - PusTmParams& params = creator.getParams(); - params.dataWrapper.type = ecss::DataTypes::RAW; - params.dataWrapper.dataUnion.raw.data = data; - params.dataWrapper.dataUnion.raw.len = len; + creator.setRawUserData(data, len); } void TmStoreHelper::setSourceDataSerializable(SerializeIF* serializable) { - PusTmParams& params = creator.getParams(); - params.dataWrapper.type = ecss::DataTypes::SERIALIZABLE; - params.dataWrapper.dataUnion.serializable = serializable; + creator.setSerializableUserData(serializable); } ReturnValue_t TmStoreHelper::addPacketToStore() { creator.updateSpLengthField(); uint8_t* dataPtr; - tmStore->getFreeElement(¤tAddr, creator.getSerializedSize(), &dataPtr); + ReturnValue_t result = + tmStore->getFreeElement(¤tAddr, creator.getSerializedSize(), &dataPtr); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } size_t serLen = 0; return creator.serialize(&dataPtr, &serLen, creator.getSerializedSize(), SerializeIF::Endianness::NETWORK); @@ -55,4 +51,5 @@ ReturnValue_t TmStoreHelper::addPacketToStore() { void TmStoreHelper::setTimeStamper(TimeStamperIF* timeStamper_) { creator.setTimeStamper(timeStamper_); } + void TmStoreHelper::setApid(uint16_t apid) { creator.setApid(apid); } diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index f32c6e08..28d950d4 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -27,5 +27,6 @@ add_subdirectory(cfdp) add_subdirectory(hal) add_subdirectory(internalerror) add_subdirectory(devicehandler) +add_subdirectory(tmtcservices) target_include_directories(${FSFW_TEST_TGT} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/unittests/mocks/SimpleSerializable.h b/unittests/mocks/SimpleSerializable.h index 5c28a09a..222f1729 100644 --- a/unittests/mocks/SimpleSerializable.h +++ b/unittests/mocks/SimpleSerializable.h @@ -1,8 +1,8 @@ #ifndef FSFW_TESTS_SIMPLESERIALIZABLE_H #define FSFW_TESTS_SIMPLESERIALIZABLE_H -#include "fsfw/serialize.h" #include "fsfw/osal/Endiness.h" +#include "fsfw/serialize.h" class SimpleSerializable : public SerializeIF { public: diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index 2cbe6132..968d2b1e 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -13,7 +13,8 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { size_t len = 0; SECTION("Little Endian Normal") { - REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); @@ -23,7 +24,9 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { } SECTION("Little Endian Simple") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + REQUIRE( + simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); @@ -35,7 +38,8 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { REQUIRE(simpleSer.serializeNe(&ptr, &len, buf.size()) == HasReturnvaluesIF::RETURN_OK); @@ -51,14 +55,18 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { SECTION("Big Endian Simple") { SECTION("Explicit") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE( + simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::BIG) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), + SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::serializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::serializeNe(buf.data(), buf.size()) == + HasReturnvaluesIF::RETURN_OK); } CHECK(buf[0] == 1); CHECK(buf[1] == 2); @@ -102,7 +110,8 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { size_t len = buf.size(); SECTION("Little Endian Normal") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); CHECK(ptr == buf.data() + 3); @@ -110,17 +119,20 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { } SECTION("Little Endian Simple") { - REQUIRE(simpleSer.SerializeIF::deSerialize(ptr, len, SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerialize(ptr, len, SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); } SECTION("Big Endian Normal") { SECTION("Explicit") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { REQUIRE(simpleSer.SerializeIF::deSerializeNe(&ptr, &len) == HasReturnvaluesIF::RETURN_OK); @@ -133,14 +145,18 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { SECTION("Big Endian Simple") { SECTION("Explicit") { - REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), SerializeIF::Endianness::BIG) == + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), + SerializeIF::Endianness::BIG) == HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), + SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::deSerializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerializeNe(buf.data(), buf.size()) == + HasReturnvaluesIF::RETURN_OK); } CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 1); diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp index 1bae5912..16883458 100644 --- a/unittests/tmtcpacket/testCcsds.cpp +++ b/unittests/tmtcpacket/testCcsds.cpp @@ -1,7 +1,9 @@ #include #include +#include #include "fsfw/tmtcpacket/ccsds/PacketId.h" +#include "fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h" #include "fsfw/tmtcpacket/ccsds/header.h" TEST_CASE("CCSDS Low Level", "[ccsds-ll]") { @@ -43,16 +45,73 @@ TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { REQUIRE(packetId.raw() == 0x1ff); REQUIRE(packetId.SerializeIF::serializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(buf[0] == 0x1); - REQUIRE(buf[1] == 0xff); + CHECK(buf[0] == 0x1); + CHECK(buf[1] == 0xff); + } + + SECTION("Invalid Ser") { + REQUIRE(packetId.SerializeIF::serializeNe(buf.data(), 0) == SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(packetId.SerializeIF::serializeNe(buf.data(), 1) == SerializeIF::BUFFER_TOO_SHORT); + } + + SECTION("Invalid Deser") { + REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), 1) == SerializeIF::STREAM_TOO_SHORT); + REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), 0) == SerializeIF::STREAM_TOO_SHORT); } SECTION("From Raw") { auto newId = PacketId(ccsds::PacketType::TC, true, 0x2ff); uint16_t rawId = newId.raw(); - REQUIRE(rawId == 0x1aff); - REQUIRE(PacketId::fromRaw(rawId) == newId); + CHECK(rawId == 0x1aff); + CHECK(PacketId::fromRaw(rawId) == newId); + } + + SECTION("Deserialize") { + buf[0] = 0x1a; + buf[1] = 0xff; + REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), buf.size()) == + HasReturnvaluesIF::RETURN_OK); + CHECK(packetId.apid == 0x2ff); + CHECK(packetId.packetType == ccsds::PacketType::TC); + CHECK(packetId.secHeaderFlag == true); } } -TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") {} +TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") { + PacketSeqCtrl psc; + std::array buf{}; + SECTION("Basic") { + psc.seqFlags = ccsds::SequenceFlags::FIRST_SEGMENT; + psc.seqCount = static_cast(std::round(std::pow(2, 14) - 1)); + REQUIRE(psc.raw() == 0x7fff); + REQUIRE(psc.SerializeIF::serializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(buf[0] == 0x7f); + CHECK(buf[1] == 0xff); + } + + SECTION("From Raw") { + auto newId = PacketSeqCtrl(ccsds::SequenceFlags::LAST_SEGMENT, + static_cast(std::round(std::pow(2, 14) - 2))); + uint16_t rawId = newId.raw(); + REQUIRE(rawId == 0xbffe); + CHECK(PacketSeqCtrl::fromRaw(rawId) == newId); + } + + SECTION("Deserialize") { + buf[0] = 0xbf; + buf[1] = 0xfe; + REQUIRE(psc.SerializeIF::deSerialize(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(psc.seqFlags == ccsds::SequenceFlags::LAST_SEGMENT); + CHECK(psc.seqCount == static_cast(std::round(std::pow(2, 14) - 2))); + } + + SECTION("Invalid Ser") { + REQUIRE(psc.SerializeIF::serializeNe(buf.data(), 0) == SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(psc.SerializeIF::serializeNe(buf.data(), 1) == SerializeIF::BUFFER_TOO_SHORT); + } + + SECTION("Invalid Deser") { + REQUIRE(psc.SerializeIF::deSerialize(buf.data(), 1) == SerializeIF::STREAM_TOO_SHORT); + REQUIRE(psc.SerializeIF::deSerialize(buf.data(), 0) == SerializeIF::STREAM_TOO_SHORT); + } +} diff --git a/unittests/tmtcpacket/testCcsdsCreator.cpp b/unittests/tmtcpacket/testCcsdsCreator.cpp index 91122ef9..570e791b 100644 --- a/unittests/tmtcpacket/testCcsdsCreator.cpp +++ b/unittests/tmtcpacket/testCcsdsCreator.cpp @@ -5,8 +5,9 @@ #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" TEST_CASE("CCSDS Creator", "[ccsds-creator]") { - auto params = SpacePacketParams(PacketId(ccsds::PacketType::TC, true, 0x02), - PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34), 0x16); + auto packetId = PacketId(ccsds::PacketType::TC, true, 0x02); + auto psc = PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34); + auto params = SpacePacketParams(packetId, psc, 0x16); SpacePacketCreator base = SpacePacketCreator(params); std::array buf{}; uint8_t* bufPtr = buf.data(); @@ -21,15 +22,18 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { } SECTION("Basic Test") { - REQUIRE(base.isValid()); - REQUIRE(base.getApid() == 0x02); - REQUIRE(base.getSequenceFlags() == ccsds::SequenceFlags::FIRST_SEGMENT); - REQUIRE(base.getVersion() == 0b000); - REQUIRE(base.getSequenceCount() == 0x34); - REQUIRE(base.getPacketDataLen() == 0x16); - REQUIRE(base.getPacketType() == ccsds::PacketType::TC); - REQUIRE(base.getPacketIdRaw() == 0x1802); - REQUIRE(base.getSerializedSize() == 6); + CHECK(base.isValid()); + CHECK(base); + CHECK(base.getApid() == 0x02); + CHECK(base.getSequenceFlags() == ccsds::SequenceFlags::FIRST_SEGMENT); + CHECK(base.getVersion() == 0b000); + CHECK(base.getSequenceCount() == 0x34); + CHECK(base.getPacketDataLen() == 0x16); + CHECK(base.getPacketType() == ccsds::PacketType::TC); + CHECK(base.getPacketIdRaw() == 0x1802); + CHECK(base.getSerializedSize() == 6); + CHECK(base.getPacketSeqCtrl() == psc); + CHECK(base.getPacketId() == packetId); } SECTION("Deserialization Fails") { @@ -42,18 +46,18 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { SECTION("Raw Output") { REQUIRE(base.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); // TC, and secondary header flag is set -> 0b0001100 -> 0x18 - REQUIRE(buf[0] == 0x18); + CHECK(buf[0] == 0x18); // APID 0x02 - REQUIRE(buf[1] == 0x02); + CHECK(buf[1] == 0x02); // Sequence count is one byte value, so the only set bit here is the bit // from the Sequence flag argument, which is the second bit for // SequenceFlags.FIRST_SEGMENT - REQUIRE(buf[2] == 0x40); + CHECK(buf[2] == 0x40); // Sequence Count specified above - REQUIRE(buf[3] == 0x34); + CHECK(buf[3] == 0x34); // This byte and the next byte should be 22 big endian (packet length) - REQUIRE(buf[4] == 0x00); - REQUIRE(buf[5] == 0x16); + CHECK(buf[4] == 0x00); + CHECK(buf[5] == 0x16); } SECTION("All Ones Output") { @@ -63,19 +67,20 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { base.setDataLen(static_cast(std::pow(2, 16)) - 1); REQUIRE(base.isValid()); REQUIRE(base.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(buf[0] == 0x1F); - REQUIRE(buf[1] == 0xFF); - REQUIRE(buf[2] == 0xFF); - REQUIRE(buf[3] == 0xFF); - REQUIRE(buf[4] == 0xFF); - REQUIRE(buf[5] == 0xFF); + CHECK(buf[0] == 0x1F); + CHECK(buf[1] == 0xFF); + CHECK(buf[2] == 0xFF); + CHECK(buf[3] == 0xFF); + CHECK(buf[4] == 0xFF); + CHECK(buf[5] == 0xFF); } SECTION("Invalid APID") { - SpacePacketCreator invalid = SpacePacketCreator( + SpacePacketCreator creator = SpacePacketCreator( ccsds::PacketType::TC, true, 0xFFFF, ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); - REQUIRE(not invalid.isValid()); - REQUIRE(invalid.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(not creator.isValid()); + REQUIRE(not creator); + REQUIRE(creator.serializeNe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); } SECTION("Invalid Seq Count") { diff --git a/unittests/tmtcservices/CMakeLists.txt b/unittests/tmtcservices/CMakeLists.txt new file mode 100644 index 00000000..5d1c1858 --- /dev/null +++ b/unittests/tmtcservices/CMakeLists.txt @@ -0,0 +1,2 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE +) diff --git a/unittests/tmtcservices/testStoreHelper.cpp b/unittests/tmtcservices/testStoreHelper.cpp new file mode 100644 index 00000000..0374ece5 --- /dev/null +++ b/unittests/tmtcservices/testStoreHelper.cpp @@ -0,0 +1,3 @@ +#include + +TEST_CASE("TM Store Helper", "[tm-store-helper]") {} \ No newline at end of file From f0c8fd26887ddaf27e8b7fae4094bc631bc74f0d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 10:24:43 +0200 Subject: [PATCH 088/532] some renaming --- src/fsfw/tmtcservices/CommandingServiceBase.cpp | 2 +- src/fsfw/tmtcservices/tmHelpers.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 6abe625b..05f649ef 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -298,7 +298,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, const uint ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_t objectId, const uint8_t* data, size_t dataLen) { - telemetry::SourceDataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); + telemetry::DataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); tmStoreHelper.setSourceDataSerializable(&dataWithObjId); ReturnValue_t result = telemetry::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); diff --git a/src/fsfw/tmtcservices/tmHelpers.h b/src/fsfw/tmtcservices/tmHelpers.h index 2e783039..da55495e 100644 --- a/src/fsfw/tmtcservices/tmHelpers.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -9,9 +9,9 @@ namespace telemetry { ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper); -class SourceDataWithObjectIdPrefix : public SerializeIF { +class DataWithObjectIdPrefix : public SerializeIF { public: - SourceDataWithObjectIdPrefix(object_id_t objectId, const uint8_t* srcData, size_t srcDataLen) + DataWithObjectIdPrefix(object_id_t objectId, const uint8_t* srcData, size_t srcDataLen) : objectId(objectId), srcData(srcData), srcDataLen(srcDataLen) {} ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override { From 49215270224a8b13e39e16c4ec0b08572d223f07 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 10:31:49 +0200 Subject: [PATCH 089/532] replace c include --- src/fsfw/timemanager/CCSDSTime.h | 2 +- src/fsfw/timemanager/Clock.h | 6 +++--- src/fsfw/timemanager/ReceivesTimeInfoIF.h | 6 +++--- src/fsfw/timemanager/TimeMessage.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index 2a2316af..f2841d0c 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -6,7 +6,7 @@ #include #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "Clock.h" #include "clockDefinitions.h" diff --git a/src/fsfw/timemanager/Clock.h b/src/fsfw/timemanager/Clock.h index 75c898e5..2dd01dd9 100644 --- a/src/fsfw/timemanager/Clock.h +++ b/src/fsfw/timemanager/Clock.h @@ -11,7 +11,7 @@ #ifdef WIN32 #include #else -#include +#include #endif class Clock { @@ -33,7 +33,7 @@ class Clock { * * @deprecated, we should not worry about ticks, but only time */ - static uint32_t getTicksPerSecond(void); + static uint32_t getTicksPerSecond(); /** * This system call sets the system time. * To set the time, it uses a TimeOfDay_t struct. @@ -148,7 +148,7 @@ class Clock { * @return * - @c RETURN_OK on success. */ - static ReturnValue_t setLeapSeconds(const uint16_t leapSeconds_); + static ReturnValue_t setLeapSeconds(uint16_t leapSeconds_); /** * Get the Leap Seconds since 1972 diff --git a/src/fsfw/timemanager/ReceivesTimeInfoIF.h b/src/fsfw/timemanager/ReceivesTimeInfoIF.h index 5fb915ae..a6067a33 100644 --- a/src/fsfw/timemanager/ReceivesTimeInfoIF.h +++ b/src/fsfw/timemanager/ReceivesTimeInfoIF.h @@ -1,7 +1,7 @@ #ifndef FSFW_TIMEMANAGER_RECEIVESTIMEINFOIF_H_ #define FSFW_TIMEMANAGER_RECEIVESTIMEINFOIF_H_ -#include "../ipc/MessageQueueSenderIF.h" +#include "fsfw/ipc/MessageQueueSenderIF.h" /** * This is a Interface for classes that receive timing information @@ -13,11 +13,11 @@ class ReceivesTimeInfoIF { * Returns the id of the queue which receives the timing information. * @return Queue id of the timing queue. */ - virtual MessageQueueId_t getTimeReceptionQueue() const = 0; + [[nodiscard]] virtual MessageQueueId_t getTimeReceptionQueue() const = 0; /** * Empty virtual destructor. */ - virtual ~ReceivesTimeInfoIF() {} + virtual ~ReceivesTimeInfoIF() = default; }; #endif /* FSFW_TIMEMANAGER_RECEIVESTIMEINFOIF_H_ */ diff --git a/src/fsfw/timemanager/TimeMessage.h b/src/fsfw/timemanager/TimeMessage.h index ae4a9caf..c5eed13f 100644 --- a/src/fsfw/timemanager/TimeMessage.h +++ b/src/fsfw/timemanager/TimeMessage.h @@ -3,7 +3,7 @@ #include -#include "../ipc/MessageQueueMessage.h" +#include "fsfw/ipc/MessageQueueMessage.h" #include "Clock.h" class TimeMessage : public MessageQueueMessage { From 63ee88af171a72ed0377ffc4e7da4cc7ed6cc7c6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 10:38:44 +0200 Subject: [PATCH 090/532] added base for tm store test --- src/fsfw/storagemanager/LocalPool.h | 2 +- unittests/tmtcservices/testStoreHelper.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/fsfw/storagemanager/LocalPool.h b/src/fsfw/storagemanager/LocalPool.h index 01706e9c..47f84955 100644 --- a/src/fsfw/storagemanager/LocalPool.h +++ b/src/fsfw/storagemanager/LocalPool.h @@ -81,7 +81,7 @@ class LocalPool : public SystemObject, public StorageManagerIF { /** * @brief In the LocalPool's destructor all allocated memory is freed. */ - virtual ~LocalPool(void); + ~LocalPool() override; /** * Documentation: See StorageManagerIF.h diff --git a/unittests/tmtcservices/testStoreHelper.cpp b/unittests/tmtcservices/testStoreHelper.cpp index 0374ece5..d3db0b08 100644 --- a/unittests/tmtcservices/testStoreHelper.cpp +++ b/unittests/tmtcservices/testStoreHelper.cpp @@ -1,3 +1,10 @@ #include -TEST_CASE("TM Store Helper", "[tm-store-helper]") {} \ No newline at end of file +#include "fsfw/storagemanager/LocalPool.h" +#include "fsfw/tmtcservices/TmStoreHelper.h" + +TEST_CASE("TM Store Helper", "[tm-store-helper]") { + LocalPool::LocalPoolConfig cfg = {{10, 32}, {5, 64}}; + LocalPool pool(objects::NO_OBJECT, cfg); + auto storeHelper = TmStoreHelper(2, &pool); +} \ No newline at end of file From 832367fb306f34cb096b46efa5bb50f7e64dfc67 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 10:50:52 +0200 Subject: [PATCH 091/532] replace some API components with references --- src/fsfw/pus/Service17Test.cpp | 2 +- .../pus/Service1TelecommandVerification.cpp | 2 +- src/fsfw/pus/Service5EventReporting.cpp | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 4 ++-- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 2 +- .../tmtcservices/CommandingServiceBase.cpp | 2 +- src/fsfw/tmtcservices/TmStoreHelper.cpp | 19 ++++++++++++------- src/fsfw/tmtcservices/TmStoreHelper.h | 7 ++++--- unittests/mocks/CdsShortTimestamperMock.h | 3 ++- unittests/tmtcpacket/testPusTmCreator.cpp | 2 +- unittests/tmtcservices/CMakeLists.txt | 1 + unittests/tmtcservices/testStoreHelper.cpp | 4 +++- 12 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index ea2c06e1..d9547d03 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -7,7 +7,7 @@ Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId) : PusServiceBase(objectId, apid, serviceId), - storeHelper(apid, nullptr), + storeHelper(apid), sendHelper(nullptr), packetSubCounter(0) {} diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 93525958..997b4b40 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -16,7 +16,7 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t obj serviceId(serviceId), targetDestination(targetDestination), sendHelper(nullptr), - storeHelper(apid, nullptr) { + storeHelper(apid) { tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); } diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index 847f5f80..59ad7c6c 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -12,7 +12,7 @@ Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t ap uint32_t messageQueueDepth) : PusServiceBase(objectId, apid, serviceId), sendHelper(nullptr), - storeHelper(apid, nullptr), + storeHelper(apid), maxNumberReportsPerCycle(maxNumberReportsPerCycle) { eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 03cf2fbf..6aac4660 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -26,8 +26,8 @@ uint8_t PusTmCreator::getSubService() const { return pusParams.secHeader.subserv PusTmParams& PusTmCreator::getParams() { return pusParams; } -void PusTmCreator::setTimeStamper(TimeStamperIF* timeStamper_) { - pusParams.secHeader.timeStamper = timeStamper_; +void PusTmCreator::setTimeStamper(TimeStamperIF& timeStamper_) { + pusParams.secHeader.timeStamper = &timeStamper_; updateSpLengthField(); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 9981c39c..2b62fa85 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -45,7 +45,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams); ~PusTmCreator() override = default; - void setTimeStamper(TimeStamperIF* timeStamper); + void setTimeStamper(TimeStamperIF& timeStamper); SpacePacketParams& getSpParams(); void setApid(uint16_t apid); void setDestId(uint16_t destId); diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 05f649ef..01c25f87 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -20,7 +20,7 @@ CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t a apid(apid), service(service), timeoutSeconds(commandTimeoutSeconds), - tmStoreHelper(apid, nullptr), + tmStoreHelper(apid), tmSendHelper(nullptr), commandMap(numberOfParallelCommands) { commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index 3260d4d1..a1453013 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -2,16 +2,21 @@ #include "TmTcMessage.h" -TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore, - TimeStamperIF* timeStamper) - : tmStore(tmStore) { +TmStoreHelper::TmStoreHelper(uint16_t defaultApid): tmStore(nullptr) { + creator.setApid(defaultApid); +} + +TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore) : tmStore(&tmStore) { + creator.setApid(defaultApid); +} + +TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, + TimeStamperIF& timeStamper) + : tmStore(&tmStore) { creator.setApid(defaultApid); creator.setTimeStamper(timeStamper); } -TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore) : tmStore(tmStore) { - creator.setApid(defaultApid); -} ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, uint16_t counter) { PusTmParams& params = creator.getParams(); @@ -48,7 +53,7 @@ ReturnValue_t TmStoreHelper::addPacketToStore() { SerializeIF::Endianness::NETWORK); } -void TmStoreHelper::setTimeStamper(TimeStamperIF* timeStamper_) { +void TmStoreHelper::setTimeStamper(TimeStamperIF& timeStamper_) { creator.setTimeStamper(timeStamper_); } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index 43f7e787..1707e5bb 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -9,12 +9,13 @@ class TmStoreHelper { public: - explicit TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore); - TmStoreHelper(uint16_t defaultApid, StorageManagerIF* tmStore, TimeStamperIF* timeStamper); + explicit TmStoreHelper(uint16_t defaultApid); + TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore); + TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, TimeStamperIF& timeStamper); ReturnValue_t preparePacket(uint8_t service, uint8_t subservice, uint16_t counter); - void setTimeStamper(TimeStamperIF* timeStamper); + void setTimeStamper(TimeStamperIF& timeStamper); [[nodiscard]] const store_address_t& getCurrentAddr() const; void setSourceDataRaw(const uint8_t* data, size_t len); void setSourceDataSerializable(SerializeIF* serializable); diff --git a/unittests/mocks/CdsShortTimestamperMock.h b/unittests/mocks/CdsShortTimestamperMock.h index c53c22f9..273cf24c 100644 --- a/unittests/mocks/CdsShortTimestamperMock.h +++ b/unittests/mocks/CdsShortTimestamperMock.h @@ -4,6 +4,7 @@ #include #include "fsfw/timemanager/TimeStamperIF.h" +#include "fsfw/timemanager/TimeReaderIF.h" class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { public: @@ -74,7 +75,7 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { serFailRetval = HasReturnvaluesIF::RETURN_FAILED; } - ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override { + ReturnValue_t readTimeStamp(const uint8_t* buffer, size_t maxSize) override { return deSerialize(&buffer, &maxSize, SerializeIF::Endianness::NETWORK); } size_t getTimestampLen() override { return getSerializedSize(); } diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index 035126f0..cd8f0e0b 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -129,7 +129,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { // As specified in standard, the data length fields is the total size of the packet without // the primary header minus 1 REQUIRE(creatorFromEmptyCtor.getPacketDataLen() == 8); - creatorFromEmptyCtor.setTimeStamper(&timeStamper); + creatorFromEmptyCtor.setTimeStamper(timeStamper); REQUIRE(creatorFromEmptyCtor.getFullPacketLen() == 22); REQUIRE(creatorFromEmptyCtor.getPacketDataLen() == 15); } diff --git a/unittests/tmtcservices/CMakeLists.txt b/unittests/tmtcservices/CMakeLists.txt index 5d1c1858..00dfab95 100644 --- a/unittests/tmtcservices/CMakeLists.txt +++ b/unittests/tmtcservices/CMakeLists.txt @@ -1,2 +1,3 @@ target_sources(${FSFW_TEST_TGT} PRIVATE + testStoreHelper.cpp ) diff --git a/unittests/tmtcservices/testStoreHelper.cpp b/unittests/tmtcservices/testStoreHelper.cpp index d3db0b08..8c92a228 100644 --- a/unittests/tmtcservices/testStoreHelper.cpp +++ b/unittests/tmtcservices/testStoreHelper.cpp @@ -2,9 +2,11 @@ #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tmtcservices/TmStoreHelper.h" +#include "mocks/CdsShortTimestamperMock.h" TEST_CASE("TM Store Helper", "[tm-store-helper]") { + auto timeStamper = CdsShortTimestamperMock(); LocalPool::LocalPoolConfig cfg = {{10, 32}, {5, 64}}; LocalPool pool(objects::NO_OBJECT, cfg); - auto storeHelper = TmStoreHelper(2, &pool); + auto storeHelper = TmStoreHelper(2, pool, timeStamper); } \ No newline at end of file From 4989bd0f02ac4e9055c939fae4511b2c39b9cc5b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 10:56:19 +0200 Subject: [PATCH 092/532] fixes for Linux OSAL clock --- src/fsfw/osal/linux/Clock.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/fsfw/osal/linux/Clock.cpp b/src/fsfw/osal/linux/Clock.cpp index afb4ce3a..00596dab 100644 --- a/src/fsfw/osal/linux/Clock.cpp +++ b/src/fsfw/osal/linux/Clock.cpp @@ -2,8 +2,7 @@ #include #include -#include -#include +#include #include #include @@ -11,14 +10,14 @@ #include "fsfw/ipc/MutexGuard.h" #include "fsfw/serviceinterface/ServiceInterface.h" -uint32_t Clock::getTicksPerSecond(void) { +uint32_t Clock::getTicksPerSecond() { uint32_t ticks = sysconf(_SC_CLK_TCK); return ticks; } ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { - timespec timeUnix; - timeval timeTimeval; + timespec timeUnix{}; + timeval timeTimeval{}; convertTimeOfDayToTimeval(time, &timeTimeval); timeUnix.tv_sec = timeTimeval.tv_sec; timeUnix.tv_nsec = (__syscall_slong_t)timeTimeval.tv_usec * 1000; @@ -32,7 +31,7 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { } ReturnValue_t Clock::setClock(const timeval* time) { - timespec timeUnix; + timespec timeUnix{}; timeUnix.tv_sec = time->tv_sec; timeUnix.tv_nsec = (__syscall_slong_t)time->tv_usec * 1000; int status = clock_settime(CLOCK_REALTIME, &timeUnix); @@ -44,7 +43,7 @@ ReturnValue_t Clock::setClock(const timeval* time) { } ReturnValue_t Clock::getClock_timeval(timeval* time) { - timespec timeUnix; + timespec timeUnix{}; int status = clock_gettime(CLOCK_REALTIME, &timeUnix); if (status != 0) { return HasReturnvaluesIF::RETURN_FAILED; @@ -55,18 +54,18 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { } ReturnValue_t Clock::getClock_usecs(uint64_t* time) { - timeval timeVal; + timeval timeVal{}; ReturnValue_t result = getClock_timeval(&timeVal); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - *time = (uint64_t)timeVal.tv_sec * 1e6 + timeVal.tv_usec; + *time = static_cast(timeVal.tv_sec) * 1e6 + timeVal.tv_usec; return HasReturnvaluesIF::RETURN_OK; } timeval Clock::getUptime() { - timeval uptime; + timeval uptime{}; auto result = getUptime(&uptime); if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -99,7 +98,7 @@ ReturnValue_t Clock::getUptime(timeval* uptime) { //} ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { - timeval uptime; + timeval uptime{}; ReturnValue_t result = getUptime(&uptime); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -109,7 +108,7 @@ ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { } ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { - timespec timeUnix; + timespec timeUnix{}; int status = clock_gettime(CLOCK_REALTIME, &timeUnix); if (status != 0) { // TODO errno @@ -122,7 +121,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { MutexGuard helper(timeMutex); // gmtime writes its output in a global buffer which is not Thread Safe // Therefore we have to use a Mutex here - struct telemetry* timeInfo; + struct std::tm* timeInfo; timeInfo = gmtime(&timeUnix.tv_sec); time->year = timeInfo->tm_year + 1900; time->month = timeInfo->tm_mon + 1; @@ -136,7 +135,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { } ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) { - telemetry fromTm; + std::tm fromTm{}; // Note: Fails for years before AD fromTm.tm_year = from->year - 1900; fromTm.tm_mon = from->month - 1; From 899d021e00784951fc3caa119de540d7c6341a69 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 11:15:45 +0200 Subject: [PATCH 093/532] using uint32_t as store_address requires explicit cast --- src/fsfw/cfdp/CFDPMessage.cpp | 2 +- src/fsfw/datapoollocal/HasLocalDataPoolIF.h | 4 ++-- src/fsfw/parameters/ParameterMessage.cpp | 2 +- src/fsfw/storagemanager/storeAddress.h | 18 ++++++++++++------ src/fsfw/tmtcservices/TmStoreHelper.cpp | 2 ++ src/fsfw/tmtcservices/TmStoreHelper.h | 1 + src/fsfw/tmtcservices/TmTcBridge.cpp | 2 +- unittests/action/TestActionHelper.cpp | 4 ++-- .../datapoollocal/LocalPoolManagerTest.cpp | 4 ++-- unittests/datapoollocal/LocalPoolOwnerBase.cpp | 4 ++-- unittests/storagemanager/TestNewAccessor.cpp | 2 +- unittests/tmtcservices/testStoreHelper.cpp | 17 +++++++++++++++++ 12 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/fsfw/cfdp/CFDPMessage.cpp b/src/fsfw/cfdp/CFDPMessage.cpp index fee55715..da6fe15b 100644 --- a/src/fsfw/cfdp/CFDPMessage.cpp +++ b/src/fsfw/cfdp/CFDPMessage.cpp @@ -10,7 +10,7 @@ void CFDPMessage::setCommand(CommandMessage *message, store_address_t cfdpPacket store_address_t CFDPMessage::getStoreId(const CommandMessage *message) { store_address_t storeAddressCFDPPacket; - storeAddressCFDPPacket = message->getParameter(); + storeAddressCFDPPacket = static_cast(message->getParameter()); return storeAddressCFDPPacket; } diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h index a2925a46..acbe1697 100644 --- a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h +++ b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h @@ -80,7 +80,7 @@ class HasLocalDataPoolIF { * clearing the store automatically */ virtual void handleChangedDataset(sid_t sid, - store_address_t storeId = storeId::INVALID_STORE_ADDRESS, + store_address_t storeId = store_address_t::invalid(), bool* clearMessage = nullptr) { if (clearMessage != nullptr) { *clearMessage = true; @@ -100,7 +100,7 @@ class HasLocalDataPoolIF { * after the callback. */ virtual void handleChangedPoolVariable(gp_id_t gpid, - store_address_t storeId = storeId::INVALID_STORE_ADDRESS, + store_address_t storeId = store_address_t::invalid(), bool* clearMessage = nullptr) { if (clearMessage != nullptr) { *clearMessage = true; diff --git a/src/fsfw/parameters/ParameterMessage.cpp b/src/fsfw/parameters/ParameterMessage.cpp index 9dc58365..9a7b5288 100644 --- a/src/fsfw/parameters/ParameterMessage.cpp +++ b/src/fsfw/parameters/ParameterMessage.cpp @@ -44,7 +44,7 @@ store_address_t ParameterMessage::getParameterLoadCommand(const CommandMessage* *pfc = packedParamSettings >> 16 & 0xff; *rows = packedParamSettings >> 8 & 0xff; *columns = packedParamSettings & 0xff; - return message->getParameter2(); + return static_cast(message->getParameter2()); } void ParameterMessage::clear(CommandMessage* message) { diff --git a/src/fsfw/storagemanager/storeAddress.h b/src/fsfw/storagemanager/storeAddress.h index 41f70573..a656cfe1 100644 --- a/src/fsfw/storagemanager/storeAddress.h +++ b/src/fsfw/storagemanager/storeAddress.h @@ -3,26 +3,26 @@ #include -namespace storeId { -static constexpr uint32_t INVALID_STORE_ADDRESS = 0xffffffff; -} - /** * This union defines the type that identifies where a data packet is * stored in the store. It comprises of a raw part to read it as raw value and * a structured part to use it in pool-like stores. */ union store_address_t { + public: + static constexpr uint32_t INVALID_RAW = 0xffffffff; /** * Default Constructor, initializing to INVALID_ADDRESS */ - store_address_t() : raw(storeId::INVALID_STORE_ADDRESS) {} + store_address_t() : raw(INVALID_RAW) {} /** * Constructor to create an address object using the raw address * * @param rawAddress */ - store_address_t(uint32_t rawAddress) : raw(rawAddress) {} + explicit store_address_t(uint32_t rawAddress) : raw(rawAddress) {} + + static store_address_t invalid() { return {}; }; /** * Constructor to create an address object using pool @@ -52,6 +52,12 @@ union store_address_t { uint32_t raw; bool operator==(const store_address_t& other) const { return raw == other.raw; } + bool operator!=(const store_address_t& other) const { return raw != other.raw; } + + store_address_t& operator=(const uint32_t rawAddr) { + raw = rawAddr; + return *this; + } }; #endif /* FSFW_STORAGEMANAGER_STOREADDRESS_H_ */ diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index a1453013..5f766c3f 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -58,3 +58,5 @@ void TmStoreHelper::setTimeStamper(TimeStamperIF& timeStamper_) { } void TmStoreHelper::setApid(uint16_t apid) { creator.setApid(apid); } + +PusTmCreator& TmStoreHelper::getCreatorRef() { return creator; } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index 1707e5bb..ebaff707 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -15,6 +15,7 @@ class TmStoreHelper { ReturnValue_t preparePacket(uint8_t service, uint8_t subservice, uint16_t counter); + PusTmCreator& getCreatorRef(); void setTimeStamper(TimeStamperIF& timeStamper); [[nodiscard]] const store_address_t& getCurrentAddr() const; void setSourceDataRaw(const uint8_t* data, size_t len); diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index 8ea67119..6af03600 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -166,7 +166,7 @@ ReturnValue_t TmTcBridge::handleTmQueue() { } ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage* message) { - store_address_t storeId = 0; + store_address_t storeId; if (tmFifo == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index 6461a195..dd252d88 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -80,7 +80,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { } SECTION("Handle failed") { - store_address_t toLongParamAddress = StorageManagerIF::INVALID_ADDRESS; + store_address_t toLongParamAddress = store_address_t::invalid(); std::array toLongData = {5, 4, 3, 2, 1}; REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == retval::CATCH_OK); ActionMessage::setCommand(&actionMessage, testActionId, toLongParamAddress); @@ -98,7 +98,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { } SECTION("Missing IPC Data") { - ActionMessage::setCommand(&actionMessage, testActionId, StorageManagerIF::INVALID_ADDRESS); + ActionMessage::setCommand(&actionMessage, testActionId, store_address_t::invalid()); CHECK(not testDhMock.executeActionCalled); REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK); CommandMessage testMessage; diff --git a/unittests/datapoollocal/LocalPoolManagerTest.cpp b/unittests/datapoollocal/LocalPoolManagerTest.cpp index 58a6065e..6d9f162c 100644 --- a/unittests/datapoollocal/LocalPoolManagerTest.cpp +++ b/unittests/datapoollocal/LocalPoolManagerTest.cpp @@ -392,13 +392,13 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { CHECK(gpidToCheck == lpool::uint8VarGpid); HousekeepingMessage::setUpdateSnapshotSetCommand(&hkCmd, lpool::testSid, - storeId::INVALID_STORE_ADDRESS); + store_address_t::invalid()); CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); CHECK(poolOwner->changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); CHECK(sidToCheck == lpool::testSid); HousekeepingMessage::setUpdateSnapshotVariableCommand(&hkCmd, lpool::uint8VarGpid, - storeId::INVALID_STORE_ADDRESS); + store_address_t::invalid()); CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); CHECK(poolOwner->changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); CHECK(gpidToCheck == lpool::uint8VarGpid); diff --git a/unittests/datapoollocal/LocalPoolOwnerBase.cpp b/unittests/datapoollocal/LocalPoolOwnerBase.cpp index 6f054893..2743e7f7 100644 --- a/unittests/datapoollocal/LocalPoolOwnerBase.cpp +++ b/unittests/datapoollocal/LocalPoolOwnerBase.cpp @@ -90,7 +90,7 @@ bool LocalPoolOwnerBase::changedDataSetCallbackWasCalled(sid_t &sid, store_addre sid = changedDatasetSid; storeId = storeIdForChangedSet; this->changedDatasetSid.raw = sid_t::INVALID_SID; - this->storeIdForChangedSet = storeId::INVALID_STORE_ADDRESS; + this->storeIdForChangedSet = store_address_t::invalid(); return condition; } @@ -108,7 +108,7 @@ bool LocalPoolOwnerBase::changedVariableCallbackWasCalled(gp_id_t &gpid, store_a gpid = changedPoolVariableGpid; storeId = storeIdForChangedVariable; this->changedPoolVariableGpid.raw = gp_id_t::INVALID_GPID; - this->storeIdForChangedVariable = storeId::INVALID_STORE_ADDRESS; + this->storeIdForChangedVariable = store_address_t::invalid(); return condition; } diff --git a/unittests/storagemanager/TestNewAccessor.cpp b/unittests/storagemanager/TestNewAccessor.cpp index 2cc2e469..996239a6 100644 --- a/unittests/storagemanager/TestNewAccessor.cpp +++ b/unittests/storagemanager/TestNewAccessor.cpp @@ -162,7 +162,7 @@ TEST_CASE("New Accessor", "[NewAccessor]") { REQUIRE(result == retval::CATCH_OK); { StorageAccessor accessor(testStoreId); - StorageAccessor accessor2(0); + StorageAccessor accessor2(store_address_t::invalid()); accessor2 = std::move(accessor); REQUIRE(accessor.data() == nullptr); std::array data; diff --git a/unittests/tmtcservices/testStoreHelper.cpp b/unittests/tmtcservices/testStoreHelper.cpp index 8c92a228..4740ef87 100644 --- a/unittests/tmtcservices/testStoreHelper.cpp +++ b/unittests/tmtcservices/testStoreHelper.cpp @@ -9,4 +9,21 @@ TEST_CASE("TM Store Helper", "[tm-store-helper]") { LocalPool::LocalPoolConfig cfg = {{10, 32}, {5, 64}}; LocalPool pool(objects::NO_OBJECT, cfg); auto storeHelper = TmStoreHelper(2, pool, timeStamper); + + SECTION("State") { + REQUIRE(storeHelper.getCurrentAddr() == store_address_t::invalid()); + REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); + auto& creator = storeHelper.getCreatorRef(); + REQUIRE(creator.getApid() == 2); + REQUIRE(creator.getService() == 17); + REQUIRE(creator.getSubService() == 1); + REQUIRE(creator.getSequenceCount() == 0); + REQUIRE(creator.getMessageTypeCounter() == 1); + } + + SECTION("Basic") { + REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid()); + } } \ No newline at end of file From 973d4ee8a5fac7aa12e29acb160e88eef070beb4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 11:24:13 +0200 Subject: [PATCH 094/532] some more ref replacements --- src/fsfw/pus/Service17Test.cpp | 4 ++-- src/fsfw/pus/Service17Test.h | 2 +- src/fsfw/pus/Service1TelecommandVerification.cpp | 2 +- src/fsfw/tmtcservices/CommandingServiceBase.cpp | 4 ++-- src/fsfw/tmtcservices/CommandingServiceBase.h | 2 +- src/fsfw/tmtcservices/TmStoreHelper.cpp | 12 +++++++----- src/fsfw/tmtcservices/TmStoreHelper.h | 6 +++--- unittests/tmtcservices/testStoreHelper.cpp | 5 +++++ 8 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index d9547d03..d7c5a71b 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -42,11 +42,11 @@ ReturnValue_t Service17Test::initialize() { if (tmStore == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } - storeHelper.setTmStore(tmStore); + storeHelper.setTmStore(*tmStore); } return result; } -void Service17Test::setCustomTmStore(StorageManagerIF* tmStore_) { +void Service17Test::setCustomTmStore(StorageManagerIF& tmStore_) { storeHelper.setTmStore(tmStore_); } diff --git a/src/fsfw/pus/Service17Test.h b/src/fsfw/pus/Service17Test.h index a5bfa974..54efcaa5 100644 --- a/src/fsfw/pus/Service17Test.h +++ b/src/fsfw/pus/Service17Test.h @@ -35,7 +35,7 @@ class Service17Test : public PusServiceBase { Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId); - void setCustomTmStore(StorageManagerIF* tmStore); + void setCustomTmStore(StorageManagerIF& tmStore); ~Service17Test() override; ReturnValue_t handleRequest(uint8_t subservice) override; diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 997b4b40..56259c1f 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -100,7 +100,7 @@ ReturnValue_t Service1TelecommandVerification::initialize() { if (tmStore == nullptr) { return ObjectManager::CHILD_INIT_FAILED; } - storeHelper.setTmStore(tmStore); + storeHelper.setTmStore(*tmStore); } return SystemObject::initialize(); } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 01c25f87..1a548751 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -96,7 +96,7 @@ ReturnValue_t CommandingServiceBase::initialize() { if (tmStore == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } - tmStoreHelper.setTmStore(tmStore); + tmStoreHelper.setTmStore(*tmStore); } if (errReporter == nullptr) { errReporter = @@ -419,7 +419,7 @@ void CommandingServiceBase::checkTimeout() { void CommandingServiceBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; } -void CommandingServiceBase::setCustomTmStore(StorageManagerIF* store) { +void CommandingServiceBase::setCustomTmStore(StorageManagerIF& store) { tmStoreHelper.setTmStore(store); } ReturnValue_t CommandingServiceBase::setUpTcReader(store_address_t storeId) { diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 9b8aa61e..9d116400 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -70,7 +70,7 @@ class CommandingServiceBase : public SystemObject, size_t queueDepth = 20); ~CommandingServiceBase() override; - void setCustomTmStore(StorageManagerIF* store); + void setCustomTmStore(StorageManagerIF& store); /** * This setter can be used to set the packet source individually instead * of using the default static framework ID set in the factory. diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index 5f766c3f..79c617e7 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -28,16 +28,18 @@ ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, StorageManagerIF* TmStoreHelper::getTmStore() { return tmStore; } -void TmStoreHelper::setTmStore(StorageManagerIF* store) { tmStore = store; } +void TmStoreHelper::setTmStore(StorageManagerIF& store) { tmStore = &store; } + const store_address_t& TmStoreHelper::getCurrentAddr() const { return currentAddr; } + ReturnValue_t TmStoreHelper::deletePacket() { return tmStore->deleteData(currentAddr); } -void TmStoreHelper::setSourceDataRaw(const uint8_t* data, size_t len) { - creator.setRawUserData(data, len); +ReturnValue_t TmStoreHelper::setSourceDataRaw(const uint8_t* data, size_t len) { + return creator.setRawUserData(data, len); } -void TmStoreHelper::setSourceDataSerializable(SerializeIF* serializable) { - creator.setSerializableUserData(serializable); +ReturnValue_t TmStoreHelper::setSourceDataSerializable(SerializeIF* serializable) { + return creator.setSerializableUserData(serializable); } ReturnValue_t TmStoreHelper::addPacketToStore() { diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index ebaff707..cf7d3c74 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -18,11 +18,11 @@ class TmStoreHelper { PusTmCreator& getCreatorRef(); void setTimeStamper(TimeStamperIF& timeStamper); [[nodiscard]] const store_address_t& getCurrentAddr() const; - void setSourceDataRaw(const uint8_t* data, size_t len); - void setSourceDataSerializable(SerializeIF* serializable); + ReturnValue_t setSourceDataRaw(const uint8_t* data, size_t len); + ReturnValue_t setSourceDataSerializable(SerializeIF* serializable); void setApid(uint16_t apid); StorageManagerIF* getTmStore(); - void setTmStore(StorageManagerIF* store); + void setTmStore(StorageManagerIF& store); ReturnValue_t addPacketToStore(); ReturnValue_t deletePacket(); diff --git a/unittests/tmtcservices/testStoreHelper.cpp b/unittests/tmtcservices/testStoreHelper.cpp index 4740ef87..7e52ea14 100644 --- a/unittests/tmtcservices/testStoreHelper.cpp +++ b/unittests/tmtcservices/testStoreHelper.cpp @@ -12,6 +12,7 @@ TEST_CASE("TM Store Helper", "[tm-store-helper]") { SECTION("State") { REQUIRE(storeHelper.getCurrentAddr() == store_address_t::invalid()); + REQUIRE(storeHelper.getTmStore() == &pool); REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); auto& creator = storeHelper.getCreatorRef(); REQUIRE(creator.getApid() == 2); @@ -25,5 +26,9 @@ TEST_CASE("TM Store Helper", "[tm-store-helper]") { REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid()); + auto accessor = pool.getData(storeHelper.getCurrentAddr()); + REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK); + // Not going to verify individual fields, the creator was unittested separately + REQUIRE(accessor.second.size() == 22); } } \ No newline at end of file From e2ad37e3e6e1e7644d1475d3296f79005a7ca0de Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 11:26:45 +0200 Subject: [PATCH 095/532] more ref replacements --- src/fsfw/pus/CService200ModeCommanding.cpp | 6 +++--- src/fsfw/pus/CService201HealthCommanding.cpp | 2 +- src/fsfw/pus/Service1TelecommandVerification.cpp | 4 ++-- src/fsfw/pus/Service20ParameterManagement.cpp | 2 +- src/fsfw/pus/Service5EventReporting.cpp | 2 +- src/fsfw/pus/Service8FunctionManagement.cpp | 2 +- src/fsfw/tmtcpacket/pus/CustomUserDataIF.h | 2 +- src/fsfw/tmtcpacket/pus/defs.h | 4 ++-- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 2 +- src/fsfw/tmtcservices/CommandingServiceBase.cpp | 4 ++-- src/fsfw/tmtcservices/CommandingServiceBase.h | 2 +- src/fsfw/tmtcservices/TmStoreHelper.cpp | 2 +- src/fsfw/tmtcservices/TmStoreHelper.h | 2 +- unittests/tmtcpacket/testPusTcCreator.cpp | 2 +- unittests/tmtcpacket/testPusTmCreator.cpp | 2 +- 18 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index 41be3d13..9990280c 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -96,13 +96,13 @@ ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply ReturnValue_t CService200ModeCommanding::prepareModeReply(const CommandMessage *reply, object_id_t objectId) { ModePacket modeReplyPacket(objectId, ModeMessage::getMode(reply), ModeMessage::getSubmode(reply)); - return sendTmPacket(Subservice::REPLY_MODE_REPLY, &modeReplyPacket); + return sendTmPacket(Subservice::REPLY_MODE_REPLY, modeReplyPacket); } ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMessage *reply, object_id_t objectId) { ModePacket wrongModeReply(objectId, ModeMessage::getMode(reply), ModeMessage::getSubmode(reply)); - ReturnValue_t result = sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, &wrongModeReply); + ReturnValue_t result = sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, wrongModeReply); if (result == RETURN_OK) { // We want to produce an error here in any case because the mode was not correct return RETURN_FAILED; @@ -113,7 +113,7 @@ ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMess ReturnValue_t CService200ModeCommanding::prepareCantReachModeReply(const CommandMessage *reply, object_id_t objectId) { CantReachModePacket cantReachModePacket(objectId, ModeMessage::getCantReachModeReason(reply)); - ReturnValue_t result = sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, &cantReachModePacket); + ReturnValue_t result = sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, cantReachModePacket); if (result == RETURN_OK) { // We want to produce an error here in any case because the mode was not reached return RETURN_FAILED; diff --git a/src/fsfw/pus/CService201HealthCommanding.cpp b/src/fsfw/pus/CService201HealthCommanding.cpp index 644e0d7c..c668ea52 100644 --- a/src/fsfw/pus/CService201HealthCommanding.cpp +++ b/src/fsfw/pus/CService201HealthCommanding.cpp @@ -102,5 +102,5 @@ ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *rep auto health = static_cast(HealthMessage::getHealth(reply)); auto oldHealth = static_cast(HealthMessage::getOldHealth(reply)); HealthSetReply healthSetReply(health, oldHealth); - return sendTmPacket(Subservice::REPLY_HEALTH_SET, &healthSetReply); + return sendTmPacket(Subservice::REPLY_HEALTH_SET, healthSetReply); } diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 56259c1f..624a73d0 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -69,7 +69,7 @@ ReturnValue_t Service1TelecommandVerification::generateFailureReport( message->getTcSequenceControl(), message->getStep(), message->getErrorCode(), message->getParameter1(), message->getParameter2()); storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); - storeHelper.setSourceDataSerializable(&report); + storeHelper.setSourceDataSerializable(report); return telemetry::storeAndSendTmPacket(storeHelper, sendHelper); } @@ -78,7 +78,7 @@ ReturnValue_t Service1TelecommandVerification::generateSuccessReport( SuccessReport report(message->getReportId(), message->getTcPacketId(), message->getTcSequenceControl(), message->getStep()); storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); - storeHelper.setSourceDataSerializable(&report); + storeHelper.setSourceDataSerializable(report); return telemetry::storeAndSendTmPacket(storeHelper, sendHelper); } diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index 9354c80d..0922793c 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -177,7 +177,7 @@ ReturnValue_t Service20ParameterManagement::handleReply(const CommandMessage* re ParameterId_t parameterId = ParameterMessage::getParameterId(reply); ParameterDumpReply parameterReply(objectId, parameterId, parameterData.second.data(), parameterData.second.size()); - sendTmPacket(static_cast(Subservice::PARAMETER_DUMP_REPLY), ¶meterReply); + sendTmPacket(static_cast(Subservice::PARAMETER_DUMP_REPLY), parameterReply); return HasReturnvaluesIF::RETURN_OK; } default: diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index 59ad7c6c..e9c9c095 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -48,7 +48,7 @@ ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) EventReport report(message.getEventId(), message.getReporter(), message.getParameter1(), message.getParameter2()); storeHelper.preparePacket(serviceId, message.getSeverity(), packetSubCounter); - storeHelper.setSourceDataSerializable(&report); + storeHelper.setSourceDataSerializable(report); ReturnValue_t result = telemetry::storeAndSendTmPacket(storeHelper, sendHelper); if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/pus/Service8FunctionManagement.cpp b/src/fsfw/pus/Service8FunctionManagement.cpp index 0b3784be..c9da6d58 100644 --- a/src/fsfw/pus/Service8FunctionManagement.cpp +++ b/src/fsfw/pus/Service8FunctionManagement.cpp @@ -138,7 +138,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* return result; } DataReply dataReply(objectId, actionId, buffer, size); - result = sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), &dataReply); + result = sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), dataReply); auto deletionResult = ipcStore->deleteData(storeId); if (deletionResult != HasReturnvaluesIF::RETURN_OK) { diff --git a/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h b/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h index ddbce9f1..779a0414 100644 --- a/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h +++ b/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h @@ -7,6 +7,6 @@ class CustomUserDataIF { public: virtual ~CustomUserDataIF() = default; virtual ReturnValue_t setRawUserData(const uint8_t* data, size_t len) = 0; - virtual ReturnValue_t setSerializableUserData(SerializeIF* serializable) = 0; + virtual ReturnValue_t setSerializableUserData(SerializeIF& serializable) = 0; }; #endif // FSFW_TMTCPACKET_CREATORDATAIF_H diff --git a/src/fsfw/tmtcpacket/pus/defs.h b/src/fsfw/tmtcpacket/pus/defs.h index 72a154ff..69b3415c 100644 --- a/src/fsfw/tmtcpacket/pus/defs.h +++ b/src/fsfw/tmtcpacket/pus/defs.h @@ -45,9 +45,9 @@ struct DataWrapper { dataUnion.raw.len = bufPair.second; } - void setSerializable(SerializeIF* serializable) { + void setSerializable(SerializeIF& serializable) { type = DataTypes::SERIALIZABLE; - dataUnion.serializable = serializable; + dataUnion.serializable = &serializable; } }; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 9ffd6eb4..992ec388 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -101,7 +101,7 @@ ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF *serializable) { +ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF& serializable) { // TODO: Check length field? pusParams.dataWrapper.setSerializable(serializable); updateSpLengthField(); diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 4e5951a5..90b32973 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -47,7 +47,7 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF [[nodiscard]] uint8_t getSubService() const override; [[nodiscard]] uint16_t getSourceId() const override; ReturnValue_t setRawUserData(const uint8_t *data, size_t len) override; - ReturnValue_t setSerializableUserData(SerializeIF *serializable) override; + ReturnValue_t setSerializableUserData(SerializeIF& serializable) override; private: ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 6aac4660..662e74be 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -128,7 +128,7 @@ ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { updateSpLengthField(); return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PusTmCreator::setSerializableUserData(SerializeIF* serializable) { +ReturnValue_t PusTmCreator::setSerializableUserData(SerializeIF& serializable) { pusParams.dataWrapper.setSerializable(serializable); updateSpLengthField(); return HasReturnvaluesIF::RETURN_OK; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 2b62fa85..7df760ce 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -69,7 +69,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF Endianness streamEndianness) override; [[nodiscard]] TimeStamperIF* getTimestamper() const; ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override; - ReturnValue_t setSerializableUserData(SerializeIF* serializable) override; + ReturnValue_t setSerializableUserData(SerializeIF& serializable) override; private: void setup(); diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 1a548751..3fac5bd2 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -300,7 +300,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_ const uint8_t* data, size_t dataLen) { telemetry::DataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); - tmStoreHelper.setSourceDataSerializable(&dataWithObjId); + tmStoreHelper.setSourceDataSerializable(dataWithObjId); ReturnValue_t result = telemetry::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); if (result == HasReturnvaluesIF::RETURN_OK) { this->tmPacketCounter++; @@ -308,7 +308,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_ return result; } -ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeIF* sourceData) { +ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeIF& sourceData) { tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); tmStoreHelper.setSourceDataSerializable(sourceData); ReturnValue_t result = telemetry::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 9d116400..48575724 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -313,7 +313,7 @@ class CommandingServiceBase : public SystemObject, * @param content This is a pointer to the serialized packet * @param header Serialize IF header which will be placed before content */ - ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF* sourceData); + ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF& sourceData); void checkAndExecuteFifo(CommandMapIter& iter); diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index 79c617e7..e7753f44 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -38,7 +38,7 @@ ReturnValue_t TmStoreHelper::setSourceDataRaw(const uint8_t* data, size_t len) { return creator.setRawUserData(data, len); } -ReturnValue_t TmStoreHelper::setSourceDataSerializable(SerializeIF* serializable) { +ReturnValue_t TmStoreHelper::setSourceDataSerializable(SerializeIF& serializable) { return creator.setSerializableUserData(serializable); } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index cf7d3c74..fc6de002 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -19,7 +19,7 @@ class TmStoreHelper { void setTimeStamper(TimeStamperIF& timeStamper); [[nodiscard]] const store_address_t& getCurrentAddr() const; ReturnValue_t setSourceDataRaw(const uint8_t* data, size_t len); - ReturnValue_t setSourceDataSerializable(SerializeIF* serializable); + ReturnValue_t setSourceDataSerializable(SerializeIF& serializable); void setApid(uint16_t apid); StorageManagerIF* getTmStore(); void setTmStore(StorageManagerIF& store); diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index 978833cd..c5b0743b 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -85,7 +85,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { SECTION("Test with Application Data Serializable") { auto& params = creator.getPusParams(); auto simpleSer = SimpleSerializable(); - creator.setSerializableUserData(&simpleSer); + creator.setSerializableUserData(simpleSer); REQUIRE(creator.getSerializedSize() == 16); REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(serLen == 16); diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index cd8f0e0b..ad8a1d4d 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -113,7 +113,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { SECTION("Serialize with Serializable") { auto simpleSer = SimpleSerializable(); - creator.setSerializableUserData(&simpleSer); + creator.setSerializableUserData(simpleSer); REQUIRE(creator.getFullPacketLen() == 25); REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[20] == 1); From 2a34c831b199ab747e2bbab6db4237602157d873 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 11:33:12 +0200 Subject: [PATCH 096/532] use Be instead of Ne, which could be confused --- src/fsfw/serialize/SerializeIF.h | 16 ++++++++-------- unittests/serialize/testSerializeIF.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 54a1f4e3..921d8a5e 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -62,9 +62,9 @@ class SerializeIF { virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const = 0; /** - * Forwards to regular @serialize call with network endianness + * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t serializeNe(uint8_t** buffer, size_t* size, size_t maxSize) { + virtual ReturnValue_t serializeBe(uint8_t** buffer, size_t* size, size_t maxSize) { return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } /** @@ -103,9 +103,9 @@ class SerializeIF { virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) = 0; /** - * Forwards to regular @deSerialize call with network endianness + * Forwards to regular @deSerialize call with big (network) endianness */ - virtual ReturnValue_t deSerializeNe(const uint8_t** buffer, size_t* size) { + virtual ReturnValue_t deSerializeBe(const uint8_t** buffer, size_t* size) { return deSerialize(buffer, size, SerializeIF::Endianness::NETWORK); } /** @@ -129,9 +129,9 @@ class SerializeIF { return serialize(&buffer, &tmpSize, maxSize, streamEndianness); } /** - * Forwards to regular @serialize call with network endianness + * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t serializeNe(uint8_t *buffer, size_t maxSize) const { + virtual ReturnValue_t serializeBe(uint8_t *buffer, size_t maxSize) const { return serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); } /** @@ -154,9 +154,9 @@ class SerializeIF { return deSerialize(&buffer, &maxSize, streamEndianness); } /** - * Forwards to regular @serialize call with network endianness + * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t deSerializeNe(const uint8_t *buffer, size_t maxSize) { + virtual ReturnValue_t deSerializeBe(const uint8_t *buffer, size_t maxSize) { return deSerialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); } /** diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index 2cbe6132..694f6d7f 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -38,7 +38,7 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.serializeNe(&ptr, &len, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.serializeBe(&ptr, &len, buf.size()) == HasReturnvaluesIF::RETURN_OK); } CHECK(buf[0] == 1); @@ -58,7 +58,7 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::serializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::serializeBe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); } CHECK(buf[0] == 1); CHECK(buf[1] == 2); @@ -123,7 +123,7 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::deSerializeNe(&ptr, &len) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerializeBe(&ptr, &len) == HasReturnvaluesIF::RETURN_OK); } CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 1); @@ -140,7 +140,7 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::deSerializeNe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerializeBe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); } CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 1); From 36e3956efb612ccfceb696744e8571e17c156d36 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 13:39:07 +0200 Subject: [PATCH 097/532] finished tm store helper tests --- src/fsfw/tmtcservices/TmStoreHelper.cpp | 14 +++- src/fsfw/tmtcservices/TmStoreHelper.h | 14 +++- unittests/mocks/MessageQueueMockBase.h | 14 ++-- unittests/tmtcservices/CMakeLists.txt | 1 + unittests/tmtcservices/testSendHelper.cpp | 5 ++ unittests/tmtcservices/testStoreHelper.cpp | 77 +++++++++++++++++++++- 6 files changed, 112 insertions(+), 13 deletions(-) create mode 100644 unittests/tmtcservices/testSendHelper.cpp diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index e7753f44..87a530ef 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -26,13 +26,19 @@ ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, return HasReturnvaluesIF::RETURN_OK; } -StorageManagerIF* TmStoreHelper::getTmStore() { return tmStore; } +StorageManagerIF* TmStoreHelper::getTmStore() const { return tmStore; } void TmStoreHelper::setTmStore(StorageManagerIF& store) { tmStore = &store; } const store_address_t& TmStoreHelper::getCurrentAddr() const { return currentAddr; } -ReturnValue_t TmStoreHelper::deletePacket() { return tmStore->deleteData(currentAddr); } +ReturnValue_t TmStoreHelper::deletePacket() { + ReturnValue_t result = tmStore->deleteData(currentAddr); + if(result == HasReturnvaluesIF::RETURN_OK) { + currentAddr = store_address_t::invalid(); + } + return result; +} ReturnValue_t TmStoreHelper::setSourceDataRaw(const uint8_t* data, size_t len) { return creator.setRawUserData(data, len); @@ -62,3 +68,7 @@ void TmStoreHelper::setTimeStamper(TimeStamperIF& timeStamper_) { void TmStoreHelper::setApid(uint16_t apid) { creator.setApid(apid); } PusTmCreator& TmStoreHelper::getCreatorRef() { return creator; } + +TimeStamperIF* TmStoreHelper::getTimeStamper() const { return creator.getTimestamper(); } + +uint16_t TmStoreHelper::getApid() const { return creator.getApid(); } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index fc6de002..b253361e 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -16,13 +16,21 @@ class TmStoreHelper { ReturnValue_t preparePacket(uint8_t service, uint8_t subservice, uint16_t counter); PusTmCreator& getCreatorRef(); + void setTimeStamper(TimeStamperIF& timeStamper); + [[nodiscard]] TimeStamperIF* getTimeStamper() const; + + [[nodiscard]] StorageManagerIF* getTmStore() const; + void setTmStore(StorageManagerIF& store); + + void setApid(uint16_t apid); + [[nodiscard]] uint16_t getApid() const; + [[nodiscard]] const store_address_t& getCurrentAddr() const; ReturnValue_t setSourceDataRaw(const uint8_t* data, size_t len); ReturnValue_t setSourceDataSerializable(SerializeIF& serializable); - void setApid(uint16_t apid); - StorageManagerIF* getTmStore(); - void setTmStore(StorageManagerIF& store); + + ReturnValue_t addPacketToStore(); ReturnValue_t deletePacket(); diff --git a/unittests/mocks/MessageQueueMockBase.h b/unittests/mocks/MessageQueueMockBase.h index d3323186..92729a7a 100644 --- a/unittests/mocks/MessageQueueMockBase.h +++ b/unittests/mocks/MessageQueueMockBase.h @@ -18,11 +18,11 @@ class MessageQueueMockBase : public MessageQueueBase { uint8_t messageSentCounter = 0; bool messageSent = false; - bool wasMessageSent(uint8_t* messageSentCounter = nullptr, bool resetCounter = true) { + bool wasMessageSent(uint8_t* messageSentCounter_ = nullptr, bool resetCounter = true) { bool tempMessageSent = messageSent; messageSent = false; - if (messageSentCounter != nullptr) { - *messageSentCounter = this->messageSentCounter; + if (messageSentCounter_ != nullptr) { + *messageSentCounter_ = this->messageSentCounter; } if (resetCounter) { this->messageSentCounter = 0; @@ -40,7 +40,7 @@ class MessageQueueMockBase : public MessageQueueBase { return receiveMessage(&message); } - virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override { + ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override { if (messagesSentQueue.empty()) { return MessageQueueIF::EMPTY; } @@ -50,8 +50,8 @@ class MessageQueueMockBase : public MessageQueueBase { messagesSentQueue.pop(); return HasReturnvaluesIF::RETURN_OK; } - virtual ReturnValue_t flush(uint32_t* count) { return HasReturnvaluesIF::RETURN_OK; } - virtual ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, + ReturnValue_t flush(uint32_t* count) override { return HasReturnvaluesIF::RETURN_OK; } + ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, MessageQueueId_t sentFrom, bool ignoreFault = false) override { messageSent = true; @@ -61,7 +61,7 @@ class MessageQueueMockBase : public MessageQueueBase { return HasReturnvaluesIF::RETURN_OK; } - virtual ReturnValue_t reply(MessageQueueMessageIF* message) override { + ReturnValue_t reply(MessageQueueMessageIF* message) override { return sendMessageFrom(MessageQueueIF::NO_QUEUE, message, this->getId(), false); } diff --git a/unittests/tmtcservices/CMakeLists.txt b/unittests/tmtcservices/CMakeLists.txt index 00dfab95..791066ad 100644 --- a/unittests/tmtcservices/CMakeLists.txt +++ b/unittests/tmtcservices/CMakeLists.txt @@ -1,3 +1,4 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testStoreHelper.cpp + testSendHelper.cpp ) diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp new file mode 100644 index 00000000..66c7ab59 --- /dev/null +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -0,0 +1,5 @@ +#include + +TEST_CASE("TM Send Helper", "[tm-send-helper]") { + +} \ No newline at end of file diff --git a/unittests/tmtcservices/testStoreHelper.cpp b/unittests/tmtcservices/testStoreHelper.cpp index 7e52ea14..275a6238 100644 --- a/unittests/tmtcservices/testStoreHelper.cpp +++ b/unittests/tmtcservices/testStoreHelper.cpp @@ -3,15 +3,17 @@ #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tmtcservices/TmStoreHelper.h" #include "mocks/CdsShortTimestamperMock.h" +#include "mocks/SimpleSerializable.h" TEST_CASE("TM Store Helper", "[tm-store-helper]") { auto timeStamper = CdsShortTimestamperMock(); - LocalPool::LocalPoolConfig cfg = {{10, 32}, {5, 64}}; + LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; LocalPool pool(objects::NO_OBJECT, cfg); auto storeHelper = TmStoreHelper(2, pool, timeStamper); SECTION("State") { REQUIRE(storeHelper.getCurrentAddr() == store_address_t::invalid()); + REQUIRE(storeHelper.getTimeStamper() == &timeStamper); REQUIRE(storeHelper.getTmStore() == &pool); REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); auto& creator = storeHelper.getCreatorRef(); @@ -22,6 +24,25 @@ TEST_CASE("TM Store Helper", "[tm-store-helper]") { REQUIRE(creator.getMessageTypeCounter() == 1); } + SECTION("Timestamper Setter") { + auto timeStamper2 = CdsShortTimestamperMock(); + storeHelper.setTimeStamper(timeStamper2); + REQUIRE(storeHelper.getTimeStamper() == &timeStamper2); + } + + SECTION("Pool Setter") { + LocalPool::LocalPoolConfig cfg2 = {{10, 32}, {5, 64}}; + LocalPool pool2(objects::NO_OBJECT, cfg); + storeHelper.setTmStore(pool2); + REQUIRE(storeHelper.getTmStore() == &pool2); + } + + SECTION("APID Setter") { + storeHelper.setApid(3); + auto& creator = storeHelper.getCreatorRef(); + REQUIRE(creator.getApid() == 3); + } + SECTION("Basic") { REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); @@ -31,4 +52,58 @@ TEST_CASE("TM Store Helper", "[tm-store-helper]") { // Not going to verify individual fields, the creator was unittested separately REQUIRE(accessor.second.size() == 22); } + + SECTION("Deletion") { + REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid()); + { + auto accessor = pool.getData(storeHelper.getCurrentAddr()); + REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK); + REQUIRE(accessor.second.size() == 22); + accessor.second.release(); + } + REQUIRE(storeHelper.deletePacket() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.getCurrentAddr() == store_address_t::invalid()); + auto accessor = pool.getData(storeHelper.getCurrentAddr()); + REQUIRE(accessor.first != HasReturnvaluesIF::RETURN_OK); + } + + SECTION("With App Data Raw") { + REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); + std::array data = {1, 2, 3}; + REQUIRE(storeHelper.setSourceDataRaw(data.data(), data.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid()); + auto accessor = pool.getData(storeHelper.getCurrentAddr()); + REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK); + // Not going to verify individual fields, the creator was unittested separately + REQUIRE(accessor.second.size() == 25); + } + + SECTION("With App Data Serializable") { + REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); + auto serializable = SimpleSerializable(); + REQUIRE(storeHelper.setSourceDataSerializable(serializable) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid()); + auto accessor = pool.getData(storeHelper.getCurrentAddr()); + REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK); + // Not going to verify individual fields, the creator was unittested separately + REQUIRE(accessor.second.size() == 25); + } + + SECTION("APID Only CTOR") { + auto storeHelperApidOnly = TmStoreHelper(2); + REQUIRE(storeHelperApidOnly.getApid() == 2); + REQUIRE(storeHelperApidOnly.getTmStore() == nullptr); + REQUIRE(storeHelperApidOnly.getTimeStamper() == nullptr); + } + + SECTION("APID and TM Store Only CTOR") { + auto storeHelperApidOnly = TmStoreHelper(2, pool); + REQUIRE(storeHelperApidOnly.getApid() == 2); + REQUIRE(storeHelperApidOnly.getTmStore() == &pool); + REQUIRE(storeHelperApidOnly.getTimeStamper() == nullptr); + } } \ No newline at end of file From 1a7d7b172b0e29d2612686f3e5a9350b16881019 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 14:04:06 +0200 Subject: [PATCH 098/532] set up new internal error reporter mock --- src/fsfw/ipc/MessageQueueBase.cpp | 2 +- src/fsfw/ipc/MessageQueueBase.h | 30 ++++----- src/fsfw/ipc/MessageQueueIF.h | 10 +-- src/fsfw/osal/host/MessageQueue.cpp | 4 +- src/fsfw/osal/host/QueueFactory.cpp | 5 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 2 +- src/fsfw/tmtcservices/TmSendHelper.cpp | 15 +++-- src/fsfw/tmtcservices/TmSendHelper.h | 8 ++- .../TestInternalErrorReporter.cpp | 12 ++-- unittests/mocks/CMakeLists.txt | 1 + unittests/mocks/InternalErrorReporterMock.h | 11 +++ unittests/mocks/MessageQueueMockBase.cpp | 67 +++++++++++++++++++ unittests/mocks/MessageQueueMockBase.h | 63 +++-------------- unittests/tmtcservices/testSendHelper.cpp | 4 +- 14 files changed, 140 insertions(+), 94 deletions(-) create mode 100644 unittests/mocks/InternalErrorReporterMock.h create mode 100644 unittests/mocks/MessageQueueMockBase.cpp diff --git a/src/fsfw/ipc/MessageQueueBase.cpp b/src/fsfw/ipc/MessageQueueBase.cpp index c43670ed..56041bee 100644 --- a/src/fsfw/ipc/MessageQueueBase.cpp +++ b/src/fsfw/ipc/MessageQueueBase.cpp @@ -8,7 +8,7 @@ MessageQueueBase::MessageQueueBase(MessageQueueId_t id, MessageQueueId_t default } } -MessageQueueBase::~MessageQueueBase() {} +MessageQueueBase::~MessageQueueBase() = default; ReturnValue_t MessageQueueBase::sendToDefault(MessageQueueMessageIF* message) { return sendToDefaultFrom(message, this->getId(), false); diff --git a/src/fsfw/ipc/MessageQueueBase.h b/src/fsfw/ipc/MessageQueueBase.h index 942b6121..9c05b1a2 100644 --- a/src/fsfw/ipc/MessageQueueBase.h +++ b/src/fsfw/ipc/MessageQueueBase.h @@ -7,28 +7,28 @@ class MessageQueueBase : public MessageQueueIF { public: MessageQueueBase(MessageQueueId_t id, MessageQueueId_t defaultDest, MqArgs* mqArgs); - virtual ~MessageQueueBase(); + ~MessageQueueBase() override; // Default implementations for MessageQueueIF where possible - virtual MessageQueueId_t getLastPartner() const override; - virtual MessageQueueId_t getId() const override; - virtual MqArgs& getMqArgs() override; - virtual void setDefaultDestination(MessageQueueId_t defaultDestination) override; - virtual MessageQueueId_t getDefaultDestination() const override; - virtual bool isDefaultDestinationSet() const override; - virtual ReturnValue_t sendMessage(MessageQueueId_t sendTo, MessageQueueMessageIF* message, + [[nodiscard]] MessageQueueId_t getLastPartner() const override; + [[nodiscard]] MessageQueueId_t getId() const override; + MqArgs& getMqArgs() override; + void setDefaultDestination(MessageQueueId_t defaultDestination) override; + [[nodiscard]] MessageQueueId_t getDefaultDestination() const override; + [[nodiscard]] bool isDefaultDestinationSet() const override; + ReturnValue_t sendMessage(MessageQueueId_t sendTo, MessageQueueMessageIF* message, bool ignoreFault) override; - virtual ReturnValue_t sendToDefault(MessageQueueMessageIF* message) override; - virtual ReturnValue_t reply(MessageQueueMessageIF* message) override; - virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message, + ReturnValue_t sendToDefault(MessageQueueMessageIF* message) override; + ReturnValue_t reply(MessageQueueMessageIF* message) override; + ReturnValue_t receiveMessage(MessageQueueMessageIF* message, MessageQueueId_t* receivedFrom) override; - virtual ReturnValue_t sendToDefaultFrom(MessageQueueMessageIF* message, MessageQueueId_t sentFrom, + ReturnValue_t sendToDefaultFrom(MessageQueueMessageIF* message, MessageQueueId_t sentFrom, bool ignoreFault = false) override; // OSAL specific, forward the abstract function - virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) = 0; - virtual ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, - MessageQueueId_t sentFrom, bool ignoreFault = false) = 0; + ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override = 0; + ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, + MessageQueueId_t sentFrom, bool ignoreFault = false) override = 0; protected: MessageQueueId_t id = MessageQueueIF::NO_QUEUE; diff --git a/src/fsfw/ipc/MessageQueueIF.h b/src/fsfw/ipc/MessageQueueIF.h index 9532b2d6..4f69695a 100644 --- a/src/fsfw/ipc/MessageQueueIF.h +++ b/src/fsfw/ipc/MessageQueueIF.h @@ -30,7 +30,7 @@ class MessageQueueIF { //! [EXPORT] : [COMMENT] Returned if the target destination is invalid. static constexpr ReturnValue_t DESTINATION_INVALID = MAKE_RETURN_CODE(4); - virtual ~MessageQueueIF() {} + virtual ~MessageQueueIF() = default; /** * @brief This operation sends a message to the last communication partner. * @details @@ -82,11 +82,11 @@ class MessageQueueIF { /** * @brief This method returns the message queue ID of the last communication partner. */ - virtual MessageQueueId_t getLastPartner() const = 0; + [[nodiscard]] virtual MessageQueueId_t getLastPartner() const = 0; /** * @brief This method returns the message queue ID of this class's message queue. */ - virtual MessageQueueId_t getId() const = 0; + [[nodiscard]] virtual MessageQueueId_t getId() const = 0; /** * @brief With the sendMessage call, a queue message is sent to a receiving queue. @@ -159,9 +159,9 @@ class MessageQueueIF { /** * @brief This method is a simple getter for the default destination. */ - virtual MessageQueueId_t getDefaultDestination() const = 0; + [[nodiscard]] virtual MessageQueueId_t getDefaultDestination() const = 0; - virtual bool isDefaultDestinationSet() const = 0; + [[nodiscard]] virtual bool isDefaultDestinationSet() const = 0; virtual MqArgs& getMqArgs() = 0; }; diff --git a/src/fsfw/osal/host/MessageQueue.cpp b/src/fsfw/osal/host/MessageQueue.cpp index 5eb0c99a..dad05a5a 100644 --- a/src/fsfw/osal/host/MessageQueue.cpp +++ b/src/fsfw/osal/host/MessageQueue.cpp @@ -65,11 +65,11 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, // But I will still return a failure here. return HasReturnvaluesIF::RETURN_FAILED; } - MessageQueue* targetQueue = + auto* targetQueue = dynamic_cast(QueueMapManager::instance()->getMessageQueue(sendTo)); if (targetQueue == nullptr) { if (not ignoreFault) { - InternalErrorReporterIF* internalErrorReporter = + auto* internalErrorReporter = ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); if (internalErrorReporter != nullptr) { internalErrorReporter->queueMessageNotSent(); diff --git a/src/fsfw/osal/host/QueueFactory.cpp b/src/fsfw/osal/host/QueueFactory.cpp index 732892ca..e2d83fd4 100644 --- a/src/fsfw/osal/host/QueueFactory.cpp +++ b/src/fsfw/osal/host/QueueFactory.cpp @@ -13,7 +13,6 @@ ReturnValue_t MessageQueueSenderIF::sendMessage(MessageQueueId_t sendTo, MessageQueueMessageIF* message, MessageQueueId_t sentFrom, bool ignoreFault) { return MessageQueue::sendMessageFromMessageQueue(sendTo, message, sentFrom, ignoreFault); - return HasReturnvaluesIF::RETURN_OK; } QueueFactory* QueueFactory::instance() { @@ -23,9 +22,9 @@ QueueFactory* QueueFactory::instance() { return factoryInstance; } -QueueFactory::QueueFactory() {} +QueueFactory::QueueFactory() = default; -QueueFactory::~QueueFactory() {} +QueueFactory::~QueueFactory() = default; MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* args) { diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index e7a0e5b9..6a21b65b 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -131,7 +131,7 @@ void PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelp } void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { - tmSendHelper.setMsgSource(requestQueue->getId()); + tmSendHelper.setMsgQueue(requestQueue); tmSendHelper.setMsgDestination(requestQueue->getDefaultDestination()); if (errReporter == nullptr) { errReporter = diff --git a/src/fsfw/tmtcservices/TmSendHelper.cpp b/src/fsfw/tmtcservices/TmSendHelper.cpp index 76591ca2..f8c76b75 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmSendHelper.cpp @@ -2,15 +2,21 @@ #include "fsfw/ipc/MessageQueueSenderIF.h" -TmSendHelper::TmSendHelper(MessageQueueId_t tmtcMsgDest, MessageQueueId_t tmtcMsgSrc, +TmSendHelper::TmSendHelper(MessageQueueIF* queue, MessageQueueId_t tmtcMsgDest, InternalErrorReporterIF *reporter) - : tmtcMsgDest(tmtcMsgDest), tmtcMsgSrc(tmtcMsgSrc), errReporter(reporter) {} + : tmtcMsgDest(tmtcMsgDest), queue(queue), errReporter(reporter) {} + +TmSendHelper::TmSendHelper(MessageQueueIF *queue, InternalErrorReporterIF *reporter) + : queue(queue), errReporter(reporter) {} TmSendHelper::TmSendHelper(InternalErrorReporterIF *reporter) : errReporter(reporter) {} ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) { + if(queue == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } TmTcMessage message(storeId); - ReturnValue_t result = MessageQueueSenderIF::sendMessage(tmtcMsgDest, &message, tmtcMsgSrc); + ReturnValue_t result = queue->sendMessage(tmtcMsgDest, &message, ignoreFault); if (result != HasReturnvaluesIF::RETURN_OK) { if (errReporter != nullptr) { errReporter->lostTm(); @@ -22,8 +28,7 @@ ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) { void TmSendHelper::setMsgDestination(MessageQueueId_t msgDest) { tmtcMsgDest = msgDest; } -void TmSendHelper::setMsgSource(MessageQueueId_t msgSrc) { tmtcMsgSrc = msgSrc; } - void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF *reporter) { errReporter = reporter; } +void TmSendHelper::setMsgQueue(MessageQueueIF *queue_) { queue = queue_; } diff --git a/src/fsfw/tmtcservices/TmSendHelper.h b/src/fsfw/tmtcservices/TmSendHelper.h index f7acb237..bca0d4a2 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.h +++ b/src/fsfw/tmtcservices/TmSendHelper.h @@ -10,16 +10,18 @@ class TmSendHelper { public: explicit TmSendHelper(InternalErrorReporterIF* reporter); - TmSendHelper(MessageQueueId_t tmtcMsgDest, MessageQueueId_t tmtcMsgSrc, + TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter); + TmSendHelper(MessageQueueIF* queue, MessageQueueId_t tmtcMsgDest, InternalErrorReporterIF* reporter); + void setMsgQueue(MessageQueueIF* queue); void setMsgDestination(MessageQueueId_t msgDest); - void setMsgSource(MessageQueueId_t msgSrc); void setInternalErrorReporter(InternalErrorReporterIF* reporter); ReturnValue_t sendPacket(const store_address_t& storeId); private: MessageQueueId_t tmtcMsgDest = MessageQueueIF::NO_QUEUE; - MessageQueueId_t tmtcMsgSrc = MessageQueueIF::NO_QUEUE; + bool ignoreFault = false; + MessageQueueIF* queue = nullptr; InternalErrorReporterIF* errReporter; }; diff --git a/unittests/internalerror/TestInternalErrorReporter.cpp b/unittests/internalerror/TestInternalErrorReporter.cpp index 2b999fae..7349400e 100644 --- a/unittests/internalerror/TestInternalErrorReporter.cpp +++ b/unittests/internalerror/TestInternalErrorReporter.cpp @@ -33,7 +33,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { MessageQueueIF* hkQueue = QueueFactory::instance()->createMessageQueue(1); internalErrorReporter->getSubscriptionInterface()->subscribeForSetUpdateMessage( InternalErrorDataset::ERROR_SET_ID, objects::NO_OBJECT, hkQueue->getId(), true); - StorageManagerIF* ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); + auto* ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); SECTION("MessageQueueFull") { CommandMessage message; ActionMessage::setCompletionReply(&message, 10, true); @@ -57,7 +57,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { REQUIRE(gpid.objectId == objects::INTERNAL_ERROR_REPORTER); // We need the object ID of the reporter here (NO_OBJECT) InternalErrorDataset dataset(objects::INTERNAL_ERROR_REPORTER); - CCSDSTime::CDS_short time; + CCSDSTime::CDS_short time{}; ConstAccessorPair data = ipcStore->getData(storeAddress); REQUIRE(data.first == HasReturnvaluesIF::RETURN_OK); HousekeepingSnapshot hkSnapshot(&time, &dataset); @@ -87,7 +87,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { ConstAccessorPair data = ipcStore->getData(storeAddress); REQUIRE(data.first == HasReturnvaluesIF::RETURN_OK); - CCSDSTime::CDS_short time; + CCSDSTime::CDS_short time{}; // We need the object ID of the reporter here (NO_OBJECT) InternalErrorDataset dataset(objects::INTERNAL_ERROR_REPORTER); HousekeepingSnapshot hkSnapshot(&time, &dataset); @@ -107,10 +107,10 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { // Message Queue Id MessageQueueId_t id = internalErrorReporter->getCommandQueue(); REQUIRE(id != MessageQueueIF::NO_QUEUE); - CommandMessage message; + CommandMessage message2; sid_t sid(objects::INTERNAL_ERROR_REPORTER, InternalErrorDataset::ERROR_SET_ID); - HousekeepingMessage::setToggleReportingCommand(&message, sid, true, false); - result = hkQueue->sendMessage(id, &message); + HousekeepingMessage::setToggleReportingCommand(&message2, sid, true, false); + result = hkQueue->sendMessage(id, &message2); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); internalErrorReporter->performOperation(0); } diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 50a34ce8..90448798 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -4,4 +4,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE DeviceFdirMock.cpp CookieIFMock.cpp ComIFMock.cpp + MessageQueueMockBase.cpp ) diff --git a/unittests/mocks/InternalErrorReporterMock.h b/unittests/mocks/InternalErrorReporterMock.h new file mode 100644 index 00000000..ccc158d0 --- /dev/null +++ b/unittests/mocks/InternalErrorReporterMock.h @@ -0,0 +1,11 @@ +#ifndef FSFW_TESTS_INTERNALERRORREPORTERMOCK_H +#define FSFW_TESTS_INTERNALERRORREPORTERMOCK_H + +#include "fsfw/internalerror/InternalErrorReporterIF.h" + +class InternalErrorReporterMock: public InternalErrorReporterIF { + public: + InternalErrorReporterMock(); + private: +}; +#endif // FSFW_TESTS_INTERNALERRORREPORTERMOCK_H diff --git a/unittests/mocks/MessageQueueMockBase.cpp b/unittests/mocks/MessageQueueMockBase.cpp new file mode 100644 index 00000000..8c577851 --- /dev/null +++ b/unittests/mocks/MessageQueueMockBase.cpp @@ -0,0 +1,67 @@ +#include "MessageQueueMockBase.h" + + +MessageQueueMockBase::MessageQueueMockBase() + : MessageQueueBase(MessageQueueIF::NO_QUEUE, MessageQueueIF::NO_QUEUE, nullptr) {} + +MessageQueueMockBase::MessageQueueMockBase(MessageQueueId_t queueId) + : MessageQueueBase(queueId, MessageQueueIF::NO_QUEUE, nullptr) {} + +bool MessageQueueMockBase::wasMessageSent(uint8_t* messageSentCounter_, bool resetCounter) { + bool tempMessageSent = messageSent; + messageSent = false; + if (messageSentCounter_ != nullptr) { + *messageSentCounter_ = this->messageSentCounter; + } + if (resetCounter) { + this->messageSentCounter = 0; + } + return tempMessageSent; +} + +ReturnValue_t MessageQueueMockBase::popMessage() { + CommandMessage message; + message.clear(); + return receiveMessage(&message); +} + +ReturnValue_t MessageQueueMockBase::receiveMessage(MessageQueueMessageIF* message) { + if (messagesSentQueue.empty()) { + return MessageQueueIF::EMPTY; + } + this->last = message->getSender(); + std::memcpy(message->getBuffer(), messagesSentQueue.front().getBuffer(), + message->getMessageSize()); + messagesSentQueue.pop(); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t MessageQueueMockBase::flush(uint32_t* count) { + return HasReturnvaluesIF::RETURN_FAILED; +} + +ReturnValue_t MessageQueueMockBase::sendMessageFrom(MessageQueueId_t sendTo, + MessageQueueMessageIF* message, + MessageQueueId_t sentFrom, bool ignoreFault) { + messageSent = true; + messageSentCounter++; + MessageQueueMessage& messageRef = *(dynamic_cast(message)); + messagesSentQueue.push(messageRef); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t MessageQueueMockBase::reply(MessageQueueMessageIF* message) { + return sendMessageFrom(MessageQueueIF::NO_QUEUE, message, this->getId(), false); +} + +void MessageQueueMockBase::clearMessages(bool clearCommandMessages) { + while (not messagesSentQueue.empty()) { + if (clearCommandMessages) { + CommandMessage message; + std::memcpy(message.getBuffer(), messagesSentQueue.front().getBuffer(), + message.getMessageSize()); + message.clear(); + } + messagesSentQueue.pop(); + } +} diff --git a/unittests/mocks/MessageQueueMockBase.h b/unittests/mocks/MessageQueueMockBase.h index 92729a7a..4a4b7ce7 100644 --- a/unittests/mocks/MessageQueueMockBase.h +++ b/unittests/mocks/MessageQueueMockBase.h @@ -12,71 +12,30 @@ class MessageQueueMockBase : public MessageQueueBase { public: - MessageQueueMockBase() - : MessageQueueBase(MessageQueueIF::NO_QUEUE, MessageQueueIF::NO_QUEUE, nullptr) {} + MessageQueueMockBase(); + + explicit MessageQueueMockBase(MessageQueueId_t queueId); uint8_t messageSentCounter = 0; bool messageSent = false; - bool wasMessageSent(uint8_t* messageSentCounter_ = nullptr, bool resetCounter = true) { - bool tempMessageSent = messageSent; - messageSent = false; - if (messageSentCounter_ != nullptr) { - *messageSentCounter_ = this->messageSentCounter; - } - if (resetCounter) { - this->messageSentCounter = 0; - } - return tempMessageSent; - } + bool wasMessageSent(uint8_t* messageSentCounter_ = nullptr, bool resetCounter = true); /** * Pop a message, clearing it in the process. * @return */ - ReturnValue_t popMessage() { - CommandMessage message; - message.clear(); - return receiveMessage(&message); - } + ReturnValue_t popMessage(); - ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override { - if (messagesSentQueue.empty()) { - return MessageQueueIF::EMPTY; - } - this->last = message->getSender(); - std::memcpy(message->getBuffer(), messagesSentQueue.front().getBuffer(), - message->getMessageSize()); - messagesSentQueue.pop(); - return HasReturnvaluesIF::RETURN_OK; - } - ReturnValue_t flush(uint32_t* count) override { return HasReturnvaluesIF::RETURN_OK; } + ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override; + + ReturnValue_t flush(uint32_t* count) override; ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, MessageQueueId_t sentFrom, - bool ignoreFault = false) override { - messageSent = true; - messageSentCounter++; - MessageQueueMessage& messageRef = *(dynamic_cast(message)); - messagesSentQueue.push(messageRef); - return HasReturnvaluesIF::RETURN_OK; - } - - ReturnValue_t reply(MessageQueueMessageIF* message) override { - return sendMessageFrom(MessageQueueIF::NO_QUEUE, message, this->getId(), false); - } - - void clearMessages(bool clearCommandMessages = true) { - while (not messagesSentQueue.empty()) { - if (clearCommandMessages) { - CommandMessage message; - std::memcpy(message.getBuffer(), messagesSentQueue.front().getBuffer(), - message.getMessageSize()); - message.clear(); - } - messagesSentQueue.pop(); - } - } + bool ignoreFault = false) override; + ReturnValue_t reply(MessageQueueMessageIF* message) override; + void clearMessages(bool clearCommandMessages = true); private: std::queue messagesSentQueue; }; diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 66c7ab59..84ef0162 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -1,5 +1,7 @@ #include -TEST_CASE("TM Send Helper", "[tm-send-helper]") { +#include "fsfw/tmtcservices/TmSendHelper.h" +TEST_CASE("TM Send Helper", "[tm-send-helper]") { + TmSendHelper sendHelper(nullptr); } \ No newline at end of file From 9ee6da47e9218bf7aad3a475bed32a490232c84e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 14:31:57 +0200 Subject: [PATCH 099/532] improving mocks --- src/fsfw/tmtcservices/TmSendHelper.cpp | 8 ++++++-- src/fsfw/tmtcservices/TmSendHelper.h | 8 +++++--- unittests/mocks/CMakeLists.txt | 1 + unittests/mocks/InternalErrorReporterMock.cpp | 13 +++++++++++++ unittests/mocks/InternalErrorReporterMock.h | 7 +++++++ unittests/mocks/MessageQueueMockBase.cpp | 17 +++++++++++++---- unittests/mocks/MessageQueueMockBase.h | 13 ++++++++++--- unittests/tmtcservices/testSendHelper.cpp | 10 +++++++++- 8 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 unittests/mocks/InternalErrorReporterMock.cpp diff --git a/src/fsfw/tmtcservices/TmSendHelper.cpp b/src/fsfw/tmtcservices/TmSendHelper.cpp index f8c76b75..2f57433d 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmSendHelper.cpp @@ -2,8 +2,7 @@ #include "fsfw/ipc/MessageQueueSenderIF.h" -TmSendHelper::TmSendHelper(MessageQueueIF* queue, MessageQueueId_t tmtcMsgDest, - InternalErrorReporterIF *reporter) +TmSendHelper::TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF *reporter, MessageQueueId_t tmtcMsgDest) : tmtcMsgDest(tmtcMsgDest), queue(queue), errReporter(reporter) {} TmSendHelper::TmSendHelper(MessageQueueIF *queue, InternalErrorReporterIF *reporter) @@ -32,3 +31,8 @@ void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF *reporter) { errReporter = reporter; } void TmSendHelper::setMsgQueue(MessageQueueIF *queue_) { queue = queue_; } + +ReturnValue_t TmSendHelper::sendPacket(MessageQueueId_t dest, const store_address_t &storeId) { + setMsgDestination(dest); + return sendPacket(storeId); +} diff --git a/src/fsfw/tmtcservices/TmSendHelper.h b/src/fsfw/tmtcservices/TmSendHelper.h index bca0d4a2..7e11daad 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.h +++ b/src/fsfw/tmtcservices/TmSendHelper.h @@ -9,13 +9,15 @@ class TmSendHelper { public: - explicit TmSendHelper(InternalErrorReporterIF* reporter); + TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter, MessageQueueId_t tmtcMsgDest); TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter); - TmSendHelper(MessageQueueIF* queue, MessageQueueId_t tmtcMsgDest, - InternalErrorReporterIF* reporter); + explicit TmSendHelper(InternalErrorReporterIF* reporter); + + void setMsgQueue(MessageQueueIF* queue); void setMsgDestination(MessageQueueId_t msgDest); void setInternalErrorReporter(InternalErrorReporterIF* reporter); + ReturnValue_t sendPacket(MessageQueueId_t dest, const store_address_t& storeId); ReturnValue_t sendPacket(const store_address_t& storeId); private: diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 90448798..04024559 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -5,4 +5,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE CookieIFMock.cpp ComIFMock.cpp MessageQueueMockBase.cpp + InternalErrorReporterMock.cpp ) diff --git a/unittests/mocks/InternalErrorReporterMock.cpp b/unittests/mocks/InternalErrorReporterMock.cpp new file mode 100644 index 00000000..9988234b --- /dev/null +++ b/unittests/mocks/InternalErrorReporterMock.cpp @@ -0,0 +1,13 @@ +#include "InternalErrorReporterMock.h" + +InternalErrorReporterMock::InternalErrorReporterMock() = default; + +void InternalErrorReporterMock::queueMessageNotSent() { + queueMsgNotSentCallCnt++; +} +void InternalErrorReporterMock::lostTm() { + lostTmCallCnt++; +} +void InternalErrorReporterMock::storeFull() { + storeFullCallCnt++; +} diff --git a/unittests/mocks/InternalErrorReporterMock.h b/unittests/mocks/InternalErrorReporterMock.h index ccc158d0..d2921630 100644 --- a/unittests/mocks/InternalErrorReporterMock.h +++ b/unittests/mocks/InternalErrorReporterMock.h @@ -5,7 +5,14 @@ class InternalErrorReporterMock: public InternalErrorReporterIF { public: + unsigned int queueMsgNotSentCallCnt = 0; + unsigned int lostTmCallCnt = 0; + unsigned int storeFullCallCnt = 0; InternalErrorReporterMock(); + void queueMessageNotSent() override; + void lostTm() override; + void storeFull() override; + private: }; #endif // FSFW_TESTS_INTERNALERRORREPORTERMOCK_H diff --git a/unittests/mocks/MessageQueueMockBase.cpp b/unittests/mocks/MessageQueueMockBase.cpp index 8c577851..63caee26 100644 --- a/unittests/mocks/MessageQueueMockBase.cpp +++ b/unittests/mocks/MessageQueueMockBase.cpp @@ -43,10 +43,13 @@ ReturnValue_t MessageQueueMockBase::flush(uint32_t* count) { ReturnValue_t MessageQueueMockBase::sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, MessageQueueId_t sentFrom, bool ignoreFault) { - messageSent = true; - messageSentCounter++; - MessageQueueMessage& messageRef = *(dynamic_cast(message)); - messagesSentQueue.push(messageRef); + auto iter = sendMap.find(sendTo); + if (iter == sendMap.end()) { + sendMap.emplace(sendTo, SendInfo(message, 1)); + } else { + iter->second.callCount += 1; + iter->second.msgs.push(message); + } return HasReturnvaluesIF::RETURN_OK; } @@ -55,6 +58,12 @@ ReturnValue_t MessageQueueMockBase::reply(MessageQueueMessageIF* message) { } void MessageQueueMockBase::clearMessages(bool clearCommandMessages) { + for (const auto& destInfo: sendMap) { + if (clearCommandMessages) { + CommandMessage message; + std::memcpy(message.getBuffer(), destInfo.second.msgs.front()->getBuffer(), + message.getMessageSize()); + } while (not messagesSentQueue.empty()) { if (clearCommandMessages) { CommandMessage message; diff --git a/unittests/mocks/MessageQueueMockBase.h b/unittests/mocks/MessageQueueMockBase.h index 4a4b7ce7..e42a0a67 100644 --- a/unittests/mocks/MessageQueueMockBase.h +++ b/unittests/mocks/MessageQueueMockBase.h @@ -3,6 +3,7 @@ #include #include +#include #include "CatchDefinitions.h" #include "fsfw/ipc/CommandMessage.h" @@ -10,14 +11,21 @@ #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/MessageQueueMessage.h" +struct SendInfo { + explicit SendInfo(MessageQueueMessageIF* initMsg, unsigned int initCallCnt = 1): callCount(initCallCnt) { + msgs.push(initMsg); + } + unsigned int callCount = 0; + std::queue msgs; +}; + class MessageQueueMockBase : public MessageQueueBase { public: MessageQueueMockBase(); explicit MessageQueueMockBase(MessageQueueId_t queueId); - uint8_t messageSentCounter = 0; - bool messageSent = false; + std::map sendMap; bool wasMessageSent(uint8_t* messageSentCounter_ = nullptr, bool resetCounter = true); @@ -37,7 +45,6 @@ class MessageQueueMockBase : public MessageQueueBase { void clearMessages(bool clearCommandMessages = true); private: - std::queue messagesSentQueue; }; #endif /* FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_ */ diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 84ef0162..6e6fb069 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -1,7 +1,15 @@ #include #include "fsfw/tmtcservices/TmSendHelper.h" +#include "mocks/InternalErrorReporterMock.h" +#include "mocks/MessageQueueMockBase.h" TEST_CASE("TM Send Helper", "[tm-send-helper]") { - TmSendHelper sendHelper(nullptr); + auto errReporter = InternalErrorReporterMock(); + auto msgQueue = MessageQueueMockBase(); + TmSendHelper sendHelper(&msgQueue, &errReporter); + + SECTION("State") { + + } } \ No newline at end of file From e030878023080a487fc8a14853ac51486316fe71 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 14:33:10 +0200 Subject: [PATCH 100/532] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b814840..1cfcc568 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] -# [v5.0.0] 18.07.2022 +# [v5.0.0] 25.07.2022 ## Changes From 54fc35eae7e4778cff19eb8ab358e26ae53dd393 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 14:36:18 +0200 Subject: [PATCH 101/532] re-run afmt --- src/fsfw/container/SimpleRingBuffer.cpp | 14 +++++++------- unittests/container/RingBufferTest.cpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/fsfw/container/SimpleRingBuffer.cpp b/src/fsfw/container/SimpleRingBuffer.cpp index 437e72ea..c104ea97 100644 --- a/src/fsfw/container/SimpleRingBuffer.cpp +++ b/src/fsfw/container/SimpleRingBuffer.cpp @@ -1,10 +1,10 @@ #include "fsfw/container/SimpleRingBuffer.h" -#include "fsfw/FSFW.h" - -#include "fsfw/serviceinterface.h" #include +#include "fsfw/FSFW.h" +#include "fsfw/serviceinterface.h" + SimpleRingBuffer::SimpleRingBuffer(const size_t size, bool overwriteOld, size_t maxExcessBytes) : RingBufferBase<>(0, size, overwriteOld), maxExcessBytes(maxExcessBytes) { if (maxExcessBytes > size) { @@ -51,15 +51,15 @@ void SimpleRingBuffer::confirmBytesWritten(size_t amount) { } ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) { - if(data == nullptr) { + if (data == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } - if(amount > getMaxSize()) { + if (amount > getMaxSize()) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SimpleRingBuffer::writeData: Amount of data too large" << std::endl; + sif::error << "SimpleRingBuffer::writeData: Amount of data too large" << std::endl; #else - sif::printError("SimpleRingBuffer::writeData: Amount of data too large\n"); + sif::printError("SimpleRingBuffer::writeData: Amount of data too large\n"); #endif #endif return HasReturnvaluesIF::RETURN_FAILED; diff --git a/unittests/container/RingBufferTest.cpp b/unittests/container/RingBufferTest.cpp index 9ae58388..f4f111a6 100644 --- a/unittests/container/RingBufferTest.cpp +++ b/unittests/container/RingBufferTest.cpp @@ -237,12 +237,12 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { SECTION("Overflow") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - // Writing more than the buffer is large. + // Writing more than the buffer is large. // This write will be rejected and is seen as a configuration mistake REQUIRE(ringBuffer.writeData(testData, 13) == retval::CATCH_FAILED); REQUIRE(ringBuffer.getAvailableReadData() == 0); ringBuffer.clear(); - // Using FreeElement allows the usage of excessBytes but + // Using FreeElement allows the usage of excessBytes but // should be used with caution uint8_t *ptr = nullptr; REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == retval::CATCH_OK); From 380f1d02069debf2267f25cd432a49bea40ad1ae Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 14:40:10 +0200 Subject: [PATCH 102/532] remove obsolete returns --- src/fsfw/serialize/EndianConverter.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/fsfw/serialize/EndianConverter.h b/src/fsfw/serialize/EndianConverter.h index 9d6c73a3..dc8944ca 100644 --- a/src/fsfw/serialize/EndianConverter.h +++ b/src/fsfw/serialize/EndianConverter.h @@ -75,7 +75,6 @@ class EndianConverter { } #elif BYTE_ORDER_SYSTEM == BIG_ENDIAN memcpy(out, in, size); - return; #endif } @@ -112,7 +111,6 @@ class EndianConverter { for (size_t count = 0; count < size; count++) { out[size - count - 1] = in[count]; } - return; #elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN memcpy(out, in, size); #endif From f3af88ae40e3dbaddac256cfcf13d0b4e9774c45 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 14:44:19 +0200 Subject: [PATCH 103/532] add [[nodiscard]] and const specifiers --- src/fsfw/serialize/SerializeIF.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 921d8a5e..7ef8c925 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -59,18 +59,18 @@ class SerializeIF { * - @c RETURN_FAILED Generic error * - @c RETURN_OK Successful serialization */ - virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const = 0; /** * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t serializeBe(uint8_t** buffer, size_t* size, size_t maxSize) { + [[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t** buffer, size_t* size, size_t maxSize) const { return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) { + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const { return serialize(buffer, size, maxSize, SerializeIF::Endianness::MACHINE); } @@ -123,7 +123,7 @@ class SerializeIF { * @param streamEndianness * @return */ - virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize, + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize, Endianness streamEndianness) const { size_t tmpSize = 0; return serialize(&buffer, &tmpSize, maxSize, streamEndianness); @@ -131,13 +131,13 @@ class SerializeIF { /** * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t serializeBe(uint8_t *buffer, size_t maxSize) const { + [[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t *buffer, size_t maxSize) const { return serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize) const { + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize) const { return serialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); } From f80be9e9fac34bfb2c3fb25647e6b11289b0934c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 14:44:49 +0200 Subject: [PATCH 104/532] run afmt --- src/fsfw/container/SimpleRingBuffer.cpp | 14 +++++++------- src/fsfw/serialize/SerializeIF.h | 14 ++++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/fsfw/container/SimpleRingBuffer.cpp b/src/fsfw/container/SimpleRingBuffer.cpp index 437e72ea..c104ea97 100644 --- a/src/fsfw/container/SimpleRingBuffer.cpp +++ b/src/fsfw/container/SimpleRingBuffer.cpp @@ -1,10 +1,10 @@ #include "fsfw/container/SimpleRingBuffer.h" -#include "fsfw/FSFW.h" - -#include "fsfw/serviceinterface.h" #include +#include "fsfw/FSFW.h" +#include "fsfw/serviceinterface.h" + SimpleRingBuffer::SimpleRingBuffer(const size_t size, bool overwriteOld, size_t maxExcessBytes) : RingBufferBase<>(0, size, overwriteOld), maxExcessBytes(maxExcessBytes) { if (maxExcessBytes > size) { @@ -51,15 +51,15 @@ void SimpleRingBuffer::confirmBytesWritten(size_t amount) { } ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) { - if(data == nullptr) { + if (data == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } - if(amount > getMaxSize()) { + if (amount > getMaxSize()) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SimpleRingBuffer::writeData: Amount of data too large" << std::endl; + sif::error << "SimpleRingBuffer::writeData: Amount of data too large" << std::endl; #else - sif::printError("SimpleRingBuffer::writeData: Amount of data too large\n"); + sif::printError("SimpleRingBuffer::writeData: Amount of data too large\n"); #endif #endif return HasReturnvaluesIF::RETURN_FAILED; diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 7ef8c925..47212ab1 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -60,17 +60,19 @@ class SerializeIF { * - @c RETURN_OK Successful serialization */ [[nodiscard]] virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const = 0; + Endianness streamEndianness) const = 0; /** * Forwards to regular @serialize call with big (network) endianness */ - [[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t** buffer, size_t* size, size_t maxSize) const { + [[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t **buffer, size_t *size, + size_t maxSize) const { return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - [[nodiscard]] virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const { + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, + size_t maxSize) const { return serialize(buffer, size, maxSize, SerializeIF::Endianness::MACHINE); } @@ -105,13 +107,13 @@ class SerializeIF { /** * Forwards to regular @deSerialize call with big (network) endianness */ - virtual ReturnValue_t deSerializeBe(const uint8_t** buffer, size_t* size) { + virtual ReturnValue_t deSerializeBe(const uint8_t **buffer, size_t *size) { return deSerialize(buffer, size, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size) { + virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size) { return deSerialize(buffer, size, SerializeIF::Endianness::MACHINE); } @@ -124,7 +126,7 @@ class SerializeIF { * @return */ [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize, - Endianness streamEndianness) const { + Endianness streamEndianness) const { size_t tmpSize = 0; return serialize(&buffer, &tmpSize, maxSize, streamEndianness); } From 6d0fa36f8acf75bcc93e16bf275f270b5ec5fb76 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 19:36:56 +0200 Subject: [PATCH 105/532] cleaning up message queue mock and subscription API --- src/fsfw/datapoollocal/HasLocalDataPoolIF.h | 3 +- .../datapoollocal/LocalDataPoolManager.cpp | 77 ++-- src/fsfw/datapoollocal/LocalDataPoolManager.h | 45 +- .../ProvidesDataPoolSubscriptionIF.h | 69 ++- src/fsfw/housekeeping/AcceptsHkPacketsIF.h | 6 +- .../internalerror/InternalErrorReporter.cpp | 5 +- src/fsfw/ipc/MessageQueueBase.h | 8 +- src/fsfw/ipc/MessageQueueMessage.cpp | 36 +- src/fsfw/ipc/MessageQueueMessage.h | 113 ++--- src/fsfw/ipc/MessageQueueMessageIF.h | 32 +- src/fsfw/osal/linux/Clock.cpp | 2 +- src/fsfw/serialize/SerializeIF.h | 4 +- src/fsfw/timemanager/CCSDSTime.h | 2 +- src/fsfw/timemanager/TimeMessage.h | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 2 +- src/fsfw/tmtcservices/TmSendHelper.cpp | 7 +- src/fsfw/tmtcservices/TmSendHelper.h | 4 +- src/fsfw/tmtcservices/TmStoreHelper.cpp | 7 +- src/fsfw/tmtcservices/TmStoreHelper.h | 1 - unittests/CatchFactory.cpp | 9 +- unittests/action/TestActionHelper.cpp | 12 +- unittests/datapoollocal/CMakeLists.txt | 8 +- .../datapoollocal/LocalPoolManagerTest.cpp | 413 ----------------- .../{DataSetTest.cpp => testDataSet.cpp} | 25 +- .../datapoollocal/testLocalPoolManager.cpp | 430 ++++++++++++++++++ ...ableTest.cpp => testLocalPoolVariable.cpp} | 0 ...VectorTest.cpp => testLocalPoolVector.cpp} | 4 +- unittests/mocks/CdsShortTimestamperMock.h | 4 +- unittests/mocks/HkReceiverMock.h | 10 +- unittests/mocks/InternalErrorReporterMock.cpp | 12 +- unittests/mocks/InternalErrorReporterMock.h | 2 +- .../LocalPoolOwnerBase.cpp | 17 +- .../LocalPoolOwnerBase.h | 64 ++- unittests/mocks/MessageQueueMockBase.cpp | 151 ++++-- unittests/mocks/MessageQueueMockBase.h | 41 +- unittests/serialize/testSerializeIF.cpp | 6 +- unittests/testcfg/objects/systemObjectList.h | 2 +- unittests/tmtcservices/testSendHelper.cpp | 4 +- 39 files changed, 916 insertions(+), 725 deletions(-) delete mode 100644 unittests/datapoollocal/LocalPoolManagerTest.cpp rename unittests/datapoollocal/{DataSetTest.cpp => testDataSet.cpp} (93%) create mode 100644 unittests/datapoollocal/testLocalPoolManager.cpp rename unittests/datapoollocal/{LocalPoolVariableTest.cpp => testLocalPoolVariable.cpp} (100%) rename unittests/datapoollocal/{LocalPoolVectorTest.cpp => testLocalPoolVector.cpp} (98%) rename unittests/{datapoollocal => mocks}/LocalPoolOwnerBase.cpp (90%) rename unittests/{datapoollocal => mocks}/LocalPoolOwnerBase.h (68%) diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h index acbe1697..b7a6198e 100644 --- a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h +++ b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h @@ -79,8 +79,7 @@ class HasLocalDataPoolIF { * @param clearMessage If this is set to true, the pool manager will take care of * clearing the store automatically */ - virtual void handleChangedDataset(sid_t sid, - store_address_t storeId = store_address_t::invalid(), + virtual void handleChangedDataset(sid_t sid, store_address_t storeId = store_address_t::invalid(), bool* clearMessage = nullptr) { if (clearMessage != nullptr) { *clearMessage = true; diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 9b7f800f..2ab737bf 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -1,6 +1,5 @@ #include "fsfw/datapoollocal/LocalDataPoolManager.h" -#include #include #include "fsfw/datapoollocal.h" @@ -15,6 +14,7 @@ #include "internal/HasLocalDpIFManagerAttorney.h" #include "internal/LocalPoolDataSetAttorney.h" +// TODO: Get rid of this. This should be a constructor argument, not something hardcoded in any way object_id_t LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse, @@ -57,7 +57,7 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { } if (defaultHkDestination != objects::NO_OBJECT) { - AcceptsHkPacketsIF* hkPacketReceiver = + auto* hkPacketReceiver = ObjectManager::instance()->get(defaultHkDestination); if (hkPacketReceiver != nullptr) { hkDestinationId = hkPacketReceiver->getHkQueue(); @@ -335,29 +335,32 @@ void LocalDataPoolManager::resetHkUpdateResetHelper() { } } -ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool enableReporting, - float collectionInterval, - bool isDiagnostics, - object_id_t packetDestination) { - AcceptsHkPacketsIF* hkReceiverObject = - ObjectManager::instance()->get(packetDestination); - if (hkReceiverObject == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "subscribeForPeriodicPacket", - QUEUE_OR_DESTINATION_INVALID); - return QUEUE_OR_DESTINATION_INVALID; - } +ReturnValue_t LocalDataPoolManager::subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams params) { + return subscribeForPeriodicPacket(params); +} +ReturnValue_t LocalDataPoolManager::subscribeForDiagPeriodicPacket( + subdp::DiagnosticsHkPeriodicParams params) { + return subscribeForPeriodicPacket(params); +} + +ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(subdp::ParamsBase& params) { struct HkReceiver hkReceiver; - hkReceiver.dataId.sid = sid; + hkReceiver.dataId.sid = params.sid; hkReceiver.reportingType = ReportingType::PERIODIC; hkReceiver.dataType = DataType::DATA_SET; - hkReceiver.destinationQueue = hkReceiverObject->getHkQueue(); + if (params.receiver == MessageQueueIF::NO_QUEUE) { + hkReceiver.destinationQueue = hkDestinationId; + } else { + hkReceiver.destinationQueue = params.receiver; + } - LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); + LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid); if (dataSet != nullptr) { - LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enableReporting); - LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics); - LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, collectionInterval, + LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, params.enableReporting); + LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics()); + LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, params.collectionInterval, owner->getPeriodicOperationFrequency()); } @@ -365,27 +368,30 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool e return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid, bool isDiagnostics, - bool reportingEnabled, - object_id_t packetDestination) { - AcceptsHkPacketsIF* hkReceiverObject = - ObjectManager::instance()->get(packetDestination); - if (hkReceiverObject == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "subscribeForPeriodicPacket", - QUEUE_OR_DESTINATION_INVALID); - return QUEUE_OR_DESTINATION_INVALID; - } +ReturnValue_t LocalDataPoolManager::subscribeForRegularUpdatePacket( + subdp::RegularHkUpdateParams params) { + return subscribeForUpdatePacket(params); +} +ReturnValue_t LocalDataPoolManager::subscribeForDiagUpdatePacket( + subdp::DiagnosticsHkUpdateParams params) { + return subscribeForUpdatePacket(params); +} +ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(subdp::ParamsBase& params) { struct HkReceiver hkReceiver; - hkReceiver.dataId.sid = sid; + hkReceiver.dataId.sid = params.sid; hkReceiver.reportingType = ReportingType::UPDATE_HK; hkReceiver.dataType = DataType::DATA_SET; - hkReceiver.destinationQueue = hkReceiverObject->getHkQueue(); + if (params.receiver == MessageQueueIF::NO_QUEUE) { + hkReceiver.destinationQueue = hkDestinationId; + } else { + hkReceiver.destinationQueue = params.receiver; + } - LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); + LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid); if (dataSet != nullptr) { LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true); - LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics); + LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics()); } hkReceivers.push_back(hkReceiver); @@ -639,6 +645,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, /* Error, all destinations invalid */ printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateHousekeepingPacket", QUEUE_OR_DESTINATION_INVALID); + return QUEUE_OR_DESTINATION_INVALID; } destination = hkDestinationId; } @@ -879,3 +886,7 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, } LocalDataPoolManager* LocalDataPoolManager::getPoolManagerHandle() { return this; } + +void LocalDataPoolManager::setHkDestinationId(MessageQueueId_t hkDestId) { + hkDestinationId = hkDestId; +} diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/datapoollocal/LocalDataPoolManager.h index e7ec0b6f..041a4b05 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.h @@ -8,6 +8,7 @@ #include "ProvidesDataPoolSubscriptionIF.h" #include "fsfw/datapool/DataSetIF.h" #include "fsfw/datapool/PoolEntry.h" +#include "fsfw/housekeeping/AcceptsHkPacketsIF.h" #include "fsfw/housekeeping/HousekeepingMessage.h" #include "fsfw/housekeeping/HousekeepingPacketDownlink.h" #include "fsfw/housekeeping/PeriodicHousekeepingHelper.h" @@ -80,7 +81,9 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces */ LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse, bool appendValidityBuffer = true); - virtual ~LocalDataPoolManager(); + ~LocalDataPoolManager() override; + + void setHkDestinationId(MessageQueueId_t hkDestId); /** * Assigns the queue to use. Make sure to call this in the #initialize @@ -112,31 +115,6 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces */ virtual ReturnValue_t performHkOperation(); - /** - * @brief Subscribe for the generation of periodic packets. - * @details - * This subscription mechanism will generally be used by the data creator - * to generate housekeeping packets which are downlinked directly. - * @return - */ - ReturnValue_t subscribeForPeriodicPacket( - sid_t sid, bool enableReporting, float collectionInterval, bool isDiagnostics, - object_id_t packetDestination = defaultHkDestination) override; - - /** - * @brief Subscribe for the generation of packets if the dataset - * is marked as changed. - * @details - * This subscription mechanism will generally be used by the data creator. - * @param sid - * @param isDiagnostics - * @param packetDestination - * @return - */ - ReturnValue_t subscribeForUpdatePacket( - sid_t sid, bool reportingEnabled, bool isDiagnostics, - object_id_t packetDestination = defaultHkDestination) override; - /** * @brief Subscribe for a notification message which will be sent * if a dataset has changed. @@ -151,7 +129,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces * Otherwise, only an notification message is sent. * @return */ - ReturnValue_t subscribeForSetUpdateMessage(const uint32_t setId, object_id_t destinationObject, + ReturnValue_t subscribeForSetUpdateMessage(uint32_t setId, object_id_t destinationObject, MessageQueueId_t targetQueueId, bool generateSnapshot) override; @@ -169,7 +147,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces * Otherwise, only an notification message is sent. * @return */ - ReturnValue_t subscribeForVariableUpdateMessage(const lp_id_t localPoolId, + ReturnValue_t subscribeForVariableUpdateMessage(lp_id_t localPoolId, object_id_t destinationObject, MessageQueueId_t targetQueueId, bool generateSnapshot) override; @@ -252,7 +230,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces */ void clearReceiversList(); - object_id_t getCreatorObjectId() const; + [[nodiscard]] object_id_t getCreatorObjectId() const; /** * Get the pointer to the mutex. Can be used to lock the data pool @@ -262,7 +240,14 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces */ MutexIF* getMutexHandle(); - virtual LocalDataPoolManager* getPoolManagerHandle() override; + 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: /** Core data structure for the actual pool data */ diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index 1f13a09d..4fa86ef0 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -1,14 +1,56 @@ #ifndef FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_ #define FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_ -#include "../ipc/messageQueueDefinitions.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "fsfw/housekeeping/AcceptsHkPacketsIF.h" +#include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/ipc/messageQueueDefinitions.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "localPoolDefinitions.h" +namespace subdp { + +struct ParamsBase { + ParamsBase(sid_t sid, bool enableReporting, float collectionInterval, bool diagnostics) + : sid(sid), + enableReporting(enableReporting), + collectionInterval(collectionInterval), + diagnostics(diagnostics) {} + + [[nodiscard]] bool isDiagnostics() const { return diagnostics; } + + sid_t sid; + bool enableReporting; + float collectionInterval; + MessageQueueId_t receiver = MessageQueueIF::NO_QUEUE; + + protected: + bool diagnostics; +}; + +struct RegularHkPeriodicParams : public ParamsBase { + RegularHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval) + : ParamsBase(sid, enableReporting, collectionInterval, false) {} +}; + +struct DiagnosticsHkPeriodicParams : public ParamsBase { + DiagnosticsHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval) + : ParamsBase(sid, enableReporting, collectionInterval, true) {} +}; + +struct RegularHkUpdateParams : public ParamsBase { + RegularHkUpdateParams(sid_t sid, bool enableReporting) + : ParamsBase(sid, enableReporting, 0.0, false) {} +}; + +struct DiagnosticsHkUpdateParams : public ParamsBase { + DiagnosticsHkUpdateParams(sid_t sid, bool enableReporting) + : ParamsBase(sid, enableReporting, 0.0, true) {} +}; +} // namespace subdp + class ProvidesDataPoolSubscriptionIF { public: - virtual ~ProvidesDataPoolSubscriptionIF(){}; - + virtual ~ProvidesDataPoolSubscriptionIF() = default; /** * @brief Subscribe for the generation of periodic packets. * @details @@ -16,9 +58,11 @@ class ProvidesDataPoolSubscriptionIF { * to generate housekeeping packets which are downlinked directly. * @return */ - virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting, - float collectionInterval, bool isDiagnostics, - object_id_t packetDestination) = 0; + virtual ReturnValue_t subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams params) = 0; + virtual ReturnValue_t subscribeForDiagPeriodicPacket( + subdp::DiagnosticsHkPeriodicParams params) = 0; + /** * @brief Subscribe for the generation of packets if the dataset * is marked as changed. @@ -29,9 +73,9 @@ class ProvidesDataPoolSubscriptionIF { * @param packetDestination * @return */ - virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, - bool isDiagnostics, - object_id_t packetDestination) = 0; + virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; + virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; + /** * @brief Subscribe for a notification message which will be sent * if a dataset has changed. @@ -46,8 +90,7 @@ class ProvidesDataPoolSubscriptionIF { * Otherwise, only an notification message is sent. * @return */ - virtual ReturnValue_t subscribeForSetUpdateMessage(const uint32_t setId, - object_id_t destinationObject, + virtual ReturnValue_t subscribeForSetUpdateMessage(uint32_t setId, object_id_t destinationObject, MessageQueueId_t targetQueueId, bool generateSnapshot) = 0; /** @@ -64,7 +107,7 @@ class ProvidesDataPoolSubscriptionIF { * only an notification message is sent. * @return */ - virtual ReturnValue_t subscribeForVariableUpdateMessage(const lp_id_t localPoolId, + virtual ReturnValue_t subscribeForVariableUpdateMessage(lp_id_t localPoolId, object_id_t destinationObject, MessageQueueId_t targetQueueId, bool generateSnapshot) = 0; diff --git a/src/fsfw/housekeeping/AcceptsHkPacketsIF.h b/src/fsfw/housekeeping/AcceptsHkPacketsIF.h index 07882829..7648e7ed 100644 --- a/src/fsfw/housekeeping/AcceptsHkPacketsIF.h +++ b/src/fsfw/housekeeping/AcceptsHkPacketsIF.h @@ -1,12 +1,12 @@ #ifndef FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_ #define FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_ -#include "../ipc/MessageQueueMessageIF.h" +#include "fsfw/ipc/MessageQueueMessageIF.h" class AcceptsHkPacketsIF { public: - virtual ~AcceptsHkPacketsIF(){}; - virtual MessageQueueId_t getHkQueue() const = 0; + virtual ~AcceptsHkPacketsIF() = default; + [[nodiscard]] virtual MessageQueueId_t getHkQueue() const = 0; }; #endif /* FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_ */ diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index fa16ec3f..12c5aaeb 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -129,8 +129,9 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(errorPoolIds::TM_HITS, new PoolEntry()); localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, new PoolEntry()); localDataPoolMap.emplace(errorPoolIds::STORE_HITS, new PoolEntry()); - poolManager.subscribeForPeriodicPacket(internalErrorSid, false, getPeriodicOperationFrequency(), - true); + poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams( + internalErrorSid, false, + static_cast(getPeriodicOperationFrequency()) / static_cast(1000.0))); internalErrorDataset.setValidity(true, true); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/ipc/MessageQueueBase.h b/src/fsfw/ipc/MessageQueueBase.h index 9c05b1a2..c4de8eeb 100644 --- a/src/fsfw/ipc/MessageQueueBase.h +++ b/src/fsfw/ipc/MessageQueueBase.h @@ -17,18 +17,18 @@ class MessageQueueBase : public MessageQueueIF { [[nodiscard]] MessageQueueId_t getDefaultDestination() const override; [[nodiscard]] bool isDefaultDestinationSet() const override; ReturnValue_t sendMessage(MessageQueueId_t sendTo, MessageQueueMessageIF* message, - bool ignoreFault) override; + bool ignoreFault) override; ReturnValue_t sendToDefault(MessageQueueMessageIF* message) override; ReturnValue_t reply(MessageQueueMessageIF* message) override; ReturnValue_t receiveMessage(MessageQueueMessageIF* message, - MessageQueueId_t* receivedFrom) override; + MessageQueueId_t* receivedFrom) override; ReturnValue_t sendToDefaultFrom(MessageQueueMessageIF* message, MessageQueueId_t sentFrom, - bool ignoreFault = false) override; + bool ignoreFault = false) override; // OSAL specific, forward the abstract function ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override = 0; ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, - MessageQueueId_t sentFrom, bool ignoreFault = false) override = 0; + MessageQueueId_t sentFrom, bool ignoreFault = false) override = 0; protected: MessageQueueId_t id = MessageQueueIF::NO_QUEUE; diff --git a/src/fsfw/ipc/MessageQueueMessage.cpp b/src/fsfw/ipc/MessageQueueMessage.cpp index 6899915a..6e841c7f 100644 --- a/src/fsfw/ipc/MessageQueueMessage.cpp +++ b/src/fsfw/ipc/MessageQueueMessage.cpp @@ -10,10 +10,10 @@ MessageQueueMessage::MessageQueueMessage() : messageSize(getMinimumMessageSize() } MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) - : messageSize(this->HEADER_SIZE + size) { - if (size <= this->MAX_DATA_SIZE) { - memcpy(this->getData(), data, size); - this->messageSize = this->HEADER_SIZE + size; + : messageSize(MessageQueueMessage::HEADER_SIZE + size) { + if (size <= MessageQueueMessage::MAX_DATA_SIZE) { + std::memcpy(internalBuffer + MessageQueueMessage::HEADER_SIZE, data, size); + this->messageSize = MessageQueueMessage::HEADER_SIZE + size; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "MessageQueueMessage: Passed size larger than maximum" @@ -21,21 +21,23 @@ MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) << std::endl; #endif memset(this->internalBuffer, 0, sizeof(this->internalBuffer)); - this->messageSize = this->HEADER_SIZE; + this->messageSize = MessageQueueMessage::HEADER_SIZE; } } -MessageQueueMessage::~MessageQueueMessage() {} +MessageQueueMessage::~MessageQueueMessage() = default; const uint8_t* MessageQueueMessage::getBuffer() const { return this->internalBuffer; } uint8_t* MessageQueueMessage::getBuffer() { return this->internalBuffer; } const uint8_t* MessageQueueMessage::getData() const { - return this->internalBuffer + this->HEADER_SIZE; + return this->internalBuffer + MessageQueueMessage::HEADER_SIZE; } -uint8_t* MessageQueueMessage::getData() { return this->internalBuffer + this->HEADER_SIZE; } +uint8_t* MessageQueueMessage::getData() { + return this->internalBuffer + MessageQueueMessage::HEADER_SIZE; +} MessageQueueId_t MessageQueueMessage::getSender() const { MessageQueueId_t temp_id; @@ -58,14 +60,22 @@ void MessageQueueMessage::print(bool printWholeMessage) { } } -void MessageQueueMessage::clear() { memset(this->getBuffer(), 0, this->MAX_MESSAGE_SIZE); } +void MessageQueueMessage::clear() { + memset(this->getBuffer(), 0, MessageQueueMessage::MAX_MESSAGE_SIZE); +} size_t MessageQueueMessage::getMessageSize() const { return this->messageSize; } -void MessageQueueMessage::setMessageSize(size_t messageSize) { this->messageSize = messageSize; } +void MessageQueueMessage::setMessageSize(size_t messageSize_) { this->messageSize = messageSize_; } -size_t MessageQueueMessage::getMinimumMessageSize() const { return this->MIN_MESSAGE_SIZE; } +size_t MessageQueueMessage::getMinimumMessageSize() const { + return MessageQueueMessage::MIN_MESSAGE_SIZE; +} -size_t MessageQueueMessage::getMaximumMessageSize() const { return this->MAX_MESSAGE_SIZE; } +size_t MessageQueueMessage::getMaximumMessageSize() const { + return MessageQueueMessage::MAX_MESSAGE_SIZE; +} -size_t MessageQueueMessage::getMaximumDataSize() const { return this->MAX_DATA_SIZE; } +size_t MessageQueueMessage::getMaximumDataSize() const { + return MessageQueueMessage::MAX_DATA_SIZE; +} diff --git a/src/fsfw/ipc/MessageQueueMessage.h b/src/fsfw/ipc/MessageQueueMessage.h index 30e50ffe..a3d596f1 100644 --- a/src/fsfw/ipc/MessageQueueMessage.h +++ b/src/fsfw/ipc/MessageQueueMessage.h @@ -25,6 +25,30 @@ */ class MessageQueueMessage : public MessageQueueMessageIF { public: + /** + * @brief This constant defines the maximum size of the data content, + * excluding the header. + * @details + * It may be changed if necessary, but in general should be kept + * as small as possible. + */ + static const size_t MAX_DATA_SIZE = 24; + /** + * @brief This constant defines the maximum total size in bytes + * of a sent message. + * @details + * It is the sum of the maximum data and the header size. Be aware that + * this constant is used to define the buffer sizes for every message + * queue in the system. So, a change here may have significant impact on + * the required resources. + */ + static constexpr size_t MAX_MESSAGE_SIZE = MAX_DATA_SIZE + HEADER_SIZE; + /** + * @brief Defines the minimum size of a message where only the + * header is included + */ + static constexpr size_t MIN_MESSAGE_SIZE = HEADER_SIZE; + /** * @brief The class is initialized empty with this constructor. * @details @@ -50,59 +74,12 @@ class MessageQueueMessage : public MessageQueueMessageIF { * @brief As no memory is allocated in this class, * the destructor is empty. */ - virtual ~MessageQueueMessage(); + ~MessageQueueMessage() override; - /** - * @brief The size information of each message is stored in - * this attribute. - * @details - * It is public to simplify usage and to allow for passing the size - * address as a pointer. Care must be taken when inheriting from this class, - * as every child class is responsible for managing the size information by - * itself. When using the class to receive a message, the size information - * is updated automatically. - * - * Please note that the minimum size is limited by the size of the header - * while the maximum size is limited by the maximum allowed message size. - */ - size_t messageSize; - /** - * @brief This constant defines the maximum size of the data content, - * excluding the header. - * @details - * It may be changed if necessary, but in general should be kept - * as small as possible. - */ - static const size_t MAX_DATA_SIZE = 24; - - /** - * @brief This constant defines the maximum total size in bytes - * of a sent message. - * @details - * It is the sum of the maximum data and the header size. Be aware that - * this constant is used to define the buffer sizes for every message - * queue in the system. So, a change here may have significant impact on - * the required resources. - */ - static constexpr size_t MAX_MESSAGE_SIZE = MAX_DATA_SIZE + HEADER_SIZE; - /** - * @brief Defines the minimum size of a message where only the - * header is included - */ - static constexpr size_t MIN_MESSAGE_SIZE = HEADER_SIZE; - - private: - /** - * @brief This is the internal buffer that contains the - * actual message data. - */ - uint8_t internalBuffer[MAX_MESSAGE_SIZE]; - - public: /** * @brief This method is used to get the complete data of the message. */ - const uint8_t* getBuffer() const override; + [[nodiscard]] const uint8_t* getBuffer() const override; /** * @brief This method is used to get the complete data of the message. */ @@ -112,7 +89,7 @@ class MessageQueueMessage : public MessageQueueMessageIF { * @details * It shall be used by child classes to add data at the right position. */ - const uint8_t* getData() const override; + [[nodiscard]] const uint8_t* getData() const override; /** * @brief This method is used to fetch the data content of the message. * @details @@ -123,7 +100,7 @@ class MessageQueueMessage : public MessageQueueMessageIF { * @brief This method is used to extract the sender's message * queue id information from a received message. */ - MessageQueueId_t getSender() const override; + [[nodiscard]] MessageQueueId_t getSender() const override; /** * @brief With this method, the whole content * and the message size is set to zero. @@ -138,16 +115,40 @@ class MessageQueueMessage : public MessageQueueMessageIF { */ void setSender(MessageQueueId_t setId) override; - virtual size_t getMessageSize() const override; - virtual void setMessageSize(size_t messageSize) override; - virtual size_t getMinimumMessageSize() const override; - virtual size_t getMaximumMessageSize() const override; - virtual size_t getMaximumDataSize() const override; + [[nodiscard]] size_t getMessageSize() const override; + void setMessageSize(size_t messageSize) override; + [[nodiscard]] size_t getMinimumMessageSize() const override; + [[nodiscard]] size_t getMaximumMessageSize() const override; + [[nodiscard]] size_t getMaximumDataSize() const override; /** * @brief This is a debug method that prints the content. */ void print(bool printWholeMessage); + + /** + * TODO: This really should not be public. If it should be possible to pass size address as a + * pointer, add a getter function returning a const reference to the size + * @brief The size information of each message is stored in + * this attribute. + * @details + * It is public to simplify usage and to allow for passing the size + * address as a pointer. Care must be taken when inheriting from this class, + * as every child class is responsible for managing the size information by + * itself. When using the class to receive a message, the size information + * is updated automatically. + * + * Please note that the minimum size is limited by the size of the header + * while the maximum size is limited by the maximum allowed message size. + */ + size_t messageSize; + + private: + /** + * @brief This is the internal buffer that contains the + * actual message data. + */ + uint8_t internalBuffer[MAX_MESSAGE_SIZE] = {}; }; #endif /* FSFW_IPC_MESSAGEQUEUEMESSAGE_H_ */ diff --git a/src/fsfw/ipc/MessageQueueMessageIF.h b/src/fsfw/ipc/MessageQueueMessageIF.h index dae28926..300a90ab 100644 --- a/src/fsfw/ipc/MessageQueueMessageIF.h +++ b/src/fsfw/ipc/MessageQueueMessageIF.h @@ -14,7 +14,7 @@ class MessageQueueMessageIF { */ static const size_t HEADER_SIZE = sizeof(MessageQueueId_t); - virtual ~MessageQueueMessageIF(){}; + virtual ~MessageQueueMessageIF() = default; /** * @brief With this method, the whole content and the message @@ -29,7 +29,7 @@ class MessageQueueMessageIF { * @brief Get read-only pointer to the complete data of the message. * @return */ - virtual const uint8_t* getBuffer() const = 0; + [[nodiscard]] virtual const uint8_t* getBuffer() const = 0; /** * @brief This method is used to get the complete data of the message. @@ -48,14 +48,14 @@ class MessageQueueMessageIF { * @brief This method is used to extract the sender's message queue id * information from a received message. */ - virtual MessageQueueId_t getSender() const = 0; + [[nodiscard]] virtual MessageQueueId_t getSender() const = 0; /** * @brief This method is used to fetch the data content of the message. * @details * It shall be used by child classes to add data at the right position. */ - virtual const uint8_t* getData() const = 0; + [[nodiscard]] virtual const uint8_t* getData() const = 0; /** * @brief This method is used to fetch the data content of the message. * @details @@ -67,12 +67,28 @@ class MessageQueueMessageIF { * Get constant message size of current message implementation. * @return */ - virtual size_t getMessageSize() const = 0; + [[nodiscard]] virtual size_t getMessageSize() const = 0; + /** + * Sets the current message size of a given message + * @param messageSize + */ virtual void setMessageSize(size_t messageSize) = 0; - virtual size_t getMinimumMessageSize() const = 0; - virtual size_t getMaximumMessageSize() const = 0; - virtual size_t getMaximumDataSize() const = 0; + /** + * Returns the smallest possible message size, including any headers + * @return + */ + [[nodiscard]] virtual size_t getMinimumMessageSize() const = 0; + /** + * Returns the largest possible message size, including any headers + * @return + */ + [[nodiscard]] virtual size_t getMaximumMessageSize() const = 0; + /** + * Returns the largest possible data size without any headers + * @return + */ + [[nodiscard]] virtual size_t getMaximumDataSize() const = 0; }; #endif /* FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_ */ diff --git a/src/fsfw/osal/linux/Clock.cpp b/src/fsfw/osal/linux/Clock.cpp index 00596dab..a173bbc5 100644 --- a/src/fsfw/osal/linux/Clock.cpp +++ b/src/fsfw/osal/linux/Clock.cpp @@ -2,9 +2,9 @@ #include #include -#include #include +#include #include #include "fsfw/ipc/MutexGuard.h" diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 40e19530..136bd419 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -64,7 +64,7 @@ class SerializeIF { /** * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t serializeBe(uint8_t** buffer, size_t* size, size_t maxSize) { + virtual ReturnValue_t serializeBe(uint8_t **buffer, size_t *size, size_t maxSize) { return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } /** @@ -105,7 +105,7 @@ class SerializeIF { /** * Forwards to regular @deSerialize call with big (network) endianness */ - virtual ReturnValue_t deSerializeBe(const uint8_t** buffer, size_t* size) { + virtual ReturnValue_t deSerializeBe(const uint8_t **buffer, size_t *size) { return deSerialize(buffer, size, SerializeIF::Endianness::NETWORK); } /** diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index f2841d0c..3f4361f8 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -6,9 +6,9 @@ #include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "Clock.h" #include "clockDefinitions.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" bool operator<(const timeval &lhs, const timeval &rhs); bool operator<=(const timeval &lhs, const timeval &rhs); diff --git a/src/fsfw/timemanager/TimeMessage.h b/src/fsfw/timemanager/TimeMessage.h index c5eed13f..62833036 100644 --- a/src/fsfw/timemanager/TimeMessage.h +++ b/src/fsfw/timemanager/TimeMessage.h @@ -3,8 +3,8 @@ #include -#include "fsfw/ipc/MessageQueueMessage.h" #include "Clock.h" +#include "fsfw/ipc/MessageQueueMessage.h" class TimeMessage : public MessageQueueMessage { protected: diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 992ec388..d6748619 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -101,7 +101,7 @@ ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF& serializable) { +ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF &serializable) { // TODO: Check length field? pusParams.dataWrapper.setSerializable(serializable); updateSpLengthField(); diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 90b32973..0f903e7b 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -47,7 +47,7 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF [[nodiscard]] uint8_t getSubService() const override; [[nodiscard]] uint16_t getSourceId() const override; ReturnValue_t setRawUserData(const uint8_t *data, size_t len) override; - ReturnValue_t setSerializableUserData(SerializeIF& serializable) override; + ReturnValue_t setSerializableUserData(SerializeIF &serializable) override; private: ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, diff --git a/src/fsfw/tmtcservices/TmSendHelper.cpp b/src/fsfw/tmtcservices/TmSendHelper.cpp index 2f57433d..7b464ad8 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmSendHelper.cpp @@ -2,16 +2,17 @@ #include "fsfw/ipc/MessageQueueSenderIF.h" -TmSendHelper::TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF *reporter, MessageQueueId_t tmtcMsgDest) +TmSendHelper::TmSendHelper(MessageQueueIF *queue, InternalErrorReporterIF *reporter, + MessageQueueId_t tmtcMsgDest) : tmtcMsgDest(tmtcMsgDest), queue(queue), errReporter(reporter) {} TmSendHelper::TmSendHelper(MessageQueueIF *queue, InternalErrorReporterIF *reporter) - : queue(queue), errReporter(reporter) {} + : queue(queue), errReporter(reporter) {} TmSendHelper::TmSendHelper(InternalErrorReporterIF *reporter) : errReporter(reporter) {} ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) { - if(queue == nullptr) { + if (queue == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } TmTcMessage message(storeId); diff --git a/src/fsfw/tmtcservices/TmSendHelper.h b/src/fsfw/tmtcservices/TmSendHelper.h index 7e11daad..4cb159da 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.h +++ b/src/fsfw/tmtcservices/TmSendHelper.h @@ -9,11 +9,11 @@ class TmSendHelper { public: - TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter, MessageQueueId_t tmtcMsgDest); + TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter, + MessageQueueId_t tmtcMsgDest); TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter); explicit TmSendHelper(InternalErrorReporterIF* reporter); - void setMsgQueue(MessageQueueIF* queue); void setMsgDestination(MessageQueueId_t msgDest); void setInternalErrorReporter(InternalErrorReporterIF* reporter); diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index 87a530ef..eb538518 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -2,7 +2,7 @@ #include "TmTcMessage.h" -TmStoreHelper::TmStoreHelper(uint16_t defaultApid): tmStore(nullptr) { +TmStoreHelper::TmStoreHelper(uint16_t defaultApid) : tmStore(nullptr) { creator.setApid(defaultApid); } @@ -17,7 +17,6 @@ TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, creator.setTimeStamper(timeStamper); } - ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, uint16_t counter) { PusTmParams& params = creator.getParams(); params.secHeader.service = service; @@ -33,8 +32,8 @@ void TmStoreHelper::setTmStore(StorageManagerIF& store) { tmStore = &store; } const store_address_t& TmStoreHelper::getCurrentAddr() const { return currentAddr; } ReturnValue_t TmStoreHelper::deletePacket() { - ReturnValue_t result = tmStore->deleteData(currentAddr); - if(result == HasReturnvaluesIF::RETURN_OK) { + ReturnValue_t result = tmStore->deleteData(currentAddr); + if (result == HasReturnvaluesIF::RETURN_OK) { currentAddr = store_address_t::invalid(); } return result; diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index b253361e..3a868d97 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -30,7 +30,6 @@ class TmStoreHelper { ReturnValue_t setSourceDataRaw(const uint8_t* data, size_t len); ReturnValue_t setSourceDataSerializable(SerializeIF& serializable); - ReturnValue_t addPacketToStore(); ReturnValue_t deletePacket(); diff --git a/unittests/CatchFactory.cpp b/unittests/CatchFactory.cpp index 5dce8372..fdb5fd08 100644 --- a/unittests/CatchFactory.cpp +++ b/unittests/CatchFactory.cpp @@ -10,7 +10,6 @@ #include #include -#include "datapoollocal/LocalPoolOwnerBase.h" #include "mocks/HkReceiverMock.h" #include "tests/TestsConfig.h" @@ -34,8 +33,6 @@ void Factory::produceFrameworkObjects(void* args) { new EventManager(objects::EVENT_MANAGER); new HealthTable(objects::HEALTH_TABLE); new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); - - new LocalPoolOwnerBase(objects::TEST_LOCAL_POOL_OWNER_BASE); new HkReceiverMock(objects::HK_RECEIVER_MOCK); { @@ -54,6 +51,9 @@ void Factory::produceFrameworkObjects(void* args) { } } +// TODO: Our tests, and the code base in general should really not depend on some arbitrary function +// like this. Instead, this should be more like a general struct containing all important +// object IDs which are then explicitely passed in the object constructor void Factory::setStaticFrameworkObjectIds() { PusServiceBase::packetSource = objects::NO_OBJECT; PusServiceBase::packetDestination = objects::NO_OBJECT; @@ -66,7 +66,8 @@ void Factory::setStaticFrameworkObjectIds() { DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT; - LocalDataPoolManager::defaultHkDestination = objects::HK_RECEIVER_MOCK; + // TODO: Incredibly ugly, get rid of it + LocalDataPoolManager::defaultHkDestination = objects::NO_OBJECT; DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT; } diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index dd252d88..952f4572 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -57,8 +57,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { step += 1; CHECK(testMqMock.wasMessageSent()); CommandMessage testMessage; - REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(testMqMock.getNextSentMessage(testMessage) == HasReturnvaluesIF::RETURN_OK); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(testMessage.getParameter() == static_cast(testActionId)); uint32_t parameter2 = ((uint32_t)step << 16) | (uint32_t)status; @@ -72,8 +71,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { actionHelper.finish(false, testMqMock.getId(), testActionId, status); CHECK(testMqMock.wasMessageSent()); CommandMessage testMessage; - REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(testMqMock.getNextSentMessage(testMessage) == HasReturnvaluesIF::RETURN_OK); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::COMPLETION_FAILED)); REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId); REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(status)); @@ -89,8 +87,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { REQUIRE(ipcStore->getData(toLongParamAddress).first == static_cast(StorageManagerIF::DATA_DOES_NOT_EXIST)); CommandMessage testMessage; - REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(testMqMock.getNextSentMessage(testMessage) == HasReturnvaluesIF::RETURN_OK); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(ActionMessage::getReturnCode(&testMessage) == 0xAFFE); REQUIRE(ActionMessage::getStep(&testMessage) == 0); @@ -102,8 +99,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { CHECK(not testDhMock.executeActionCalled); REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK); CommandMessage testMessage; - REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(testMqMock.getNextSentMessage(testMessage) == HasReturnvaluesIF::RETURN_OK); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(StorageManagerIF::ILLEGAL_STORAGE_ID)); diff --git a/unittests/datapoollocal/CMakeLists.txt b/unittests/datapoollocal/CMakeLists.txt index bf465282..6b8946a2 100644 --- a/unittests/datapoollocal/CMakeLists.txt +++ b/unittests/datapoollocal/CMakeLists.txt @@ -1,7 +1,7 @@ target_sources(${FSFW_TEST_TGT} PRIVATE - LocalPoolVariableTest.cpp - LocalPoolVectorTest.cpp - DataSetTest.cpp - LocalPoolManagerTest.cpp + testLocalPoolVariable.cpp + testLocalPoolVector.cpp + testDataSet.cpp + testLocalPoolManager.cpp LocalPoolOwnerBase.cpp ) diff --git a/unittests/datapoollocal/LocalPoolManagerTest.cpp b/unittests/datapoollocal/LocalPoolManagerTest.cpp deleted file mode 100644 index 6d9f162c..00000000 --- a/unittests/datapoollocal/LocalPoolManagerTest.cpp +++ /dev/null @@ -1,413 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "CatchDefinitions.h" -#include "LocalPoolOwnerBase.h" - -TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { - LocalPoolOwnerBase* poolOwner = - ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); - - MessageQueueMockBase* poolOwnerMock = poolOwner->getMockQueueHandle(); - REQUIRE(poolOwnerMock != nullptr); - - // MessageQueueIF* hkCommander = QueueFactory::instance()->createMessageQueue(); - CommandMessage messageSent; - uint8_t messagesSent = 0; - - SECTION("BasicTest") { - { - /* For code coverage, should not crash */ - LocalDataPoolManager manager(nullptr, nullptr); - } - auto owner = poolOwner->poolManager.getOwner(); - REQUIRE(owner != nullptr); - CHECK(owner->getObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE); - - /* Subscribe for message generation on update. */ - REQUIRE(poolOwner->subscribeWrapperSetUpdate() == retval::CATCH_OK); - /* Subscribe for an update message. */ - poolOwner->dataset.setChanged(true); - /* Now the update message should be generated. */ - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - REQUIRE(poolOwnerMock->wasMessageSent() == true); - - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); - CHECK(messageSent.getCommand() == - static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - - /* Should have been reset. */ - CHECK(poolOwner->dataset.hasChanged() == false); - /* Set changed again, result should be the same. */ - poolOwner->dataset.setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); - CHECK(messageSent.getCommand() == - static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - - /* Now subscribe for set update HK as well. */ - REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK); - poolOwner->dataset.setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 2); - /* first message sent should be the update notification, considering - the internal list is a vector checked in insertion order. */ - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); - CHECK(messageSent.getCommand() == - static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); - CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); - /* Clear message to avoid memory leak, our mock won't do it for us (yet) */ - CommandMessageCleaner::clearCommandMessage(&messageSent); - } - - SECTION("SetSnapshotUpdateTest") { - /* Set the variables in the set to certain values. These are checked later. */ - { - PoolReadGuard readHelper(&poolOwner->dataset); - REQUIRE(readHelper.getReadResult() == retval::CATCH_OK); - poolOwner->dataset.localPoolVarUint8.value = 5; - poolOwner->dataset.localPoolVarFloat.value = -12.242; - poolOwner->dataset.localPoolUint16Vec.value[0] = 2; - poolOwner->dataset.localPoolUint16Vec.value[1] = 32; - poolOwner->dataset.localPoolUint16Vec.value[2] = 42932; - } - - /* Subscribe for snapshot generation on update. */ - REQUIRE(poolOwner->subscribeWrapperSetUpdateSnapshot() == retval::CATCH_OK); - poolOwner->dataset.setChanged(true); - - /* Store current time, we are going to check the (approximate) time equality later */ - timeval now; - Clock::getClock_timeval(&now); - - /* Trigger generation of snapshot */ - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); - /* Check that snapshot was generated */ - CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_SET)); - /* Now we deserialize the snapshot into a new dataset instance */ - CCSDSTime::CDS_short cdsShort; - LocalPoolTestDataSet newSet; - HousekeepingSnapshot snapshot(&cdsShort, &newSet); - store_address_t storeId; - HousekeepingMessage::getUpdateSnapshotSetCommand(&messageSent, &storeId); - ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); - REQUIRE(accessorPair.first == retval::CATCH_OK); - const uint8_t* readOnlyPtr = accessorPair.second.data(); - size_t sizeToDeserialize = accessorPair.second.size(); - CHECK(newSet.localPoolVarFloat.value == 0); - CHECK(newSet.localPoolVarUint8 == 0); - CHECK(newSet.localPoolUint16Vec.value[0] == 0); - CHECK(newSet.localPoolUint16Vec.value[1] == 0); - CHECK(newSet.localPoolUint16Vec.value[2] == 0); - /* Fill the dataset and timestamp */ - REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); - /* Now we check that the snapshot is actually correct */ - CHECK(newSet.localPoolVarFloat.value == Catch::Approx(-12.242)); - CHECK(newSet.localPoolVarUint8 == 5); - CHECK(newSet.localPoolUint16Vec.value[0] == 2); - CHECK(newSet.localPoolUint16Vec.value[1] == 32); - CHECK(newSet.localPoolUint16Vec.value[2] == 42932); - - /* Now we check that both times are equal */ - timeval timeFromHK; - auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort); - CHECK(result == HasReturnvaluesIF::RETURN_OK); - timeval difference = timeFromHK - now; - CHECK(timevalOperations::toDouble(difference) < 1.0); - } - - SECTION("VariableSnapshotTest") { - /* Acquire subscription interface */ - ProvidesDataPoolSubscriptionIF* subscriptionIF = poolOwner->getSubscriptionInterface(); - REQUIRE(subscriptionIF != nullptr); - - /* Subscribe for variable snapshot */ - REQUIRE(poolOwner->subscribeWrapperVariableSnapshot(lpool::uint8VarId) == retval::CATCH_OK); - auto poolVar = - dynamic_cast*>(poolOwner->getPoolObjectHandle(lpool::uint8VarId)); - REQUIRE(poolVar != nullptr); - - { - PoolReadGuard rg(poolVar); - CHECK(rg.getReadResult() == retval::CATCH_OK); - poolVar->value = 25; - } - - poolVar->setChanged(true); - /* Store current time, we are going to check the (approximate) time equality later */ - CCSDSTime::CDS_short timeCdsNow; - timeval now; - Clock::getClock_timeval(&now); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - - /* Check update snapshot was sent. */ - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - - /* Should have been reset. */ - CHECK(poolVar->hasChanged() == false); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); - CHECK(messageSent.getCommand() == - static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE)); - /* Now we deserialize the snapshot into a new dataset instance */ - CCSDSTime::CDS_short cdsShort; - lp_var_t varCopy = lp_var_t(lpool::uint8VarGpid); - HousekeepingSnapshot snapshot(&cdsShort, &varCopy); - store_address_t storeId; - HousekeepingMessage::getUpdateSnapshotVariableCommand(&messageSent, &storeId); - ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); - REQUIRE(accessorPair.first == retval::CATCH_OK); - const uint8_t* readOnlyPtr = accessorPair.second.data(); - size_t sizeToDeserialize = accessorPair.second.size(); - CHECK(varCopy.value == 0); - /* Fill the dataset and timestamp */ - REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); - CHECK(varCopy.value == 25); - - /* Now we check that both times are equal */ - timeval timeFromHK; - auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort); - CHECK(result == HasReturnvaluesIF::RETURN_OK); - timeval difference = timeFromHK - now; - CHECK(timevalOperations::toDouble(difference) < 1.0); - } - - SECTION("VariableNotificationTest") { - /* Acquire subscription interface */ - ProvidesDataPoolSubscriptionIF* subscriptionIF = poolOwner->getSubscriptionInterface(); - REQUIRE(subscriptionIF != nullptr); - - /* Subscribe for variable update */ - REQUIRE(poolOwner->subscribeWrapperVariableUpdate(lpool::uint8VarId) == retval::CATCH_OK); - lp_var_t* poolVar = - dynamic_cast*>(poolOwner->getPoolObjectHandle(lpool::uint8VarId)); - REQUIRE(poolVar != nullptr); - poolVar->setChanged(true); - REQUIRE(poolVar->hasChanged() == true); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - - /* Check update notification was sent. */ - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - /* Should have been reset. */ - CHECK(poolVar->hasChanged() == false); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); - CHECK(messageSent.getCommand() == - static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); - /* Now subscribe for the dataset update (HK and update) again with subscription interface */ - REQUIRE(subscriptionIF->subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT, - objects::HK_RECEIVER_MOCK, - false) == retval::CATCH_OK); - REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK); - - poolOwner->dataset.setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - /* Now two messages should be sent. */ - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 2); - poolOwnerMock->clearMessages(true); - - poolOwner->dataset.setChanged(true); - poolVar->setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - /* Now three messages should be sent. */ - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 3); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); - CHECK(messageSent.getCommand() == - static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); - CHECK(messageSent.getCommand() == - static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); - CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); - CommandMessageCleaner::clearCommandMessage(&messageSent); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == static_cast(MessageQueueIF::EMPTY)); - } - - SECTION("PeriodicHKAndMessaging") { - /* Now we subcribe for a HK periodic generation. Even when it's difficult to simulate - the temporal behaviour correctly the HK manager should generate a HK packet - immediately and the periodic helper depends on HK op function calls anyway instead of - using the clock, so we could also just call performHkOperation multiple times */ - REQUIRE(poolOwner->subscribePeriodicHk(true) == retval::CATCH_OK); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - /* Now HK packet should be sent as message immediately. */ - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - LocalPoolDataSetBase* setHandle = poolOwner->getDataSetHandle(lpool::testSid); - REQUIRE(setHandle != nullptr); - CHECK(poolOwner->poolManager.generateHousekeepingPacket(lpool::testSid, setHandle, false) == - retval::CATCH_OK); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - CHECK(setHandle->getReportingEnabled() == true); - CommandMessage hkCmd; - HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - CHECK(setHandle->getReportingEnabled() == false); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - CHECK(setHandle->getReportingEnabled() == true); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - CHECK(setHandle->getReportingEnabled() == false); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, - false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - /* For non-diagnostics and a specified minimum frequency of 0.2 seconds, the - resulting collection interval should be 1.0 second */ - CHECK(poolOwner->dataset.getCollectionInterval() == 1.0); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - /* Now HK packet should be sent as message. */ - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid); - sid_t sidToCheck; - store_address_t storeId; - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - CHECK(poolOwner->changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); - CHECK(sidToCheck == lpool::testSid); - - /* Now we test the handling is the dataset is set to diagnostic */ - poolOwner->dataset.setDiagnostic(true); - - HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == - static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); - /* We still expect a failure message being sent */ - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, - false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == - static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == - static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, - true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == - static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); - - HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid); - gp_id_t gpidToCheck; - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - CHECK(poolOwner->changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); - CHECK(gpidToCheck == lpool::uint8VarGpid); - - HousekeepingMessage::setUpdateSnapshotSetCommand(&hkCmd, lpool::testSid, - store_address_t::invalid()); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - CHECK(poolOwner->changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); - CHECK(sidToCheck == lpool::testSid); - - HousekeepingMessage::setUpdateSnapshotVariableCommand(&hkCmd, lpool::uint8VarGpid, - store_address_t::invalid()); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); - CHECK(poolOwner->changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); - CHECK(gpidToCheck == lpool::uint8VarGpid); - - poolOwner->poolManager.printPoolEntry(lpool::uint8VarId); - } - - /* we need to reset the subscription list because the pool owner - is a global object. */ - CHECK(poolOwner->reset() == retval::CATCH_OK); - poolOwnerMock->clearMessages(true); -} diff --git a/unittests/datapoollocal/DataSetTest.cpp b/unittests/datapoollocal/testDataSet.cpp similarity index 93% rename from unittests/datapoollocal/DataSetTest.cpp rename to unittests/datapoollocal/testDataSet.cpp index c9f023ef..62bf59bb 100644 --- a/unittests/datapoollocal/DataSetTest.cpp +++ b/unittests/datapoollocal/testDataSet.cpp @@ -13,11 +13,10 @@ #include "tests/TestsConfig.h" TEST_CASE("DataSetTest", "[DataSetTest]") { - LocalPoolOwnerBase* poolOwner = - ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + auto queue = MessageQueueMockBase(); + LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); + REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); LocalPoolStaticTestDataSet localSet; SECTION("BasicTest") { @@ -30,9 +29,9 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { size_t maxSize = localSet.getLocalPoolIdsSerializedSize(true); uint8_t localPoolIdBuff[maxSize]; /* Skip size field */ - lp_id_t* lpIds = reinterpret_cast(localPoolIdBuff + 1); + auto* lpIds = reinterpret_cast(localPoolIdBuff + 1); size_t serSize = 0; - uint8_t* localPoolIdBuffPtr = reinterpret_cast(localPoolIdBuff); + auto* localPoolIdBuffPtr = reinterpret_cast(localPoolIdBuff); /* Test local pool ID serialization */ CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize, @@ -200,7 +199,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { } /* Common fault test cases */ - LocalPoolObjectBase* variableHandle = poolOwner->getPoolObjectHandle(lpool::uint32VarId); + LocalPoolObjectBase* variableHandle = poolOwner.getPoolObjectHandle(lpool::uint32VarId); CHECK(variableHandle != nullptr); CHECK(localSet.registerVariable(variableHandle) == static_cast(DataSetIF::DATA_SET_FULL)); variableHandle = nullptr; @@ -209,7 +208,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { } SECTION("MorePoolVariables") { - LocalDataSet set(poolOwner, 2, 10); + LocalDataSet set(&poolOwner, 2, 10); /* Register same variables again to get more than 8 registered variables */ for (uint8_t idx = 0; idx < 8; idx++) { @@ -234,7 +233,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { uint8_t* buffPtr = buffer; CHECK(set.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); - std::array validityBuffer; + std::array validityBuffer{}; std::memcpy(validityBuffer.data(), buffer + 9 + sizeof(uint16_t) * 3, 2); /* The first 9 variables should be valid */ CHECK(validityBuffer[0] == 0xff); @@ -258,7 +257,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { SECTION("SharedDataSet") { object_id_t sharedSetId = objects::SHARED_SET_ID; - SharedLocalDataSet sharedSet(sharedSetId, poolOwner, lpool::testSetId, 5); + SharedLocalDataSet sharedSet(sharedSetId, &poolOwner, lpool::testSetId, 5); localSet.localPoolVarUint8.setReadWriteMode(pool_rwm_t::VAR_WRITE); localSet.localPoolUint16Vec.setReadWriteMode(pool_rwm_t::VAR_WRITE); CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == retval::CATCH_OK); @@ -279,8 +278,4 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { sharedSet.setReadCommitProtectionBehaviour(true); } - - /* we need to reset the subscription list because the pool owner - is a global object. */ - CHECK(poolOwner->reset() == retval::CATCH_OK); } diff --git a/unittests/datapoollocal/testLocalPoolManager.cpp b/unittests/datapoollocal/testLocalPoolManager.cpp new file mode 100644 index 00000000..9c979df2 --- /dev/null +++ b/unittests/datapoollocal/testLocalPoolManager.cpp @@ -0,0 +1,430 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "CatchDefinitions.h" +#include "LocalPoolOwnerBase.h" +#include "mocks/HkReceiverMock.h" + +TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { + const MessageQueueId_t defaultDestId = 1; + const MessageQueueId_t hkDest = defaultDestId; + const MessageQueueId_t subscriberId = 2; + auto hkReceiver = HkReceiverMock(hkDest); + auto queue = MessageQueueMockBase(); + LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); + REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + + MessageQueueMockBase& poolOwnerMock = poolOwner.getMockQueueHandle(); + + // TODO: This is ugly. This should be an arbitrary ctor argument. Fix this in the pool + // manager + poolOwnerMock.setDefaultDestination(defaultDestId); + poolOwner.setHkDestId(hkDest); + + auto* hkMan = poolOwner.getHkManagerHandle(); + + CommandMessage messageSent; + + SECTION("Basic Test") { + { + /* For code coverage, should not crash */ + LocalDataPoolManager manager(nullptr, nullptr); + } + auto owner = poolOwner.poolManager.getOwner(); + REQUIRE(owner != nullptr); + CHECK(owner->getObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE); + + /* Subscribe for message generation on update. */ + REQUIRE(poolOwner.subscribeWrapperSetUpdate(subscriberId) == retval::CATCH_OK); + /* Subscribe for an update message. */ + poolOwner.dataset.setChanged(true); + /* Now the update message should be generated. */ + REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwnerMock.wasMessageSent()); + + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + CHECK(messageSent.getCommand() == + static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); + + /* Should have been reset. */ + CHECK(poolOwner.dataset.hasChanged() == false); + poolOwnerMock.clearMessages(true); + /* Set changed again, result should be the same. */ + poolOwner.dataset.setChanged(true); + REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + + REQUIRE(poolOwnerMock.wasMessageSent() == true); + CHECK(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + CHECK(messageSent.getCommand() == + static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); + + poolOwnerMock.clearMessages(true); + /* Now subscribe for set update HK as well. */ + REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == retval::CATCH_OK); + poolOwner.dataset.setChanged(true); + REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwnerMock.wasMessageSent() == true); + CHECK(poolOwnerMock.numberOfSentMessage() == 2); + // first message sent should be the update notification + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + CHECK(messageSent.getCommand() == + static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); + REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == retval::CATCH_OK); + CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); + /* Clear message to avoid memory leak, our mock won't do it for us (yet) */ + CommandMessageCleaner::clearCommandMessage(&messageSent); + } + + SECTION("SetSnapshotUpdateTest") { + /* Set the variables in the set to certain values. These are checked later. */ + { + PoolReadGuard readHelper(&poolOwner.dataset); + REQUIRE(readHelper.getReadResult() == retval::CATCH_OK); + poolOwner.dataset.localPoolVarUint8.value = 5; + poolOwner.dataset.localPoolVarFloat.value = -12.242; + poolOwner.dataset.localPoolUint16Vec.value[0] = 2; + poolOwner.dataset.localPoolUint16Vec.value[1] = 32; + poolOwner.dataset.localPoolUint16Vec.value[2] = 42932; + } + + /* Subscribe for snapshot generation on update. */ + REQUIRE(poolOwner.subscribeWrapperSetUpdateSnapshot(subscriberId) == retval::CATCH_OK); + poolOwner.dataset.setChanged(true); + + /* Store current time, we are going to check the (approximate) time equality later */ + timeval now{}; + Clock::getClock_timeval(&now); + + /* Trigger generation of snapshot */ + REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwnerMock.wasMessageSent()); + CHECK(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + /* Check that snapshot was generated */ + CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_SET)); + /* Now we deserialize the snapshot into a new dataset instance */ + CCSDSTime::CDS_short cdsShort{}; + LocalPoolTestDataSet newSet; + HousekeepingSnapshot snapshot(&cdsShort, &newSet); + store_address_t storeId; + HousekeepingMessage::getUpdateSnapshotSetCommand(&messageSent, &storeId); + ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); + REQUIRE(accessorPair.first == retval::CATCH_OK); + const uint8_t* readOnlyPtr = accessorPair.second.data(); + size_t sizeToDeserialize = accessorPair.second.size(); + CHECK(newSet.localPoolVarFloat.value == 0); + CHECK(newSet.localPoolVarUint8 == 0); + CHECK(newSet.localPoolUint16Vec.value[0] == 0); + CHECK(newSet.localPoolUint16Vec.value[1] == 0); + CHECK(newSet.localPoolUint16Vec.value[2] == 0); + /* Fill the dataset and timestamp */ + REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, + SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + /* Now we check that the snapshot is actually correct */ + CHECK(newSet.localPoolVarFloat.value == Catch::Approx(-12.242)); + CHECK(newSet.localPoolVarUint8 == 5); + CHECK(newSet.localPoolUint16Vec.value[0] == 2); + CHECK(newSet.localPoolUint16Vec.value[1] == 32); + CHECK(newSet.localPoolUint16Vec.value[2] == 42932); + + /* Now we check that both times are equal */ + timeval timeFromHK{}; + auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort); + CHECK(result == HasReturnvaluesIF::RETURN_OK); + timeval difference = timeFromHK - now; + CHECK(timevalOperations::toDouble(difference) < 1.0); + } + + SECTION("VariableSnapshotTest") { + /* Acquire subscription interface */ + ProvidesDataPoolSubscriptionIF* subscriptionIF = poolOwner.getSubscriptionInterface(); + REQUIRE(subscriptionIF != nullptr); + + /* Subscribe for variable snapshot */ + REQUIRE(poolOwner.subscribeWrapperVariableSnapshot(subscriberId, lpool::uint8VarId) == + retval::CATCH_OK); + auto poolVar = + dynamic_cast*>(poolOwner.getPoolObjectHandle(lpool::uint8VarId)); + REQUIRE(poolVar != nullptr); + + { + PoolReadGuard rg(poolVar); + CHECK(rg.getReadResult() == retval::CATCH_OK); + poolVar->value = 25; + } + + poolVar->setChanged(true); + /* Store current time, we are going to check the (approximate) time equality later */ + CCSDSTime::CDS_short timeCdsNow{}; + timeval now{}; + Clock::getClock_timeval(&now); + REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + + /* Check update snapshot was sent. */ + REQUIRE(poolOwnerMock.wasMessageSent()); + CHECK(poolOwnerMock.numberOfSentMessage() == 1); + + /* Should have been reset. */ + CHECK(poolVar->hasChanged() == false); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + CHECK(messageSent.getCommand() == + static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE)); + /* Now we deserialize the snapshot into a new dataset instance */ + CCSDSTime::CDS_short cdsShort{}; + lp_var_t varCopy = lp_var_t(lpool::uint8VarGpid); + HousekeepingSnapshot snapshot(&cdsShort, &varCopy); + store_address_t storeId; + HousekeepingMessage::getUpdateSnapshotVariableCommand(&messageSent, &storeId); + ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); + REQUIRE(accessorPair.first == retval::CATCH_OK); + const uint8_t* readOnlyPtr = accessorPair.second.data(); + size_t sizeToDeserialize = accessorPair.second.size(); + CHECK(varCopy.value == 0); + /* Fill the dataset and timestamp */ + REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, + SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + CHECK(varCopy.value == 25); + + /* Now we check that both times are equal */ + timeval timeFromHK{}; + auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort); + CHECK(result == HasReturnvaluesIF::RETURN_OK); + timeval difference = timeFromHK - now; + CHECK(timevalOperations::toDouble(difference) < 1.0); + } + + SECTION("VariableNotificationTest") { + /* Acquire subscription interface */ + ProvidesDataPoolSubscriptionIF* subscriptionIF = poolOwner.getSubscriptionInterface(); + REQUIRE(subscriptionIF != nullptr); + + /* Subscribe for variable update */ + REQUIRE(poolOwner.subscribeWrapperVariableUpdate(subscriberId, lpool::uint8VarId) == + retval::CATCH_OK); + auto* poolVar = + dynamic_cast*>(poolOwner.getPoolObjectHandle(lpool::uint8VarId)); + REQUIRE(poolVar != nullptr); + poolVar->setChanged(true); + REQUIRE(poolVar->hasChanged() == true); + REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + + /* Check update notification was sent. */ + REQUIRE(poolOwnerMock.wasMessageSent()); + CHECK(poolOwnerMock.numberOfSentMessage() == 1); + /* Should have been reset. */ + CHECK(poolVar->hasChanged() == false); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + CHECK(messageSent.getCommand() == + static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); + /* Now subscribe for the dataset update (HK and update) again with subscription interface */ + REQUIRE(subscriptionIF->subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT, + subscriberId, false) == retval::CATCH_OK); + REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == retval::CATCH_OK); + + poolOwner.dataset.setChanged(true); + poolOwnerMock.clearMessages(); + REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + /* Now two messages should be sent. */ + REQUIRE(poolOwnerMock.wasMessageSent()); + CHECK(poolOwnerMock.numberOfSentMessage() == 2); + poolOwnerMock.clearMessages(true); + + poolOwner.dataset.setChanged(true); + poolOwnerMock.clearMessages(true); + poolVar->setChanged(true); + REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + /* Now three messages should be sent. */ + REQUIRE(poolOwnerMock.wasMessageSent()); + CHECK(poolOwnerMock.numberOfSentMessage() == 3); + CHECK(poolOwnerMock.numberOfSentMessage(subscriberId) == 2); + CHECK(poolOwnerMock.numberOfSentMessage(hkDest) == 1); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + CHECK(messageSent.getCommand() == + static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); + REQUIRE(poolOwnerMock.clearLastSentMessage(subscriberId) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == + HasReturnvaluesIF::RETURN_OK); + CHECK(messageSent.getCommand() == + static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); + REQUIRE(poolOwnerMock.clearLastSentMessage(subscriberId) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == retval::CATCH_OK); + CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); + REQUIRE(poolOwnerMock.clearLastSentMessage() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == MessageQueueIF::EMPTY); + REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == MessageQueueIF::EMPTY); + } + + SECTION("PeriodicHKAndMessaging") { + /* Now we subcribe for a HK periodic generation. Even when it's difficult to simulate + the temporal behaviour correctly the HK manager should generate a HK packet + immediately and the periodic helper depends on HK op function calls anyway instead of + using the clock, so we could also just call performHkOperation multiple times */ + REQUIRE(poolOwner.subscribePeriodicHk(true) == retval::CATCH_OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + /* Now HK packet should be sent as message immediately. */ + REQUIRE(poolOwnerMock.wasMessageSent()); + CHECK(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + + LocalPoolDataSetBase* setHandle = poolOwner.getDataSetHandle(lpool::testSid); + REQUIRE(setHandle != nullptr); + CHECK(poolOwner.poolManager.generateHousekeepingPacket(lpool::testSid, setHandle, false) == + retval::CATCH_OK); + REQUIRE(poolOwnerMock.wasMessageSent()); + CHECK(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + + CHECK(setHandle->getReportingEnabled() == true); + CommandMessage hkCmd; + HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(setHandle->getReportingEnabled() == false); + REQUIRE(poolOwnerMock.wasMessageSent()); + CHECK(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + + HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, false); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(setHandle->getReportingEnabled() == true); + REQUIRE(poolOwnerMock.wasMessageSent()); + CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + + HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(setHandle->getReportingEnabled() == false); + REQUIRE(poolOwnerMock.wasMessageSent()); + CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + + HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, + false); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + /* For non-diagnostics and a specified minimum frequency of 0.2 seconds, the + resulting collection interval should be 1.0 second */ + CHECK(poolOwner.dataset.getCollectionInterval() == 1.0); + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + + HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); + REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + /* Now HK packet should be sent as message. */ + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + poolOwnerMock.clearMessages(); + + HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + poolOwnerMock.clearMessages(); + + HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid); + sid_t sidToCheck; + store_address_t storeId; + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); + CHECK(sidToCheck == lpool::testSid); + + /* Now we test the handling is the dataset is set to diagnostic */ + poolOwner.dataset.setDiagnostic(true); + + HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == + static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); + /* We still expect a failure message being sent */ + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + + HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, + false); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == + static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + + HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == + static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + + HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, true); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + poolOwnerMock.clearMessages(); + + HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, + true); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + poolOwnerMock.clearMessages(); + + HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, true); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + poolOwnerMock.clearMessages(); + + HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, true); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + poolOwnerMock.clearMessages(); + + HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == + static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + poolOwnerMock.clearMessages(); + + HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, true); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.wasMessageSent()); + REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + poolOwnerMock.clearMessages(); + + HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid); + gp_id_t gpidToCheck; + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); + CHECK(gpidToCheck == lpool::uint8VarGpid); + + HousekeepingMessage::setUpdateSnapshotSetCommand(&hkCmd, lpool::testSid, + store_address_t::invalid()); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); + CHECK(sidToCheck == lpool::testSid); + + HousekeepingMessage::setUpdateSnapshotVariableCommand(&hkCmd, lpool::uint8VarGpid, + store_address_t::invalid()); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); + CHECK(gpidToCheck == lpool::uint8VarGpid); + + poolOwner.poolManager.printPoolEntry(lpool::uint8VarId); + } + + /* we need to reset the subscription list because the pool owner + is a global object. */ + CHECK(poolOwner.reset() == retval::CATCH_OK); + poolOwnerMock.clearMessages(true); +} diff --git a/unittests/datapoollocal/LocalPoolVariableTest.cpp b/unittests/datapoollocal/testLocalPoolVariable.cpp similarity index 100% rename from unittests/datapoollocal/LocalPoolVariableTest.cpp rename to unittests/datapoollocal/testLocalPoolVariable.cpp diff --git a/unittests/datapoollocal/LocalPoolVectorTest.cpp b/unittests/datapoollocal/testLocalPoolVector.cpp similarity index 98% rename from unittests/datapoollocal/LocalPoolVectorTest.cpp rename to unittests/datapoollocal/testLocalPoolVector.cpp index 2235ad39..331d4e09 100644 --- a/unittests/datapoollocal/LocalPoolVectorTest.cpp +++ b/unittests/datapoollocal/testLocalPoolVector.cpp @@ -4,11 +4,11 @@ #include #include "CatchDefinitions.h" -#include "LocalPoolOwnerBase.h" +#include "mocks/LocalPoolOwnerBase.h" #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { - LocalPoolOwnerBase* poolOwner = + auto* poolOwner = ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner != nullptr); REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); diff --git a/unittests/mocks/CdsShortTimestamperMock.h b/unittests/mocks/CdsShortTimestamperMock.h index 273cf24c..784ef7f4 100644 --- a/unittests/mocks/CdsShortTimestamperMock.h +++ b/unittests/mocks/CdsShortTimestamperMock.h @@ -3,8 +3,8 @@ #include -#include "fsfw/timemanager/TimeStamperIF.h" #include "fsfw/timemanager/TimeReaderIF.h" +#include "fsfw/timemanager/TimeStamperIF.h" class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { public: @@ -75,7 +75,7 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { serFailRetval = HasReturnvaluesIF::RETURN_FAILED; } - ReturnValue_t readTimeStamp(const uint8_t* buffer, size_t maxSize) override { + ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override { return deSerialize(&buffer, &maxSize, SerializeIF::Endianness::NETWORK); } size_t getTimestampLen() override { return getSerializedSize(); } diff --git a/unittests/mocks/HkReceiverMock.h b/unittests/mocks/HkReceiverMock.h index 8d4b4983..33a43a81 100644 --- a/unittests/mocks/HkReceiverMock.h +++ b/unittests/mocks/HkReceiverMock.h @@ -2,13 +2,15 @@ #define FSFW_UNITTEST_TESTS_MOCKS_HKRECEIVERMOCK_H_ #include -#include -class HkReceiverMock : public SystemObject, public AcceptsHkPacketsIF { +class HkReceiverMock : public AcceptsHkPacketsIF { public: - HkReceiverMock(object_id_t objectId) : SystemObject(objectId) {} + explicit HkReceiverMock(MessageQueueId_t queueId) : queueId(queueId) {} - MessageQueueId_t getHkQueue() const { return MessageQueueIF::NO_QUEUE; } + [[nodiscard]] MessageQueueId_t getHkQueue() const override { return queueId; } + + private: + MessageQueueId_t queueId; }; #endif /* FSFW_UNITTEST_TESTS_MOCKS_HKRECEIVERMOCK_H_ */ diff --git a/unittests/mocks/InternalErrorReporterMock.cpp b/unittests/mocks/InternalErrorReporterMock.cpp index 9988234b..c7758a13 100644 --- a/unittests/mocks/InternalErrorReporterMock.cpp +++ b/unittests/mocks/InternalErrorReporterMock.cpp @@ -2,12 +2,6 @@ InternalErrorReporterMock::InternalErrorReporterMock() = default; -void InternalErrorReporterMock::queueMessageNotSent() { - queueMsgNotSentCallCnt++; -} -void InternalErrorReporterMock::lostTm() { - lostTmCallCnt++; -} -void InternalErrorReporterMock::storeFull() { - storeFullCallCnt++; -} +void InternalErrorReporterMock::queueMessageNotSent() { queueMsgNotSentCallCnt++; } +void InternalErrorReporterMock::lostTm() { lostTmCallCnt++; } +void InternalErrorReporterMock::storeFull() { storeFullCallCnt++; } diff --git a/unittests/mocks/InternalErrorReporterMock.h b/unittests/mocks/InternalErrorReporterMock.h index d2921630..f6babe09 100644 --- a/unittests/mocks/InternalErrorReporterMock.h +++ b/unittests/mocks/InternalErrorReporterMock.h @@ -3,7 +3,7 @@ #include "fsfw/internalerror/InternalErrorReporterIF.h" -class InternalErrorReporterMock: public InternalErrorReporterIF { +class InternalErrorReporterMock : public InternalErrorReporterIF { public: unsigned int queueMsgNotSentCallCnt = 0; unsigned int lostTmCallCnt = 0; diff --git a/unittests/datapoollocal/LocalPoolOwnerBase.cpp b/unittests/mocks/LocalPoolOwnerBase.cpp similarity index 90% rename from unittests/datapoollocal/LocalPoolOwnerBase.cpp rename to unittests/mocks/LocalPoolOwnerBase.cpp index 2743e7f7..f269e066 100644 --- a/unittests/datapoollocal/LocalPoolOwnerBase.cpp +++ b/unittests/mocks/LocalPoolOwnerBase.cpp @@ -1,18 +1,17 @@ #include "LocalPoolOwnerBase.h" -LocalPoolOwnerBase::LocalPoolOwnerBase(object_id_t objectId) - : SystemObject(objectId), poolManager(this, messageQueue), dataset(this, lpool::testSetId) { - messageQueue = new MessageQueueMockBase(); -} +LocalPoolOwnerBase::LocalPoolOwnerBase(MessageQueueIF &queue, object_id_t objectId) + : SystemObject(objectId), + queue(queue), + poolManager(this, &queue), + dataset(this, lpool::testSetId) {} -LocalPoolOwnerBase::~LocalPoolOwnerBase() { - QueueFactory::instance()->deleteMessageQueue(messageQueue); -} +LocalPoolOwnerBase::~LocalPoolOwnerBase() = default; ReturnValue_t LocalPoolOwnerBase::initializeHkManager() { if (not initialized) { initialized = true; - return poolManager.initialize(messageQueue); + return poolManager.initialize(&queue); } return HasReturnvaluesIF::RETURN_OK; } @@ -125,3 +124,5 @@ void LocalPoolOwnerBase::handleChangedPoolVariable(gp_id_t globPoolId, store_add this->changedPoolVariableGpid = globPoolId; this->storeIdForChangedVariable = storeId; } + +void LocalPoolOwnerBase::setHkDestId(MessageQueueId_t id) { poolManager.setHkDestinationId(id); } diff --git a/unittests/datapoollocal/LocalPoolOwnerBase.h b/unittests/mocks/LocalPoolOwnerBase.h similarity index 68% rename from unittests/datapoollocal/LocalPoolOwnerBase.h rename to unittests/mocks/LocalPoolOwnerBase.h index 0bcebc00..1dcd6cf2 100644 --- a/unittests/datapoollocal/LocalPoolOwnerBase.h +++ b/unittests/mocks/LocalPoolOwnerBase.h @@ -64,26 +64,29 @@ class LocalPoolTestDataSet : public LocalDataSet { class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF { public: - LocalPoolOwnerBase(object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE); + explicit LocalPoolOwnerBase(MessageQueueIF& queue, + object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE); - ~LocalPoolOwnerBase(); + ~LocalPoolOwnerBase() override; - object_id_t getObjectId() const override { return SystemObject::getObjectId(); } + [[nodiscard]] object_id_t getObjectId() const override { return SystemObject::getObjectId(); } ReturnValue_t initializeHkManager(); + void setHkDestId(MessageQueueId_t id); + ReturnValue_t initializeHkManagerAfterTaskCreation(); /** Command queue for housekeeping messages. */ - MessageQueueId_t getCommandQueue() const override { return messageQueue->getId(); } + [[nodiscard]] MessageQueueId_t getCommandQueue() const override { return queue.getId(); } // This is called by initializeAfterTaskCreation of the HK manager. - virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; LocalDataPoolManager* getHkManagerHandle() override { return &poolManager; } - dur_millis_t getPeriodicOperationFrequency() const override { return 200; } + [[nodiscard]] dur_millis_t getPeriodicOperationFrequency() const override { return 200; } /** * This function is used by the pool manager to get a valid dataset @@ -91,41 +94,54 @@ class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF { * @param sid Corresponding structure ID * @return */ - virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override { return &dataset; } + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override { return &dataset; } - virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) override; + LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) override; - MessageQueueMockBase* getMockQueueHandle() const { - return dynamic_cast(messageQueue); + [[nodiscard]] MessageQueueMockBase& getMockQueueHandle() const { + return dynamic_cast(queue); } ReturnValue_t subscribePeriodicHk(bool enableReporting) { - return poolManager.subscribeForPeriodicPacket(lpool::testSid, enableReporting, 0.2, false); + return poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(lpool::testSid, enableReporting, 0.2)); } - ReturnValue_t subscribeWrapperSetUpdate() { + ReturnValue_t subscribeWrapperSetUpdate(MessageQueueId_t receiverId) { return poolManager.subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT, - objects::HK_RECEIVER_MOCK, false); + receiverId, false); } - ReturnValue_t subscribeWrapperSetUpdateSnapshot() { + ReturnValue_t subscribeWrapperSetUpdateSnapshot(MessageQueueId_t receiverId) { return poolManager.subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT, - objects::HK_RECEIVER_MOCK, true); + receiverId, true); } - ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false) { - return poolManager.subscribeForUpdatePacket(lpool::testSid, diagnostics, false, - objects::HK_RECEIVER_MOCK); + ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false, + AcceptsHkPacketsIF* receiver = nullptr) { + if (diagnostics) { + auto params = subdp::DiagnosticsHkUpdateParams(lpool::testSid, true); + if (receiver != nullptr) { + params.receiver = receiver->getHkQueue(); + } + return poolManager.subscribeForDiagUpdatePacket(params); + } else { + auto params = subdp::RegularHkUpdateParams(lpool::testSid, true); + if (receiver != nullptr) { + params.receiver = receiver->getHkQueue(); + } + return poolManager.subscribeForRegularUpdatePacket(params); + } } - ReturnValue_t subscribeWrapperVariableUpdate(lp_id_t localPoolId) { + ReturnValue_t subscribeWrapperVariableUpdate(MessageQueueId_t receiverId, lp_id_t localPoolId) { return poolManager.subscribeForVariableUpdateMessage(localPoolId, MessageQueueIF::NO_QUEUE, - objects::HK_RECEIVER_MOCK, false); + receiverId, false); } - ReturnValue_t subscribeWrapperVariableSnapshot(lp_id_t localPoolId) { + ReturnValue_t subscribeWrapperVariableSnapshot(MessageQueueId_t receiverId, lp_id_t localPoolId) { return poolManager.subscribeForVariableUpdateMessage(localPoolId, MessageQueueIF::NO_QUEUE, - objects::HK_RECEIVER_MOCK, true); + receiverId, true); } ReturnValue_t reset(); @@ -155,7 +171,7 @@ class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF { lp_vec_t testUint16Vec = lp_vec_t(this, lpool::uint16Vec3Id); lp_vec_t testInt64Vec = lp_vec_t(this, lpool::int64Vec2Id); - MessageQueueIF* messageQueue = nullptr; + MessageQueueIF& queue; bool initialized = false; bool initializedAfterTaskCreation = false; diff --git a/unittests/mocks/MessageQueueMockBase.cpp b/unittests/mocks/MessageQueueMockBase.cpp index 63caee26..16388e25 100644 --- a/unittests/mocks/MessageQueueMockBase.cpp +++ b/unittests/mocks/MessageQueueMockBase.cpp @@ -1,5 +1,7 @@ #include "MessageQueueMockBase.h" +#include +#include MessageQueueMockBase::MessageQueueMockBase() : MessageQueueBase(MessageQueueIF::NO_QUEUE, MessageQueueIF::NO_QUEUE, nullptr) {} @@ -7,32 +9,47 @@ MessageQueueMockBase::MessageQueueMockBase() MessageQueueMockBase::MessageQueueMockBase(MessageQueueId_t queueId) : MessageQueueBase(queueId, MessageQueueIF::NO_QUEUE, nullptr) {} -bool MessageQueueMockBase::wasMessageSent(uint8_t* messageSentCounter_, bool resetCounter) { - bool tempMessageSent = messageSent; - messageSent = false; - if (messageSentCounter_ != nullptr) { - *messageSentCounter_ = this->messageSentCounter; - } - if (resetCounter) { - this->messageSentCounter = 0; - } - return tempMessageSent; +bool MessageQueueMockBase::wasMessageSent() const { + return std::any_of( + sendMap.begin(), sendMap.end(), + [](const std::pair& pair) { return pair.second.callCount > 0; }); } -ReturnValue_t MessageQueueMockBase::popMessage() { - CommandMessage message; - message.clear(); - return receiveMessage(&message); +size_t MessageQueueMockBase::numberOfSentMessage() const { + size_t callCount = 0; + for (auto& destInfo : sendMap) { + callCount += destInfo.second.callCount; + } + return callCount; +} + +size_t MessageQueueMockBase::numberOfSentMessage(MessageQueueId_t id) const { + auto iter = sendMap.find(id); + if (iter == sendMap.end()) { + return 0; + } + return iter->second.callCount; +} + +ReturnValue_t MessageQueueMockBase::clearLastReceivedMessage(bool clearCmdMsg) { + if (receivedMsgs.empty()) { + return MessageQueueIF::EMPTY; + } + if (clearCmdMsg) { + CommandMessage message; + std::memcpy(message.getBuffer(), receivedMsgs.front().getBuffer(), message.getMessageSize()); + message.clearCommandMessage(); + } + receivedMsgs.pop_front(); + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t MessageQueueMockBase::receiveMessage(MessageQueueMessageIF* message) { - if (messagesSentQueue.empty()) { + if (receivedMsgs.empty()) { return MessageQueueIF::EMPTY; } - this->last = message->getSender(); - std::memcpy(message->getBuffer(), messagesSentQueue.front().getBuffer(), - message->getMessageSize()); - messagesSentQueue.pop(); + std::memcpy(message->getBuffer(), receivedMsgs.front().getBuffer(), message->getMessageSize()); + receivedMsgs.pop_front(); return HasReturnvaluesIF::RETURN_OK; } @@ -43,12 +60,18 @@ ReturnValue_t MessageQueueMockBase::flush(uint32_t* count) { ReturnValue_t MessageQueueMockBase::sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, MessageQueueId_t sentFrom, bool ignoreFault) { + if (message == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } auto iter = sendMap.find(sendTo); + MessageQueueMessage messageCopy; if (iter == sendMap.end()) { - sendMap.emplace(sendTo, SendInfo(message, 1)); + createMsgCopy(messageCopy, *message); + sendMap.emplace(sendTo, SendInfo(messageCopy, 1)); } else { iter->second.callCount += 1; - iter->second.msgs.push(message); + createMsgCopy(messageCopy, *message); + iter->second.msgs.push_back(messageCopy); } return HasReturnvaluesIF::RETURN_OK; } @@ -58,19 +81,87 @@ ReturnValue_t MessageQueueMockBase::reply(MessageQueueMessageIF* message) { } void MessageQueueMockBase::clearMessages(bool clearCommandMessages) { - for (const auto& destInfo: sendMap) { - if (clearCommandMessages) { - CommandMessage message; - std::memcpy(message.getBuffer(), destInfo.second.msgs.front()->getBuffer(), - message.getMessageSize()); + if (not clearCommandMessages) { + sendMap.clear(); + return; } - while (not messagesSentQueue.empty()) { - if (clearCommandMessages) { + for (auto& destInfo : sendMap) { + for (auto& msg : destInfo.second.msgs) { CommandMessage message; - std::memcpy(message.getBuffer(), messagesSentQueue.front().getBuffer(), + std::memcpy(message.getBuffer(), destInfo.second.msgs.front().getBuffer(), message.getMessageSize()); message.clear(); + destInfo.second.msgs.pop_front(); + destInfo.second.callCount--; + } + } + sendMap.clear(); +} + +void MessageQueueMockBase::addReceivedMessage(MessageQueueMessageIF& msg) { + MessageQueueMessage messageCopy; + createMsgCopy(messageCopy, msg); + receivedMsgs.push_back(messageCopy); +} + +void MessageQueueMockBase::createMsgCopy(MessageQueueMessageIF& into, MessageQueueMessageIF& from) { + if (from.getMessageSize() > into.getMaximumDataSize()) { + throw std::invalid_argument("Passed message does not fit into message copy"); + } + std::memcpy(into.getBuffer(), from.getBuffer(), from.getMaximumDataSize()); +} + +ReturnValue_t MessageQueueMockBase::getNextSentMessage(MessageQueueId_t id, + MessageQueueMessageIF& message) { + auto iter = sendMap.find(id); + if (iter == sendMap.end() or iter->second.callCount == 0) { + return MessageQueueIF::EMPTY; + } + createMsgCopy(message, iter->second.msgs.front()); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t MessageQueueMockBase::getNextSentMessage(MessageQueueMessageIF& message) { + return getNextSentMessage(MessageQueueBase::getDefaultDestination(), message); +} + +ReturnValue_t MessageQueueMockBase::clearLastSentMessage(MessageQueueId_t destId, + bool clearCmdMsg) { + auto iter = sendMap.find(destId); + if (iter == sendMap.end()) { + return MessageQueueIF::EMPTY; + } + return clearLastSentMessage(iter, clearCmdMsg); +} + +ReturnValue_t MessageQueueMockBase::clearLastSentMessage(bool clearCmdMsg) { + auto iter = sendMap.find(getDefaultDestination()); + if (iter == sendMap.end()) { + return MessageQueueIF::EMPTY; + } + ReturnValue_t result = clearLastSentMessage(iter, clearCmdMsg); + clearEmptyEntries(); + return result; +} + +ReturnValue_t MessageQueueMockBase::clearLastSentMessage( + std::map::iterator& iter, bool clearCmdMsg) { + if (clearCmdMsg) { + CommandMessage message; + std::memcpy(message.getBuffer(), iter->second.msgs.front().getBuffer(), + message.getMessageSize()); + message.clear(); + } + iter->second.msgs.pop_front(); + iter->second.callCount--; + return HasReturnvaluesIF::RETURN_OK; +} +void MessageQueueMockBase::clearEmptyEntries() { + for (auto it = sendMap.cbegin(); it != sendMap.cend();) { + if (it->second.callCount == 0) { + sendMap.erase(it++); + } else { + ++it; } - messagesSentQueue.pop(); } } diff --git a/unittests/mocks/MessageQueueMockBase.h b/unittests/mocks/MessageQueueMockBase.h index e42a0a67..fa63b171 100644 --- a/unittests/mocks/MessageQueueMockBase.h +++ b/unittests/mocks/MessageQueueMockBase.h @@ -2,8 +2,8 @@ #define FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_ #include -#include #include +#include #include "CatchDefinitions.h" #include "fsfw/ipc/CommandMessage.h" @@ -12,39 +12,52 @@ #include "fsfw/ipc/MessageQueueMessage.h" struct SendInfo { - explicit SendInfo(MessageQueueMessageIF* initMsg, unsigned int initCallCnt = 1): callCount(initCallCnt) { - msgs.push(initMsg); + explicit SendInfo(MessageQueueMessage& initMsg, unsigned int initCallCnt = 1) + : callCount(initCallCnt) { + msgs.push_back(initMsg); } unsigned int callCount = 0; - std::queue msgs; + std::deque msgs; }; class MessageQueueMockBase : public MessageQueueBase { public: MessageQueueMockBase(); + void addReceivedMessage(MessageQueueMessageIF& msg); explicit MessageQueueMockBase(MessageQueueId_t queueId); - std::map sendMap; - - bool wasMessageSent(uint8_t* messageSentCounter_ = nullptr, bool resetCounter = true); - + //! Get next message which was sent to the default destination + ReturnValue_t getNextSentMessage(MessageQueueMessageIF& message); + //! Get message which was sent to a specific ID + ReturnValue_t getNextSentMessage(MessageQueueId_t id, MessageQueueMessageIF& message); + [[nodiscard]] bool wasMessageSent() const; + [[nodiscard]] size_t numberOfSentMessage() const; + [[nodiscard]] size_t numberOfSentMessage(MessageQueueId_t id) const; /** * Pop a message, clearing it in the process. * @return */ - ReturnValue_t popMessage(); - - ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override; + ReturnValue_t clearLastReceivedMessage(bool clearCmdMsg = true); ReturnValue_t flush(uint32_t* count) override; ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, - MessageQueueId_t sentFrom, - bool ignoreFault = false) override; + MessageQueueId_t sentFrom, bool ignoreFault = false) override; ReturnValue_t reply(MessageQueueMessageIF* message) override; - void clearMessages(bool clearCommandMessages = true); + ReturnValue_t clearLastSentMessage(MessageQueueId_t destId, bool clearCmdMsg = true); + ReturnValue_t clearLastSentMessage(bool clearCmdMsg = true); + void clearMessages(bool clearCmdMsg = true); + private: + using SendMap = std::map; + SendMap sendMap; + std::deque receivedMsgs; + + void clearEmptyEntries(); + ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override; + static ReturnValue_t clearLastSentMessage(SendMap::iterator& iter, bool clearCmdMsg = true); + static void createMsgCopy(MessageQueueMessageIF& into, MessageQueueMessageIF& from); }; #endif /* FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_ */ diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index b619025a..ecd61357 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -65,7 +65,8 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::serializeBe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::serializeBe(buf.data(), buf.size()) == + HasReturnvaluesIF::RETURN_OK); } CHECK(buf[0] == 1); CHECK(buf[1] == 2); @@ -154,7 +155,8 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::deSerializeBe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerializeBe(buf.data(), buf.size()) == + HasReturnvaluesIF::RETURN_OK); } CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 1); diff --git a/unittests/testcfg/objects/systemObjectList.h b/unittests/testcfg/objects/systemObjectList.h index 7d12e5c6..1e86d5f7 100644 --- a/unittests/testcfg/objects/systemObjectList.h +++ b/unittests/testcfg/objects/systemObjectList.h @@ -31,4 +31,4 @@ enum sourceObjects : uint32_t { }; } -#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ +#endif /* HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 6e6fb069..9877d2ef 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -9,7 +9,5 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") { auto msgQueue = MessageQueueMockBase(); TmSendHelper sendHelper(&msgQueue, &errReporter); - SECTION("State") { - - } + SECTION("State") {} } \ No newline at end of file From 935e135f1c4235772eb0748314df9192bb59d789 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 19:42:05 +0200 Subject: [PATCH 106/532] normal queue sufficient --- unittests/action/TestActionHelper.cpp | 4 +- unittests/mocks/CMakeLists.txt | 2 +- unittests/mocks/LocalPoolOwnerBase.h | 2 +- ...QueueMockBase.cpp => MessageQueueMock.cpp} | 63 +++++++++---------- ...sageQueueMockBase.h => MessageQueueMock.h} | 12 ++-- unittests/osal/CMakeLists.txt | 2 +- .../osal/{TestMessageQueue.cpp => testMq.cpp} | 0 unittests/tmtcservices/testSendHelper.cpp | 2 +- 8 files changed, 42 insertions(+), 45 deletions(-) rename unittests/mocks/{MessageQueueMockBase.cpp => MessageQueueMock.cpp} (63%) rename unittests/mocks/{MessageQueueMockBase.h => MessageQueueMock.h} (89%) rename unittests/osal/{TestMessageQueue.cpp => testMq.cpp} (100%) diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index 952f4572..bf5589ab 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -6,11 +6,11 @@ #include #include -#include "mocks/MessageQueueMockBase.h" +#include "mocks/MessageQueueMock.h" TEST_CASE("Action Helper", "[ActionHelper]") { ActionHelperOwnerMockBase testDhMock; - MessageQueueMockBase testMqMock; + MessageQueueMock testMqMock; ActionHelper actionHelper = ActionHelper(&testDhMock, dynamic_cast(&testMqMock)); CommandMessage actionMessage; ActionId_t testActionId = 777; diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 04024559..9ecb013a 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -4,6 +4,6 @@ target_sources(${FSFW_TEST_TGT} PRIVATE DeviceFdirMock.cpp CookieIFMock.cpp ComIFMock.cpp - MessageQueueMockBase.cpp + MessageQueueMock.cpp InternalErrorReporterMock.cpp ) diff --git a/unittests/mocks/LocalPoolOwnerBase.h b/unittests/mocks/LocalPoolOwnerBase.h index 1dcd6cf2..132885ac 100644 --- a/unittests/mocks/LocalPoolOwnerBase.h +++ b/unittests/mocks/LocalPoolOwnerBase.h @@ -10,7 +10,7 @@ #include #include -#include "../mocks/MessageQueueMockBase.h" +#include "../mocks/MessageQueueMock.h" #include "tests/TestsConfig.h" namespace lpool { diff --git a/unittests/mocks/MessageQueueMockBase.cpp b/unittests/mocks/MessageQueueMock.cpp similarity index 63% rename from unittests/mocks/MessageQueueMockBase.cpp rename to unittests/mocks/MessageQueueMock.cpp index 16388e25..cb9bf0b7 100644 --- a/unittests/mocks/MessageQueueMockBase.cpp +++ b/unittests/mocks/MessageQueueMock.cpp @@ -1,21 +1,21 @@ -#include "MessageQueueMockBase.h" +#include "MessageQueueMock.h" #include #include -MessageQueueMockBase::MessageQueueMockBase() +MessageQueueMock::MessageQueueMock() : MessageQueueBase(MessageQueueIF::NO_QUEUE, MessageQueueIF::NO_QUEUE, nullptr) {} -MessageQueueMockBase::MessageQueueMockBase(MessageQueueId_t queueId) +MessageQueueMock::MessageQueueMock(MessageQueueId_t queueId) : MessageQueueBase(queueId, MessageQueueIF::NO_QUEUE, nullptr) {} -bool MessageQueueMockBase::wasMessageSent() const { +bool MessageQueueMock::wasMessageSent() const { return std::any_of( sendMap.begin(), sendMap.end(), [](const std::pair& pair) { return pair.second.callCount > 0; }); } -size_t MessageQueueMockBase::numberOfSentMessage() const { +size_t MessageQueueMock::numberOfSentMessage() const { size_t callCount = 0; for (auto& destInfo : sendMap) { callCount += destInfo.second.callCount; @@ -23,7 +23,7 @@ size_t MessageQueueMockBase::numberOfSentMessage() const { return callCount; } -size_t MessageQueueMockBase::numberOfSentMessage(MessageQueueId_t id) const { +size_t MessageQueueMock::numberOfSentMessage(MessageQueueId_t id) const { auto iter = sendMap.find(id); if (iter == sendMap.end()) { return 0; @@ -31,7 +31,7 @@ size_t MessageQueueMockBase::numberOfSentMessage(MessageQueueId_t id) const { return iter->second.callCount; } -ReturnValue_t MessageQueueMockBase::clearLastReceivedMessage(bool clearCmdMsg) { +ReturnValue_t MessageQueueMock::clearLastReceivedMessage(bool clearCmdMsg) { if (receivedMsgs.empty()) { return MessageQueueIF::EMPTY; } @@ -40,26 +40,24 @@ ReturnValue_t MessageQueueMockBase::clearLastReceivedMessage(bool clearCmdMsg) { std::memcpy(message.getBuffer(), receivedMsgs.front().getBuffer(), message.getMessageSize()); message.clearCommandMessage(); } - receivedMsgs.pop_front(); + receivedMsgs.pop(); return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t MessageQueueMockBase::receiveMessage(MessageQueueMessageIF* message) { +ReturnValue_t MessageQueueMock::receiveMessage(MessageQueueMessageIF* message) { if (receivedMsgs.empty()) { return MessageQueueIF::EMPTY; } std::memcpy(message->getBuffer(), receivedMsgs.front().getBuffer(), message->getMessageSize()); - receivedMsgs.pop_front(); + receivedMsgs.pop(); return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t MessageQueueMockBase::flush(uint32_t* count) { - return HasReturnvaluesIF::RETURN_FAILED; -} +ReturnValue_t MessageQueueMock::flush(uint32_t* count) { return HasReturnvaluesIF::RETURN_FAILED; } -ReturnValue_t MessageQueueMockBase::sendMessageFrom(MessageQueueId_t sendTo, - MessageQueueMessageIF* message, - MessageQueueId_t sentFrom, bool ignoreFault) { +ReturnValue_t MessageQueueMock::sendMessageFrom(MessageQueueId_t sendTo, + MessageQueueMessageIF* message, + MessageQueueId_t sentFrom, bool ignoreFault) { if (message == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } @@ -71,48 +69,48 @@ ReturnValue_t MessageQueueMockBase::sendMessageFrom(MessageQueueId_t sendTo, } else { iter->second.callCount += 1; createMsgCopy(messageCopy, *message); - iter->second.msgs.push_back(messageCopy); + iter->second.msgs.push(messageCopy); } return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t MessageQueueMockBase::reply(MessageQueueMessageIF* message) { +ReturnValue_t MessageQueueMock::reply(MessageQueueMessageIF* message) { return sendMessageFrom(MessageQueueIF::NO_QUEUE, message, this->getId(), false); } -void MessageQueueMockBase::clearMessages(bool clearCommandMessages) { +void MessageQueueMock::clearMessages(bool clearCommandMessages) { if (not clearCommandMessages) { sendMap.clear(); return; } for (auto& destInfo : sendMap) { - for (auto& msg : destInfo.second.msgs) { + while (!destInfo.second.msgs.empty()) { CommandMessage message; std::memcpy(message.getBuffer(), destInfo.second.msgs.front().getBuffer(), message.getMessageSize()); message.clear(); - destInfo.second.msgs.pop_front(); + destInfo.second.msgs.pop(); destInfo.second.callCount--; } } sendMap.clear(); } -void MessageQueueMockBase::addReceivedMessage(MessageQueueMessageIF& msg) { +void MessageQueueMock::addReceivedMessage(MessageQueueMessageIF& msg) { MessageQueueMessage messageCopy; createMsgCopy(messageCopy, msg); - receivedMsgs.push_back(messageCopy); + receivedMsgs.push(messageCopy); } -void MessageQueueMockBase::createMsgCopy(MessageQueueMessageIF& into, MessageQueueMessageIF& from) { +void MessageQueueMock::createMsgCopy(MessageQueueMessageIF& into, MessageQueueMessageIF& from) { if (from.getMessageSize() > into.getMaximumDataSize()) { throw std::invalid_argument("Passed message does not fit into message copy"); } std::memcpy(into.getBuffer(), from.getBuffer(), from.getMaximumDataSize()); } -ReturnValue_t MessageQueueMockBase::getNextSentMessage(MessageQueueId_t id, - MessageQueueMessageIF& message) { +ReturnValue_t MessageQueueMock::getNextSentMessage(MessageQueueId_t id, + MessageQueueMessageIF& message) { auto iter = sendMap.find(id); if (iter == sendMap.end() or iter->second.callCount == 0) { return MessageQueueIF::EMPTY; @@ -121,12 +119,11 @@ ReturnValue_t MessageQueueMockBase::getNextSentMessage(MessageQueueId_t id, return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t MessageQueueMockBase::getNextSentMessage(MessageQueueMessageIF& message) { +ReturnValue_t MessageQueueMock::getNextSentMessage(MessageQueueMessageIF& message) { return getNextSentMessage(MessageQueueBase::getDefaultDestination(), message); } -ReturnValue_t MessageQueueMockBase::clearLastSentMessage(MessageQueueId_t destId, - bool clearCmdMsg) { +ReturnValue_t MessageQueueMock::clearLastSentMessage(MessageQueueId_t destId, bool clearCmdMsg) { auto iter = sendMap.find(destId); if (iter == sendMap.end()) { return MessageQueueIF::EMPTY; @@ -134,7 +131,7 @@ ReturnValue_t MessageQueueMockBase::clearLastSentMessage(MessageQueueId_t destId return clearLastSentMessage(iter, clearCmdMsg); } -ReturnValue_t MessageQueueMockBase::clearLastSentMessage(bool clearCmdMsg) { +ReturnValue_t MessageQueueMock::clearLastSentMessage(bool clearCmdMsg) { auto iter = sendMap.find(getDefaultDestination()); if (iter == sendMap.end()) { return MessageQueueIF::EMPTY; @@ -144,7 +141,7 @@ ReturnValue_t MessageQueueMockBase::clearLastSentMessage(bool clearCmdMsg) { return result; } -ReturnValue_t MessageQueueMockBase::clearLastSentMessage( +ReturnValue_t MessageQueueMock::clearLastSentMessage( std::map::iterator& iter, bool clearCmdMsg) { if (clearCmdMsg) { CommandMessage message; @@ -152,11 +149,11 @@ ReturnValue_t MessageQueueMockBase::clearLastSentMessage( message.getMessageSize()); message.clear(); } - iter->second.msgs.pop_front(); + iter->second.msgs.pop(); iter->second.callCount--; return HasReturnvaluesIF::RETURN_OK; } -void MessageQueueMockBase::clearEmptyEntries() { +void MessageQueueMock::clearEmptyEntries() { for (auto it = sendMap.cbegin(); it != sendMap.cend();) { if (it->second.callCount == 0) { sendMap.erase(it++); diff --git a/unittests/mocks/MessageQueueMockBase.h b/unittests/mocks/MessageQueueMock.h similarity index 89% rename from unittests/mocks/MessageQueueMockBase.h rename to unittests/mocks/MessageQueueMock.h index fa63b171..fbfa1ba9 100644 --- a/unittests/mocks/MessageQueueMockBase.h +++ b/unittests/mocks/MessageQueueMock.h @@ -14,18 +14,18 @@ struct SendInfo { explicit SendInfo(MessageQueueMessage& initMsg, unsigned int initCallCnt = 1) : callCount(initCallCnt) { - msgs.push_back(initMsg); + msgs.push(initMsg); } unsigned int callCount = 0; - std::deque msgs; + std::queue msgs; }; -class MessageQueueMockBase : public MessageQueueBase { +class MessageQueueMock : public MessageQueueBase { public: - MessageQueueMockBase(); + MessageQueueMock(); void addReceivedMessage(MessageQueueMessageIF& msg); - explicit MessageQueueMockBase(MessageQueueId_t queueId); + explicit MessageQueueMock(MessageQueueId_t queueId); //! Get next message which was sent to the default destination ReturnValue_t getNextSentMessage(MessageQueueMessageIF& message); @@ -52,7 +52,7 @@ class MessageQueueMockBase : public MessageQueueBase { private: using SendMap = std::map; SendMap sendMap; - std::deque receivedMsgs; + std::queue receivedMsgs; void clearEmptyEntries(); ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override; diff --git a/unittests/osal/CMakeLists.txt b/unittests/osal/CMakeLists.txt index 030d363b..0c93eba1 100644 --- a/unittests/osal/CMakeLists.txt +++ b/unittests/osal/CMakeLists.txt @@ -1,5 +1,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE - TestMessageQueue.cpp + testMq.cpp TestSemaphore.cpp TestClock.cpp ) diff --git a/unittests/osal/TestMessageQueue.cpp b/unittests/osal/testMq.cpp similarity index 100% rename from unittests/osal/TestMessageQueue.cpp rename to unittests/osal/testMq.cpp diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 9877d2ef..09d34a50 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -2,7 +2,7 @@ #include "fsfw/tmtcservices/TmSendHelper.h" #include "mocks/InternalErrorReporterMock.h" -#include "mocks/MessageQueueMockBase.h" +#include "mocks/MessageQueueMock.h" TEST_CASE("TM Send Helper", "[tm-send-helper]") { auto errReporter = InternalErrorReporterMock(); From a88f767ccacdb8e1c30c61075493972e71bbc3d6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 19:49:19 +0200 Subject: [PATCH 107/532] all tests running again --- unittests/datapoollocal/CMakeLists.txt | 1 - unittests/datapoollocal/testDataSet.cpp | 5 +++-- unittests/datapoollocal/testLocalPoolManager.cpp | 6 +++--- unittests/datapoollocal/testLocalPoolVariable.cpp | 13 +++++-------- unittests/datapoollocal/testLocalPoolVector.cpp | 10 ++++------ unittests/mocks/CMakeLists.txt | 1 + unittests/mocks/LocalPoolOwnerBase.h | 4 ++-- unittests/tmtcservices/testSendHelper.cpp | 6 ++++-- 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/unittests/datapoollocal/CMakeLists.txt b/unittests/datapoollocal/CMakeLists.txt index 6b8946a2..016645fd 100644 --- a/unittests/datapoollocal/CMakeLists.txt +++ b/unittests/datapoollocal/CMakeLists.txt @@ -3,5 +3,4 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testLocalPoolVector.cpp testDataSet.cpp testLocalPoolManager.cpp - LocalPoolOwnerBase.cpp ) diff --git a/unittests/datapoollocal/testDataSet.cpp b/unittests/datapoollocal/testDataSet.cpp index 62bf59bb..0ef5a77f 100644 --- a/unittests/datapoollocal/testDataSet.cpp +++ b/unittests/datapoollocal/testDataSet.cpp @@ -9,11 +9,12 @@ #include #include "CatchDefinitions.h" -#include "LocalPoolOwnerBase.h" +#include "mocks/LocalPoolOwnerBase.h" +#include "mocks/MessageQueueMock.h" #include "tests/TestsConfig.h" TEST_CASE("DataSetTest", "[DataSetTest]") { - auto queue = MessageQueueMockBase(); + auto queue = MessageQueueMock(); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); diff --git a/unittests/datapoollocal/testLocalPoolManager.cpp b/unittests/datapoollocal/testLocalPoolManager.cpp index 9c979df2..228ab08c 100644 --- a/unittests/datapoollocal/testLocalPoolManager.cpp +++ b/unittests/datapoollocal/testLocalPoolManager.cpp @@ -12,7 +12,7 @@ #include #include "CatchDefinitions.h" -#include "LocalPoolOwnerBase.h" +#include "mocks/LocalPoolOwnerBase.h" #include "mocks/HkReceiverMock.h" TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { @@ -20,12 +20,12 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { const MessageQueueId_t hkDest = defaultDestId; const MessageQueueId_t subscriberId = 2; auto hkReceiver = HkReceiverMock(hkDest); - auto queue = MessageQueueMockBase(); + auto queue = MessageQueueMock(); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); - MessageQueueMockBase& poolOwnerMock = poolOwner.getMockQueueHandle(); + MessageQueueMock& poolOwnerMock = poolOwner.getMockQueueHandle(); // TODO: This is ugly. This should be an arbitrary ctor argument. Fix this in the pool // manager diff --git a/unittests/datapoollocal/testLocalPoolVariable.cpp b/unittests/datapoollocal/testLocalPoolVariable.cpp index 3479cdbe..dda5aca6 100644 --- a/unittests/datapoollocal/testLocalPoolVariable.cpp +++ b/unittests/datapoollocal/testLocalPoolVariable.cpp @@ -4,15 +4,14 @@ #include #include "CatchDefinitions.h" -#include "LocalPoolOwnerBase.h" +#include "mocks/LocalPoolOwnerBase.h" #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { - auto* poolOwner = - ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + auto queue = MessageQueueMock(); + LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); + REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); SECTION("Basic Tests") { /* very basic test. */ @@ -106,6 +105,4 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { lp_var_t invalidObjectVar2 = lp_var_t(globPoolId); lp_var_t invalidObjectVar3 = lp_var_t(nullptr, lpool::uint8VarId); } - - CHECK(poolOwner->reset() == retval::CATCH_OK); } diff --git a/unittests/datapoollocal/testLocalPoolVector.cpp b/unittests/datapoollocal/testLocalPoolVector.cpp index 331d4e09..dc91fa7e 100644 --- a/unittests/datapoollocal/testLocalPoolVector.cpp +++ b/unittests/datapoollocal/testLocalPoolVector.cpp @@ -8,11 +8,10 @@ #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { - auto* poolOwner = - ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + auto queue = MessageQueueMock(); + LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); + REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); SECTION("BasicTest") { // very basic test. @@ -106,5 +105,4 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id, nullptr, pool_rwm_t::VAR_READ); REQUIRE(readOnlyVec.commit() == static_cast(PoolVariableIF::INVALID_READ_WRITE_MODE)); } - poolOwner->reset(); } diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 9ecb013a..7bc8fd30 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -6,4 +6,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE ComIFMock.cpp MessageQueueMock.cpp InternalErrorReporterMock.cpp + LocalPoolOwnerBase.cpp ) diff --git a/unittests/mocks/LocalPoolOwnerBase.h b/unittests/mocks/LocalPoolOwnerBase.h index 132885ac..329aa0b3 100644 --- a/unittests/mocks/LocalPoolOwnerBase.h +++ b/unittests/mocks/LocalPoolOwnerBase.h @@ -98,8 +98,8 @@ class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF { LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) override; - [[nodiscard]] MessageQueueMockBase& getMockQueueHandle() const { - return dynamic_cast(queue); + [[nodiscard]] MessageQueueMock& getMockQueueHandle() const { + return dynamic_cast(queue); } ReturnValue_t subscribePeriodicHk(bool enableReporting) { diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 09d34a50..fc5b86bd 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -1,4 +1,5 @@ #include +#include #include "fsfw/tmtcservices/TmSendHelper.h" #include "mocks/InternalErrorReporterMock.h" @@ -6,8 +7,9 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") { auto errReporter = InternalErrorReporterMock(); - auto msgQueue = MessageQueueMockBase(); + auto msgQueue = MessageQueueMock(); TmSendHelper sendHelper(&msgQueue, &errReporter); - SECTION("State") {} + SECTION("State") { + } } \ No newline at end of file From 586993c081b953963d2eb9ac635cd46391212357 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 20:31:06 +0200 Subject: [PATCH 108/532] completed send helper tests --- src/fsfw/pus/Service17Test.cpp | 5 +- .../pus/Service1TelecommandVerification.cpp | 1 - src/fsfw/pus/Service5EventReporting.cpp | 1 - src/fsfw/storagemanager/LocalPool.cpp | 15 ++- src/fsfw/storagemanager/LocalPool.h | 1 + src/fsfw/storagemanager/StorageManagerIF.h | 2 + .../tmtcservices/CommandingServiceBase.cpp | 1 - src/fsfw/tmtcservices/PusServiceBase.cpp | 4 +- src/fsfw/tmtcservices/TmSendHelper.cpp | 34 ++++--- src/fsfw/tmtcservices/TmSendHelper.h | 22 +++-- .../datapoollocal/testLocalPoolManager.cpp | 50 +++++----- unittests/mocks/InternalErrorReporterMock.cpp | 6 ++ unittests/mocks/InternalErrorReporterMock.h | 5 +- unittests/mocks/MessageQueueMock.cpp | 16 +++- unittests/mocks/MessageQueueMock.h | 7 +- unittests/storagemanager/CMakeLists.txt | 4 +- .../{TestNewAccessor.cpp => testAccessor.cpp} | 6 +- .../{TestPool.cpp => testPool.cpp} | 9 +- unittests/tmtcservices/testSendHelper.cpp | 92 ++++++++++++++++++- 19 files changed, 211 insertions(+), 70 deletions(-) rename unittests/storagemanager/{TestNewAccessor.cpp => testAccessor.cpp} (98%) rename unittests/storagemanager/{TestPool.cpp => testPool.cpp} (97%) diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index d7c5a71b..631cf939 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -6,10 +6,7 @@ #include "fsfw/tmtcservices/tmHelpers.h" Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId) - : PusServiceBase(objectId, apid, serviceId), - storeHelper(apid), - sendHelper(nullptr), - packetSubCounter(0) {} + : PusServiceBase(objectId, apid, serviceId), storeHelper(apid), packetSubCounter(0) {} Service17Test::~Service17Test() = default; diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 624a73d0..7b5e7973 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -15,7 +15,6 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t obj apid(apid), serviceId(serviceId), targetDestination(targetDestination), - sendHelper(nullptr), storeHelper(apid) { tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); } diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index e9c9c095..44f7861a 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -11,7 +11,6 @@ Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t ap uint8_t serviceId, size_t maxNumberReportsPerCycle, uint32_t messageQueueDepth) : PusServiceBase(objectId, apid, serviceId), - sendHelper(nullptr), storeHelper(apid), maxNumberReportsPerCycle(maxNumberReportsPerCycle) { eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index cee1d407..f8b2bdb3 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -194,8 +194,6 @@ void LocalPool::clearStore() { for (auto& size : sizeList) { size = STORAGE_FREE; } - // std::memset(sizeList[index], 0xff, - // numberOfElements[index] * sizeof(size_type)); } } @@ -338,3 +336,16 @@ void LocalPool::clearSubPool(max_subpools_t subpoolIndex) { } LocalPool::max_subpools_t LocalPool::getNumberOfSubPools() const { return NUMBER_OF_SUBPOOLS; } + +bool LocalPool::hasDataAtId(store_address_t storeId) const { + if (storeId.poolIndex >= NUMBER_OF_SUBPOOLS) { + return false; + } + if ((storeId.packetIndex >= numberOfElements[storeId.poolIndex])) { + return false; + } + if (sizeLists[storeId.poolIndex][storeId.packetIndex] != STORAGE_FREE) { + return true; + } + return false; +} diff --git a/src/fsfw/storagemanager/LocalPool.h b/src/fsfw/storagemanager/LocalPool.h index 47f84955..1c1d4006 100644 --- a/src/fsfw/storagemanager/LocalPool.h +++ b/src/fsfw/storagemanager/LocalPool.h @@ -132,6 +132,7 @@ class LocalPool : public SystemObject, public StorageManagerIF { * @return */ max_subpools_t getNumberOfSubPools() const override; + bool hasDataAtId(store_address_t storeId) const override; protected: /** diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index a8313344..90ea4587 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -163,6 +163,8 @@ class StorageManagerIF : public HasReturnvaluesIF { virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** p_data, bool ignoreFault = false) = 0; + [[nodiscard]] virtual bool hasDataAtId(store_address_t storeId) const = 0; + /** * Clears the whole store. * Use with care! diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 3fac5bd2..10cc2689 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -21,7 +21,6 @@ CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t a service(service), timeoutSeconds(commandTimeoutSeconds), tmStoreHelper(apid), - tmSendHelper(nullptr), commandMap(numberOfParallelCommands) { commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth); diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 6a21b65b..26f08694 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -131,8 +131,8 @@ void PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelp } void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { - tmSendHelper.setMsgQueue(requestQueue); - tmSendHelper.setMsgDestination(requestQueue->getDefaultDestination()); + tmSendHelper.setMsgQueue(*requestQueue); + tmSendHelper.setDefaultDestination(requestQueue->getDefaultDestination()); if (errReporter == nullptr) { errReporter = ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); diff --git a/src/fsfw/tmtcservices/TmSendHelper.cpp b/src/fsfw/tmtcservices/TmSendHelper.cpp index 7b464ad8..0b9d854c 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmSendHelper.cpp @@ -2,38 +2,50 @@ #include "fsfw/ipc/MessageQueueSenderIF.h" -TmSendHelper::TmSendHelper(MessageQueueIF *queue, InternalErrorReporterIF *reporter, +TmSendHelper::TmSendHelper() = default; + +TmSendHelper::TmSendHelper(MessageQueueIF &queue, InternalErrorReporterIF &reporter, MessageQueueId_t tmtcMsgDest) - : tmtcMsgDest(tmtcMsgDest), queue(queue), errReporter(reporter) {} + : defaultDest(tmtcMsgDest), queue(&queue), errReporter(&reporter) {} -TmSendHelper::TmSendHelper(MessageQueueIF *queue, InternalErrorReporterIF *reporter) - : queue(queue), errReporter(reporter) {} +TmSendHelper::TmSendHelper(MessageQueueIF &queue, InternalErrorReporterIF &reporter) + : queue(&queue), errReporter(&reporter) {} -TmSendHelper::TmSendHelper(InternalErrorReporterIF *reporter) : errReporter(reporter) {} +TmSendHelper::TmSendHelper(InternalErrorReporterIF &reporter) : errReporter(&reporter) {} ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) { if (queue == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } TmTcMessage message(storeId); - ReturnValue_t result = queue->sendMessage(tmtcMsgDest, &message, ignoreFault); + ReturnValue_t result = queue->sendMessage(defaultDest, &message, ignoreFault); if (result != HasReturnvaluesIF::RETURN_OK) { - if (errReporter != nullptr) { + if (errReporter != nullptr and not ignoreFault) { errReporter->lostTm(); } return result; } - return HasReturnvaluesIF::RETURN_OK; + return result; } -void TmSendHelper::setMsgDestination(MessageQueueId_t msgDest) { tmtcMsgDest = msgDest; } +void TmSendHelper::setDefaultDestination(MessageQueueId_t msgDest) { defaultDest = msgDest; } void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF *reporter) { errReporter = reporter; } -void TmSendHelper::setMsgQueue(MessageQueueIF *queue_) { queue = queue_; } +void TmSendHelper::setMsgQueue(MessageQueueIF &queue_) { queue = &queue_; } ReturnValue_t TmSendHelper::sendPacket(MessageQueueId_t dest, const store_address_t &storeId) { - setMsgDestination(dest); + setDefaultDestination(dest); return sendPacket(storeId); } + +MessageQueueId_t TmSendHelper::getDefaultDestination() const { return defaultDest; } + +bool TmSendHelper::areFaultsIgnored() const { return ignoreFault; } +void TmSendHelper::ignoreFaults() { ignoreFault = true; } +void TmSendHelper::dontIgnoreFaults() { ignoreFault = false; } + +InternalErrorReporterIF *TmSendHelper::getInternalErrorReporter() const { return errReporter; } + +MessageQueueIF *TmSendHelper::getMsgQueue() const { return queue; } diff --git a/src/fsfw/tmtcservices/TmSendHelper.h b/src/fsfw/tmtcservices/TmSendHelper.h index 4cb159da..dee5a495 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.h +++ b/src/fsfw/tmtcservices/TmSendHelper.h @@ -9,22 +9,30 @@ class TmSendHelper { public: - TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter, + TmSendHelper(); + TmSendHelper(MessageQueueIF& queue, InternalErrorReporterIF& reporter, MessageQueueId_t tmtcMsgDest); - TmSendHelper(MessageQueueIF* queue, InternalErrorReporterIF* reporter); - explicit TmSendHelper(InternalErrorReporterIF* reporter); + TmSendHelper(MessageQueueIF& queue, InternalErrorReporterIF& reporter); + explicit TmSendHelper(InternalErrorReporterIF& reporter); - void setMsgQueue(MessageQueueIF* queue); - void setMsgDestination(MessageQueueId_t msgDest); + void setMsgQueue(MessageQueueIF& queue); + MessageQueueIF* getMsgQueue() const; + + void setDefaultDestination(MessageQueueId_t msgDest); + [[nodiscard]] MessageQueueId_t getDefaultDestination() const; + [[nodiscard]] bool areFaultsIgnored() const; + void ignoreFaults(); + void dontIgnoreFaults(); void setInternalErrorReporter(InternalErrorReporterIF* reporter); + [[nodiscard]] InternalErrorReporterIF* getInternalErrorReporter() const; ReturnValue_t sendPacket(MessageQueueId_t dest, const store_address_t& storeId); ReturnValue_t sendPacket(const store_address_t& storeId); private: - MessageQueueId_t tmtcMsgDest = MessageQueueIF::NO_QUEUE; + MessageQueueId_t defaultDest = MessageQueueIF::NO_QUEUE; bool ignoreFault = false; MessageQueueIF* queue = nullptr; - InternalErrorReporterIF* errReporter; + InternalErrorReporterIF* errReporter = nullptr; }; #endif // FSFW_TMTCPACKET_TMSENDHELPER_H diff --git a/unittests/datapoollocal/testLocalPoolManager.cpp b/unittests/datapoollocal/testLocalPoolManager.cpp index 228ab08c..e5282c16 100644 --- a/unittests/datapoollocal/testLocalPoolManager.cpp +++ b/unittests/datapoollocal/testLocalPoolManager.cpp @@ -12,8 +12,8 @@ #include #include "CatchDefinitions.h" -#include "mocks/LocalPoolOwnerBase.h" #include "mocks/HkReceiverMock.h" +#include "mocks/LocalPoolOwnerBase.h" TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { const MessageQueueId_t defaultDestId = 1; @@ -65,7 +65,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); REQUIRE(poolOwnerMock.wasMessageSent() == true); - CHECK(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.numberOfSentMessages() == 1); REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); @@ -76,7 +76,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { poolOwner.dataset.setChanged(true); REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); REQUIRE(poolOwnerMock.wasMessageSent() == true); - CHECK(poolOwnerMock.numberOfSentMessage() == 2); + CHECK(poolOwnerMock.numberOfSentMessages() == 2); // first message sent should be the update notification REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); CHECK(messageSent.getCommand() == @@ -110,7 +110,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Trigger generation of snapshot */ REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.numberOfSentMessages() == 1); REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); /* Check that snapshot was generated */ CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_SET)); @@ -174,7 +174,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Check update snapshot was sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.numberOfSentMessages() == 1); /* Should have been reset. */ CHECK(poolVar->hasChanged() == false); @@ -222,7 +222,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Check update notification was sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.numberOfSentMessages() == 1); /* Should have been reset. */ CHECK(poolVar->hasChanged() == false); REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); @@ -238,7 +238,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); /* Now two messages should be sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.numberOfSentMessage() == 2); + CHECK(poolOwnerMock.numberOfSentMessages() == 2); poolOwnerMock.clearMessages(true); poolOwner.dataset.setChanged(true); @@ -247,9 +247,9 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); /* Now three messages should be sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.numberOfSentMessage() == 3); - CHECK(poolOwnerMock.numberOfSentMessage(subscriberId) == 2); - CHECK(poolOwnerMock.numberOfSentMessage(hkDest) == 1); + CHECK(poolOwnerMock.numberOfSentMessages() == 3); + CHECK(poolOwnerMock.numberOfSentMessagesToDest(subscriberId) == 2); + CHECK(poolOwnerMock.numberOfSentMessagesToDest(hkDest) == 1); REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); @@ -275,7 +275,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); /* Now HK packet should be sent as message immediately. */ REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.numberOfSentMessages() == 1); CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); LocalPoolDataSetBase* setHandle = poolOwner.getDataSetHandle(lpool::testSid); @@ -283,7 +283,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { CHECK(poolOwner.poolManager.generateHousekeepingPacket(lpool::testSid, setHandle, false) == retval::CATCH_OK); REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.numberOfSentMessages() == 1); CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); CHECK(setHandle->getReportingEnabled() == true); @@ -292,7 +292,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); CHECK(setHandle->getReportingEnabled() == false); REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.numberOfSentMessage() == 1); + CHECK(poolOwnerMock.numberOfSentMessages() == 1); CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, false); @@ -314,7 +314,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { resulting collection interval should be 1.0 second */ CHECK(poolOwner.dataset.getCollectionInterval() == 1.0); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); @@ -322,13 +322,13 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); /* Now HK packet should be sent as message. */ REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid); @@ -346,7 +346,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); /* We still expect a failure message being sent */ REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, @@ -354,52 +354,52 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, true); CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, true); CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, true); CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, true); CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, true); CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.numberOfSentMessage() == 1); + REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid); diff --git a/unittests/mocks/InternalErrorReporterMock.cpp b/unittests/mocks/InternalErrorReporterMock.cpp index c7758a13..f53a1ed4 100644 --- a/unittests/mocks/InternalErrorReporterMock.cpp +++ b/unittests/mocks/InternalErrorReporterMock.cpp @@ -5,3 +5,9 @@ InternalErrorReporterMock::InternalErrorReporterMock() = default; void InternalErrorReporterMock::queueMessageNotSent() { queueMsgNotSentCallCnt++; } void InternalErrorReporterMock::lostTm() { lostTmCallCnt++; } void InternalErrorReporterMock::storeFull() { storeFullCallCnt++; } + +void InternalErrorReporterMock::reset() { + queueMsgNotSentCallCnt = 0; + lostTmCallCnt = 0; + storeFullCallCnt = 0; +} diff --git a/unittests/mocks/InternalErrorReporterMock.h b/unittests/mocks/InternalErrorReporterMock.h index f6babe09..e1ad35ae 100644 --- a/unittests/mocks/InternalErrorReporterMock.h +++ b/unittests/mocks/InternalErrorReporterMock.h @@ -9,10 +9,11 @@ class InternalErrorReporterMock : public InternalErrorReporterIF { unsigned int lostTmCallCnt = 0; unsigned int storeFullCallCnt = 0; InternalErrorReporterMock(); + void reset(); + + private: void queueMessageNotSent() override; void lostTm() override; void storeFull() override; - - private: }; #endif // FSFW_TESTS_INTERNALERRORREPORTERMOCK_H diff --git a/unittests/mocks/MessageQueueMock.cpp b/unittests/mocks/MessageQueueMock.cpp index cb9bf0b7..c514cc2e 100644 --- a/unittests/mocks/MessageQueueMock.cpp +++ b/unittests/mocks/MessageQueueMock.cpp @@ -15,7 +15,7 @@ bool MessageQueueMock::wasMessageSent() const { [](const std::pair& pair) { return pair.second.callCount > 0; }); } -size_t MessageQueueMock::numberOfSentMessage() const { +size_t MessageQueueMock::numberOfSentMessages() const { size_t callCount = 0; for (auto& destInfo : sendMap) { callCount += destInfo.second.callCount; @@ -23,7 +23,7 @@ size_t MessageQueueMock::numberOfSentMessage() const { return callCount; } -size_t MessageQueueMock::numberOfSentMessage(MessageQueueId_t id) const { +size_t MessageQueueMock::numberOfSentMessagesToDest(MessageQueueId_t id) const { auto iter = sendMap.find(id); if (iter == sendMap.end()) { return 0; @@ -31,6 +31,10 @@ size_t MessageQueueMock::numberOfSentMessage(MessageQueueId_t id) const { return iter->second.callCount; } +size_t MessageQueueMock::numberOfSentMessagesToDefault() const { + return numberOfSentMessagesToDest(MessageQueueBase::getDefaultDestination()); +} + ReturnValue_t MessageQueueMock::clearLastReceivedMessage(bool clearCmdMsg) { if (receivedMsgs.empty()) { return MessageQueueIF::EMPTY; @@ -61,6 +65,10 @@ ReturnValue_t MessageQueueMock::sendMessageFrom(MessageQueueId_t sendTo, if (message == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } + if (nextSendFailsPair.first) { + nextSendFailsPair.first = false; + return nextSendFailsPair.second; + } auto iter = sendMap.find(sendTo); MessageQueueMessage messageCopy; if (iter == sendMap.end()) { @@ -162,3 +170,7 @@ void MessageQueueMock::clearEmptyEntries() { } } } +void MessageQueueMock::makeNextSendFail(ReturnValue_t retval) { + nextSendFailsPair.first = true; + nextSendFailsPair.second = retval; +} diff --git a/unittests/mocks/MessageQueueMock.h b/unittests/mocks/MessageQueueMock.h index fbfa1ba9..0be68223 100644 --- a/unittests/mocks/MessageQueueMock.h +++ b/unittests/mocks/MessageQueueMock.h @@ -32,8 +32,10 @@ class MessageQueueMock : public MessageQueueBase { //! Get message which was sent to a specific ID ReturnValue_t getNextSentMessage(MessageQueueId_t id, MessageQueueMessageIF& message); [[nodiscard]] bool wasMessageSent() const; - [[nodiscard]] size_t numberOfSentMessage() const; - [[nodiscard]] size_t numberOfSentMessage(MessageQueueId_t id) const; + void makeNextSendFail(ReturnValue_t retval); + [[nodiscard]] size_t numberOfSentMessages() const; + [[nodiscard]] size_t numberOfSentMessagesToDefault() const; + [[nodiscard]] size_t numberOfSentMessagesToDest(MessageQueueId_t id) const; /** * Pop a message, clearing it in the process. * @return @@ -53,6 +55,7 @@ class MessageQueueMock : public MessageQueueBase { using SendMap = std::map; SendMap sendMap; std::queue receivedMsgs; + std::pair nextSendFailsPair; void clearEmptyEntries(); ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override; diff --git a/unittests/storagemanager/CMakeLists.txt b/unittests/storagemanager/CMakeLists.txt index 7b6280df..d2bb4dbc 100644 --- a/unittests/storagemanager/CMakeLists.txt +++ b/unittests/storagemanager/CMakeLists.txt @@ -1,4 +1,4 @@ target_sources(${FSFW_TEST_TGT} PRIVATE - TestNewAccessor.cpp - TestPool.cpp + testAccessor.cpp + testPool.cpp ) diff --git a/unittests/storagemanager/TestNewAccessor.cpp b/unittests/storagemanager/testAccessor.cpp similarity index 98% rename from unittests/storagemanager/TestNewAccessor.cpp rename to unittests/storagemanager/testAccessor.cpp index 996239a6..1404646b 100644 --- a/unittests/storagemanager/TestNewAccessor.cpp +++ b/unittests/storagemanager/testAccessor.cpp @@ -6,11 +6,11 @@ #include "CatchDefinitions.h" -TEST_CASE("New Accessor", "[NewAccessor]") { +TEST_CASE("Pool Accessor", "[pool-accessor]") { LocalPool::LocalPoolConfig poolCfg = {{1, 10}}; LocalPool SimplePool = LocalPool(0, poolCfg); - std::array testDataArray; - std::array receptionArray; + std::array testDataArray{}; + std::array receptionArray{}; store_address_t testStoreId; ReturnValue_t result = retval::CATCH_FAILED; diff --git a/unittests/storagemanager/TestPool.cpp b/unittests/storagemanager/testPool.cpp similarity index 97% rename from unittests/storagemanager/TestPool.cpp rename to unittests/storagemanager/testPool.cpp index e37c6934..03cac72a 100644 --- a/unittests/storagemanager/TestPool.cpp +++ b/unittests/storagemanager/testPool.cpp @@ -10,10 +10,10 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { LocalPool::LocalPoolConfig config = {{1, 10}}; LocalPool simplePool(0, config); - std::array testDataArray; - std::array receptionArray; + std::array testDataArray{}; + std::array receptionArray{}; store_address_t testStoreId; - ReturnValue_t result = retval::CATCH_FAILED; + ReturnValue_t result; uint8_t* pointer = nullptr; const uint8_t* constPointer = nullptr; @@ -23,8 +23,10 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { size_t size = 10; SECTION("Basic tests") { + REQUIRE(not simplePool.hasDataAtId(testStoreId)); result = simplePool.addData(&testStoreId, testDataArray.data(), size); REQUIRE(result == retval::CATCH_OK); + REQUIRE(simplePool.hasDataAtId(testStoreId)); result = simplePool.getData(testStoreId, &constPointer, &size); REQUIRE(result == retval::CATCH_OK); memcpy(receptionArray.data(), constPointer, size); @@ -40,6 +42,7 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { } result = simplePool.deleteData(testStoreId); REQUIRE(result == retval::CATCH_OK); + REQUIRE(not simplePool.hasDataAtId(testStoreId)); result = simplePool.addData(&testStoreId, testDataArray.data(), 15); CHECK(result == (int)StorageManagerIF::DATA_TOO_LARGE); } diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index fc5b86bd..9daeded5 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -1,15 +1,103 @@ #include #include +#include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tmtcservices/TmSendHelper.h" +#include "fsfw/tmtcservices/TmStoreHelper.h" +#include "mocks/CdsShortTimestamperMock.h" #include "mocks/InternalErrorReporterMock.h" #include "mocks/MessageQueueMock.h" TEST_CASE("TM Send Helper", "[tm-send-helper]") { + MessageQueueId_t destId = 1; auto errReporter = InternalErrorReporterMock(); auto msgQueue = MessageQueueMock(); - TmSendHelper sendHelper(&msgQueue, &errReporter); + msgQueue.setDefaultDestination(destId); + TmSendHelper sendHelper(msgQueue, errReporter, destId); + auto timeStamper = CdsShortTimestamperMock(); + LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; + LocalPool pool(objects::NO_OBJECT, cfg); + auto storeHelper = TmStoreHelper(2, pool, timeStamper); - SECTION("State") { + SECTION("State and Setters") { + REQUIRE(sendHelper.getInternalErrorReporter() == &errReporter); + REQUIRE(sendHelper.getDefaultDestination() == destId); + REQUIRE(sendHelper.getMsgQueue() == &msgQueue); + } + + SECTION("Setters") { + REQUIRE(not sendHelper.areFaultsIgnored()); + sendHelper.ignoreFaults(); + REQUIRE(sendHelper.areFaultsIgnored()); + sendHelper.dontIgnoreFaults(); + REQUIRE(not sendHelper.areFaultsIgnored()); + REQUIRE(sendHelper.getDefaultDestination() == destId); + sendHelper.setDefaultDestination(destId + 1); + REQUIRE(sendHelper.getDefaultDestination() == destId + 1); + sendHelper.setInternalErrorReporter(nullptr); + REQUIRE(sendHelper.getInternalErrorReporter() == nullptr); + } + + SECTION("Default CTOR") { + TmSendHelper emptyHelper; + REQUIRE(emptyHelper.getInternalErrorReporter() == nullptr); + REQUIRE(emptyHelper.getDefaultDestination() == MessageQueueIF::NO_QUEUE); + store_address_t dummy; + // basic robustness + REQUIRE(emptyHelper.sendPacket(dummy) == HasReturnvaluesIF::RETURN_FAILED); + } + + SECTION("One Arg CTOR") { + TmSendHelper helper(errReporter); + REQUIRE(helper.getInternalErrorReporter() == &errReporter); + REQUIRE(helper.getDefaultDestination() == MessageQueueIF::NO_QUEUE); + REQUIRE(helper.getMsgQueue() == nullptr); + } + + SECTION("Two Arg CTOR") { + TmSendHelper helper(msgQueue, errReporter); + REQUIRE(helper.getInternalErrorReporter() == &errReporter); + REQUIRE(helper.getDefaultDestination() == MessageQueueIF::NO_QUEUE); + REQUIRE(helper.getMsgQueue() == &msgQueue); + } + SECTION("Send") { + storeHelper.preparePacket(17, 2, 0); + REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + store_address_t storeId = storeHelper.getCurrentAddr(); + REQUIRE(sendHelper.sendPacket(storeId) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(msgQueue.wasMessageSent()); + REQUIRE(msgQueue.numberOfSentMessagesToDefault() == 1); + TmTcMessage msg; + REQUIRE(msgQueue.getNextSentMessage(msg) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(msg.getStorageId() == storeId); + REQUIRE(pool.hasDataAtId(msg.getStorageId())); + } + + SECTION("Send to Non-Default") { + storeHelper.preparePacket(17, 2, 0); + REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + store_address_t storeId = storeHelper.getCurrentAddr(); + REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(msgQueue.wasMessageSent()); + REQUIRE(msgQueue.numberOfSentMessagesToDest(destId + 1) == 1); + } + + SECTION("Sending fails, errors not ignored") { + msgQueue.makeNextSendFail(HasReturnvaluesIF::RETURN_FAILED); + storeHelper.preparePacket(17, 2, 0); + REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + store_address_t storeId = storeHelper.getCurrentAddr(); + REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(errReporter.lostTmCallCnt == 1); + } + + SECTION("Sending fails, errors ignored") { + msgQueue.makeNextSendFail(HasReturnvaluesIF::RETURN_FAILED); + storeHelper.preparePacket(17, 2, 0); + sendHelper.ignoreFaults(); + REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + store_address_t storeId = storeHelper.getCurrentAddr(); + REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(errReporter.lostTmCallCnt == 0); } } \ No newline at end of file From c83f75c51537618a1b31e46a0d24d192d861ae19 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 20:41:01 +0200 Subject: [PATCH 109/532] some more tests using TM send helper --- src/fsfw/tmtcservices/tmHelpers.cpp | 15 ++++++++++----- src/fsfw/tmtcservices/tmHelpers.h | 3 ++- unittests/tmtcservices/testSendHelper.cpp | 18 +++++++++++++----- unittests/tmtcservices/testStoreHelper.cpp | 1 + 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/fsfw/tmtcservices/tmHelpers.cpp b/src/fsfw/tmtcservices/tmHelpers.cpp index d7bc66cf..50b40c76 100644 --- a/src/fsfw/tmtcservices/tmHelpers.cpp +++ b/src/fsfw/tmtcservices/tmHelpers.cpp @@ -1,11 +1,16 @@ #include "tmHelpers.h" -ReturnValue_t telemetry::storeAndSendTmPacket(TmStoreHelper &storeHelper, - TmSendHelper &sendHelper) { - storeHelper.addPacketToStore(); - ReturnValue_t result = sendHelper.sendPacket(storeHelper.getCurrentAddr()); +ReturnValue_t telemetry::storeAndSendTmPacket(TmStoreHelper &storeHelper, TmSendHelper &sendHelper, + bool delOnFailure) { + ReturnValue_t result = storeHelper.addPacketToStore(); if (result != HasReturnvaluesIF::RETURN_OK) { - storeHelper.deletePacket(); + return result; + } + result = sendHelper.sendPacket(storeHelper.getCurrentAddr()); + if (result != HasReturnvaluesIF::RETURN_OK) { + if (delOnFailure) { + storeHelper.deletePacket(); + } } return result; } diff --git a/src/fsfw/tmtcservices/tmHelpers.h b/src/fsfw/tmtcservices/tmHelpers.h index da55495e..e49e11ae 100644 --- a/src/fsfw/tmtcservices/tmHelpers.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -7,7 +7,8 @@ // I'd prefer to use tm, but there have been nameclashes with the tm struct namespace telemetry { -ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper); +ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper, + bool delOnFailure = true); class DataWithObjectIdPrefix : public SerializeIF { public: diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 9daeded5..17a1d990 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -1,9 +1,9 @@ #include -#include #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tmtcservices/TmSendHelper.h" #include "fsfw/tmtcservices/TmStoreHelper.h" +#include "fsfw/tmtcservices/tmHelpers.h" #include "mocks/CdsShortTimestamperMock.h" #include "mocks/InternalErrorReporterMock.h" #include "mocks/MessageQueueMock.h" @@ -61,10 +61,18 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") { REQUIRE(helper.getMsgQueue() == &msgQueue); } SECTION("Send") { - storeHelper.preparePacket(17, 2, 0); - REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); - store_address_t storeId = storeHelper.getCurrentAddr(); - REQUIRE(sendHelper.sendPacket(storeId) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.preparePacket(17, 2, 0) == HasReturnvaluesIF::RETURN_OK); + store_address_t storeId; + SECTION("Separate Helpers") { + REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + storeId = storeHelper.getCurrentAddr(); + REQUIRE(sendHelper.sendPacket(storeId) == HasReturnvaluesIF::RETURN_OK); + } + SECTION("Helper Wrapper") { + REQUIRE(telemetry::storeAndSendTmPacket(storeHelper, sendHelper) == + HasReturnvaluesIF::RETURN_OK); + storeId = storeHelper.getCurrentAddr(); + } REQUIRE(msgQueue.wasMessageSent()); REQUIRE(msgQueue.numberOfSentMessagesToDefault() == 1); TmTcMessage msg; diff --git a/unittests/tmtcservices/testStoreHelper.cpp b/unittests/tmtcservices/testStoreHelper.cpp index 275a6238..5220957a 100644 --- a/unittests/tmtcservices/testStoreHelper.cpp +++ b/unittests/tmtcservices/testStoreHelper.cpp @@ -2,6 +2,7 @@ #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tmtcservices/TmStoreHelper.h" +#include "fsfw/tmtcservices/tmHelpers.h" #include "mocks/CdsShortTimestamperMock.h" #include "mocks/SimpleSerializable.h" From 7d87274844f61c05dc98cdb3c170a8ec09ef259e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 20:53:18 +0200 Subject: [PATCH 110/532] add old api but mark it deprecated --- .../ProvidesDataPoolSubscriptionIF.h | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index 4fa86ef0..6170e7ac 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -52,7 +52,7 @@ class ProvidesDataPoolSubscriptionIF { public: virtual ~ProvidesDataPoolSubscriptionIF() = default; /** - * @brief Subscribe for the generation of periodic packets. + * @brief Subscribe for the generation of periodic packets. Used for regular HK packets * @details * This subscription mechanism will generally be used by the data creator * to generate housekeeping packets which are downlinked directly. @@ -60,9 +60,29 @@ class ProvidesDataPoolSubscriptionIF { */ virtual ReturnValue_t subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams params) = 0; + /** + * @brief Subscribe for the generation of periodic packets. Used for diagnostic packets + * @details + * This subscription mechanism will generally be used by the data creator + * to generate housekeeping packets which are downlinked directly. + * @return + */ virtual ReturnValue_t subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams params) = 0; + [[deprecated("Please use the new API which takes all arguments as one wrapper struct")]] + virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting, + float collectionInterval, bool isDiagnostics, + object_id_t packetDestination) { + if(isDiagnostics) { + subdp::DiagnosticsHkPeriodicParams params(sid, enableReporting, collectionInterval); + return subscribeForDiagPeriodicPacket(params); + } else { + subdp::RegularHkPeriodicParams params(sid, enableReporting, collectionInterval); + return subscribeForRegularPeriodicPacket(params); + } + } + /** * @brief Subscribe for the generation of packets if the dataset * is marked as changed. @@ -76,6 +96,19 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; + [[deprecated("Please use the new API which takes all arguments as one wrapper struct")]] + virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, + bool isDiagnostics, + object_id_t packetDestination) { + if(isDiagnostics) { + subdp::DiagnosticsHkUpdateParams params(sid, reportingEnabled); + return subscribeForDiagUpdatePacket(params); + } else { + subdp::RegularHkUpdateParams params(sid, reportingEnabled); + return subscribeForRegularUpdatePacket(params); + } + } + /** * @brief Subscribe for a notification message which will be sent * if a dataset has changed. From 6d00fc65c073637f1e93a10180d80a1c8564d5f0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 21:08:04 +0200 Subject: [PATCH 111/532] fix memory leak --- .../datapoollocal/LocalDataPoolManager.cpp | 24 ++++--------------- src/fsfw/datapoollocal/LocalDataPoolManager.h | 4 ++-- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 2ab737bf..45ef9567 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -291,11 +291,7 @@ ReturnValue_t LocalDataPoolManager::addUpdateToStore(HousekeepingSnapshot& updat void LocalDataPoolManager::handleChangeResetLogic(DataType type, DataId dataId, MarkChangedIF* toReset) { - if (hkUpdateResetList == nullptr) { - /* Config error */ - return; - } - HkUpdateResetList& listRef = *hkUpdateResetList; + HkUpdateResetList& listRef = hkUpdateResetList; for (auto& changeInfo : listRef) { if (changeInfo.dataType != type) { continue; @@ -326,11 +322,7 @@ void LocalDataPoolManager::handleChangeResetLogic(DataType type, DataId dataId, } void LocalDataPoolManager::resetHkUpdateResetHelper() { - if (hkUpdateResetList == nullptr) { - return; - } - - for (auto& changeInfo : *hkUpdateResetList) { + for (auto& changeInfo : hkUpdateResetList) { changeInfo.currentUpdateCounter = changeInfo.updateCounter; } } @@ -442,11 +434,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForVariableUpdateMessage( } void LocalDataPoolManager::handleHkUpdateResetListInsertion(DataType dataType, DataId dataId) { - if (hkUpdateResetList == nullptr) { - hkUpdateResetList = new std::vector(); - } - - for (auto& updateResetStruct : *hkUpdateResetList) { + for (auto& updateResetStruct : hkUpdateResetList) { if (dataType == DataType::DATA_SET) { if (updateResetStruct.dataId.sid == dataId.sid) { updateResetStruct.updateCounter++; @@ -470,7 +458,7 @@ void LocalDataPoolManager::handleHkUpdateResetListInsertion(DataType dataType, D } else { hkUpdateResetHelper.dataId.localPoolId = dataId.localPoolId; } - hkUpdateResetList->push_back(hkUpdateResetHelper); + hkUpdateResetList.push_back(hkUpdateResetHelper); } ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* message) { @@ -824,9 +812,7 @@ void LocalDataPoolManager::clearReceiversList() { /* Clear the vector completely and releases allocated memory. */ HkReceivers().swap(hkReceivers); /* Also clear the reset helper if it exists */ - if (hkUpdateResetList != nullptr) { - HkUpdateResetList().swap(*hkUpdateResetList); - } + HkUpdateResetList().swap(hkUpdateResetList); } MutexIF* LocalDataPoolManager::getLocalPoolMutex() { return this->mutex; } diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/datapoollocal/LocalDataPoolManager.h index 041a4b05..998ca03b 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.h @@ -297,8 +297,8 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces using HkUpdateResetList = std::vector; /** This list is used to manage creating multiple update packets and only resetting - the update flag if all of them were created. Will only be created when needed. */ - HkUpdateResetList* hkUpdateResetList = nullptr; + the update flag if all of them were created. */ + HkUpdateResetList hkUpdateResetList = HkUpdateResetList(); /** This is the map holding the actual data. Should only be initialized * once ! */ From c12669fe501bfd77e916e75649cb8e4022729c50 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 22:10:20 +0200 Subject: [PATCH 112/532] this should fix the mmeory leak --- src/fsfw/datapoollocal/LocalDataPoolManager.cpp | 11 +++++------ unittests/mocks/LocalPoolOwnerBase.cpp | 10 +++++----- unittests/mocks/LocalPoolOwnerBase.h | 11 +++++++++-- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 45ef9567..7a18b7bf 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -209,9 +209,9 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei } /* Prepare and send update snapshot */ - timeval now; + timeval now{}; Clock::getClock_timeval(&now); - CCSDSTime::CDS_short cds; + CCSDSTime::CDS_short cds{}; CCSDSTime::convertToCcsds(&cds, &now); HousekeepingSnapshot updatePacket( reinterpret_cast(&cds), sizeof(cds), @@ -245,9 +245,9 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei } /* Prepare and send update snapshot */ - timeval now; + timeval now{}; Clock::getClock_timeval(&now); - CCSDSTime::CDS_short cds; + CCSDSTime::CDS_short cds{}; CCSDSTime::convertToCcsds(&cds, &now); HousekeepingSnapshot updatePacket( reinterpret_cast(&cds), sizeof(cds), @@ -291,8 +291,7 @@ ReturnValue_t LocalDataPoolManager::addUpdateToStore(HousekeepingSnapshot& updat void LocalDataPoolManager::handleChangeResetLogic(DataType type, DataId dataId, MarkChangedIF* toReset) { - HkUpdateResetList& listRef = hkUpdateResetList; - for (auto& changeInfo : listRef) { + for (auto& changeInfo : hkUpdateResetList) { if (changeInfo.dataType != type) { continue; } diff --git a/unittests/mocks/LocalPoolOwnerBase.cpp b/unittests/mocks/LocalPoolOwnerBase.cpp index f269e066..df295b95 100644 --- a/unittests/mocks/LocalPoolOwnerBase.cpp +++ b/unittests/mocks/LocalPoolOwnerBase.cpp @@ -19,12 +19,12 @@ ReturnValue_t LocalPoolOwnerBase::initializeHkManager() { ReturnValue_t LocalPoolOwnerBase::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { // Default initialization empty for now. - localDataPoolMap.emplace(lpool::uint8VarId, new PoolEntry({0})); - localDataPoolMap.emplace(lpool::floatVarId, new PoolEntry({0})); - localDataPoolMap.emplace(lpool::uint32VarId, new PoolEntry({0})); + localDataPoolMap.emplace(lpool::uint8VarId, &u8PoolEntry); + localDataPoolMap.emplace(lpool::floatVarId, &floatPoolEntry); + localDataPoolMap.emplace(lpool::uint32VarId, &u32PoolEntry); - localDataPoolMap.emplace(lpool::uint16Vec3Id, new PoolEntry({0, 0, 0})); - localDataPoolMap.emplace(lpool::int64Vec2Id, new PoolEntry({0, 0})); + localDataPoolMap.emplace(lpool::uint16Vec3Id, &u16VecPoolEntry); + localDataPoolMap.emplace(lpool::int64Vec2Id, &i64VecPoolEntry); return HasReturnvaluesIF::RETURN_OK; } diff --git a/unittests/mocks/LocalPoolOwnerBase.h b/unittests/mocks/LocalPoolOwnerBase.h index 329aa0b3..3233d5d4 100644 --- a/unittests/mocks/LocalPoolOwnerBase.h +++ b/unittests/mocks/LocalPoolOwnerBase.h @@ -7,10 +7,12 @@ #include #include #include +#include "fsfw/datapool/PoolEntry.h" + #include #include -#include "../mocks/MessageQueueMock.h" +#include "mocks/MessageQueueMock.h" #include "tests/TestsConfig.h" namespace lpool { @@ -164,10 +166,15 @@ class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF { gp_id_t changedPoolVariableGpid; store_address_t storeIdForChangedVariable; + PoolEntry u8PoolEntry = PoolEntry({0}); + PoolEntry floatPoolEntry = PoolEntry({0}); + PoolEntry u32PoolEntry = PoolEntry({0}); + PoolEntry u16VecPoolEntry = PoolEntry({0, 0, 0}); + PoolEntry i64VecPoolEntry = PoolEntry({0, 0}); + lp_var_t testUint8 = lp_var_t(this, lpool::uint8VarId); lp_var_t testFloat = lp_var_t(this, lpool::floatVarId); lp_var_t testUint32 = lp_var_t(this, lpool::uint32VarId); - lp_vec_t testUint16Vec = lp_vec_t(this, lpool::uint16Vec3Id); lp_vec_t testInt64Vec = lp_vec_t(this, lpool::int64Vec2Id); From db33f9cc7ed5a29b05a79d55d8c66b86f683159d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 22:22:08 +0200 Subject: [PATCH 113/532] maybe this teardown fixes the leak --- src/fsfw/objectmanager/ObjectManager.h | 2 +- unittests/CatchFactory.cpp | 1 - unittests/CatchRunner.cpp | 2 ++ unittests/CatchSetup.cpp | 6 ++++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/fsfw/objectmanager/ObjectManager.h b/src/fsfw/objectmanager/ObjectManager.h index 50e4af00..e0e74792 100644 --- a/src/fsfw/objectmanager/ObjectManager.h +++ b/src/fsfw/objectmanager/ObjectManager.h @@ -38,7 +38,7 @@ class ObjectManager : public ObjectManagerIF { /** * @brief In the class's destructor, all objects in the list are deleted. */ - virtual ~ObjectManager(); + ~ObjectManager() override; ReturnValue_t insert(object_id_t id, SystemObjectIF* object) override; ReturnValue_t remove(object_id_t id) override; void initialize() override; diff --git a/unittests/CatchFactory.cpp b/unittests/CatchFactory.cpp index fdb5fd08..d5d12935 100644 --- a/unittests/CatchFactory.cpp +++ b/unittests/CatchFactory.cpp @@ -33,7 +33,6 @@ void Factory::produceFrameworkObjects(void* args) { new EventManager(objects::EVENT_MANAGER); new HealthTable(objects::HEALTH_TABLE); new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); - new HkReceiverMock(objects::HK_RECEIVER_MOCK); { PoolManager::LocalPoolConfig poolCfg = {{100, 16}, {50, 32}, {25, 64}, {15, 128}, {5, 1024}}; diff --git a/unittests/CatchRunner.cpp b/unittests/CatchRunner.cpp index 1377049c..9bdcb676 100644 --- a/unittests/CatchRunner.cpp +++ b/unittests/CatchRunner.cpp @@ -13,6 +13,7 @@ #include extern int customSetup(); +extern int customTeardown(); int main(int argc, char* argv[]) { customSetup(); @@ -21,5 +22,6 @@ int main(int argc, char* argv[]) { int result = Catch::Session().run(argc, argv); // global clean-up + customTeardown(); return result; } diff --git a/unittests/CatchSetup.cpp b/unittests/CatchSetup.cpp index 06f5190a..3b918e05 100644 --- a/unittests/CatchSetup.cpp +++ b/unittests/CatchSetup.cpp @@ -29,3 +29,9 @@ int customSetup() { objMan->initialize(); return 0; } + +int customTeardown() { + ObjectManager* objMan = ObjectManager::instance(); + delete objMan; + return 0; +} From 747243684d61c70a1a5ba92149fb5c871ea44012 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 22:29:18 +0200 Subject: [PATCH 114/532] more leaks --- src/fsfw/internalerror/InternalErrorReporter.cpp | 6 +++--- src/fsfw/internalerror/InternalErrorReporter.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index 12c5aaeb..32038406 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -126,9 +126,9 @@ MessageQueueId_t InternalErrorReporter::getCommandQueue() const { ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(errorPoolIds::TM_HITS, new PoolEntry()); - localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, new PoolEntry()); - localDataPoolMap.emplace(errorPoolIds::STORE_HITS, new PoolEntry()); + localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry); + localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry); + localDataPoolMap.emplace(errorPoolIds::STORE_HITS,&storeHitsEntry); poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams( internalErrorSid, false, static_cast(getPeriodicOperationFrequency()) / static_cast(1000.0))); diff --git a/src/fsfw/internalerror/InternalErrorReporter.h b/src/fsfw/internalerror/InternalErrorReporter.h index 549be4bd..ca82d1a4 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.h +++ b/src/fsfw/internalerror/InternalErrorReporter.h @@ -72,6 +72,9 @@ class InternalErrorReporter : public SystemObject, uint32_t queueHits = 0; uint32_t tmHits = 0; uint32_t storeHits = 0; + PoolEntry tmHitsEntry = PoolEntry(); + PoolEntry storeHitsEntry = PoolEntry(); + PoolEntry queueHitsEntry = PoolEntry(); uint32_t getAndResetQueueHits(); void incrementQueueHits(); From e48b6f143242363b136b56b331cd9448cb3ac6c5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Jul 2022 22:36:53 +0200 Subject: [PATCH 115/532] possible double delete --- src/fsfw/health/HealthTable.h | 4 ++-- src/fsfw/objectmanager/ObjectManager.cpp | 6 +++--- unittests/CatchSetup.cpp | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/fsfw/health/HealthTable.h b/src/fsfw/health/HealthTable.h index 60e00f92..076228c1 100644 --- a/src/fsfw/health/HealthTable.h +++ b/src/fsfw/health/HealthTable.h @@ -9,8 +9,8 @@ class HealthTable : public HealthTableIF, public SystemObject { public: - HealthTable(object_id_t objectid); - virtual ~HealthTable(); + explicit HealthTable(object_id_t objectid); + ~HealthTable() override; void setMutexTimeout(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs); diff --git a/src/fsfw/objectmanager/ObjectManager.cpp b/src/fsfw/objectmanager/ObjectManager.cpp index 2017938a..a0278988 100644 --- a/src/fsfw/objectmanager/ObjectManager.cpp +++ b/src/fsfw/objectmanager/ObjectManager.cpp @@ -21,7 +21,7 @@ void ObjectManager::setObjectFactoryFunction(produce_function_t objFactoryFunc, this->factoryArgs = factoryArgs; } -ObjectManager::ObjectManager() {} +ObjectManager::ObjectManager() = default; ObjectManager::~ObjectManager() { for (auto const& iter : objectList) { @@ -36,7 +36,7 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) { // sif::debug << "ObjectManager::insert: Object " << std::hex // << (int)id << std::dec << " inserted." << std::endl; #endif - return this->RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::insert: Object ID " << std::hex << static_cast(id) @@ -53,7 +53,7 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) { } ReturnValue_t ObjectManager::remove(object_id_t id) { - if (this->getSystemObject(id) != NULL) { + if (this->getSystemObject(id) != nullptr) { this->objectList.erase(id); #if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::debug << "ObjectManager::removeObject: Object " << std::hex diff --git a/unittests/CatchSetup.cpp b/unittests/CatchSetup.cpp index 3b918e05..1bdc20f4 100644 --- a/unittests/CatchSetup.cpp +++ b/unittests/CatchSetup.cpp @@ -31,7 +31,5 @@ int customSetup() { } int customTeardown() { - ObjectManager* objMan = ObjectManager::instance(); - delete objMan; return 0; } From bdf71d4e664ffa230306270e60e0a1f33e44465a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 10:21:16 +0200 Subject: [PATCH 116/532] add new HasReturnvaluesIF features --- .../ProvidesDataPoolSubscriptionIF.h | 22 ++++++++++--------- .../internalerror/InternalErrorReporter.cpp | 2 +- src/fsfw/returnvalues/HasReturnvaluesIF.h | 21 +++++++++++++----- src/fsfw/tmtcservices/CMakeLists.txt | 1 + .../tmtcservices/TmStoreAndSendHelper.cpp | 3 +++ src/fsfw/tmtcservices/TmStoreAndSendHelper.h | 18 +++++++++++++++ src/fsfw/tmtcservices/tmHelpers.h | 10 ++++----- unittests/CatchSetup.cpp | 4 +--- unittests/mocks/LocalPoolOwnerBase.h | 3 +-- 9 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp create mode 100644 src/fsfw/tmtcservices/TmStoreAndSendHelper.h diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index 6170e7ac..e1aca321 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -70,11 +70,12 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams params) = 0; - [[deprecated("Please use the new API which takes all arguments as one wrapper struct")]] - virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting, - float collectionInterval, bool isDiagnostics, - object_id_t packetDestination) { - if(isDiagnostics) { + [[deprecated( + "Please use the new API which takes all arguments as one wrapper " + "struct")]] virtual ReturnValue_t + subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval, + bool isDiagnostics, object_id_t packetDestination) { + if (isDiagnostics) { subdp::DiagnosticsHkPeriodicParams params(sid, enableReporting, collectionInterval); return subscribeForDiagPeriodicPacket(params); } else { @@ -96,11 +97,12 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; - [[deprecated("Please use the new API which takes all arguments as one wrapper struct")]] - virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, - bool isDiagnostics, - object_id_t packetDestination) { - if(isDiagnostics) { + [[deprecated( + "Please use the new API which takes all arguments as one wrapper " + "struct")]] virtual ReturnValue_t + subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics, + object_id_t packetDestination) { + if (isDiagnostics) { subdp::DiagnosticsHkUpdateParams params(sid, reportingEnabled); return subscribeForDiagUpdatePacket(params); } else { diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index 32038406..0e404d22 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -128,7 +128,7 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry); localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry); - localDataPoolMap.emplace(errorPoolIds::STORE_HITS,&storeHitsEntry); + localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry); poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams( internalErrorSid, false, static_cast(getPeriodicOperationFrequency()) / static_cast(1000.0))); diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/HasReturnvaluesIF.h index eec80228..4d59c26b 100644 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ b/src/fsfw/returnvalues/HasReturnvaluesIF.h @@ -10,11 +10,21 @@ #define MAKE_RETURN_CODE(number) ((INTERFACE_ID << 8) + (number)) typedef uint16_t ReturnValue_t; +namespace retval { +static constexpr ReturnValue_t OK = 0; +static constexpr ReturnValue_t FAILED = 1; + +static constexpr ReturnValue_t makeCode(uint8_t classId, uint8_t number) { + return (static_cast(classId) << 8) + number; +} +} // namespace retval + class HasReturnvaluesIF { public: - static const ReturnValue_t RETURN_OK = 0; - static const ReturnValue_t RETURN_FAILED = 1; - virtual ~HasReturnvaluesIF() {} + static const ReturnValue_t RETURN_OK = retval::OK; + static const ReturnValue_t RETURN_FAILED = retval::FAILED; + + virtual ~HasReturnvaluesIF() = default; /** * It is discouraged to use the input parameters 0,0 and 0,1 as this @@ -23,8 +33,9 @@ class HasReturnvaluesIF { * @param number * @return */ - static constexpr ReturnValue_t makeReturnCode(uint8_t classId, uint8_t number) { - return (static_cast(classId) << 8) + number; + [[deprecated("Use retval::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode( + uint8_t classId, uint8_t number) { + return retval::makeCode(classId, number); } }; diff --git a/src/fsfw/tmtcservices/CMakeLists.txt b/src/fsfw/tmtcservices/CMakeLists.txt index 42ac6128..ca3c887e 100644 --- a/src/fsfw/tmtcservices/CMakeLists.txt +++ b/src/fsfw/tmtcservices/CMakeLists.txt @@ -9,5 +9,6 @@ target_sources( SpacePacketParser.cpp TmStoreHelper.cpp TmSendHelper.cpp + TmStoreAndSendHelper.cpp tcHelpers.cpp tmHelpers.cpp) diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp new file mode 100644 index 00000000..9e858ed6 --- /dev/null +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp @@ -0,0 +1,3 @@ +#include "TmStoreAndSendHelper.h" + +StoreAndSendWrapper::StoreAndSendWrapper(TmStoreHelper& storeHelper, TmSendHelper& sendHelper) {} diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.h b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h new file mode 100644 index 00000000..d75d6839 --- /dev/null +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h @@ -0,0 +1,18 @@ +#ifndef FSFW_TMTCSERVICES_TMSTOREANDSENDHELPER_H +#define FSFW_TMTCSERVICES_TMSTOREANDSENDHELPER_H + +#include "TmSendHelper.h" +#include "TmStoreHelper.h" + +class StoreAndSendWrapper { + public: + StoreAndSendWrapper(TmStoreHelper& storeHelper, TmSendHelper& sendHelper) + : storeHelper(storeHelper), sendHelper(sendHelper) {} + ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper, + bool delOnFailure = true); + TmStoreHelper& storeHelper; + TmSendHelper& sendHelper; + bool delOnFailure = true; +}; + +#endif // FSFW_TMTCSERVICES_TMSTOREANDSENDHELPER_H diff --git a/src/fsfw/tmtcservices/tmHelpers.h b/src/fsfw/tmtcservices/tmHelpers.h index e49e11ae..6a754bdf 100644 --- a/src/fsfw/tmtcservices/tmHelpers.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -7,9 +7,6 @@ // I'd prefer to use tm, but there have been nameclashes with the tm struct namespace telemetry { -ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper, - bool delOnFailure = true); - class DataWithObjectIdPrefix : public SerializeIF { public: DataWithObjectIdPrefix(object_id_t objectId, const uint8_t* srcData, size_t srcDataLen) @@ -34,8 +31,11 @@ class DataWithObjectIdPrefix : public SerializeIF { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override { - // TODO: Implement - return HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = SerializeAdapter::deSerialize(&objectId, buffer, size, streamEndianness); + if (result != retval::OK) { + return result; + } + return retval::FAILED; } private: diff --git a/unittests/CatchSetup.cpp b/unittests/CatchSetup.cpp index 1bdc20f4..9206c2e1 100644 --- a/unittests/CatchSetup.cpp +++ b/unittests/CatchSetup.cpp @@ -30,6 +30,4 @@ int customSetup() { return 0; } -int customTeardown() { - return 0; -} +int customTeardown() { return 0; } diff --git a/unittests/mocks/LocalPoolOwnerBase.h b/unittests/mocks/LocalPoolOwnerBase.h index 3233d5d4..f1d1225f 100644 --- a/unittests/mocks/LocalPoolOwnerBase.h +++ b/unittests/mocks/LocalPoolOwnerBase.h @@ -7,11 +7,10 @@ #include #include #include -#include "fsfw/datapool/PoolEntry.h" - #include #include +#include "fsfw/datapool/PoolEntry.h" #include "mocks/MessageQueueMock.h" #include "tests/TestsConfig.h" From b827bd8370ad22f6910e1979bfd2f150fc239321 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 10:22:05 +0200 Subject: [PATCH 117/532] update HasReturnvaluesIF 1. Add new retval namespace which contains OK and FAIL returnvalue 2. Also contains makeCode constexpr function 3. Mark HasReturnvaluesIF::makeReturnCode deprecated This prevents from having to implement an interface just to use a shorter version of the general returnvalues. A namespace is better suited for this I think --- src/fsfw/returnvalues/HasReturnvaluesIF.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/HasReturnvaluesIF.h index eec80228..4d59c26b 100644 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ b/src/fsfw/returnvalues/HasReturnvaluesIF.h @@ -10,11 +10,21 @@ #define MAKE_RETURN_CODE(number) ((INTERFACE_ID << 8) + (number)) typedef uint16_t ReturnValue_t; +namespace retval { +static constexpr ReturnValue_t OK = 0; +static constexpr ReturnValue_t FAILED = 1; + +static constexpr ReturnValue_t makeCode(uint8_t classId, uint8_t number) { + return (static_cast(classId) << 8) + number; +} +} // namespace retval + class HasReturnvaluesIF { public: - static const ReturnValue_t RETURN_OK = 0; - static const ReturnValue_t RETURN_FAILED = 1; - virtual ~HasReturnvaluesIF() {} + static const ReturnValue_t RETURN_OK = retval::OK; + static const ReturnValue_t RETURN_FAILED = retval::FAILED; + + virtual ~HasReturnvaluesIF() = default; /** * It is discouraged to use the input parameters 0,0 and 0,1 as this @@ -23,8 +33,9 @@ class HasReturnvaluesIF { * @param number * @return */ - static constexpr ReturnValue_t makeReturnCode(uint8_t classId, uint8_t number) { - return (static_cast(classId) << 8) + number; + [[deprecated("Use retval::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode( + uint8_t classId, uint8_t number) { + return retval::makeCode(classId, number); } }; From 88ebb67c8db9c9cc14958216f2443ce989a3a0dc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 10:27:44 +0200 Subject: [PATCH 118/532] fix deprecation warnings --- src/fsfw/cfdp/definitions.h | 18 +++++++++--------- src/fsfw/osal/common/TcpTmTcServer.h | 2 +- src/fsfw/tasks/FixedTimeslotTaskIF.h | 2 +- src/fsfw_tests/internal/osal/testMq.cpp | 10 ++++------ .../serialize/IntTestSerialization.cpp | 15 +++++++-------- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index eb21f5bf..93d15bcb 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -16,27 +16,27 @@ static constexpr uint8_t VERSION_BITS = 0b00100000; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; static constexpr ReturnValue_t INVALID_TLV_TYPE = - HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 1); + retval::makeCode(CFDP_CLASS_ID, 1); static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = - HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 2); + retval::makeCode(CFDP_CLASS_ID, 2); static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = - HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 3); + retval::makeCode(CFDP_CLASS_ID, 3); static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = - HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 4); + retval::makeCode(CFDP_CLASS_ID, 4); //! Can not parse options. This can also occur because there are options //! available but the user did not pass a valid options array static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = - HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 5); + retval::makeCode(CFDP_CLASS_ID, 5); static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = - HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 6); + retval::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES = - HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 6); + retval::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = - HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 8); + retval::makeCode(CFDP_CLASS_ID, 8); //! Can not parse filestore response because user did not pass a valid instance //! or remaining size is invalid static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE = - HasReturnvaluesIF::makeReturnCode(CFDP_CLASS_ID, 9); + retval::makeCode(CFDP_CLASS_ID, 9); //! Checksum types according to the SANA Checksum Types registry //! https://sanaregistry.org/r/checksum_identifiers/ diff --git a/src/fsfw/osal/common/TcpTmTcServer.h b/src/fsfw/osal/common/TcpTmTcServer.h index faf6e0a1..ae3fce39 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.h +++ b/src/fsfw/osal/common/TcpTmTcServer.h @@ -108,7 +108,7 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb StorageManagerIF* tmStore = nullptr; private: - static constexpr ReturnValue_t CONN_BROKEN = HasReturnvaluesIF::makeReturnCode(1, 0); + static constexpr ReturnValue_t CONN_BROKEN = retval::makeCode(1, 0); //! TMTC bridge is cached. object_id_t tmtcBridgeId = objects::NO_OBJECT; TcpTmTcBridge* tmtcBridge = nullptr; diff --git a/src/fsfw/tasks/FixedTimeslotTaskIF.h b/src/fsfw/tasks/FixedTimeslotTaskIF.h index 3f5e30d8..6a552d81 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskIF.h +++ b/src/fsfw/tasks/FixedTimeslotTaskIF.h @@ -15,7 +15,7 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF { ~FixedTimeslotTaskIF() override = default; static constexpr ReturnValue_t SLOT_LIST_EMPTY = - HasReturnvaluesIF::makeReturnCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0); + retval::makeCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0); /** * Add an object with a slot time and the execution step to the task. diff --git a/src/fsfw_tests/internal/osal/testMq.cpp b/src/fsfw_tests/internal/osal/testMq.cpp index 0f78dbb9..30b46d63 100644 --- a/src/fsfw_tests/internal/osal/testMq.cpp +++ b/src/fsfw_tests/internal/osal/testMq.cpp @@ -7,8 +7,6 @@ #include "fsfw_tests/internal/UnittDefinitions.h" -using retval = HasReturnvaluesIF; - void testmq::testMq() { std::string id = "[testMq]"; MessageQueueIF* testSenderMq = QueueFactory::instance()->createMessageQueue(1); @@ -22,22 +20,22 @@ void testmq::testMq() { testSenderMq->setDefaultDestination(testReceiverMqId); auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - if (result != retval::RETURN_OK) { + if (result != retval::OK) { unitt::put_error(id); } MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - if (result != retval::RETURN_OK or recvMessage.getData()[0] != 42) { + if (result != retval::OK or recvMessage.getData()[0] != 42) { unitt::put_error(id); } result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - if (result != retval::RETURN_OK) { + if (result != retval::OK) { unitt::put_error(id); } MessageQueueId_t senderId = 0; result = testReceiverMq->receiveMessage(&recvMessage, &senderId); - if (result != retval::RETURN_OK or recvMessage.getData()[0] != 42) { + if (result != retval::OK or recvMessage.getData()[0] != 42) { unitt::put_error(id); } if (senderId != testSenderMqId) { diff --git a/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp b/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp index 8e1f2bdd..1e2a385c 100644 --- a/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp +++ b/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp @@ -8,24 +8,23 @@ #include "fsfw_tests/internal/UnittDefinitions.h" -using retval = HasReturnvaluesIF; std::array testserialize::test_array = {0}; ReturnValue_t testserialize::test_serialization() { // Here, we test all serialization tools. First test basic cases. ReturnValue_t result = test_endianness_tools(); - if (result != retval::RETURN_OK) { + if (result != retval::OK) { return result; } result = test_autoserialization(); - if (result != retval::RETURN_OK) { + if (result != retval::OK) { return result; } result = test_serial_buffer_adapter(); - if (result != retval::RETURN_OK) { + if (result != retval::OK) { return result; } - return retval::RETURN_OK; + return retval::OK; } ReturnValue_t testserialize::test_endianness_tools() { @@ -49,7 +48,7 @@ ReturnValue_t testserialize::test_endianness_tools() { if (test_array[0] != 0 and test_array[1] != 1) { return unitt::put_error(id); } - return retval::RETURN_OK; + return retval::OK; } ReturnValue_t testserialize::test_autoserialization() { @@ -153,7 +152,7 @@ ReturnValue_t testserialize::test_autoserialization() { } // Check overflow - return retval::RETURN_OK; + return retval::OK; } // TODO: Also test for constant buffers. @@ -206,5 +205,5 @@ ReturnValue_t testserialize::test_serial_buffer_adapter() { if (testUint16 != 16) { return unitt::put_error(id); } - return retval::RETURN_OK; + return retval::OK; } From 500a5602bd81d4530b7ae1e75f318f640d58a390 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 11:09:57 +0200 Subject: [PATCH 119/532] added additional TM store and send helper --- src/fsfw/pus/CService200ModeCommanding.cpp | 6 +-- src/fsfw/pus/Service17Test.cpp | 10 ++-- src/fsfw/pus/Service17Test.h | 4 +- .../pus/Service1TelecommandVerification.cpp | 7 +-- .../pus/Service1TelecommandVerification.h | 2 + src/fsfw/pus/Service20ParameterManagement.cpp | 6 +-- src/fsfw/pus/Service2DeviceAccess.cpp | 2 +- src/fsfw/pus/Service5EventReporting.cpp | 7 ++- src/fsfw/pus/Service5EventReporting.h | 3 +- src/fsfw/pus/Service8FunctionManagement.cpp | 2 +- src/fsfw/pus/Service8FunctionManagement.h | 2 +- src/fsfw/tmtcpacket/pus/PusIF.h | 4 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 8 +++ src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 2 + .../tmtcservices/CommandingServiceBase.cpp | 26 ++-------- src/fsfw/tmtcservices/CommandingServiceBase.h | 35 +++---------- src/fsfw/tmtcservices/TmSendHelper.h | 3 +- .../tmtcservices/TmStoreAndSendHelper.cpp | 50 ++++++++++++++++++- src/fsfw/tmtcservices/TmStoreAndSendHelper.h | 46 +++++++++++++++-- src/fsfw/tmtcservices/TmStoreHelper.cpp | 4 ++ src/fsfw/tmtcservices/TmStoreHelper.h | 2 + src/fsfw/tmtcservices/tmHelpers.cpp | 15 ------ src/fsfw_hal/linux/CommandExecutor.h | 14 +++--- unittests/tmtcservices/testSendHelper.cpp | 5 -- 24 files changed, 154 insertions(+), 111 deletions(-) diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index 9990280c..2e8e78a3 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -96,13 +96,13 @@ ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply ReturnValue_t CService200ModeCommanding::prepareModeReply(const CommandMessage *reply, object_id_t objectId) { ModePacket modeReplyPacket(objectId, ModeMessage::getMode(reply), ModeMessage::getSubmode(reply)); - return sendTmPacket(Subservice::REPLY_MODE_REPLY, modeReplyPacket); + return tmHelper.sendTmPacket(Subservice::REPLY_MODE_REPLY, modeReplyPacket); } ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMessage *reply, object_id_t objectId) { ModePacket wrongModeReply(objectId, ModeMessage::getMode(reply), ModeMessage::getSubmode(reply)); - ReturnValue_t result = sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, wrongModeReply); + ReturnValue_t result = tmHelper.sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, wrongModeReply); if (result == RETURN_OK) { // We want to produce an error here in any case because the mode was not correct return RETURN_FAILED; @@ -113,7 +113,7 @@ ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMess ReturnValue_t CService200ModeCommanding::prepareCantReachModeReply(const CommandMessage *reply, object_id_t objectId) { CantReachModePacket cantReachModePacket(objectId, ModeMessage::getCantReachModeReason(reply)); - ReturnValue_t result = sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, cantReachModePacket); + ReturnValue_t result = tmHelper.sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, cantReachModePacket); if (result == RETURN_OK) { // We want to produce an error here in any case because the mode was not reached return RETURN_FAILED; diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index 631cf939..b40d2d70 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -6,20 +6,20 @@ #include "fsfw/tmtcservices/tmHelpers.h" Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId) - : PusServiceBase(objectId, apid, serviceId), storeHelper(apid), packetSubCounter(0) {} + : PusServiceBase(objectId, apid, serviceId), + storeHelper(apid), + tmHelper(serviceId, storeHelper, sendHelper) {} Service17Test::~Service17Test() = default; ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { switch (subservice) { case Subservice::CONNECTION_TEST: { - storeHelper.preparePacket(serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter); - return telemetry::storeAndSendTmPacket(storeHelper, sendHelper); + return tmHelper.sendTmPacket(Subservice::CONNECTION_TEST_REPORT); } case Subservice::EVENT_TRIGGER_TEST: { - storeHelper.preparePacket(serviceId, Subservice::CONNECTION_TEST_REPORT, packetSubCounter++); triggerEvent(TEST, 1234, 5678); - return telemetry::storeAndSendTmPacket(storeHelper, sendHelper); + return tmHelper.sendTmPacket(Subservice::EVENT_TRIGGER_TEST); } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; diff --git a/src/fsfw/pus/Service17Test.h b/src/fsfw/pus/Service17Test.h index 54efcaa5..771fbe55 100644 --- a/src/fsfw/pus/Service17Test.h +++ b/src/fsfw/pus/Service17Test.h @@ -4,6 +4,7 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tmtcservices/PusServiceBase.h" #include "fsfw/tmtcservices/TmStoreHelper.h" +#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" /** * @brief Test Service @@ -45,8 +46,7 @@ class Service17Test : public PusServiceBase { protected: TmStoreHelper storeHelper; TmSendHelper sendHelper; - - uint16_t packetSubCounter = 0; + TmStoreAndSendWrapper tmHelper; }; #endif /* FSFW_PUS_SERVICE17TEST_H_ */ diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 7b5e7973..102ae5a0 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -15,7 +15,8 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t obj apid(apid), serviceId(serviceId), targetDestination(targetDestination), - storeHelper(apid) { + storeHelper(apid), + tmHelper(serviceId, storeHelper, sendHelper) { tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); } @@ -69,7 +70,7 @@ ReturnValue_t Service1TelecommandVerification::generateFailureReport( message->getParameter1(), message->getParameter2()); storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); storeHelper.setSourceDataSerializable(report); - return telemetry::storeAndSendTmPacket(storeHelper, sendHelper); + return tmHelper.storeAndSendTmPacket(); } ReturnValue_t Service1TelecommandVerification::generateSuccessReport( @@ -78,7 +79,7 @@ ReturnValue_t Service1TelecommandVerification::generateSuccessReport( message->getTcSequenceControl(), message->getStep()); storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); storeHelper.setSourceDataSerializable(report); - return telemetry::storeAndSendTmPacket(storeHelper, sendHelper); + return tmHelper.storeAndSendTmPacket(); } ReturnValue_t Service1TelecommandVerification::initialize() { diff --git a/src/fsfw/pus/Service1TelecommandVerification.h b/src/fsfw/pus/Service1TelecommandVerification.h index a87acdfe..5709e6a9 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.h +++ b/src/fsfw/pus/Service1TelecommandVerification.h @@ -9,6 +9,7 @@ #include "fsfw/tmtcservices/PusVerificationReport.h" #include "fsfw/tmtcservices/TmSendHelper.h" #include "fsfw/tmtcservices/TmStoreHelper.h" +#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" /** * @brief Verify TC acceptance, start, progress and execution. @@ -84,6 +85,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, TmSendHelper sendHelper; TmStoreHelper storeHelper; + TmStoreAndSendWrapper tmHelper; StorageManagerIF* tmStore = nullptr; MessageQueueIF* tmQueue = nullptr; diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index 0922793c..ccb5a3b5 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -14,7 +14,7 @@ Service20ParameterManagement::Service20ParameterManagement(object_id_t objectId, : CommandingServiceBase(objectId, apid, serviceId, numberOfParallelCommands, commandTimeoutSeconds) {} -Service20ParameterManagement::~Service20ParameterManagement() {} +Service20ParameterManagement::~Service20ParameterManagement() = default; ReturnValue_t Service20ParameterManagement::isValidSubservice(uint8_t subservice) { switch (static_cast(subservice)) { @@ -64,7 +64,7 @@ ReturnValue_t Service20ParameterManagement::checkAndAcquireTargetID(object_id_t* ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue( MessageQueueId_t* messageQueueToSet, object_id_t* objectId) { // check ReceivesParameterMessagesIF property of target - ReceivesParameterMessagesIF* possibleTarget = + auto* possibleTarget = ObjectManager::instance()->get(*objectId); if (possibleTarget == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -177,7 +177,7 @@ ReturnValue_t Service20ParameterManagement::handleReply(const CommandMessage* re ParameterId_t parameterId = ParameterMessage::getParameterId(reply); ParameterDumpReply parameterReply(objectId, parameterId, parameterData.second.data(), parameterData.second.size()); - sendTmPacket(static_cast(Subservice::PARAMETER_DUMP_REPLY), parameterReply); + tmHelper.sendTmPacket(static_cast(Subservice::PARAMETER_DUMP_REPLY), parameterReply); return HasReturnvaluesIF::RETURN_OK; } default: diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index 8060b2b6..008d8128 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -148,7 +148,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs // Init our dummy packet and correct endianness of object ID before // sending it back. WiretappingPacket tmPacket(DeviceHandlerMessage::getDeviceObjectId(reply), data); - sendTmPacket(subservice, tmPacket.objectId, tmPacket.data, size); + tmHelper.sendTmPacket(subservice, tmPacket.objectId, tmPacket.data, size); } MessageQueueId_t Service2DeviceAccess::getDeviceQueue() { return commandQueue->getId(); } diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index 44f7861a..a895ad0d 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -12,6 +12,7 @@ Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t ap uint32_t messageQueueDepth) : PusServiceBase(objectId, apid, serviceId), storeHelper(apid), + tmHelper(serviceId, storeHelper, sendHelper), maxNumberReportsPerCycle(maxNumberReportsPerCycle) { eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); } @@ -46,9 +47,9 @@ ReturnValue_t Service5EventReporting::performService() { ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) { EventReport report(message.getEventId(), message.getReporter(), message.getParameter1(), message.getParameter2()); - storeHelper.preparePacket(serviceId, message.getSeverity(), packetSubCounter); + storeHelper.preparePacket(serviceId, message.getSeverity(), tmHelper.sendCounter); storeHelper.setSourceDataSerializable(report); - ReturnValue_t result = telemetry::storeAndSendTmPacket(storeHelper, sendHelper); + ReturnValue_t result = tmHelper.storeAndSendTmPacket(); if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service5EventReporting::generateEventReport: " @@ -59,8 +60,6 @@ ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) "Service5EventReporting::generateEventReport: " "Could not send TM packet\n"); #endif - } else { - packetSubCounter++; } return result; } diff --git a/src/fsfw/pus/Service5EventReporting.h b/src/fsfw/pus/Service5EventReporting.h index a357e5fc..fcbdcb6b 100644 --- a/src/fsfw/pus/Service5EventReporting.h +++ b/src/fsfw/pus/Service5EventReporting.h @@ -2,6 +2,7 @@ #define FSFW_PUS_SERVICE5EVENTREPORTING_H_ #include "fsfw/events/EventMessage.h" +#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" #include "fsfw/tmtcservices/PusServiceBase.h" /** @@ -74,11 +75,11 @@ class Service5EventReporting : public PusServiceBase { }; private: - uint16_t packetSubCounter = 0; MessageQueueIF* eventQueue = nullptr; bool enableEventReport = true; TmSendHelper sendHelper; TmStoreHelper storeHelper; + TmStoreAndSendWrapper tmHelper; const uint8_t maxNumberReportsPerCycle; ReturnValue_t generateEventReport(EventMessage message); diff --git a/src/fsfw/pus/Service8FunctionManagement.cpp b/src/fsfw/pus/Service8FunctionManagement.cpp index c9da6d58..cec4e423 100644 --- a/src/fsfw/pus/Service8FunctionManagement.cpp +++ b/src/fsfw/pus/Service8FunctionManagement.cpp @@ -138,7 +138,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* return result; } DataReply dataReply(objectId, actionId, buffer, size); - result = sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), dataReply); + result = tmHelper.sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), dataReply); auto deletionResult = ipcStore->deleteData(storeId); if (deletionResult != HasReturnvaluesIF::RETURN_OK) { diff --git a/src/fsfw/pus/Service8FunctionManagement.h b/src/fsfw/pus/Service8FunctionManagement.h index 649b3257..38aaf4f4 100644 --- a/src/fsfw/pus/Service8FunctionManagement.h +++ b/src/fsfw/pus/Service8FunctionManagement.h @@ -32,7 +32,7 @@ class Service8FunctionManagement : public CommandingServiceBase { public: Service8FunctionManagement(object_id_t objectId, uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands = 4, uint16_t commandTimeoutSeconds = 60); - virtual ~Service8FunctionManagement(); + ~Service8FunctionManagement() override; protected: /* CSB abstract functions implementation . See CSB documentation. */ diff --git a/src/fsfw/tmtcpacket/pus/PusIF.h b/src/fsfw/tmtcpacket/pus/PusIF.h index 8c346b1d..93223ba8 100644 --- a/src/fsfw/tmtcpacket/pus/PusIF.h +++ b/src/fsfw/tmtcpacket/pus/PusIF.h @@ -10,9 +10,9 @@ class PusIF : public SpacePacketIF { public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::PUS_IF; static constexpr ReturnValue_t INVALID_PUS_VERSION = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); + retval::makeCode(INTERFACE_ID, 0); static constexpr ReturnValue_t INVALID_CRC_16 = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); + retval::makeCode(INTERFACE_ID, 1); ~PusIF() override = default; /** diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 662e74be..71149613 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -133,3 +133,11 @@ ReturnValue_t PusTmCreator::setSerializableUserData(SerializeIF& serializable) { updateSpLengthField(); return HasReturnvaluesIF::RETURN_OK; } + +void PusTmCreator::setService(uint8_t service) { + pusParams.secHeader.service = service; +} + +void PusTmCreator::setSubservice(uint8_t subservice) { + pusParams.secHeader.subservice = subservice; +} diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 7df760ce..41f72c38 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -49,6 +49,8 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF SpacePacketParams& getSpParams(); void setApid(uint16_t apid); void setDestId(uint16_t destId); + void setService(uint8_t service); + void setSubservice(uint8_t subservice); void setMessageTypeCounter(uint16_t messageTypeCounter); PusTmParams& getParams(); void updateSpLengthField(); diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 10cc2689..7839aa87 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -21,6 +21,7 @@ CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t a service(service), timeoutSeconds(commandTimeoutSeconds), tmStoreHelper(apid), + tmHelper(service, tmStoreHelper, tmSendHelper), commandMap(numberOfParallelCommands) { commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth); @@ -286,35 +287,16 @@ void CommandingServiceBase::handleRequestQueue() { ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen) { - tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); - tmStoreHelper.setSourceDataRaw(sourceData, sourceDataLen); - ReturnValue_t result = telemetry::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); - if (result == HasReturnvaluesIF::RETURN_OK) { - this->tmPacketCounter++; - } - return result; + return tmHelper.sendTmPacket(subservice, sourceData, sourceDataLen); } ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_t objectId, const uint8_t* data, size_t dataLen) { - telemetry::DataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); - tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); - tmStoreHelper.setSourceDataSerializable(dataWithObjId); - ReturnValue_t result = telemetry::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); - if (result == HasReturnvaluesIF::RETURN_OK) { - this->tmPacketCounter++; - } - return result; + return tmHelper.sendTmPacket(subservice, objectId, data, dataLen); } ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeIF& sourceData) { - tmStoreHelper.preparePacket(service, subservice, tmPacketCounter); - tmStoreHelper.setSourceDataSerializable(sourceData); - ReturnValue_t result = telemetry::storeAndSendTmPacket(tmStoreHelper, tmSendHelper); - if (result == HasReturnvaluesIF::RETURN_OK) { - this->tmPacketCounter++; - } - return result; + return tmHelper.sendTmPacket(subservice, sourceData); } void CommandingServiceBase::startExecution(store_address_t storeId, CommandMapIter iter) { diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 48575724..e96c02d7 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -6,6 +6,7 @@ #include "TmStoreHelper.h" #include "VerificationReporter.h" #include "fsfw/FSFW.h" +#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" #include "fsfw/container/FIFO.h" #include "fsfw/container/FixedMap.h" #include "fsfw/ipc/CommandMessage.h" @@ -251,18 +252,15 @@ class CommandingServiceBase : public SystemObject, const uint16_t timeoutSeconds; - uint8_t tmPacketCounter = 0; - - StorageManagerIF* ipcStore = nullptr; - PusTcReader tcReader; TmStoreHelper tmStoreHelper; TmSendHelper tmSendHelper; + TmStoreAndSendWrapper tmHelper; StorageManagerIF* tcStore = nullptr; + StorageManagerIF* ipcStore = nullptr; MessageQueueIF* commandQueue = nullptr; - MessageQueueIF* requestQueue = nullptr; VerificationReporter verificationReporter; @@ -286,33 +284,12 @@ class CommandingServiceBase : public SystemObject, */ PeriodicTaskIF* executingTask = nullptr; - /** - * @brief Send TM data from pointer to data. - * If a header is supplied it is added before data - * @param subservice Number of subservice - * @param sourceData Custom source data - * @param sourceDataLen Lenght of data in the Packet - */ + [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen); - - /** - * @brief To send TM packets of objects that still need to be serialized - * and consist of an object ID with appended data. - * @param subservice Number of subservice - * @param objectId ObjectId is placed before data - * @param data Data to append to the packet - * @param dataLen Length of Data - */ + [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket(uint8_t subservice, object_id_t objectId, const uint8_t* data, size_t dataLen); - - /** - * @brief To send packets which are contained inside a class implementing - * SerializeIF. - * @param subservice Number of subservice - * @param content This is a pointer to the serialized packet - * @param header Serialize IF header which will be placed before content - */ + [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF& sourceData); void checkAndExecuteFifo(CommandMapIter& iter); diff --git a/src/fsfw/tmtcservices/TmSendHelper.h b/src/fsfw/tmtcservices/TmSendHelper.h index dee5a495..c4bec886 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.h +++ b/src/fsfw/tmtcservices/TmSendHelper.h @@ -16,7 +16,7 @@ class TmSendHelper { explicit TmSendHelper(InternalErrorReporterIF& reporter); void setMsgQueue(MessageQueueIF& queue); - MessageQueueIF* getMsgQueue() const; + [[nodiscard]] MessageQueueIF* getMsgQueue() const; void setDefaultDestination(MessageQueueId_t msgDest); [[nodiscard]] MessageQueueId_t getDefaultDestination() const; @@ -28,6 +28,7 @@ class TmSendHelper { ReturnValue_t sendPacket(MessageQueueId_t dest, const store_address_t& storeId); ReturnValue_t sendPacket(const store_address_t& storeId); + private: MessageQueueId_t defaultDest = MessageQueueIF::NO_QUEUE; bool ignoreFault = false; diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp index 9e858ed6..f10bea32 100644 --- a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp @@ -1,3 +1,51 @@ #include "TmStoreAndSendHelper.h" +#include "tmHelpers.h" -StoreAndSendWrapper::StoreAndSendWrapper(TmStoreHelper& storeHelper, TmSendHelper& sendHelper) {} +TmStoreAndSendWrapper::TmStoreAndSendWrapper( + uint8_t defaultService, TmStoreHelper& storeHelper, TmSendHelper& sendHelper) + : storeHelper(storeHelper), sendHelper(sendHelper), defaultService(defaultService){} + +ReturnValue_t TmStoreAndSendWrapper::storeAndSendTmPacket() { + ReturnValue_t result = storeHelper.addPacketToStore(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = sendHelper.sendPacket(storeHelper.getCurrentAddr()); + if (result != HasReturnvaluesIF::RETURN_OK) { + if (delOnFailure) { + storeHelper.deletePacket(); + } + return result; + } + if(incrementSendCounter) { + sendCounter++; + } + return result; +} + +ReturnValue_t TmStoreAndSendWrapper::sendTmPacket(uint8_t subservice, const uint8_t* sourceData, + size_t sourceDataLen) { + storeHelper.preparePacket(defaultService, subservice, sendCounter); + storeHelper.setSourceDataRaw(sourceData, sourceDataLen); + return storeAndSendTmPacket(); +} + +ReturnValue_t TmStoreAndSendWrapper::sendTmPacket(uint8_t subservice, object_id_t objectId, + const uint8_t* data, size_t dataLen) { + telemetry::DataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); + storeHelper.preparePacket(defaultService, subservice, sendCounter); + storeHelper.setSourceDataSerializable(dataWithObjId); + return storeAndSendTmPacket(); +} + +ReturnValue_t TmStoreAndSendWrapper::sendTmPacket(uint8_t subservice, SerializeIF& sourceData) { + storeHelper.preparePacket(defaultService, subservice, sendCounter); + storeHelper.setSourceDataSerializable(sourceData); + return storeAndSendTmPacket(); +} + +ReturnValue_t TmStoreAndSendWrapper::sendTmPacket(uint8_t subservice) { + storeHelper.preparePacket(defaultService, subservice, sendCounter); + storeHelper.setSourceDataRaw(nullptr, 0); + return storeAndSendTmPacket(); +} diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.h b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h index d75d6839..44ad1799 100644 --- a/src/fsfw/tmtcservices/TmStoreAndSendHelper.h +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h @@ -4,15 +4,51 @@ #include "TmSendHelper.h" #include "TmStoreHelper.h" -class StoreAndSendWrapper { +/** + * Wrapper class intended to help with PUS TM handling. This wrapper class also caches the current packet count + * and the service ID + */ +class TmStoreAndSendWrapper { public: - StoreAndSendWrapper(TmStoreHelper& storeHelper, TmSendHelper& sendHelper) - : storeHelper(storeHelper), sendHelper(sendHelper) {} - ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper, - bool delOnFailure = true); + TmStoreAndSendWrapper(uint8_t defaultService, TmStoreHelper& storeHelper, TmSendHelper& sendHelper); + ReturnValue_t storeAndSendTmPacket(); + + ReturnValue_t sendTmPacket(uint8_t subservice); + /** + * @brief Send TM data from pointer to data. + * If a header is supplied it is added before data + * @param subservice Number of subservice + * @param sourceData Custom source data + * @param sourceDataLen Lenght of data in the Packet + */ + ReturnValue_t sendTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen); + + /** + * @brief To send TM packets of objects that still need to be serialized + * and consist of an object ID with appended data. + * @param subservice Number of subservice + * @param objectId ObjectId is placed before data + * @param data Data to append to the packet + * @param dataLen Length of Data + */ + ReturnValue_t sendTmPacket(uint8_t subservice, object_id_t objectId, const uint8_t* data, + size_t dataLen); + + /** + * @brief To send packets which are contained inside a class implementing + * SerializeIF. + * @param subservice Number of subservice + * @param content This is a pointer to the serialized packet + * @param header Serialize IF header which will be placed before content + */ + ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF& sourceData); + + bool incrementSendCounter = true; TmStoreHelper& storeHelper; TmSendHelper& sendHelper; bool delOnFailure = true; + uint8_t defaultService = 0; + uint16_t sendCounter = 0; }; #endif // FSFW_TMTCSERVICES_TMSTOREANDSENDHELPER_H diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index eb538518..a8105ae0 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -71,3 +71,7 @@ PusTmCreator& TmStoreHelper::getCreatorRef() { return creator; } TimeStamperIF* TmStoreHelper::getTimeStamper() const { return creator.getTimestamper(); } uint16_t TmStoreHelper::getApid() const { return creator.getApid(); } + +ReturnValue_t TmStoreHelper::setService(uint8_t service) { creator.setService(service); } + +ReturnValue_t TmStoreHelper::setSubservice(uint8_t subservice) { creator.setSubservice(subservice); } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index 3a868d97..6c18ac7f 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -27,6 +27,8 @@ class TmStoreHelper { [[nodiscard]] uint16_t getApid() const; [[nodiscard]] const store_address_t& getCurrentAddr() const; + ReturnValue_t setService(uint8_t service); + ReturnValue_t setSubservice(uint8_t subservice); ReturnValue_t setSourceDataRaw(const uint8_t* data, size_t len); ReturnValue_t setSourceDataSerializable(SerializeIF& serializable); diff --git a/src/fsfw/tmtcservices/tmHelpers.cpp b/src/fsfw/tmtcservices/tmHelpers.cpp index 50b40c76..abe2ae78 100644 --- a/src/fsfw/tmtcservices/tmHelpers.cpp +++ b/src/fsfw/tmtcservices/tmHelpers.cpp @@ -1,16 +1 @@ #include "tmHelpers.h" - -ReturnValue_t telemetry::storeAndSendTmPacket(TmStoreHelper &storeHelper, TmSendHelper &sendHelper, - bool delOnFailure) { - ReturnValue_t result = storeHelper.addPacketToStore(); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = sendHelper.sendPacket(storeHelper.getCurrentAddr()); - if (result != HasReturnvaluesIF::RETURN_OK) { - if (delOnFailure) { - storeHelper.deletePacket(); - } - } - return result; -} diff --git a/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h index 90662c0f..f5c7a803 100644 --- a/src/fsfw_hal/linux/CommandExecutor.h +++ b/src/fsfw_hal/linux/CommandExecutor.h @@ -32,26 +32,26 @@ class CommandExecutor { //! [EXPORT] : [COMMENT] Execution of the current command has finished static constexpr ReturnValue_t EXECUTION_FINISHED = - HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0); + retval::makeCode(CLASS_ID, 0); //! [EXPORT] : [COMMENT] Command is pending. This will also be returned if the user tries //! to load another command but a command is still pending - static constexpr ReturnValue_t COMMAND_PENDING = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); + static constexpr ReturnValue_t COMMAND_PENDING = retval::makeCode(CLASS_ID, 1); //! [EXPORT] : [COMMENT] Some bytes have been read from the executing process - static constexpr ReturnValue_t BYTES_READ = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); + static constexpr ReturnValue_t BYTES_READ = retval::makeCode(CLASS_ID, 2); //! [EXPORT] : [COMMENT] Command execution failed - static constexpr ReturnValue_t COMMAND_ERROR = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); + static constexpr ReturnValue_t COMMAND_ERROR = retval::makeCode(CLASS_ID, 3); //! [EXPORT] : [COMMENT] static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = - HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4); - static constexpr ReturnValue_t PCLOSE_CALL_ERROR = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 6); + retval::makeCode(CLASS_ID, 4); + static constexpr ReturnValue_t PCLOSE_CALL_ERROR =retval::makeCode(CLASS_ID, 6); /** * Constructor. Is initialized with maximum size of internal buffer to read data from the * executed process. * @param maxSize */ - CommandExecutor(const size_t maxSize); + explicit CommandExecutor(size_t maxSize); /** * Load a new command which should be executed diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 17a1d990..4271f192 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -68,11 +68,6 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") { storeId = storeHelper.getCurrentAddr(); REQUIRE(sendHelper.sendPacket(storeId) == HasReturnvaluesIF::RETURN_OK); } - SECTION("Helper Wrapper") { - REQUIRE(telemetry::storeAndSendTmPacket(storeHelper, sendHelper) == - HasReturnvaluesIF::RETURN_OK); - storeId = storeHelper.getCurrentAddr(); - } REQUIRE(msgQueue.wasMessageSent()); REQUIRE(msgQueue.numberOfSentMessagesToDefault() == 1); TmTcMessage msg; From f1c37203a48cce0660951779310e12f4d36cf0a5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 11:14:40 +0200 Subject: [PATCH 120/532] some more API improvements and replacements --- automation/Jenkinsfile | 2 +- scripts/helper.py | 2 +- src/fsfw/cfdp/definitions.h | 21 +++++++------------ src/fsfw/pus/CService200ModeCommanding.cpp | 3 ++- src/fsfw/pus/CService201HealthCommanding.cpp | 2 +- src/fsfw/pus/Service17Test.h | 2 +- .../pus/Service1TelecommandVerification.h | 2 +- src/fsfw/pus/Service20ParameterManagement.cpp | 3 +-- src/fsfw/pus/Service3Housekeeping.cpp | 3 ++- src/fsfw/pus/Service5EventReporting.h | 2 +- src/fsfw/pus/Service8FunctionManagement.cpp | 3 ++- src/fsfw/tmtcpacket/pus/PusIF.h | 6 ++---- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 4 +--- src/fsfw/tmtcservices/CommandingServiceBase.h | 15 +++++++------ src/fsfw/tmtcservices/TmSendHelper.h | 1 - .../tmtcservices/TmStoreAndSendHelper.cpp | 9 ++++---- src/fsfw/tmtcservices/TmStoreAndSendHelper.h | 7 ++++--- src/fsfw/tmtcservices/TmStoreHelper.cpp | 11 +++++----- src/fsfw/tmtcservices/TmStoreHelper.h | 4 ++-- src/fsfw_hal/linux/CommandExecutor.h | 8 +++---- 20 files changed, 49 insertions(+), 61 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index c5dcbe02..02340190 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,6 +1,6 @@ pipeline { environment { - BUILDDIR = 'build-tests' + BUILDDIR = 'cmake-build-tests' } agent { docker { image 'fsfw-ci:d3'} diff --git a/scripts/helper.py b/scripts/helper.py index 0ac616b6..0ced7186 100755 --- a/scripts/helper.py +++ b/scripts/helper.py @@ -13,7 +13,7 @@ from shutil import which from typing import List -UNITTEST_FOLDER_NAME = "build-tests" +UNITTEST_FOLDER_NAME = "cmake-build-tests" DOCS_FOLDER_NAME = "build-docs" diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 93d15bcb..c532f3c1 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -15,24 +15,17 @@ static constexpr uint8_t VERSION_BITS = 0b00100000; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; -static constexpr ReturnValue_t INVALID_TLV_TYPE = - retval::makeCode(CFDP_CLASS_ID, 1); -static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = - retval::makeCode(CFDP_CLASS_ID, 2); -static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = - retval::makeCode(CFDP_CLASS_ID, 3); -static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = - retval::makeCode(CFDP_CLASS_ID, 4); +static constexpr ReturnValue_t INVALID_TLV_TYPE = retval::makeCode(CFDP_CLASS_ID, 1); +static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = retval::makeCode(CFDP_CLASS_ID, 2); +static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = retval::makeCode(CFDP_CLASS_ID, 3); +static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = retval::makeCode(CFDP_CLASS_ID, 4); //! Can not parse options. This can also occur because there are options //! available but the user did not pass a valid options array -static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = - retval::makeCode(CFDP_CLASS_ID, 5); -static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = - retval::makeCode(CFDP_CLASS_ID, 6); +static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = retval::makeCode(CFDP_CLASS_ID, 5); +static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = retval::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES = retval::makeCode(CFDP_CLASS_ID, 6); -static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = - retval::makeCode(CFDP_CLASS_ID, 8); +static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = retval::makeCode(CFDP_CLASS_ID, 8); //! Can not parse filestore response because user did not pass a valid instance //! or remaining size is invalid static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE = diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index 2e8e78a3..ea60d00b 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -113,7 +113,8 @@ ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMess ReturnValue_t CService200ModeCommanding::prepareCantReachModeReply(const CommandMessage *reply, object_id_t objectId) { CantReachModePacket cantReachModePacket(objectId, ModeMessage::getCantReachModeReason(reply)); - ReturnValue_t result = tmHelper.sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, cantReachModePacket); + ReturnValue_t result = + tmHelper.sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, cantReachModePacket); if (result == RETURN_OK) { // We want to produce an error here in any case because the mode was not reached return RETURN_FAILED; diff --git a/src/fsfw/pus/CService201HealthCommanding.cpp b/src/fsfw/pus/CService201HealthCommanding.cpp index c668ea52..4588907f 100644 --- a/src/fsfw/pus/CService201HealthCommanding.cpp +++ b/src/fsfw/pus/CService201HealthCommanding.cpp @@ -102,5 +102,5 @@ ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *rep auto health = static_cast(HealthMessage::getHealth(reply)); auto oldHealth = static_cast(HealthMessage::getOldHealth(reply)); HealthSetReply healthSetReply(health, oldHealth); - return sendTmPacket(Subservice::REPLY_HEALTH_SET, healthSetReply); + return tmHelper.sendTmPacket(Subservice::REPLY_HEALTH_SET, healthSetReply); } diff --git a/src/fsfw/pus/Service17Test.h b/src/fsfw/pus/Service17Test.h index 771fbe55..7e2db98b 100644 --- a/src/fsfw/pus/Service17Test.h +++ b/src/fsfw/pus/Service17Test.h @@ -3,8 +3,8 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tmtcservices/PusServiceBase.h" -#include "fsfw/tmtcservices/TmStoreHelper.h" #include "fsfw/tmtcservices/TmStoreAndSendHelper.h" +#include "fsfw/tmtcservices/TmStoreHelper.h" /** * @brief Test Service diff --git a/src/fsfw/pus/Service1TelecommandVerification.h b/src/fsfw/pus/Service1TelecommandVerification.h index 5709e6a9..dcbb5017 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.h +++ b/src/fsfw/pus/Service1TelecommandVerification.h @@ -8,8 +8,8 @@ #include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" #include "fsfw/tmtcservices/TmSendHelper.h" -#include "fsfw/tmtcservices/TmStoreHelper.h" #include "fsfw/tmtcservices/TmStoreAndSendHelper.h" +#include "fsfw/tmtcservices/TmStoreHelper.h" /** * @brief Verify TC acceptance, start, progress and execution. diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index ccb5a3b5..5f479530 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -64,8 +64,7 @@ ReturnValue_t Service20ParameterManagement::checkAndAcquireTargetID(object_id_t* ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue( MessageQueueId_t* messageQueueToSet, object_id_t* objectId) { // check ReceivesParameterMessagesIF property of target - auto* possibleTarget = - ObjectManager::instance()->get(*objectId); + auto* possibleTarget = ObjectManager::instance()->get(*objectId); if (possibleTarget == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service20ParameterManagement::checkInterfaceAndAcquire" diff --git a/src/fsfw/pus/Service3Housekeeping.cpp b/src/fsfw/pus/Service3Housekeeping.cpp index 7ef5636d..df7cbe0a 100644 --- a/src/fsfw/pus/Service3Housekeeping.cpp +++ b/src/fsfw/pus/Service3Housekeeping.cpp @@ -290,7 +290,8 @@ ReturnValue_t Service3Housekeeping::generateHkReply(const CommandMessage* hkMess } HkPacket hkPacket(sid, resultPair.second.data(), resultPair.second.size()); - return sendTmPacket(static_cast(subserviceId), hkPacket.hkData, hkPacket.hkSize); + return tmHelper.sendTmPacket(static_cast(subserviceId), hkPacket.hkData, + hkPacket.hkSize); } sid_t Service3Housekeeping::buildSid(object_id_t objectId, const uint8_t** tcData, diff --git a/src/fsfw/pus/Service5EventReporting.h b/src/fsfw/pus/Service5EventReporting.h index fcbdcb6b..e6f67bfd 100644 --- a/src/fsfw/pus/Service5EventReporting.h +++ b/src/fsfw/pus/Service5EventReporting.h @@ -2,8 +2,8 @@ #define FSFW_PUS_SERVICE5EVENTREPORTING_H_ #include "fsfw/events/EventMessage.h" -#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" #include "fsfw/tmtcservices/PusServiceBase.h" +#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" /** * @brief Report on-board events like information or errors diff --git a/src/fsfw/pus/Service8FunctionManagement.cpp b/src/fsfw/pus/Service8FunctionManagement.cpp index cec4e423..f9a6a168 100644 --- a/src/fsfw/pus/Service8FunctionManagement.cpp +++ b/src/fsfw/pus/Service8FunctionManagement.cpp @@ -138,7 +138,8 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* return result; } DataReply dataReply(objectId, actionId, buffer, size); - result = tmHelper.sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), dataReply); + result = tmHelper.sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), + dataReply); auto deletionResult = ipcStore->deleteData(storeId); if (deletionResult != HasReturnvaluesIF::RETURN_OK) { diff --git a/src/fsfw/tmtcpacket/pus/PusIF.h b/src/fsfw/tmtcpacket/pus/PusIF.h index 93223ba8..5f27846e 100644 --- a/src/fsfw/tmtcpacket/pus/PusIF.h +++ b/src/fsfw/tmtcpacket/pus/PusIF.h @@ -9,10 +9,8 @@ class PusIF : public SpacePacketIF { public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::PUS_IF; - static constexpr ReturnValue_t INVALID_PUS_VERSION = - retval::makeCode(INTERFACE_ID, 0); - static constexpr ReturnValue_t INVALID_CRC_16 = - retval::makeCode(INTERFACE_ID, 1); + static constexpr ReturnValue_t INVALID_PUS_VERSION = retval::makeCode(INTERFACE_ID, 0); + static constexpr ReturnValue_t INVALID_CRC_16 = retval::makeCode(INTERFACE_ID, 1); ~PusIF() override = default; /** diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 71149613..ddcad33e 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -134,9 +134,7 @@ ReturnValue_t PusTmCreator::setSerializableUserData(SerializeIF& serializable) { return HasReturnvaluesIF::RETURN_OK; } -void PusTmCreator::setService(uint8_t service) { - pusParams.secHeader.service = service; -} +void PusTmCreator::setService(uint8_t service) { pusParams.secHeader.service = service; } void PusTmCreator::setSubservice(uint8_t subservice) { pusParams.secHeader.subservice = subservice; diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index e96c02d7..63067b07 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -6,7 +6,6 @@ #include "TmStoreHelper.h" #include "VerificationReporter.h" #include "fsfw/FSFW.h" -#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" #include "fsfw/container/FIFO.h" #include "fsfw/container/FixedMap.h" #include "fsfw/ipc/CommandMessage.h" @@ -15,6 +14,7 @@ #include "fsfw/serialize/SerializeIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" namespace Factory { void setStaticFrameworkObjectIds(); @@ -284,13 +284,12 @@ class CommandingServiceBase : public SystemObject, */ PeriodicTaskIF* executingTask = nullptr; - [[deprecated("Use function with same name provided by tmHelper")]] - ReturnValue_t sendTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen); - [[deprecated("Use function with same name provided by tmHelper")]] - ReturnValue_t sendTmPacket(uint8_t subservice, object_id_t objectId, const uint8_t* data, - size_t dataLen); - [[deprecated("Use function with same name provided by tmHelper")]] - ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF& sourceData); + [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket( + uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen); + [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket( + uint8_t subservice, object_id_t objectId, const uint8_t* data, size_t dataLen); + [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket( + uint8_t subservice, SerializeIF& sourceData); void checkAndExecuteFifo(CommandMapIter& iter); diff --git a/src/fsfw/tmtcservices/TmSendHelper.h b/src/fsfw/tmtcservices/TmSendHelper.h index c4bec886..244e7900 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.h +++ b/src/fsfw/tmtcservices/TmSendHelper.h @@ -28,7 +28,6 @@ class TmSendHelper { ReturnValue_t sendPacket(MessageQueueId_t dest, const store_address_t& storeId); ReturnValue_t sendPacket(const store_address_t& storeId); - private: MessageQueueId_t defaultDest = MessageQueueIF::NO_QUEUE; bool ignoreFault = false; diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp index f10bea32..61735ab5 100644 --- a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp @@ -1,9 +1,10 @@ #include "TmStoreAndSendHelper.h" + #include "tmHelpers.h" -TmStoreAndSendWrapper::TmStoreAndSendWrapper( - uint8_t defaultService, TmStoreHelper& storeHelper, TmSendHelper& sendHelper) - : storeHelper(storeHelper), sendHelper(sendHelper), defaultService(defaultService){} +TmStoreAndSendWrapper::TmStoreAndSendWrapper(uint8_t defaultService, TmStoreHelper& storeHelper, + TmSendHelper& sendHelper) + : storeHelper(storeHelper), sendHelper(sendHelper), defaultService(defaultService) {} ReturnValue_t TmStoreAndSendWrapper::storeAndSendTmPacket() { ReturnValue_t result = storeHelper.addPacketToStore(); @@ -17,7 +18,7 @@ ReturnValue_t TmStoreAndSendWrapper::storeAndSendTmPacket() { } return result; } - if(incrementSendCounter) { + if (incrementSendCounter) { sendCounter++; } return result; diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.h b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h index 44ad1799..1a33b7d7 100644 --- a/src/fsfw/tmtcservices/TmStoreAndSendHelper.h +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h @@ -5,12 +5,13 @@ #include "TmStoreHelper.h" /** - * Wrapper class intended to help with PUS TM handling. This wrapper class also caches the current packet count - * and the service ID + * Wrapper class intended to help with PUS TM handling. This wrapper class also caches the current + * packet count and the service ID */ class TmStoreAndSendWrapper { public: - TmStoreAndSendWrapper(uint8_t defaultService, TmStoreHelper& storeHelper, TmSendHelper& sendHelper); + TmStoreAndSendWrapper(uint8_t defaultService, TmStoreHelper& storeHelper, + TmSendHelper& sendHelper); ReturnValue_t storeAndSendTmPacket(); ReturnValue_t sendTmPacket(uint8_t subservice); diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index a8105ae0..a87ca01d 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -18,10 +18,9 @@ TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, } ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, uint16_t counter) { - PusTmParams& params = creator.getParams(); - params.secHeader.service = service; - params.secHeader.subservice = subservice; - params.secHeader.messageTypeCounter = counter; + creator.setService(service); + creator.setSubservice(subservice); + creator.setMessageTypeCounter(counter); return HasReturnvaluesIF::RETURN_OK; } @@ -72,6 +71,6 @@ TimeStamperIF* TmStoreHelper::getTimeStamper() const { return creator.getTimesta uint16_t TmStoreHelper::getApid() const { return creator.getApid(); } -ReturnValue_t TmStoreHelper::setService(uint8_t service) { creator.setService(service); } +void TmStoreHelper::setService(uint8_t service) { creator.setService(service); } -ReturnValue_t TmStoreHelper::setSubservice(uint8_t subservice) { creator.setSubservice(subservice); } +void TmStoreHelper::setSubservice(uint8_t subservice) { creator.setSubservice(subservice); } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index 6c18ac7f..e5d9eb7d 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -27,8 +27,8 @@ class TmStoreHelper { [[nodiscard]] uint16_t getApid() const; [[nodiscard]] const store_address_t& getCurrentAddr() const; - ReturnValue_t setService(uint8_t service); - ReturnValue_t setSubservice(uint8_t subservice); + void setService(uint8_t service); + void setSubservice(uint8_t subservice); ReturnValue_t setSourceDataRaw(const uint8_t* data, size_t len); ReturnValue_t setSourceDataSerializable(SerializeIF& serializable); diff --git a/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h index f5c7a803..27e78260 100644 --- a/src/fsfw_hal/linux/CommandExecutor.h +++ b/src/fsfw_hal/linux/CommandExecutor.h @@ -31,8 +31,7 @@ class CommandExecutor { static constexpr uint8_t CLASS_ID = CLASS_ID::LINUX_OSAL; //! [EXPORT] : [COMMENT] Execution of the current command has finished - static constexpr ReturnValue_t EXECUTION_FINISHED = - retval::makeCode(CLASS_ID, 0); + static constexpr ReturnValue_t EXECUTION_FINISHED = retval::makeCode(CLASS_ID, 0); //! [EXPORT] : [COMMENT] Command is pending. This will also be returned if the user tries //! to load another command but a command is still pending @@ -42,9 +41,8 @@ class CommandExecutor { //! [EXPORT] : [COMMENT] Command execution failed static constexpr ReturnValue_t COMMAND_ERROR = retval::makeCode(CLASS_ID, 3); //! [EXPORT] : [COMMENT] - static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = - retval::makeCode(CLASS_ID, 4); - static constexpr ReturnValue_t PCLOSE_CALL_ERROR =retval::makeCode(CLASS_ID, 6); + static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = retval::makeCode(CLASS_ID, 4); + static constexpr ReturnValue_t PCLOSE_CALL_ERROR = retval::makeCode(CLASS_ID, 6); /** * Constructor. Is initialized with maximum size of internal buffer to read data from the From 332e9dbfd54fc02bdab1ff95e751c23a274b3532 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 11:19:36 +0200 Subject: [PATCH 121/532] add new tests --- unittests/tmtcservices/testSendHelper.cpp | 1 - .../tmtcservices/testStoreAndSendHelper.cpp | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 unittests/tmtcservices/testStoreAndSendHelper.cpp diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 4271f192..786fe073 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -3,7 +3,6 @@ #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tmtcservices/TmSendHelper.h" #include "fsfw/tmtcservices/TmStoreHelper.h" -#include "fsfw/tmtcservices/tmHelpers.h" #include "mocks/CdsShortTimestamperMock.h" #include "mocks/InternalErrorReporterMock.h" #include "mocks/MessageQueueMock.h" diff --git a/unittests/tmtcservices/testStoreAndSendHelper.cpp b/unittests/tmtcservices/testStoreAndSendHelper.cpp new file mode 100644 index 00000000..309556b6 --- /dev/null +++ b/unittests/tmtcservices/testStoreAndSendHelper.cpp @@ -0,0 +1,19 @@ +#include + +#include "fsfw/storagemanager/LocalPool.h" +#include "fsfw/tmtcservices/TmSendHelper.h" +#include "fsfw/tmtcservices/TmStoreHelper.h" +#include "mocks/CdsShortTimestamperMock.h" + +TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { + auto timeStamper = CdsShortTimestamperMock(); + LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; + LocalPool pool(objects::NO_OBJECT, cfg); + auto storeHelper = TmStoreHelper(2, pool, timeStamper); + + MessageQueueId_t destId = 1; + auto errReporter = InternalErrorReporterMock(); + auto msgQueue = MessageQueueMock(); + msgQueue.setDefaultDestination(destId); + TmSendHelper sendHelper(msgQueue, errReporter, destId); +} From 75c824ec80cfc2e69539da1917e1913c6ef42321 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 13:59:09 +0200 Subject: [PATCH 122/532] add new VerificationReporterIF --- src/fsfw/objectmanager/frameworkObjects.h | 1 + src/fsfw/pus/CService200ModeCommanding.cpp | 7 +- src/fsfw/pus/CService201HealthCommanding.cpp | 2 +- src/fsfw/pus/Service17Test.cpp | 12 +- src/fsfw/pus/Service20ParameterManagement.cpp | 3 +- src/fsfw/pus/Service2DeviceAccess.cpp | 6 +- src/fsfw/pus/Service3Housekeeping.cpp | 3 +- src/fsfw/pus/Service8FunctionManagement.cpp | 3 +- src/fsfw/retval.h | 6 + src/fsfw/tcdistribution/PusDistributor.cpp | 6 +- src/fsfw/tcdistribution/PusDistributor.h | 2 +- .../tmtcservices/AcceptsVerifyMessageIF.h | 4 +- .../tmtcservices/CommandingServiceBase.cpp | 142 +++++++++++------- src/fsfw/tmtcservices/CommandingServiceBase.h | 34 +++-- src/fsfw/tmtcservices/PusServiceBase.cpp | 36 ++++- src/fsfw/tmtcservices/PusServiceBase.h | 20 ++- .../tmtcservices/TmStoreAndSendHelper.cpp | 45 +++--- src/fsfw/tmtcservices/TmStoreAndSendHelper.h | 29 ++-- .../tmtcservices/VerificationReporter.cpp | 105 +++---------- src/fsfw/tmtcservices/VerificationReporter.h | 32 ++-- .../tmtcservices/VerificationReporterIF.h | 57 +++++++ src/fsfw/tmtcservices/tmHelpers.h | 56 ++++--- unittests/CatchFactory.cpp | 2 - unittests/mocks/PusServiceBaseMock.cpp | 30 ++++ unittests/mocks/PusServiceBaseMock.h | 23 +++ unittests/tmtcservices/CMakeLists.txt | 1 + unittests/tmtcservices/testPsb.cpp | 5 + .../tmtcservices/testStoreAndSendHelper.cpp | 68 +++++++++ 28 files changed, 486 insertions(+), 254 deletions(-) create mode 100644 src/fsfw/retval.h create mode 100644 src/fsfw/tmtcservices/VerificationReporterIF.h create mode 100644 unittests/mocks/PusServiceBaseMock.cpp create mode 100644 unittests/mocks/PusServiceBaseMock.h create mode 100644 unittests/tmtcservices/testPsb.cpp diff --git a/src/fsfw/objectmanager/frameworkObjects.h b/src/fsfw/objectmanager/frameworkObjects.h index cddc6ba2..be664621 100644 --- a/src/fsfw/objectmanager/frameworkObjects.h +++ b/src/fsfw/objectmanager/frameworkObjects.h @@ -33,6 +33,7 @@ enum framework_objects : object_id_t { TC_STORE = 0x534f0100, TM_STORE = 0x534f0200, TIME_STAMPER = 0x53500010, + TC_VERIFICATOR = 0x53500020, FSFW_OBJECTS_END = 0x53ffffff, NO_OBJECT = 0xFFFFFFFF diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index ea60d00b..9990280c 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -96,13 +96,13 @@ ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply ReturnValue_t CService200ModeCommanding::prepareModeReply(const CommandMessage *reply, object_id_t objectId) { ModePacket modeReplyPacket(objectId, ModeMessage::getMode(reply), ModeMessage::getSubmode(reply)); - return tmHelper.sendTmPacket(Subservice::REPLY_MODE_REPLY, modeReplyPacket); + return sendTmPacket(Subservice::REPLY_MODE_REPLY, modeReplyPacket); } ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMessage *reply, object_id_t objectId) { ModePacket wrongModeReply(objectId, ModeMessage::getMode(reply), ModeMessage::getSubmode(reply)); - ReturnValue_t result = tmHelper.sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, wrongModeReply); + ReturnValue_t result = sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, wrongModeReply); if (result == RETURN_OK) { // We want to produce an error here in any case because the mode was not correct return RETURN_FAILED; @@ -113,8 +113,7 @@ ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMess ReturnValue_t CService200ModeCommanding::prepareCantReachModeReply(const CommandMessage *reply, object_id_t objectId) { CantReachModePacket cantReachModePacket(objectId, ModeMessage::getCantReachModeReason(reply)); - ReturnValue_t result = - tmHelper.sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, cantReachModePacket); + ReturnValue_t result = sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, cantReachModePacket); if (result == RETURN_OK) { // We want to produce an error here in any case because the mode was not reached return RETURN_FAILED; diff --git a/src/fsfw/pus/CService201HealthCommanding.cpp b/src/fsfw/pus/CService201HealthCommanding.cpp index 4588907f..c668ea52 100644 --- a/src/fsfw/pus/CService201HealthCommanding.cpp +++ b/src/fsfw/pus/CService201HealthCommanding.cpp @@ -102,5 +102,5 @@ ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *rep auto health = static_cast(HealthMessage::getHealth(reply)); auto oldHealth = static_cast(HealthMessage::getOldHealth(reply)); HealthSetReply healthSetReply(health, oldHealth); - return tmHelper.sendTmPacket(Subservice::REPLY_HEALTH_SET, healthSetReply); + return sendTmPacket(Subservice::REPLY_HEALTH_SET, healthSetReply); } diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index b40d2d70..d526e055 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -15,11 +15,19 @@ Service17Test::~Service17Test() = default; ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { switch (subservice) { case Subservice::CONNECTION_TEST: { - return tmHelper.sendTmPacket(Subservice::CONNECTION_TEST_REPORT); + ReturnValue_t result = tmHelper.prepareTmPacket(Subservice::CONNECTION_TEST_REPORT); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return tmHelper.storeAndSendTmPacket(); } case Subservice::EVENT_TRIGGER_TEST: { triggerEvent(TEST, 1234, 5678); - return tmHelper.sendTmPacket(Subservice::EVENT_TRIGGER_TEST); + ReturnValue_t result = tmHelper.prepareTmPacket(Subservice::EVENT_TRIGGER_TEST); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return tmHelper.storeAndSendTmPacket(); } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index 5f479530..6d6ca339 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -176,8 +176,7 @@ ReturnValue_t Service20ParameterManagement::handleReply(const CommandMessage* re ParameterId_t parameterId = ParameterMessage::getParameterId(reply); ParameterDumpReply parameterReply(objectId, parameterId, parameterData.second.data(), parameterData.second.size()); - tmHelper.sendTmPacket(static_cast(Subservice::PARAMETER_DUMP_REPLY), parameterReply); - return HasReturnvaluesIF::RETURN_OK; + return sendTmPacket(static_cast(Subservice::PARAMETER_DUMP_REPLY), parameterReply); } default: return CommandingServiceBase::INVALID_REPLY; diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index 008d8128..817a372e 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -148,7 +148,11 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs // Init our dummy packet and correct endianness of object ID before // sending it back. WiretappingPacket tmPacket(DeviceHandlerMessage::getDeviceObjectId(reply), data); - tmHelper.sendTmPacket(subservice, tmPacket.objectId, tmPacket.data, size); + result = sendTmPacket(subservice, tmPacket.objectId, tmPacket.data, size); + if (result != retval::OK) { + // TODO: Warning + return; + } } MessageQueueId_t Service2DeviceAccess::getDeviceQueue() { return commandQueue->getId(); } diff --git a/src/fsfw/pus/Service3Housekeeping.cpp b/src/fsfw/pus/Service3Housekeeping.cpp index df7cbe0a..7ef5636d 100644 --- a/src/fsfw/pus/Service3Housekeeping.cpp +++ b/src/fsfw/pus/Service3Housekeeping.cpp @@ -290,8 +290,7 @@ ReturnValue_t Service3Housekeeping::generateHkReply(const CommandMessage* hkMess } HkPacket hkPacket(sid, resultPair.second.data(), resultPair.second.size()); - return tmHelper.sendTmPacket(static_cast(subserviceId), hkPacket.hkData, - hkPacket.hkSize); + return sendTmPacket(static_cast(subserviceId), hkPacket.hkData, hkPacket.hkSize); } sid_t Service3Housekeeping::buildSid(object_id_t objectId, const uint8_t** tcData, diff --git a/src/fsfw/pus/Service8FunctionManagement.cpp b/src/fsfw/pus/Service8FunctionManagement.cpp index f9a6a168..c9da6d58 100644 --- a/src/fsfw/pus/Service8FunctionManagement.cpp +++ b/src/fsfw/pus/Service8FunctionManagement.cpp @@ -138,8 +138,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* return result; } DataReply dataReply(objectId, actionId, buffer, size); - result = tmHelper.sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), - dataReply); + result = sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), dataReply); auto deletionResult = ipcStore->deleteData(storeId); if (deletionResult != HasReturnvaluesIF::RETURN_OK) { diff --git a/src/fsfw/retval.h b/src/fsfw/retval.h new file mode 100644 index 00000000..43c4e127 --- /dev/null +++ b/src/fsfw/retval.h @@ -0,0 +1,6 @@ +#ifndef FSFW_RETVAL_H +#define FSFW_RETVAL_H + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +#endif // FSFW_RETVAL_H diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 3a7fdf34..1cef2b9f 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -12,7 +12,6 @@ PusDistributor::PusDistributor(StorageManagerIF* store_, uint16_t setApid, objec : TcDistributor(setObjectId), store(store_), checker(setApid, ccsds::PacketType::TC), - verifyChannel(), tcStatus(RETURN_FAILED), packetSource(setPacketSource) {} @@ -120,13 +119,14 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { tcStatus = queueStatus; } if (tcStatus != RETURN_OK) { - this->verifyChannel.sendFailureReport(tcverif::ACCEPTANCE_FAILURE, &reader, tcStatus); + verifyChannel->sendFailureReport( + VerifFailureParams(tcverif::ACCEPTANCE_FAILURE, reader, tcStatus)); // A failed packet is deleted immediately after reporting, // otherwise it will block memory. store->deleteData(currentMessage.getStorageId()); return RETURN_FAILED; } else { - this->verifyChannel.sendSuccessReport(tcverif::ACCEPTANCE_SUCCESS, &reader); + verifyChannel->sendSuccessReport(VerifSuccessParams(tcverif::ACCEPTANCE_SUCCESS, reader)); return RETURN_OK; } } diff --git a/src/fsfw/tcdistribution/PusDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h index fb916263..3849c793 100644 --- a/src/fsfw/tcdistribution/PusDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -48,7 +48,7 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc * With this class, verification messages are sent to the * TC Verification service. */ - VerificationReporter verifyChannel; + VerificationReporterIF* verifyChannel = nullptr; /** * The currently handled packet is stored here. */ diff --git a/src/fsfw/tmtcservices/AcceptsVerifyMessageIF.h b/src/fsfw/tmtcservices/AcceptsVerifyMessageIF.h index 7e58187b..daf67080 100644 --- a/src/fsfw/tmtcservices/AcceptsVerifyMessageIF.h +++ b/src/fsfw/tmtcservices/AcceptsVerifyMessageIF.h @@ -1,11 +1,11 @@ #ifndef FSFW_TMTCSERVICES_ACCEPTSVERIFICATIONMESSAGEIF_H_ #define FSFW_TMTCSERVICES_ACCEPTSVERIFICATIONMESSAGEIF_H_ -#include "../ipc/MessageQueueSenderIF.h" +#include "fsfw/ipc/MessageQueueSenderIF.h" class AcceptsVerifyMessageIF { public: - virtual ~AcceptsVerifyMessageIF() {} + virtual ~AcceptsVerifyMessageIF() = default; virtual MessageQueueId_t getVerificationQueue() = 0; }; diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 7839aa87..c890ecfb 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -15,13 +15,15 @@ object_id_t CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands, - uint16_t commandTimeoutSeconds, size_t queueDepth) + uint16_t commandTimeoutSeconds, size_t queueDepth, + VerificationReporterIF* verificationReporter) : SystemObject(setObjectId), apid(apid), service(service), timeoutSeconds(commandTimeoutSeconds), tmStoreHelper(apid), tmHelper(service, tmStoreHelper, tmSendHelper), + verificationReporter(verificationReporter), commandMap(numberOfParallelCommands) { commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth); @@ -105,12 +107,19 @@ ReturnValue_t CommandingServiceBase::initialize() { tmSendHelper.setInternalErrorReporter(errReporter); } } + if (verificationReporter == nullptr) { + verificationReporter = + ObjectManager::instance()->get(objects::TC_VERIFICATOR); + if (verificationReporter == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + } return RETURN_OK; } void CommandingServiceBase::handleCommandQueue() { CommandMessage reply; - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result; while (true) { result = commandQueue->receiveMessage(&reply); if (result == HasReturnvaluesIF::RETURN_OK) { @@ -175,16 +184,14 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) { break; default: if (isStep) { - verificationReporter.sendFailureReport( - tcverif::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, - iter->second.tcInfo.tcSequenceControl, result, ++iter->second.step, failureParameter1, - failureParameter2); + prepareVerificationFailureWithFullInfo(tcverif::PROGRESS_FAILURE, iter->second.tcInfo, + result, true); + failParams.step = ++iter->second.step; } else { - verificationReporter.sendFailureReport( - tcverif::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, - iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, result, 0, - failureParameter1, failureParameter2); + prepareVerificationFailureWithFullInfo(tcverif::COMPLETION_FAILURE, iter->second.tcInfo, + result, true); } + verificationReporter->sendFailureReport(failParams); failureParameter1 = 0; failureParameter2 = 0; checkAndExecuteFifo(iter); @@ -207,28 +214,26 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, Comma if (sendResult == RETURN_OK) { if (isStep and result != NO_STEP_MESSAGE) { - verificationReporter.sendSuccessReport( - tcverif::PROGRESS_SUCCESS, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, - iter->second.tcInfo.tcSequenceControl, ++iter->second.step); + prepareVerificationSuccessWithFullInfo(tcverif::PROGRESS_SUCCESS, iter->second.tcInfo); + successParams.step = ++iter->second.step; + verificationReporter->sendSuccessReport(successParams); } else { - verificationReporter.sendSuccessReport( - tcverif::COMPLETION_SUCCESS, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, - iter->second.tcInfo.tcSequenceControl, 0); + prepareVerificationSuccessWithFullInfo(tcverif::COMPLETION_SUCCESS, iter->second.tcInfo); + verificationReporter->sendSuccessReport(successParams); checkAndExecuteFifo(iter); } } else { if (isStep) { + prepareVerificationFailureWithFullInfo(tcverif::PROGRESS_FAILURE, iter->second.tcInfo, result, + true); + failParams.step = ++iter->second.step; nextCommand->clearCommandMessage(); - verificationReporter.sendFailureReport( - tcverif::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, - iter->second.tcInfo.tcSequenceControl, sendResult, ++iter->second.step, failureParameter1, - failureParameter2); + verificationReporter->sendFailureReport(failParams); } else { + prepareVerificationFailureWithFullInfo(tcverif::COMPLETION_FAILURE, iter->second.tcInfo, + result, true); nextCommand->clearCommandMessage(); - verificationReporter.sendFailureReport( - tcverif::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, - iter->second.tcInfo.tcSequenceControl, sendResult, 0, failureParameter1, - failureParameter2); + verificationReporter->sendFailureReport(failParams); } failureParameter1 = 0; failureParameter2 = 0; @@ -247,19 +252,19 @@ void CommandingServiceBase::handleRequestQueue() { result = setUpTcReader(message.getStorageId()); if (result != HasReturnvaluesIF::RETURN_OK) { // TODO: Warning? - rejectPacket(tcverif::START_FAILURE, address, &tcReader, result); + rejectPacket(tcverif::START_FAILURE, address, result); continue; } if ((tcReader.getSubService() == 0) or (isValidSubservice(tcReader.getSubService()) != RETURN_OK)) { - rejectPacket(tcverif::START_FAILURE, address, &tcReader, INVALID_SUBSERVICE); + rejectPacket(tcverif::START_FAILURE, address, INVALID_SUBSERVICE); continue; } result = getMessageQueueAndObject(tcReader.getSubService(), tcReader.getUserData(), tcReader.getUserDataLen(), &queue, &objectId); if (result != HasReturnvaluesIF::RETURN_OK) { - rejectPacket(tcverif::START_FAILURE, address, &tcReader, result); + rejectPacket(tcverif::START_FAILURE, address, result); continue; } @@ -270,14 +275,14 @@ void CommandingServiceBase::handleRequestQueue() { if (iter != commandMap.end()) { result = iter->second.fifo.insert(address); if (result != RETURN_OK) { - rejectPacket(tcverif::START_FAILURE, address, &tcReader, OBJECT_BUSY); + rejectPacket(tcverif::START_FAILURE, address, OBJECT_BUSY); } } else { CommandInfo newInfo; // Info will be set by startExecution if neccessary newInfo.objectId = objectId; result = commandMap.insert(queue, newInfo, &iter); if (result != RETURN_OK) { - rejectPacket(tcverif::START_FAILURE, address, &tcReader, BUSY); + rejectPacket(tcverif::START_FAILURE, address, BUSY); } else { startExecution(address, iter); } @@ -287,24 +292,37 @@ void CommandingServiceBase::handleRequestQueue() { ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen) { - return tmHelper.sendTmPacket(subservice, sourceData, sourceDataLen); + ReturnValue_t result = tmHelper.prepareTmPacket(subservice, sourceData, sourceDataLen); + if (result != retval::OK) { + return result; + } + return tmHelper.storeAndSendTmPacket(); } ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_t objectId, const uint8_t* data, size_t dataLen) { - return tmHelper.sendTmPacket(subservice, objectId, data, dataLen); + telemetry::DataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); + ReturnValue_t result = tmHelper.prepareTmPacket(subservice, dataWithObjId); + if (result != retval::OK) { + return result; + } + return tmHelper.storeAndSendTmPacket(); } ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeIF& sourceData) { - return tmHelper.sendTmPacket(subservice, sourceData); + ReturnValue_t result = tmHelper.prepareTmPacket(subservice, sourceData); + if (result != retval::OK) { + return result; + } + return tmHelper.storeAndSendTmPacket(); } -void CommandingServiceBase::startExecution(store_address_t storeId, CommandMapIter iter) { - ReturnValue_t result = RETURN_OK; +void CommandingServiceBase::startExecution(store_address_t storeId, CommandMapIter& iter) { CommandMessage command; iter->second.subservice = tcReader.getSubService(); - result = prepareCommand(&command, iter->second.subservice, tcReader.getUserData(), - tcReader.getUserDataLen(), &iter->second.state, iter->second.objectId); + ReturnValue_t result = + prepareCommand(&command, iter->second.subservice, tcReader.getUserData(), + tcReader.getUserDataLen(), &iter->second.state, iter->second.objectId); ReturnValue_t sendResult = RETURN_OK; switch (result) { @@ -320,10 +338,10 @@ void CommandingServiceBase::startExecution(store_address_t storeId, CommandMapIt iter->second.tcInfo.ackFlags = tcReader.getAcknowledgeFlags(); iter->second.tcInfo.tcPacketId = tcReader.getPacketIdRaw(); iter->second.tcInfo.tcSequenceControl = tcReader.getPacketSeqCtrlRaw(); - acceptPacket(tcverif::START_SUCCESS, storeId, &tcReader); + acceptPacket(tcverif::START_SUCCESS, storeId); } else { command.clearCommandMessage(); - rejectPacket(tcverif::START_FAILURE, storeId, &tcReader, sendResult); + rejectPacket(tcverif::START_FAILURE, storeId, sendResult); checkAndExecuteFifo(iter); } break; @@ -333,31 +351,31 @@ void CommandingServiceBase::startExecution(store_address_t storeId, CommandMapIt sendResult = commandQueue->sendMessage(iter.value->first, &command); } if (sendResult == RETURN_OK) { - verificationReporter.sendSuccessReport(tcverif::START_SUCCESS, &tcReader); - acceptPacket(tcverif::COMPLETION_SUCCESS, storeId, &tcReader); + verificationReporter->sendSuccessReport( + VerifSuccessParams(tcverif::START_SUCCESS, tcReader)); + acceptPacket(tcverif::COMPLETION_SUCCESS, storeId); checkAndExecuteFifo(iter); } else { command.clearCommandMessage(); - rejectPacket(tcverif::START_FAILURE, storeId, &tcReader, sendResult); + rejectPacket(tcverif::START_FAILURE, storeId, sendResult); checkAndExecuteFifo(iter); } break; default: - rejectPacket(tcverif::START_FAILURE, storeId, &tcReader, result); + rejectPacket(tcverif::START_FAILURE, storeId, result); checkAndExecuteFifo(iter); break; } } void CommandingServiceBase::rejectPacket(uint8_t reportId, store_address_t tcStoreId, - PusTcReader* correspondingTc, ReturnValue_t errorCode) { - verificationReporter.sendFailureReport(reportId, correspondingTc, errorCode); + ReturnValue_t errorCode) { + verificationReporter->sendFailureReport(VerifFailureParams(reportId, tcReader, errorCode)); tcStore->deleteData(tcStoreId); } -void CommandingServiceBase::acceptPacket(uint8_t reportId, store_address_t tcStoreId, - PusTcReader* packet) { - verificationReporter.sendSuccessReport(reportId, packet); +void CommandingServiceBase::acceptPacket(uint8_t reportId, store_address_t tcStoreId) { + verificationReporter->sendSuccessReport(VerifSuccessParams(reportId, tcReader)); tcStore->deleteData(tcStoreId); } @@ -371,7 +389,7 @@ void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) { startExecution(address, iter); } else { // TODO: Warning? - rejectPacket(tcverif::START_FAILURE, address, &tcReader, result); + rejectPacket(tcverif::START_FAILURE, address, result); } } } @@ -390,9 +408,9 @@ void CommandingServiceBase::checkTimeout() { CommandMapIter iter; for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) { if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) { - verificationReporter.sendFailureReport( - tcverif::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, - iter->second.tcInfo.tcSequenceControl, TIMEOUT); + prepareVerificationFailureWithFullInfo(tcverif::COMPLETION_FAILURE, iter->second.tcInfo, + TIMEOUT, false); + verificationReporter->sendFailureReport(failParams); checkAndExecuteFifo(iter); } } @@ -406,3 +424,25 @@ void CommandingServiceBase::setCustomTmStore(StorageManagerIF& store) { ReturnValue_t CommandingServiceBase::setUpTcReader(store_address_t storeId) { return tc::prepareTcReader(tcStore, storeId, tcReader); } + +void CommandingServiceBase::prepareVerificationFailureWithFullInfo(uint8_t reportId, + CommandInfo::TcInfo& tcInfo, + ReturnValue_t errorCode, + bool setCachedFailParams) { + failParams.reportId = reportId; + failParams.tcPacketId = tcInfo.tcPacketId; + failParams.tcPsc = tcInfo.tcSequenceControl; + failParams.ackFlags = tcInfo.ackFlags; + failParams.errorCode = errorCode; + if (setCachedFailParams) { + failParams.errorParam1 = failureParameter1; + failParams.errorParam2 = failureParameter2; + } +} +void CommandingServiceBase::prepareVerificationSuccessWithFullInfo( + uint8_t reportId, CommandingServiceBase::CommandInfo::TcInfo& tcInfo) { + failParams.reportId = reportId; + failParams.tcPacketId = tcInfo.tcPacketId; + failParams.tcPsc = tcInfo.tcSequenceControl; + failParams.ackFlags = tcInfo.ackFlags; +} diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 63067b07..202dd862 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -68,7 +68,7 @@ class CommandingServiceBase : public SystemObject, */ CommandingServiceBase(object_id_t setObjectId, uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands, uint16_t commandTimeoutSeconds, - size_t queueDepth = 20); + size_t queueDepth = 20, VerificationReporterIF* reporter = nullptr); ~CommandingServiceBase() override; void setCustomTmStore(StorageManagerIF& store); @@ -218,7 +218,7 @@ class CommandingServiceBase : public SystemObject, virtual void doPeriodicOperation(); struct CommandInfo : public SerializeIF { - struct tcInfo { + struct TcInfo { uint8_t ackFlags; uint16_t tcPacketId; uint16_t tcSequenceControl; @@ -263,7 +263,7 @@ class CommandingServiceBase : public SystemObject, MessageQueueIF* commandQueue = nullptr; MessageQueueIF* requestQueue = nullptr; - VerificationReporter verificationReporter; + VerificationReporterIF* verificationReporter; InternalErrorReporterIF* errReporter = nullptr; @@ -284,19 +284,19 @@ class CommandingServiceBase : public SystemObject, */ PeriodicTaskIF* executingTask = nullptr; - [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket( - uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen); - [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket( - uint8_t subservice, object_id_t objectId, const uint8_t* data, size_t dataLen); - [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket( - uint8_t subservice, SerializeIF& sourceData); + ReturnValue_t sendTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen); + ReturnValue_t sendTmPacket(uint8_t subservice, object_id_t objectId, const uint8_t* data, + size_t dataLen); + ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF& sourceData); void checkAndExecuteFifo(CommandMapIter& iter); + VerifFailureParams failParams; + VerifSuccessParams successParams; private: /** * This method handles internal execution of a command, - * once it has been started by @sa{startExecution()} in the request + * once it has been started by @startExecution in the request * queue handler. * It handles replies generated by the devices and relayed by the specific * service implementation. This means that it determines further course of @@ -316,26 +316,28 @@ class CommandingServiceBase : public SystemObject, * @brief Handler function for request queue * @details * Sequence of request queue handling: - * isValidSubservice -> getMessageQueueAndObject -> startExecution + * @isValidSubservice -> @getMessageQueueAndObject -> @startExecution * Generates a Start Success Reports TM[1,3] in subfunction - * @sa{startExecution()} or a Start Failure Report TM[1,4] by using the + * @startExecution or a Start Failure Report TM[1,4] by using the * TC Verification Service. */ void handleRequestQueue(); ReturnValue_t setUpTcReader(store_address_t storeId); - void rejectPacket(uint8_t reportId, store_address_t tcStoreId, PusTcReader* tcPacket, - ReturnValue_t errorCode); + void rejectPacket(uint8_t reportId, store_address_t tcStoreId, ReturnValue_t errorCode); - void acceptPacket(uint8_t reportId, store_address_t tcStoreId, PusTcReader* tcPacket); + void acceptPacket(uint8_t reportId, store_address_t tcStoreId); - void startExecution(store_address_t storeId, CommandMapIter iter); + void startExecution(store_address_t storeId, CommandMapIter& iter); void handleCommandMessage(CommandMessage* reply); void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter, CommandMessage* nextCommand, CommandMessage* reply, bool& isStep); + void prepareVerificationFailureWithFullInfo(uint8_t reportId, CommandInfo::TcInfo& tcInfo, + ReturnValue_t errorCode, bool setCachedFailParams); + void prepareVerificationSuccessWithFullInfo(uint8_t reportId, CommandInfo::TcInfo& tcInfo); void checkTimeout(); }; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 26f08694..f727e415 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -12,8 +12,12 @@ object_id_t PusServiceBase::packetSource = 0; object_id_t PusServiceBase::packetDestination = 0; -PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId) - : SystemObject(setObjectId), apid(setApid), serviceId(setServiceId) { +PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId, + VerificationReporterIF* verifyReporter) + : SystemObject(setObjectId), + apid(setApid), + serviceId(setServiceId), + verifyReporter(verifyReporter) { requestQueue = QueueFactory::instance()->createMessageQueue(PUS_SERVICE_MAX_RECEPTION); } @@ -65,16 +69,21 @@ void PusServiceBase::handleRequestQueue() { } result = tc::prepareTcReader(tcStore, message.getStorageId(), currentPacket); if (result != HasReturnvaluesIF::RETURN_OK) { - this->verifyReporter.sendFailureReport(tcverif::START_FAILURE, &this->currentPacket, result, - 0, errorParameter1, errorParameter2); + auto params = VerifFailureParams(tcverif::START_FAILURE, currentPacket, result); + params.errorParam1 = errorParameter1; + params.errorParam2 = errorParameter2; + verifyReporter->sendFailureReport(params); continue; } - result = this->handleRequest(currentPacket.getSubService()); + result = handleRequest(currentPacket.getSubService()); if (result == RETURN_OK) { - this->verifyReporter.sendSuccessReport(tcverif::COMPLETION_SUCCESS, &this->currentPacket); + verifyReporter->sendSuccessReport( + VerifSuccessParams(tcverif::COMPLETION_SUCCESS, currentPacket)); } else { - this->verifyReporter.sendFailureReport(tcverif::COMPLETION_FAILURE, &this->currentPacket, - result, 0, errorParameter1, errorParameter2); + auto params = VerifFailureParams(tcverif::COMPLETION_FAILURE, currentPacket, result); + params.errorParam1 = errorParameter1; + params.errorParam2 = errorParameter2; + verifyReporter->sendFailureReport(params); } tcStore->deleteData(message.getStorageId()); errorParameter1 = 0; @@ -109,6 +118,13 @@ ReturnValue_t PusServiceBase::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } } + if (verifyReporter == nullptr) { + verifyReporter = + ObjectManager::instance()->get(objects::TC_VERIFICATOR); + if (verifyReporter == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + } return HasReturnvaluesIF::RETURN_OK; } @@ -145,3 +161,7 @@ void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { void PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { tmStoreHelper.setApid(apid); } + +void PusServiceBase::setVerificationReporter(VerificationReporterIF* reporter) { + verifyReporter = reporter; +} diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 7df563d0..4aa6fade 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -53,18 +53,33 @@ class PusServiceBase : public ExecutableObjectIF, * @param setServiceId * The Service Identifier as specified in ECSS PUS. */ - PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId); + PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId, + VerificationReporterIF* reporter = nullptr); /** * The destructor is empty. */ ~PusServiceBase() override; void setCustomTcStore(StorageManagerIF* tcStore); + void setVerificationReporter(VerificationReporterIF* reporter); void setCustomErrorReporter(InternalErrorReporterIF* errReporter); + /** + * Helper methods if the implementing class wants to send telemetry + * @param tmSendHelper + */ void initializeTmSendHelper(TmSendHelper& tmSendHelper); + /** + * Helper methods if the implementing class wants to store telemetry + * @param tmSendHelper + */ void initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const; + /** + * Helper methods if the implementing class wants to both send and store telemetry + * @param tmSendHelper + */ void initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper); + /** * @brief The handleRequest method shall handle any kind of Telecommand * Request immediately. @@ -146,7 +161,7 @@ class PusServiceBase : public ExecutableObjectIF, * An instance of the VerificationReporter class, that simplifies * sending any kind of verification message to the TC Verification Service. */ - VerificationReporter verifyReporter; + VerificationReporterIF* verifyReporter; /** * The current Telecommand to be processed. @@ -159,6 +174,7 @@ class PusServiceBase : public ExecutableObjectIF, static object_id_t packetSource; static object_id_t packetDestination; + VerifSuccessParams successParams; private: /** diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp index 61735ab5..cab6db44 100644 --- a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp @@ -24,29 +24,36 @@ ReturnValue_t TmStoreAndSendWrapper::storeAndSendTmPacket() { return result; } -ReturnValue_t TmStoreAndSendWrapper::sendTmPacket(uint8_t subservice, const uint8_t* sourceData, - size_t sourceDataLen) { - storeHelper.preparePacket(defaultService, subservice, sendCounter); - storeHelper.setSourceDataRaw(sourceData, sourceDataLen); - return storeAndSendTmPacket(); +ReturnValue_t TmStoreAndSendWrapper::prepareTmPacket(uint8_t subservice, const uint8_t* sourceData, + size_t sourceDataLen) { + ReturnValue_t result = storeHelper.preparePacket(defaultService, subservice, sendCounter); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return storeHelper.setSourceDataRaw(sourceData, sourceDataLen); } -ReturnValue_t TmStoreAndSendWrapper::sendTmPacket(uint8_t subservice, object_id_t objectId, - const uint8_t* data, size_t dataLen) { - telemetry::DataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); - storeHelper.preparePacket(defaultService, subservice, sendCounter); - storeHelper.setSourceDataSerializable(dataWithObjId); - return storeAndSendTmPacket(); +ReturnValue_t TmStoreAndSendWrapper::prepareTmPacket( + uint8_t subservice, telemetry::DataWithObjectIdPrefix& dataWithObjectId) { + ReturnValue_t result = storeHelper.preparePacket(defaultService, subservice, sendCounter); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return storeHelper.setSourceDataSerializable(dataWithObjectId); } -ReturnValue_t TmStoreAndSendWrapper::sendTmPacket(uint8_t subservice, SerializeIF& sourceData) { - storeHelper.preparePacket(defaultService, subservice, sendCounter); - storeHelper.setSourceDataSerializable(sourceData); - return storeAndSendTmPacket(); +ReturnValue_t TmStoreAndSendWrapper::prepareTmPacket(uint8_t subservice, SerializeIF& sourceData) { + ReturnValue_t result = storeHelper.preparePacket(defaultService, subservice, sendCounter); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return storeHelper.setSourceDataSerializable(sourceData); } -ReturnValue_t TmStoreAndSendWrapper::sendTmPacket(uint8_t subservice) { - storeHelper.preparePacket(defaultService, subservice, sendCounter); - storeHelper.setSourceDataRaw(nullptr, 0); - return storeAndSendTmPacket(); +ReturnValue_t TmStoreAndSendWrapper::prepareTmPacket(uint8_t subservice) { + ReturnValue_t result = storeHelper.preparePacket(defaultService, subservice, sendCounter); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return storeHelper.setSourceDataRaw(nullptr, 0); } diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.h b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h index 1a33b7d7..eef3a373 100644 --- a/src/fsfw/tmtcservices/TmStoreAndSendHelper.h +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h @@ -3,6 +3,7 @@ #include "TmSendHelper.h" #include "TmStoreHelper.h" +#include "tmHelpers.h" /** * Wrapper class intended to help with PUS TM handling. This wrapper class also caches the current @@ -12,37 +13,41 @@ class TmStoreAndSendWrapper { public: TmStoreAndSendWrapper(uint8_t defaultService, TmStoreHelper& storeHelper, TmSendHelper& sendHelper); - ReturnValue_t storeAndSendTmPacket(); - ReturnValue_t sendTmPacket(uint8_t subservice); /** - * @brief Send TM data from pointer to data. - * If a header is supplied it is added before data + * Prepares a TM packet with the given parameters. It will also set the default service. + * @param subservice + * @return + */ + ReturnValue_t prepareTmPacket(uint8_t subservice); + /** + * Prepares a TM packet with the given parameters. It will also set the default service. * @param subservice Number of subservice * @param sourceData Custom source data * @param sourceDataLen Lenght of data in the Packet */ - ReturnValue_t sendTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen); + ReturnValue_t prepareTmPacket(uint8_t subservice, const uint8_t* sourceData, + size_t sourceDataLen); /** - * @brief To send TM packets of objects that still need to be serialized - * and consist of an object ID with appended data. + * Prepares a TM packet with the given parameters. It will also set the default service. * @param subservice Number of subservice * @param objectId ObjectId is placed before data * @param data Data to append to the packet * @param dataLen Length of Data */ - ReturnValue_t sendTmPacket(uint8_t subservice, object_id_t objectId, const uint8_t* data, - size_t dataLen); + ReturnValue_t prepareTmPacket(uint8_t subservice, + telemetry::DataWithObjectIdPrefix& dataWithObjectId); /** - * @brief To send packets which are contained inside a class implementing - * SerializeIF. + * Prepares a TM packet with the given parameters. It will also set the default service. * @param subservice Number of subservice * @param content This is a pointer to the serialized packet * @param header Serialize IF header which will be placed before content */ - ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF& sourceData); + ReturnValue_t prepareTmPacket(uint8_t subservice, SerializeIF& sourceData); + + ReturnValue_t storeAndSendTmPacket(); bool incrementSendCounter = true; TmStoreHelper& storeHelper; diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index a9b6dd47..b08756d3 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -1,29 +1,25 @@ #include "fsfw/tmtcservices/VerificationReporter.h" -#include "fsfw/ipc/MessageQueueIF.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/objectmanager/frameworkObjects.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" -object_id_t VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - -VerificationReporter::VerificationReporter() : acknowledgeQueue(MessageQueueIF::NO_QUEUE) {} +VerificationReporter::VerificationReporter(AcceptsVerifyMessageIF* receiver, object_id_t objectId) + : SystemObject(objectId) { + if (receiver != nullptr) { + acknowledgeQueue = receiver->getVerificationQueue(); + } +} VerificationReporter::~VerificationReporter() = default; -void VerificationReporter::sendSuccessReport(uint8_t set_report_id, PusTcReader* correspondingTc, - uint8_t set_step) { - if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) { - this->initialize(); - } - if (correspondingTc == nullptr) { - return; - } - PusVerificationMessage message(set_report_id, correspondingTc->getAcknowledgeFlags(), - correspondingTc->getPacketIdRaw(), - correspondingTc->getPacketSeqCtrlRaw(), 0, set_step); +void VerificationReporter::setReceiver(AcceptsVerifyMessageIF& receiver) { + acknowledgeQueue = receiver.getVerificationQueue(); +} + +ReturnValue_t VerificationReporter::sendFailureReport(VerifFailureParams params) { + PusVerificationMessage message(params.reportId, params.ackFlags, params.tcPacketId, params.tcPsc, + params.errorCode, params.step, params.errorParam1, + params.errorParam2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -31,16 +27,12 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, PusTcReader* << "to queue. Code: " << std::hex << status << std::dec << std::endl; #endif } + return status; } -void VerificationReporter::sendSuccessReport(uint8_t set_report_id, uint8_t ackFlags, - uint16_t tcPacketId, uint16_t tcSequenceControl, - uint8_t set_step) { - if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) { - this->initialize(); - } - PusVerificationMessage message(set_report_id, ackFlags, tcPacketId, tcSequenceControl, 0, - set_step); +ReturnValue_t VerificationReporter::sendSuccessReport(VerifSuccessParams params) { + PusVerificationMessage message(params.reportId, params.ackFlags, params.tcPacketId, params.tcPsc, + retval::OK, params.step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -48,64 +40,5 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, uint8_t ackF << "to queue. Code: " << std::hex << status << std::dec << std::endl; #endif } -} - -void VerificationReporter::sendFailureReport(uint8_t report_id, PusTcReader* correspondingTc, - ReturnValue_t errorCode, uint8_t step, - uint32_t parameter1, uint32_t parameter2) { - if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) { - this->initialize(); - } - if (correspondingTc == nullptr) { - return; - } - PusVerificationMessage message( - report_id, correspondingTc->getAcknowledgeFlags(), correspondingTc->getPacketIdRaw(), - correspondingTc->getPacketSeqCtrlRaw(), errorCode, step, parameter1, parameter2); - ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); - if (status != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "VerificationReporter::sendFailureReport: Error writing " - << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; -#endif - } -} - -void VerificationReporter::sendFailureReport(uint8_t report_id, uint8_t ackFlags, - uint16_t tcPacketId, uint16_t tcSequenceControl, - ReturnValue_t error_code, uint8_t step, - uint32_t parameter1, uint32_t parameter2) { - if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) { - this->initialize(); - } - PusVerificationMessage message(report_id, ackFlags, tcPacketId, tcSequenceControl, error_code, - step, parameter1, parameter2); - ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); - if (status != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "VerificationReporter::sendFailureReport: Error writing " - << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; -#endif - } -} - -void VerificationReporter::initialize() { - if (messageReceiver == objects::NO_OBJECT) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "VerificationReporter::initialize: Verification message" - " receiver object ID not set yet in Factory!" - << std::endl; -#endif - return; - } - auto* temp = ObjectManager::instance()->get(messageReceiver); - if (temp == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "VerificationReporter::initialize: Message " - << "receiver invalid. Make sure it is set up properly and " - << "implementsAcceptsVerifyMessageIF" << std::endl; -#endif - return; - } - this->acknowledgeQueue = temp->getVerificationQueue(); + return status; } diff --git a/src/fsfw/tmtcservices/VerificationReporter.h b/src/fsfw/tmtcservices/VerificationReporter.h index 1d64fd48..8ea45f79 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.h +++ b/src/fsfw/tmtcservices/VerificationReporter.h @@ -2,12 +2,11 @@ #define FSFW_TMTCSERVICES_VERIFICATIONREPORTER_H_ #include "PusVerificationReport.h" +#include "VerificationReporterIF.h" #include "fsfw/objectmanager/ObjectManagerIF.h" +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tmtcpacket/pus/tc/PusTcCreator.h" - -namespace Factory { -void setStaticFrameworkObjectIds(); -} +#include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h" /** * @brief This helper object is used to forward verification messages @@ -20,30 +19,21 @@ void setStaticFrameworkObjectIds(); * to the PUS standard. * */ -class VerificationReporter { - friend void(Factory::setStaticFrameworkObjectIds)(); - +class VerificationReporter : public SystemObject, public VerificationReporterIF { public: - VerificationReporter(); - virtual ~VerificationReporter(); + explicit VerificationReporter(AcceptsVerifyMessageIF* receiver, + object_id_t objectId = objects::TC_VERIFICATOR); + ~VerificationReporter() override; + + void setReceiver(AcceptsVerifyMessageIF& receiver); // TODO: The API is a little bit bloated. It might be better to group all the parameters // into a dedicated struct - void sendSuccessReport(uint8_t set_report_id, PusTcReader* correspondingTc, uint8_t set_step = 0); - void sendSuccessReport(uint8_t set_report_id, uint8_t ackFlags, uint16_t tcPacketId, - uint16_t tcSequenceControl, uint8_t set_step = 0); + ReturnValue_t sendSuccessReport(VerifSuccessParams params) override; - void sendFailureReport(uint8_t report_id, PusTcReader* correspondingTc, - ReturnValue_t errorCode = 0, uint8_t step = 0, uint32_t parameter1 = 0, - uint32_t parameter2 = 0); - void sendFailureReport(uint8_t report_id, uint8_t ackFlags, uint16_t tcPacketId, - uint16_t tcSequenceControl, ReturnValue_t errorCode = 0, uint8_t step = 0, - uint32_t parameter1 = 0, uint32_t parameter2 = 0); - - void initialize(); + ReturnValue_t sendFailureReport(VerifFailureParams params) override; private: - static object_id_t messageReceiver; MessageQueueId_t acknowledgeQueue; }; diff --git a/src/fsfw/tmtcservices/VerificationReporterIF.h b/src/fsfw/tmtcservices/VerificationReporterIF.h new file mode 100644 index 00000000..14b6012f --- /dev/null +++ b/src/fsfw/tmtcservices/VerificationReporterIF.h @@ -0,0 +1,57 @@ +#ifndef FSFW_TMTCSERVICES_VERIFICATIONREPORTERIF_H +#define FSFW_TMTCSERVICES_VERIFICATIONREPORTERIF_H + +#include "fsfw/retval.h" +#include "fsfw/tmtcpacket/pus/tc.h" + +struct VerifParamsBase { + VerifParamsBase() : reportId(0), tcPacketId(0), tcPsc(0) {} + VerifParamsBase(uint8_t reportId, uint16_t tcPacketId, uint16_t tcPsc) + : reportId(reportId), tcPacketId(tcPacketId), tcPsc(tcPsc) {} + uint8_t reportId; + uint16_t tcPacketId; + uint16_t tcPsc; + uint8_t ackFlags = ecss::ACK_ALL; + uint8_t step = 0; +}; + +struct VerifSuccessParams : public VerifParamsBase { + VerifSuccessParams() = default; + VerifSuccessParams(uint8_t reportId, uint16_t tcPacketId, uint16_t tcPsc) + : VerifParamsBase(reportId, tcPacketId, tcPsc) {} + VerifSuccessParams(uint8_t reportId, PusTcIF& tc) + : VerifParamsBase(reportId, tc.getPacketIdRaw(), tc.getPacketSeqCtrlRaw()) {} +}; + +struct VerifFailureParams : public VerifParamsBase { + VerifFailureParams() = default; + VerifFailureParams(uint8_t reportId, uint16_t tcPacketId, uint16_t tcPsc, ReturnValue_t errorCode, + uint32_t errorParam1, uint32_t errorParams2) + : VerifParamsBase(reportId, tcPacketId, tcPsc), errorCode(errorCode) { + errorParam1 = errorParam1; + errorParams2 = errorParams2; + } + VerifFailureParams(uint8_t reportId, uint16_t tcPacketId, uint16_t tcPsc, ReturnValue_t errorCode) + : VerifParamsBase(reportId, tcPacketId, tcPsc), errorCode(errorCode) {} + VerifFailureParams(uint8_t reportId, uint16_t tcPacketId, uint16_t tcPsc) + : VerifParamsBase(reportId, tcPacketId, tcPsc) {} + VerifFailureParams(uint8_t reportId, PusTcIF& tc, ReturnValue_t errorCode) + : VerifParamsBase(reportId, tc.getPacketIdRaw(), tc.getPacketSeqCtrlRaw()), + errorCode(errorCode) {} + VerifFailureParams(uint8_t reportId, PusTcIF& tc) + : VerifParamsBase(reportId, tc.getPacketIdRaw(), tc.getPacketSeqCtrlRaw()) {} + + ReturnValue_t errorCode = retval::OK; + uint8_t step = 0; + uint32_t errorParam1 = 0; + uint32_t errorParam2 = 0; +}; +class VerificationReporterIF { + public: + virtual ~VerificationReporterIF() = default; + + virtual ReturnValue_t sendSuccessReport(VerifSuccessParams params) = 0; + virtual ReturnValue_t sendFailureReport(VerifFailureParams params) = 0; +}; + +#endif // FSFW_TMTCSERVICES_VERIFICATIONREPORTERIF_H diff --git a/src/fsfw/tmtcservices/tmHelpers.h b/src/fsfw/tmtcservices/tmHelpers.h index 6a754bdf..ad333eb2 100644 --- a/src/fsfw/tmtcservices/tmHelpers.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -10,38 +10,60 @@ namespace telemetry { class DataWithObjectIdPrefix : public SerializeIF { public: DataWithObjectIdPrefix(object_id_t objectId, const uint8_t* srcData, size_t srcDataLen) - : objectId(objectId), srcData(srcData), srcDataLen(srcDataLen) {} + : objectId(objectId) { + dataWrapper.type = ecss::DataTypes::RAW; + dataWrapper.dataUnion.raw.data = srcData; + dataWrapper.dataUnion.raw.len = srcDataLen; + } + + DataWithObjectIdPrefix(object_id_t objectId, SerializeIF& serializable) : objectId(objectId) { + dataWrapper.type = ecss::DataTypes::SERIALIZABLE; + dataWrapper.dataUnion.serializable = &serializable; + } + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override { if (*size + getSerializedSize() > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } + if (dataWrapper.type != ecss::DataTypes::RAW) { + if ((dataWrapper.dataUnion.raw.data == nullptr) and (dataWrapper.dataUnion.raw.len > 0)) { + return retval::FAILED; + } + } else if (dataWrapper.type == ecss::DataTypes::SERIALIZABLE) { + if (dataWrapper.dataUnion.serializable == nullptr) { + return retval::FAILED; + } + } ReturnValue_t result = SerializeAdapter::serialize(&objectId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - std::memcpy(*buffer, srcData, srcDataLen); - *buffer += srcDataLen; - *size += srcDataLen; - return HasReturnvaluesIF::RETURN_OK; - } - - [[nodiscard]] size_t getSerializedSize() const override { return sizeof(objectId) + srcDataLen; } - - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) override { - ReturnValue_t result = SerializeAdapter::deSerialize(&objectId, buffer, size, streamEndianness); if (result != retval::OK) { return result; } + if (dataWrapper.type != ecss::DataTypes::RAW) { + std::memcpy(*buffer, dataWrapper.dataUnion.raw.data, dataWrapper.dataUnion.raw.len); + *buffer += dataWrapper.dataUnion.raw.len; + *size += dataWrapper.dataUnion.raw.len; + } else { + return dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, streamEndianness); + } + return retval::OK; + } + + [[nodiscard]] size_t getSerializedSize() const override { + return sizeof(objectId) + dataWrapper.getLength(); + } + + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override { + // As long as there is no way to know how long the expected data will be, this function + // does not make sense return retval::FAILED; } private: object_id_t objectId; - const uint8_t* srcData; - size_t srcDataLen; + ecss::DataWrapper dataWrapper{}; }; } // namespace telemetry diff --git a/unittests/CatchFactory.cpp b/unittests/CatchFactory.cpp index d5d12935..5ae5a9fb 100644 --- a/unittests/CatchFactory.cpp +++ b/unittests/CatchFactory.cpp @@ -60,8 +60,6 @@ void Factory::setStaticFrameworkObjectIds() { CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT; diff --git a/unittests/mocks/PusServiceBaseMock.cpp b/unittests/mocks/PusServiceBaseMock.cpp new file mode 100644 index 00000000..0303364f --- /dev/null +++ b/unittests/mocks/PusServiceBaseMock.cpp @@ -0,0 +1,30 @@ +#include "PusServiceBaseMock.h" + +ReturnValue_t PsbMock::handleRequest(uint8_t subservice) { + handleRequestCallCnt++; + subserviceQueue.push(subservice); + if (handleReqFailPair.first) { + handleReqFailPair.first = false; + return handleReqFailPair.second; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PsbMock::performService() { + performServiceCallCnt++; + if (performServiceFailPair.first) { + performServiceFailPair.first = false; + return performServiceFailPair.second; + } + return HasReturnvaluesIF::RETURN_OK; +} + +void PsbMock::reset() { + handleRequestCallCnt = 0; + performServiceCallCnt = 0; + std::queue().swap(subserviceQueue); +} +void PsbMock::makeNextHandleReqCallFail(ReturnValue_t retval) { + handleReqFailPair.first = true; + handleReqFailPair.second = retval; +} diff --git a/unittests/mocks/PusServiceBaseMock.h b/unittests/mocks/PusServiceBaseMock.h new file mode 100644 index 00000000..f441c2a8 --- /dev/null +++ b/unittests/mocks/PusServiceBaseMock.h @@ -0,0 +1,23 @@ +#ifndef FSFW_TESTS_PUSSERVICEBASEMOCK_H +#define FSFW_TESTS_PUSSERVICEBASEMOCK_H + +#include + +#include "fsfw/tmtcservices/PusServiceBase.h" + +class PsbMock : public PusServiceBase { + public: + unsigned int handleRequestCallCnt = 0; + std::queue subserviceQueue; + unsigned int performServiceCallCnt = 0; + + std::pair handleReqFailPair; + std::pair performServiceFailPair; + ReturnValue_t handleRequest(uint8_t subservice) override; + ReturnValue_t performService() override; + + void makeNextHandleReqCallFail(ReturnValue_t retval); + void reset(); +}; + +#endif // FSFW_TESTS_PUSSERVICEBASEMOCK_H diff --git a/unittests/tmtcservices/CMakeLists.txt b/unittests/tmtcservices/CMakeLists.txt index 791066ad..4cb2dc05 100644 --- a/unittests/tmtcservices/CMakeLists.txt +++ b/unittests/tmtcservices/CMakeLists.txt @@ -1,4 +1,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testStoreHelper.cpp testSendHelper.cpp + testStoreAndSendHelper.cpp ) diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp new file mode 100644 index 00000000..43e03b48 --- /dev/null +++ b/unittests/tmtcservices/testPsb.cpp @@ -0,0 +1,5 @@ +#include + +#include "fsfw/tmtcservices/PusServiceBase.h" + +TEST_CASE("Pus Service Base", "[pus-service-base]") { auto psb = PusServiceBase() } \ No newline at end of file diff --git a/unittests/tmtcservices/testStoreAndSendHelper.cpp b/unittests/tmtcservices/testStoreAndSendHelper.cpp index 309556b6..2a522600 100644 --- a/unittests/tmtcservices/testStoreAndSendHelper.cpp +++ b/unittests/tmtcservices/testStoreAndSendHelper.cpp @@ -2,8 +2,12 @@ #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tmtcservices/TmSendHelper.h" +#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" #include "fsfw/tmtcservices/TmStoreHelper.h" #include "mocks/CdsShortTimestamperMock.h" +#include "mocks/InternalErrorReporterMock.h" +#include "mocks/MessageQueueMock.h" +#include "mocks/SimpleSerializable.h" TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { auto timeStamper = CdsShortTimestamperMock(); @@ -16,4 +20,68 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { auto msgQueue = MessageQueueMock(); msgQueue.setDefaultDestination(destId); TmSendHelper sendHelper(msgQueue, errReporter, destId); + TmStoreAndSendWrapper tmHelper(17, storeHelper, sendHelper); + + SECTION("State") { + CHECK(tmHelper.sendCounter == 0); + CHECK(tmHelper.defaultService == 17); + CHECK(tmHelper.delOnFailure); + CHECK(tmHelper.incrementSendCounter); + CHECK(&tmHelper.sendHelper == &sendHelper); + CHECK(&tmHelper.storeHelper == &storeHelper); + } + + SECTION("Base Test") { + tmHelper.prepareTmPacket(2); + auto& creator = storeHelper.getCreatorRef(); + REQUIRE(creator.getSubService() == 2); + REQUIRE(creator.getService() == 17); + auto& params = creator.getParams(); + REQUIRE(params.dataWrapper.type == ecss::DataTypes::RAW); + REQUIRE(params.dataWrapper.dataUnion.raw.data == nullptr); + REQUIRE(params.dataWrapper.dataUnion.raw.len == 0); + REQUIRE(tmHelper.sendCounter == 0); + REQUIRE(tmHelper.storeAndSendTmPacket() == retval::OK); + REQUIRE(tmHelper.sendCounter == 1); + auto storeId = storeHelper.getCurrentAddr(); + REQUIRE(msgQueue.wasMessageSent()); + REQUIRE(msgQueue.numberOfSentMessagesToDefault() == 1); + TmTcMessage msg; + REQUIRE(msgQueue.getNextSentMessage(msg) == retval::OK); + REQUIRE(msg.getStorageId() == storeId); + REQUIRE(pool.hasDataAtId(msg.getStorageId())); + storeHelper.deletePacket(); + } + + SECTION("Raw Data Helper") { + std::array data = {1, 2, 3}; + REQUIRE(tmHelper.prepareTmPacket(2, data.data(), data.size()) == retval::OK); + auto& creator = storeHelper.getCreatorRef(); + auto& params = creator.getParams(); + REQUIRE(params.dataWrapper.type == ecss::DataTypes::RAW); + REQUIRE(params.dataWrapper.dataUnion.raw.data == data.data()); + REQUIRE(params.dataWrapper.dataUnion.raw.len == data.size()); + } + + SECTION("Serializable Helper") { + auto simpleSer = SimpleSerializable(); + REQUIRE(tmHelper.prepareTmPacket(2, simpleSer) == retval::OK); + auto& creator = storeHelper.getCreatorRef(); + auto& params = creator.getParams(); + REQUIRE(params.dataWrapper.type == ecss::DataTypes::SERIALIZABLE); + REQUIRE(params.dataWrapper.dataUnion.serializable == &simpleSer); + } + + SECTION("Object ID prefix Helper") { + uint32_t objectId = 0x01020304; + std::array data = {1, 2, 3}; + telemetry::DataWithObjectIdPrefix dataWithObjId(objectId, data.data(), data.size()); + REQUIRE(tmHelper.prepareTmPacket(2, dataWithObjId) == retval::OK); + auto& creator = storeHelper.getCreatorRef(); + auto& params = creator.getParams(); + REQUIRE(params.dataWrapper.type == ecss::DataTypes::SERIALIZABLE); + REQUIRE(params.dataWrapper.dataUnion.serializable == &dataWithObjId); + } + + // TODO: Error handling } From 146a0e3828c832b329ff29106bd35a2289df72bf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 14:10:24 +0200 Subject: [PATCH 123/532] created PSB mock --- unittests/mocks/CMakeLists.txt | 2 ++ unittests/mocks/PusServiceBaseMock.cpp | 3 +++ unittests/mocks/PusServiceBaseMock.h | 1 + .../mocks/PusVerificationReporterMock.cpp | 23 +++++++++++++++++++ unittests/mocks/PusVerificationReporterMock.h | 23 +++++++++++++++++++ unittests/tmtcservices/CMakeLists.txt | 1 + unittests/tmtcservices/testPsb.cpp | 8 +++++-- 7 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 unittests/mocks/PusVerificationReporterMock.cpp create mode 100644 unittests/mocks/PusVerificationReporterMock.h diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 7bc8fd30..00732c80 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -7,4 +7,6 @@ target_sources(${FSFW_TEST_TGT} PRIVATE MessageQueueMock.cpp InternalErrorReporterMock.cpp LocalPoolOwnerBase.cpp + PusVerificationReporterMock.cpp + PusServiceBaseMock.cpp ) diff --git a/unittests/mocks/PusServiceBaseMock.cpp b/unittests/mocks/PusServiceBaseMock.cpp index 0303364f..4eb51fa4 100644 --- a/unittests/mocks/PusServiceBaseMock.cpp +++ b/unittests/mocks/PusServiceBaseMock.cpp @@ -1,5 +1,8 @@ #include "PusServiceBaseMock.h" +PsbMock::PsbMock(uint8_t service, uint16_t apid, VerificationReporterIF& verifyReporter) + : PusServiceBase(0, service, apid, &verifyReporter) {} + ReturnValue_t PsbMock::handleRequest(uint8_t subservice) { handleRequestCallCnt++; subserviceQueue.push(subservice); diff --git a/unittests/mocks/PusServiceBaseMock.h b/unittests/mocks/PusServiceBaseMock.h index f441c2a8..9d1bac5d 100644 --- a/unittests/mocks/PusServiceBaseMock.h +++ b/unittests/mocks/PusServiceBaseMock.h @@ -7,6 +7,7 @@ class PsbMock : public PusServiceBase { public: + PsbMock(uint8_t service, uint16_t apid, VerificationReporterIF& verifyReporter); unsigned int handleRequestCallCnt = 0; std::queue subserviceQueue; unsigned int performServiceCallCnt = 0; diff --git a/unittests/mocks/PusVerificationReporterMock.cpp b/unittests/mocks/PusVerificationReporterMock.cpp new file mode 100644 index 00000000..fdc61aca --- /dev/null +++ b/unittests/mocks/PusVerificationReporterMock.cpp @@ -0,0 +1,23 @@ +#include "PusVerificationReporterMock.h" + +size_t PusVerificationReporterMock::successCallCount() const { return successParams.size(); } +size_t PusVerificationReporterMock::failCallCount() const { return failParams.size(); } + +VerifSuccessParams& PusVerificationReporterMock::getNextSuccessCallParams() { + return successParams.front(); +} + +void PusVerificationReporterMock::popNextFailParams() { + if (not failParams.empty()) { + failParams.pop(); + } +} + +VerifFailureParams& PusVerificationReporterMock::getNextFailCallParams() { + return failParams.front(); +} +void PusVerificationReporterMock::popNextSuccessParams() { + if (not successParams.empty()) { + successParams.pop(); + } +} diff --git a/unittests/mocks/PusVerificationReporterMock.h b/unittests/mocks/PusVerificationReporterMock.h new file mode 100644 index 00000000..87595637 --- /dev/null +++ b/unittests/mocks/PusVerificationReporterMock.h @@ -0,0 +1,23 @@ +#ifndef FSFW_TESTS_PUSVERIFICATIONREPORTERMOCK_H +#define FSFW_TESTS_PUSVERIFICATIONREPORTERMOCK_H + +#include + +#include "fsfw/tmtcservices/VerificationReporterIF.h" + +class PusVerificationReporterMock : public VerificationReporterIF { + public: + std::queue successParams; + std::queue failParams; + + [[nodiscard]] size_t successCallCount() const; + VerifSuccessParams& getNextSuccessCallParams(); + void popNextSuccessParams(); + [[nodiscard]] size_t failCallCount() const; + VerifFailureParams& getNextFailCallParams(); + void popNextFailParams(); + + ReturnValue_t sendSuccessReport(VerifSuccessParams params) override { return 0; } + ReturnValue_t sendFailureReport(VerifFailureParams params) override { return 0; } +}; +#endif // FSFW_TESTS_PUSVERIFICATIONREPORTERMOCK_H diff --git a/unittests/tmtcservices/CMakeLists.txt b/unittests/tmtcservices/CMakeLists.txt index 4cb2dc05..9e60ced1 100644 --- a/unittests/tmtcservices/CMakeLists.txt +++ b/unittests/tmtcservices/CMakeLists.txt @@ -2,4 +2,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testStoreHelper.cpp testSendHelper.cpp testStoreAndSendHelper.cpp + testPsb.cpp ) diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index 43e03b48..ea4aee61 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -1,5 +1,9 @@ #include -#include "fsfw/tmtcservices/PusServiceBase.h" +#include "mocks/PusServiceBaseMock.h" +#include "mocks/PusVerificationReporterMock.h" -TEST_CASE("Pus Service Base", "[pus-service-base]") { auto psb = PusServiceBase() } \ No newline at end of file +TEST_CASE("Pus Service Base", "[pus-service-base]") { + auto verificationReporter = PusVerificationReporterMock(); + auto psb = PsbMock(17, 0x02, verificationReporter); +} \ No newline at end of file From f14c812aff239954a7653f5640fd6664268edb71 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 14:14:00 +0200 Subject: [PATCH 124/532] removed some obsolete code --- src/fsfw/tmtcservices/PusServiceBase.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index f727e415..7ee5f8c6 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -25,7 +25,7 @@ PusServiceBase::~PusServiceBase() { QueueFactory::instance()->deleteMessageQueue ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { handleRequestQueue(); - ReturnValue_t result = this->performService(); + ReturnValue_t result = performService(); if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PusService " << (uint16_t)this->serviceId << ": performService returned with " @@ -43,17 +43,7 @@ void PusServiceBase::handleRequestQueue() { ReturnValue_t result; for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) { ReturnValue_t status = this->requestQueue->receiveMessage(&message); - // if(status != MessageQueueIF::EMPTY) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - // sif::debug << "PusServiceBase::performOperation: Receiving from " - // << "MQ ID: " << std::hex << "0x" << std::setw(8) - // << std::setfill('0') << this->requestQueue->getId() - // << std::dec << " returned: " << status << std::setfill(' ') - // << std::endl; -#endif - // } if (status == MessageQueueIF::EMPTY) { - status = RETURN_OK; break; } else if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 From d98b79cf5e639abbe66420eeca42c47593b58a85 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 16:49:46 +0200 Subject: [PATCH 125/532] adapt PSB so it can be unittested properly --- src/fsfw/pus/Service17Test.cpp | 8 +- src/fsfw/pus/Service17Test.h | 2 +- src/fsfw/pus/Service5EventReporting.cpp | 11 +- src/fsfw/pus/Service5EventReporting.h | 4 +- src/fsfw/pus/Service9TimeManagement.cpp | 4 +- src/fsfw/pus/Service9TimeManagement.h | 8 +- src/fsfw/tmtcservices/AcceptsTelemetryIF.h | 8 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 106 ++++++++++-------- src/fsfw/tmtcservices/PusServiceBase.h | 97 ++++++++++------ src/fsfw/tmtcservices/TmTcMessage.cpp | 6 +- src/fsfw/tmtcservices/TmTcMessage.h | 6 +- unittests/CatchFactory.cpp | 1 - unittests/action/TestActionHelper.cpp | 3 +- unittests/datapoollocal/testDataSet.cpp | 2 +- .../datapoollocal/testLocalPoolManager.cpp | 2 +- .../datapoollocal/testLocalPoolVariable.cpp | 2 +- .../datapoollocal/testLocalPoolVector.cpp | 2 +- unittests/mocks/AcceptsTmMock.cpp | 7 ++ unittests/mocks/AcceptsTmMock.h | 14 +++ unittests/mocks/CMakeLists.txt | 1 + unittests/mocks/MessageQueueMock.cpp | 3 - unittests/mocks/MessageQueueMock.h | 2 - unittests/mocks/PusServiceBaseMock.cpp | 4 +- unittests/mocks/PusServiceBaseMock.h | 2 +- unittests/tmtcservices/testPsb.cpp | 25 ++++- unittests/tmtcservices/testSendHelper.cpp | 4 +- .../tmtcservices/testStoreAndSendHelper.cpp | 2 +- 27 files changed, 205 insertions(+), 131 deletions(-) create mode 100644 unittests/mocks/AcceptsTmMock.cpp create mode 100644 unittests/mocks/AcceptsTmMock.h diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index d526e055..14257334 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -5,10 +5,10 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tmtcservices/tmHelpers.h" -Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId) - : PusServiceBase(objectId, apid, serviceId), - storeHelper(apid), - tmHelper(serviceId, storeHelper, sendHelper) {} +Service17Test::Service17Test(PsbParams params) + : PusServiceBase(params), + storeHelper(params.apid), + tmHelper(params.serviceId, storeHelper, sendHelper) {} Service17Test::~Service17Test() = default; diff --git a/src/fsfw/pus/Service17Test.h b/src/fsfw/pus/Service17Test.h index 7e2db98b..f2ec6e4f 100644 --- a/src/fsfw/pus/Service17Test.h +++ b/src/fsfw/pus/Service17Test.h @@ -34,7 +34,7 @@ class Service17Test : public PusServiceBase { EVENT_TRIGGER_TEST = 128, }; - Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId); + explicit Service17Test(PsbParams params); void setCustomTmStore(StorageManagerIF& tmStore); diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index a895ad0d..fa518d0f 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -7,12 +7,11 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcservices/tmHelpers.h" -Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t apid, - uint8_t serviceId, size_t maxNumberReportsPerCycle, +Service5EventReporting::Service5EventReporting(PsbParams params, size_t maxNumberReportsPerCycle, uint32_t messageQueueDepth) - : PusServiceBase(objectId, apid, serviceId), - storeHelper(apid), - tmHelper(serviceId, storeHelper, sendHelper), + : PusServiceBase(params), + storeHelper(params.apid), + tmHelper(params.serviceId, storeHelper, sendHelper), maxNumberReportsPerCycle(maxNumberReportsPerCycle) { eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); } @@ -47,7 +46,7 @@ ReturnValue_t Service5EventReporting::performService() { ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) { EventReport report(message.getEventId(), message.getReporter(), message.getParameter1(), message.getParameter2()); - storeHelper.preparePacket(serviceId, message.getSeverity(), tmHelper.sendCounter); + storeHelper.preparePacket(psbParams.serviceId, message.getSeverity(), tmHelper.sendCounter); storeHelper.setSourceDataSerializable(report); ReturnValue_t result = tmHelper.storeAndSendTmPacket(); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/src/fsfw/pus/Service5EventReporting.h b/src/fsfw/pus/Service5EventReporting.h index e6f67bfd..1f4e5a3a 100644 --- a/src/fsfw/pus/Service5EventReporting.h +++ b/src/fsfw/pus/Service5EventReporting.h @@ -41,8 +41,8 @@ */ class Service5EventReporting : public PusServiceBase { public: - Service5EventReporting(object_id_t objectId, uint16_t apid, uint8_t serviceId, - size_t maxNumberReportsPerCycle = 10, uint32_t messageQueueDepth = 10); + Service5EventReporting(PsbParams params, size_t maxNumberReportsPerCycle = 10, + uint32_t messageQueueDepth = 10); ~Service5EventReporting() override; /*** diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 4abbd5d2..4a26f993 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -5,9 +5,7 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/CCSDSTime.h" -Service9TimeManagement::Service9TimeManagement(object_id_t objectId, uint16_t apid, - uint8_t serviceId) - : PusServiceBase(objectId, apid, serviceId) {} +Service9TimeManagement::Service9TimeManagement(PsbParams params) : PusServiceBase(params) {} Service9TimeManagement::~Service9TimeManagement() = default; diff --git a/src/fsfw/pus/Service9TimeManagement.h b/src/fsfw/pus/Service9TimeManagement.h index 9369e207..b4886bb0 100644 --- a/src/fsfw/pus/Service9TimeManagement.h +++ b/src/fsfw/pus/Service9TimeManagement.h @@ -16,16 +16,16 @@ class Service9TimeManagement : public PusServiceBase { /** * @brief This service provides the capability to set the on-board time. */ - Service9TimeManagement(object_id_t objectId, uint16_t apid, uint8_t serviceId); + explicit Service9TimeManagement(PsbParams params); - virtual ~Service9TimeManagement(); + ~Service9TimeManagement() override; - virtual ReturnValue_t performService() override; + ReturnValue_t performService() override; /** * @brief Sets the onboard-time by retrieving the time to set from TC[9,128]. */ - virtual ReturnValue_t handleRequest(uint8_t subservice) override; + ReturnValue_t handleRequest(uint8_t subservice) override; virtual ReturnValue_t setTime(); diff --git a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h index 0e715130..6f8a6226 100644 --- a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h +++ b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h @@ -1,7 +1,7 @@ #ifndef FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ #define FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ -#include "../ipc/MessageQueueSenderIF.h" +#include "fsfw/ipc/MessageQueueSenderIF.h" /** * @brief This interface is implemented by classes that are sinks for * Telemetry. @@ -13,13 +13,15 @@ class AcceptsTelemetryIF { /** * @brief The virtual destructor as it is mandatory for C++ interfaces. */ - virtual ~AcceptsTelemetryIF() {} + virtual ~AcceptsTelemetryIF() = default; /** * @brief This method returns the message queue id of the telemetry * receiving message queue. * @return The telemetry reception message queue id. */ - virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) = 0; + virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) = 0; + + virtual MessageQueueId_t getReportReceptionQueue() { return getReportReceptionQueue(0); } }; #endif /* FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ */ diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 7ee5f8c6..8d250a0f 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -9,19 +9,16 @@ #include "fsfw/tmtcservices/TmTcMessage.h" #include "fsfw/tmtcservices/tcHelpers.h" -object_id_t PusServiceBase::packetSource = 0; object_id_t PusServiceBase::packetDestination = 0; -PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId, - VerificationReporterIF* verifyReporter) - : SystemObject(setObjectId), - apid(setApid), - serviceId(setServiceId), - verifyReporter(verifyReporter) { - requestQueue = QueueFactory::instance()->createMessageQueue(PUS_SERVICE_MAX_RECEPTION); -} +PusServiceBase::PusServiceBase(PsbParams params) + : SystemObject(params.objectId), psbParams(params) {} -PusServiceBase::~PusServiceBase() { QueueFactory::instance()->deleteMessageQueue(requestQueue); } +PusServiceBase::~PusServiceBase() { + if (ownedQueue) { + QueueFactory::instance()->deleteMessageQueue(psbParams.reqQueue); + } +} ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { handleRequestQueue(); @@ -42,7 +39,7 @@ void PusServiceBase::handleRequestQueue() { TmTcMessage message; ReturnValue_t result; for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) { - ReturnValue_t status = this->requestQueue->receiveMessage(&message); + ReturnValue_t status = psbParams.reqQueue->receiveMessage(&message); if (status == MessageQueueIF::EMPTY) { break; } else if (status != HasReturnvaluesIF::RETURN_OK) { @@ -53,27 +50,27 @@ void PusServiceBase::handleRequestQueue() { #else sif::printError( "PusServiceBase::performOperation: Service %d. Error receiving packet. Code: %04x\n", - serviceId, status); + psbParams.serviceId, status); #endif break; } result = tc::prepareTcReader(tcStore, message.getStorageId(), currentPacket); if (result != HasReturnvaluesIF::RETURN_OK) { - auto params = VerifFailureParams(tcverif::START_FAILURE, currentPacket, result); - params.errorParam1 = errorParameter1; - params.errorParam2 = errorParameter2; - verifyReporter->sendFailureReport(params); + auto verifParams = VerifFailureParams(tcverif::START_FAILURE, currentPacket, result); + verifParams.errorParam1 = errorParameter1; + verifParams.errorParam2 = errorParameter2; + psbParams.verifReporter->sendFailureReport(verifParams); continue; } result = handleRequest(currentPacket.getSubService()); if (result == RETURN_OK) { - verifyReporter->sendSuccessReport( + psbParams.verifReporter->sendSuccessReport( VerifSuccessParams(tcverif::COMPLETION_SUCCESS, currentPacket)); } else { - auto params = VerifFailureParams(tcverif::COMPLETION_FAILURE, currentPacket, result); - params.errorParam1 = errorParameter1; - params.errorParam2 = errorParameter2; - verifyReporter->sendFailureReport(params); + auto failParams = VerifFailureParams(tcverif::COMPLETION_FAILURE, currentPacket, result); + failParams.errorParam1 = errorParameter1; + failParams.errorParam2 = errorParameter2; + psbParams.verifReporter->sendFailureReport(failParams); } tcStore->deleteData(message.getStorageId()); errorParameter1 = 0; @@ -81,37 +78,39 @@ void PusServiceBase::handleRequestQueue() { } } -uint16_t PusServiceBase::getIdentifier() { return this->serviceId; } +uint16_t PusServiceBase::getIdentifier() { return psbParams.serviceId; } -MessageQueueId_t PusServiceBase::getRequestQueue() { return this->requestQueue->getId(); } +MessageQueueId_t PusServiceBase::getRequestQueue() { return psbParams.reqQueue->getId(); } ReturnValue_t PusServiceBase::initialize() { ReturnValue_t result = SystemObject::initialize(); if (result != RETURN_OK) { return result; } - auto* destService = ObjectManager::instance()->get(packetDestination); - auto* distributor = ObjectManager::instance()->get(packetSource); - if (destService == nullptr or distributor == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PusServiceBase::PusServiceBase: Service " << this->serviceId - << ": Configuration error. Make sure " - << "packetSource and packetDestination are defined correctly" << std::endl; -#endif - return ObjectManagerIF::CHILD_INIT_FAILED; + if (psbParams.reqQueue == nullptr) { + ownedQueue = true; + psbParams.reqQueue = QueueFactory::instance()->createMessageQueue(PSB_DEFAULT_QUEUE_DEPTH); + } else { + ownedQueue = false; } - this->requestQueue->setDefaultDestination(destService->getReportReceptionQueue()); - distributor->registerService(this); + if (psbParams.tmReceiver == nullptr) { + psbParams.tmReceiver = ObjectManager::instance()->get(packetDestination); + if (psbParams.tmReceiver != nullptr) { + psbParams.reqQueue->setDefaultDestination(psbParams.tmReceiver->getReportReceptionQueue()); + } + } + if (tcStore == nullptr) { - tcStore = ObjectManager::instance()->get(objects::IPC_STORE); + tcStore = ObjectManager::instance()->get(objects::TC_STORE); if (tcStore == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } } - if (verifyReporter == nullptr) { - verifyReporter = + + if (psbParams.verifReporter == nullptr) { + psbParams.verifReporter = ObjectManager::instance()->get(objects::TC_VERIFICATOR); - if (verifyReporter == nullptr) { + if (psbParams.verifReporter == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } } @@ -128,7 +127,7 @@ ReturnValue_t PusServiceBase::initializeAfterTaskCreation() { void PusServiceBase::setCustomTcStore(StorageManagerIF* tcStore_) { tcStore = tcStore_; } void PusServiceBase::setCustomErrorReporter(InternalErrorReporterIF* errReporter_) { - errReporter = errReporter_; + psbParams.errReporter = errReporter_; } void PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper) { @@ -137,21 +136,34 @@ void PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelp } void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { - tmSendHelper.setMsgQueue(*requestQueue); - tmSendHelper.setDefaultDestination(requestQueue->getDefaultDestination()); - if (errReporter == nullptr) { - errReporter = + if (psbParams.reqQueue != nullptr) { + tmSendHelper.setMsgQueue(*psbParams.reqQueue); + tmSendHelper.setDefaultDestination(psbParams.reqQueue->getDefaultDestination()); + } + + if (psbParams.errReporter == nullptr) { + psbParams.errReporter = ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); - if (errReporter != nullptr) { - tmSendHelper.setInternalErrorReporter(errReporter); + if (psbParams.errReporter != nullptr) { + tmSendHelper.setInternalErrorReporter(psbParams.errReporter); } } } void PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { - tmStoreHelper.setApid(apid); + tmStoreHelper.setApid(psbParams.apid); } void PusServiceBase::setVerificationReporter(VerificationReporterIF* reporter) { - verifyReporter = reporter; + psbParams.verifReporter = reporter; } + +ReturnValue_t PusServiceBase::registerService(PUSDistributorIF& distributor) { + return distributor.registerService(this); +} + +void PusServiceBase::setTmReceiver(AcceptsTelemetryIF* tmReceiver_) { + psbParams.tmReceiver = tmReceiver_; +} + +void PusServiceBase::setRequestQueue(MessageQueueIF* reqQueue) { psbParams.reqQueue = reqQueue; } diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 4aa6fade..fabe6141 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -2,6 +2,7 @@ #define FSFW_TMTCSERVICES_PUSSERVICEBASE_H_ #include "AcceptsTelecommandsIF.h" +#include "AcceptsTelemetryIF.h" #include "TmSendHelper.h" #include "TmStoreHelper.h" #include "VerificationCodes.h" @@ -11,6 +12,7 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/tcdistribution/PUSDistributorIF.h" namespace Factory { void setStaticFrameworkObjectIds(); @@ -18,6 +20,44 @@ void setStaticFrameworkObjectIds(); class StorageManagerIF; +/** + * Configuration parameters for the PUS Service Base + */ +struct PsbParams { + PsbParams() = default; + PsbParams(uint16_t apid, AcceptsTelemetryIF* tmReceiver) : apid(apid), tmReceiver(tmReceiver) {} + PsbParams(object_id_t objectId, uint16_t apid, uint8_t serviceId) + : objectId(objectId), apid(apid), serviceId(serviceId) {} + + object_id_t objectId = objects::NO_OBJECT; + uint16_t apid = 0; + uint8_t serviceId = 0; + /** + * The default destination ID for generated telemetry. If this is not set, @initialize of PSB + * will attempt to find a suitable object with the object ID @PusServiceBase::packetDestination + */ + AcceptsTelemetryIF* tmReceiver = nullptr; + /** + * An instance of the VerificationReporter class, that simplifies + * sending any kind of verification message to the TC Verification Service. If this is not set, + * @initialize of PSB will attempt to find a suitable global object with the ID + * @objects::TC_VERIFICATOR + */ + VerificationReporterIF* verifReporter = nullptr; + /** + * This is a complete instance of the telecommand reception queue + * of the class. It is initialized on construction of the class. + */ + MessageQueueIF* reqQueue = nullptr; + /** + * The internal error reporter which will be used if there are issues sending telemetry. + * If this is not set, and the TM send or store helpers are initialized with the PSB, + * the class will attempt to find a suitable global object with the ID + * @objects::INTERNAL_ERROR_REPORTER + */ + InternalErrorReporterIF* errReporter = nullptr; +}; + /** * @defgroup pus_services PUS Service Framework * These group contains all implementations of PUS Services in the OBSW. @@ -43,23 +83,33 @@ class PusServiceBase : public ExecutableObjectIF, friend void(Factory::setStaticFrameworkObjectIds)(); public: + /** + * This constant sets the maximum number of packets accepted per call. + * Remember that one packet must be completely handled in one + * #handleRequest call. + */ + static constexpr uint8_t PUS_SERVICE_MAX_RECEPTION = 10; + static constexpr uint8_t PSB_DEFAULT_QUEUE_DEPTH = 10; + /** * @brief The passed values are set, but inter-object initialization is * done in the initialize method. - * @param setObjectId - * The system object identifier of this Service instance. - * @param setApid - * The APID the Service is instantiated for. - * @param setServiceId - * The Service Identifier as specified in ECSS PUS. + * @param params All configuration parameters for the PUS Service Base */ - PusServiceBase(object_id_t setObjectId, uint16_t setApid, uint8_t setServiceId, - VerificationReporterIF* reporter = nullptr); + explicit PusServiceBase(PsbParams params); /** * The destructor is empty. */ ~PusServiceBase() override; + ReturnValue_t registerService(PUSDistributorIF& distributor); + /** + * Set the request queue which is used to receive requests. If none is set, the initialize + * function will create one + * @param reqQueue + */ + void setRequestQueue(MessageQueueIF* reqQueue); + void setTmReceiver(AcceptsTelemetryIF* tmReceiver); void setCustomTcStore(StorageManagerIF* tcStore); void setVerificationReporter(VerificationReporterIF* reporter); void setCustomErrorReporter(InternalErrorReporterIF* errReporter); @@ -136,14 +186,6 @@ class PusServiceBase : public ExecutableObjectIF, * Will be set by setTaskIF(), which is called on task creation. */ PeriodicTaskIF* taskHandle = nullptr; - /** - * The APID of this instance of the Service. - */ - uint16_t apid; - /** - * The Service Identifier. - */ - uint8_t serviceId; /** * One of two error parameters for additional error information. */ @@ -152,38 +194,19 @@ class PusServiceBase : public ExecutableObjectIF, * One of two error parameters for additional error information. */ uint32_t errorParameter2 = 0; - /** - * This is a complete instance of the telecommand reception queue - * of the class. It is initialized on construction of the class. - */ - MessageQueueIF* requestQueue = nullptr; - /** - * An instance of the VerificationReporter class, that simplifies - * sending any kind of verification message to the TC Verification Service. - */ - VerificationReporterIF* verifyReporter; - + PsbParams psbParams; /** * The current Telecommand to be processed. * It is deleted after handleRequest was executed. */ PusTcReader currentPacket; StorageManagerIF* tcStore = nullptr; - InternalErrorReporterIF* errReporter = nullptr; - - static object_id_t packetSource; + bool ownedQueue = true; static object_id_t packetDestination; VerifSuccessParams successParams; private: - /** - * This constant sets the maximum number of packets accepted per call. - * Remember that one packet must be completely handled in one - * #handleRequest call. - */ - static const uint8_t PUS_SERVICE_MAX_RECEPTION = 10; - void handleRequestQueue(); }; diff --git a/src/fsfw/tmtcservices/TmTcMessage.cpp b/src/fsfw/tmtcservices/TmTcMessage.cpp index ca76760f..bd071b5b 100644 --- a/src/fsfw/tmtcservices/TmTcMessage.cpp +++ b/src/fsfw/tmtcservices/TmTcMessage.cpp @@ -4,7 +4,7 @@ TmTcMessage::TmTcMessage() { this->messageSize += sizeof(store_address_t); } -TmTcMessage::~TmTcMessage() {} +TmTcMessage::~TmTcMessage() = default; store_address_t TmTcMessage::getStorageId() { store_address_t temp_id; @@ -18,9 +18,9 @@ TmTcMessage::TmTcMessage(store_address_t storeId) { } size_t TmTcMessage::getMinimumMessageSize() const { - return this->HEADER_SIZE + sizeof(store_address_t); + return TmTcMessage::HEADER_SIZE + sizeof(store_address_t); } void TmTcMessage::setStorageId(store_address_t storeId) { - memcpy(this->getData(), &storeId, sizeof(store_address_t)); + std::memcpy(this->getData(), &storeId, sizeof(store_address_t)); } diff --git a/src/fsfw/tmtcservices/TmTcMessage.h b/src/fsfw/tmtcservices/TmTcMessage.h index a0f67894..3fba6d7a 100644 --- a/src/fsfw/tmtcservices/TmTcMessage.h +++ b/src/fsfw/tmtcservices/TmTcMessage.h @@ -18,7 +18,7 @@ class TmTcMessage : public MessageQueueMessage { * @brief This call always returns the same fixed size of the message. * @return Returns HEADER_SIZE + @c sizeof(store_address_t). */ - size_t getMinimumMessageSize() const override; + [[nodiscard]] size_t getMinimumMessageSize() const override; public: /** @@ -30,11 +30,11 @@ class TmTcMessage : public MessageQueueMessage { * into the message. * @param packet_id The packet id to put into the message. */ - TmTcMessage(store_address_t packetId); + explicit TmTcMessage(store_address_t packetId); /** * @brief The class's destructor is empty. */ - ~TmTcMessage(); + ~TmTcMessage() override; /** * @brief This getter returns the packet id in the correct format. * @return Returns the packet id. diff --git a/unittests/CatchFactory.cpp b/unittests/CatchFactory.cpp index 5ae5a9fb..1d10c582 100644 --- a/unittests/CatchFactory.cpp +++ b/unittests/CatchFactory.cpp @@ -54,7 +54,6 @@ void Factory::produceFrameworkObjects(void* args) { // like this. Instead, this should be more like a general struct containing all important // object IDs which are then explicitely passed in the object constructor void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetSource = objects::NO_OBJECT; PusServiceBase::packetDestination = objects::NO_OBJECT; CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index bf5589ab..849e57d2 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -10,7 +10,8 @@ TEST_CASE("Action Helper", "[ActionHelper]") { ActionHelperOwnerMockBase testDhMock; - MessageQueueMock testMqMock; + // TODO: Setting another number here breaks the test. Find out why + MessageQueueMock testMqMock(MessageQueueIF::NO_QUEUE); ActionHelper actionHelper = ActionHelper(&testDhMock, dynamic_cast(&testMqMock)); CommandMessage actionMessage; ActionId_t testActionId = 777; diff --git a/unittests/datapoollocal/testDataSet.cpp b/unittests/datapoollocal/testDataSet.cpp index 0ef5a77f..532208f5 100644 --- a/unittests/datapoollocal/testDataSet.cpp +++ b/unittests/datapoollocal/testDataSet.cpp @@ -14,7 +14,7 @@ #include "tests/TestsConfig.h" TEST_CASE("DataSetTest", "[DataSetTest]") { - auto queue = MessageQueueMock(); + auto queue = MessageQueueMock(1); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); diff --git a/unittests/datapoollocal/testLocalPoolManager.cpp b/unittests/datapoollocal/testLocalPoolManager.cpp index e5282c16..bdeec8c0 100644 --- a/unittests/datapoollocal/testLocalPoolManager.cpp +++ b/unittests/datapoollocal/testLocalPoolManager.cpp @@ -20,7 +20,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { const MessageQueueId_t hkDest = defaultDestId; const MessageQueueId_t subscriberId = 2; auto hkReceiver = HkReceiverMock(hkDest); - auto queue = MessageQueueMock(); + auto queue = MessageQueueMock(3); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); diff --git a/unittests/datapoollocal/testLocalPoolVariable.cpp b/unittests/datapoollocal/testLocalPoolVariable.cpp index dda5aca6..b3ae07e0 100644 --- a/unittests/datapoollocal/testLocalPoolVariable.cpp +++ b/unittests/datapoollocal/testLocalPoolVariable.cpp @@ -8,7 +8,7 @@ #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { - auto queue = MessageQueueMock(); + auto queue = MessageQueueMock(1); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); diff --git a/unittests/datapoollocal/testLocalPoolVector.cpp b/unittests/datapoollocal/testLocalPoolVector.cpp index dc91fa7e..e04bf643 100644 --- a/unittests/datapoollocal/testLocalPoolVector.cpp +++ b/unittests/datapoollocal/testLocalPoolVector.cpp @@ -8,7 +8,7 @@ #include "tests/TestsConfig.h" TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { - auto queue = MessageQueueMock(); + auto queue = MessageQueueMock(1); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); diff --git a/unittests/mocks/AcceptsTmMock.cpp b/unittests/mocks/AcceptsTmMock.cpp new file mode 100644 index 00000000..9142308d --- /dev/null +++ b/unittests/mocks/AcceptsTmMock.cpp @@ -0,0 +1,7 @@ +#include "AcceptsTmMock.h" + +AcceptsTmMock::AcceptsTmMock(MessageQueueId_t queueToReturn) : returnedQueue(queueToReturn) {} + +MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) { + return returnedQueue; +} diff --git a/unittests/mocks/AcceptsTmMock.h b/unittests/mocks/AcceptsTmMock.h new file mode 100644 index 00000000..b0ccc9a7 --- /dev/null +++ b/unittests/mocks/AcceptsTmMock.h @@ -0,0 +1,14 @@ +#ifndef FSFW_TESTS_ACCEPTSTMMOCK_H +#define FSFW_TESTS_ACCEPTSTMMOCK_H + +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" + +class AcceptsTmMock : public AcceptsTelemetryIF { + public: + explicit AcceptsTmMock(MessageQueueId_t queueToReturn); + + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override; + + MessageQueueId_t returnedQueue; +}; +#endif // FSFW_TESTS_ACCEPTSTMMOCK_H diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 00732c80..5bb37db4 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -9,4 +9,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE LocalPoolOwnerBase.cpp PusVerificationReporterMock.cpp PusServiceBaseMock.cpp + AcceptsTmMock.cpp ) diff --git a/unittests/mocks/MessageQueueMock.cpp b/unittests/mocks/MessageQueueMock.cpp index c514cc2e..215a7830 100644 --- a/unittests/mocks/MessageQueueMock.cpp +++ b/unittests/mocks/MessageQueueMock.cpp @@ -3,9 +3,6 @@ #include #include -MessageQueueMock::MessageQueueMock() - : MessageQueueBase(MessageQueueIF::NO_QUEUE, MessageQueueIF::NO_QUEUE, nullptr) {} - MessageQueueMock::MessageQueueMock(MessageQueueId_t queueId) : MessageQueueBase(queueId, MessageQueueIF::NO_QUEUE, nullptr) {} diff --git a/unittests/mocks/MessageQueueMock.h b/unittests/mocks/MessageQueueMock.h index 0be68223..52ba5dfe 100644 --- a/unittests/mocks/MessageQueueMock.h +++ b/unittests/mocks/MessageQueueMock.h @@ -22,8 +22,6 @@ struct SendInfo { class MessageQueueMock : public MessageQueueBase { public: - MessageQueueMock(); - void addReceivedMessage(MessageQueueMessageIF& msg); explicit MessageQueueMock(MessageQueueId_t queueId); diff --git a/unittests/mocks/PusServiceBaseMock.cpp b/unittests/mocks/PusServiceBaseMock.cpp index 4eb51fa4..ef36d09e 100644 --- a/unittests/mocks/PusServiceBaseMock.cpp +++ b/unittests/mocks/PusServiceBaseMock.cpp @@ -1,7 +1,6 @@ #include "PusServiceBaseMock.h" -PsbMock::PsbMock(uint8_t service, uint16_t apid, VerificationReporterIF& verifyReporter) - : PusServiceBase(0, service, apid, &verifyReporter) {} +PsbMock::PsbMock(PsbParams params) : PusServiceBase(params) {} ReturnValue_t PsbMock::handleRequest(uint8_t subservice) { handleRequestCallCnt++; @@ -27,6 +26,7 @@ void PsbMock::reset() { performServiceCallCnt = 0; std::queue().swap(subserviceQueue); } + void PsbMock::makeNextHandleReqCallFail(ReturnValue_t retval) { handleReqFailPair.first = true; handleReqFailPair.second = retval; diff --git a/unittests/mocks/PusServiceBaseMock.h b/unittests/mocks/PusServiceBaseMock.h index 9d1bac5d..42620662 100644 --- a/unittests/mocks/PusServiceBaseMock.h +++ b/unittests/mocks/PusServiceBaseMock.h @@ -7,7 +7,7 @@ class PsbMock : public PusServiceBase { public: - PsbMock(uint8_t service, uint16_t apid, VerificationReporterIF& verifyReporter); + explicit PsbMock(PsbParams params); unsigned int handleRequestCallCnt = 0; std::queue subserviceQueue; unsigned int performServiceCallCnt = 0; diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index ea4aee61..53fe763d 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -1,9 +1,32 @@ #include +#include "fsfw/ipc/QueueFactory.h" +#include "mocks/AcceptsTmMock.h" +#include "mocks/MessageQueueMock.h" #include "mocks/PusServiceBaseMock.h" #include "mocks/PusVerificationReporterMock.h" TEST_CASE("Pus Service Base", "[pus-service-base]") { auto verificationReporter = PusVerificationReporterMock(); - auto psb = PsbMock(17, 0x02, verificationReporter); + auto msgQueue = MessageQueueMock(1); + auto tmReceiver = AcceptsTmMock(2); + auto psbParams = PsbParams(0, 0x02, 17); + psbParams.verifReporter = &verificationReporter; + psbParams.reqQueue = &msgQueue; + psbParams.tmReceiver = &tmReceiver; + auto psb = PsbMock(psbParams); + store_address_t dummyId(1); + auto reqQueue = psb.getRequestQueue(); + TmTcMessage tmtcMsg(dummyId); + REQUIRE(psb.initialize() == HasReturnvaluesIF::RETURN_OK); + + SECTION("State") { + REQUIRE(psb.getIdentifier() == 17); + REQUIRE(psb.getObjectId() == 0); + } + + SECTION("Send Request") { + msgQueue.addReceivedMessage(tmtcMsg); + REQUIRE(psb.performOperation(0) == retval::OK); + } } \ No newline at end of file diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 786fe073..82adc04b 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -8,9 +8,9 @@ #include "mocks/MessageQueueMock.h" TEST_CASE("TM Send Helper", "[tm-send-helper]") { - MessageQueueId_t destId = 1; + MessageQueueId_t destId = 2; auto errReporter = InternalErrorReporterMock(); - auto msgQueue = MessageQueueMock(); + auto msgQueue = MessageQueueMock(1); msgQueue.setDefaultDestination(destId); TmSendHelper sendHelper(msgQueue, errReporter, destId); auto timeStamper = CdsShortTimestamperMock(); diff --git a/unittests/tmtcservices/testStoreAndSendHelper.cpp b/unittests/tmtcservices/testStoreAndSendHelper.cpp index 2a522600..73051f8e 100644 --- a/unittests/tmtcservices/testStoreAndSendHelper.cpp +++ b/unittests/tmtcservices/testStoreAndSendHelper.cpp @@ -17,7 +17,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { MessageQueueId_t destId = 1; auto errReporter = InternalErrorReporterMock(); - auto msgQueue = MessageQueueMock(); + auto msgQueue = MessageQueueMock(2); msgQueue.setDefaultDestination(destId); TmSendHelper sendHelper(msgQueue, errReporter, destId); TmStoreAndSendWrapper tmHelper(17, storeHelper, sendHelper); From 1954ce0ea409a1b981d42198a882cdf1033edbe3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 17:41:10 +0200 Subject: [PATCH 126/532] default PUS receiver set automatically now --- .../tmtcservices/CommandingServiceBase.cpp | 2 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 24 +++++-- src/fsfw/tmtcservices/PusServiceBase.h | 15 +++- .../tmtcservices/VerificationReporter.cpp | 26 +++++++ src/fsfw/tmtcservices/VerificationReporter.h | 3 + src/fsfw/tmtcservices/tcHelpers.cpp | 4 +- src/fsfw/tmtcservices/tcHelpers.h | 2 +- unittests/mocks/PusServiceBaseMock.cpp | 8 +++ unittests/mocks/PusServiceBaseMock.h | 1 + .../mocks/PusVerificationReporterMock.cpp | 11 +++ unittests/mocks/PusVerificationReporterMock.h | 4 +- unittests/tmtcservices/testPsb.cpp | 68 +++++++++++++++++-- 12 files changed, 149 insertions(+), 19 deletions(-) diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index c890ecfb..0815c838 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -422,7 +422,7 @@ void CommandingServiceBase::setCustomTmStore(StorageManagerIF& store) { tmStoreHelper.setTmStore(store); } ReturnValue_t CommandingServiceBase::setUpTcReader(store_address_t storeId) { - return tc::prepareTcReader(tcStore, storeId, tcReader); + return tc::prepareTcReader(*tcStore, storeId, tcReader); } void CommandingServiceBase::prepareVerificationFailureWithFullInfo(uint8_t reportId, diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 8d250a0f..c283d655 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -10,6 +10,7 @@ #include "fsfw/tmtcservices/tcHelpers.h" object_id_t PusServiceBase::packetDestination = 0; +object_id_t PusServiceBase::pusDistributor = 0; PusServiceBase::PusServiceBase(PsbParams params) : SystemObject(params.objectId), psbParams(params) {} @@ -54,9 +55,11 @@ void PusServiceBase::handleRequestQueue() { #endif break; } - result = tc::prepareTcReader(tcStore, message.getStorageId(), currentPacket); + result = tc::prepareTcReader(*psbParams.tcPool, message.getStorageId(), currentPacket); if (result != HasReturnvaluesIF::RETURN_OK) { - auto verifParams = VerifFailureParams(tcverif::START_FAILURE, currentPacket, result); + // We were not even able to retrieve the TC, so we can not retrieve any TC properties either + // without segfaulting + auto verifParams = VerifFailureParams(tcverif::START_FAILURE, 0, 0, result); verifParams.errorParam1 = errorParameter1; verifParams.errorParam2 = errorParameter2; psbParams.verifReporter->sendFailureReport(verifParams); @@ -72,7 +75,7 @@ void PusServiceBase::handleRequestQueue() { failParams.errorParam2 = errorParameter2; psbParams.verifReporter->sendFailureReport(failParams); } - tcStore->deleteData(message.getStorageId()); + psbParams.tcPool->deleteData(message.getStorageId()); errorParameter1 = 0; errorParameter2 = 0; } @@ -100,9 +103,16 @@ ReturnValue_t PusServiceBase::initialize() { } } - if (tcStore == nullptr) { - tcStore = ObjectManager::instance()->get(objects::TC_STORE); - if (tcStore == nullptr) { + if (psbParams.pusDistributor != nullptr) { + psbParams.pusDistributor = ObjectManager::instance()->get(pusDistributor); + if (psbParams.pusDistributor != nullptr) { + registerService(*psbParams.pusDistributor); + } + } + + if (psbParams.tcPool == nullptr) { + psbParams.tcPool = ObjectManager::instance()->get(objects::TC_STORE); + if (psbParams.tcPool == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } } @@ -124,7 +134,7 @@ ReturnValue_t PusServiceBase::initializeAfterTaskCreation() { return HasReturnvaluesIF::RETURN_OK; } -void PusServiceBase::setCustomTcStore(StorageManagerIF* tcStore_) { tcStore = tcStore_; } +void PusServiceBase::setCustomTcStore(StorageManagerIF* tcPool) { psbParams.tcPool = tcPool; } void PusServiceBase::setCustomErrorReporter(InternalErrorReporterIF* errReporter_) { psbParams.errReporter = errReporter_; diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index fabe6141..1c1c417d 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -56,6 +56,19 @@ struct PsbParams { * @objects::INTERNAL_ERROR_REPORTER */ InternalErrorReporterIF* errReporter = nullptr; + /** + * The storage manager which will be used to retrieve any TC packet using the store ID + * received via a message. If this is not set, the class will attempt to find a suitable global + * object with the ID @objects::TC_STORE + */ + StorageManagerIF* tcPool = nullptr; + /** + * Usually, packets are sent via a dedicated PUS distributor. If this distributor is set, + * the PUS service will register itself there. Otherwise, the base class will try to find + * a suitable global distributor with the static ID @PusServiceBase::pusDistributor and + * register itself at that object. + */ + PUSDistributorIF* pusDistributor = nullptr; }; /** @@ -200,10 +213,10 @@ class PusServiceBase : public ExecutableObjectIF, * It is deleted after handleRequest was executed. */ PusTcReader currentPacket; - StorageManagerIF* tcStore = nullptr; bool ownedQueue = true; static object_id_t packetDestination; + static object_id_t pusDistributor; VerifSuccessParams successParams; private: diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index b08756d3..25d7cd4a 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -1,8 +1,11 @@ #include "fsfw/tmtcservices/VerificationReporter.h" +#include "fsfw/objectmanager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcservices/PusVerificationReport.h" +object_id_t VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION; + VerificationReporter::VerificationReporter(AcceptsVerifyMessageIF* receiver, object_id_t objectId) : SystemObject(objectId) { if (receiver != nullptr) { @@ -42,3 +45,26 @@ ReturnValue_t VerificationReporter::sendSuccessReport(VerifSuccessParams params) } return status; } + +ReturnValue_t VerificationReporter::initialize() { + if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) { + auto* receiver = ObjectManager::instance()->get(DEFAULT_RECEIVER); + if (receiver != nullptr) { + acknowledgeQueue = receiver->getVerificationQueue(); + } else { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error + << "Could not find a suitable verification message receiver. Please ensure that it is set" + " via the constructor or creating a global one with the ID " + "VerificationReporter::DEFAULT_RECEIVER" + << std::endl; +#else + sif::printError( + "Could not find a suitable verification message receiver. Please ensure " + "that it is set via the constructor or creating a global one with the ID " + "VerificationReporter::DEFAULT_RECEIVER\n"); +#endif + } + } + return SystemObject::initialize(); +} diff --git a/src/fsfw/tmtcservices/VerificationReporter.h b/src/fsfw/tmtcservices/VerificationReporter.h index 8ea45f79..8b224808 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.h +++ b/src/fsfw/tmtcservices/VerificationReporter.h @@ -33,6 +33,9 @@ class VerificationReporter : public SystemObject, public VerificationReporterIF ReturnValue_t sendFailureReport(VerifFailureParams params) override; + static object_id_t DEFAULT_RECEIVER; + ReturnValue_t initialize() override; + private: MessageQueueId_t acknowledgeQueue; }; diff --git a/src/fsfw/tmtcservices/tcHelpers.cpp b/src/fsfw/tmtcservices/tcHelpers.cpp index 91f6e3be..a51bab46 100644 --- a/src/fsfw/tmtcservices/tcHelpers.cpp +++ b/src/fsfw/tmtcservices/tcHelpers.cpp @@ -1,10 +1,10 @@ #include "tcHelpers.h" -ReturnValue_t tc::prepareTcReader(StorageManagerIF *tcStore, store_address_t storeId, +ReturnValue_t tc::prepareTcReader(StorageManagerIF &tcStore, store_address_t storeId, PusTcReader &tcReader) { const uint8_t *dataPtr; size_t dataLen = 0; - ReturnValue_t result = tcStore->getData(storeId, &dataPtr, &dataLen); + ReturnValue_t result = tcStore.getData(storeId, &dataPtr, &dataLen); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcservices/tcHelpers.h b/src/fsfw/tmtcservices/tcHelpers.h index fc19ae33..e2bbf509 100644 --- a/src/fsfw/tmtcservices/tcHelpers.h +++ b/src/fsfw/tmtcservices/tcHelpers.h @@ -7,7 +7,7 @@ namespace tc { -ReturnValue_t prepareTcReader(StorageManagerIF* tcStore, store_address_t storeId, +ReturnValue_t prepareTcReader(StorageManagerIF& tcStore, store_address_t storeId, PusTcReader& tcReader); } // namespace tc diff --git a/unittests/mocks/PusServiceBaseMock.cpp b/unittests/mocks/PusServiceBaseMock.cpp index ef36d09e..21f6a360 100644 --- a/unittests/mocks/PusServiceBaseMock.cpp +++ b/unittests/mocks/PusServiceBaseMock.cpp @@ -31,3 +31,11 @@ void PsbMock::makeNextHandleReqCallFail(ReturnValue_t retval) { handleReqFailPair.first = true; handleReqFailPair.second = retval; } +bool PsbMock::getAndPopNextSubservice(uint8_t& subservice) { + if (subserviceQueue.empty()) { + return false; + } + subservice = subserviceQueue.front(); + subserviceQueue.pop(); + return true; +} diff --git a/unittests/mocks/PusServiceBaseMock.h b/unittests/mocks/PusServiceBaseMock.h index 42620662..31ac43d3 100644 --- a/unittests/mocks/PusServiceBaseMock.h +++ b/unittests/mocks/PusServiceBaseMock.h @@ -18,6 +18,7 @@ class PsbMock : public PusServiceBase { ReturnValue_t performService() override; void makeNextHandleReqCallFail(ReturnValue_t retval); + bool getAndPopNextSubservice(uint8_t& subservice); void reset(); }; diff --git a/unittests/mocks/PusVerificationReporterMock.cpp b/unittests/mocks/PusVerificationReporterMock.cpp index fdc61aca..87b37a5a 100644 --- a/unittests/mocks/PusVerificationReporterMock.cpp +++ b/unittests/mocks/PusVerificationReporterMock.cpp @@ -16,8 +16,19 @@ void PusVerificationReporterMock::popNextFailParams() { VerifFailureParams& PusVerificationReporterMock::getNextFailCallParams() { return failParams.front(); } + void PusVerificationReporterMock::popNextSuccessParams() { if (not successParams.empty()) { successParams.pop(); } } + +ReturnValue_t PusVerificationReporterMock::sendSuccessReport(VerifSuccessParams params) { + successParams.push(params); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PusVerificationReporterMock::sendFailureReport(VerifFailureParams params) { + failParams.push(params); + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/unittests/mocks/PusVerificationReporterMock.h b/unittests/mocks/PusVerificationReporterMock.h index 87595637..5bbd36cc 100644 --- a/unittests/mocks/PusVerificationReporterMock.h +++ b/unittests/mocks/PusVerificationReporterMock.h @@ -17,7 +17,7 @@ class PusVerificationReporterMock : public VerificationReporterIF { VerifFailureParams& getNextFailCallParams(); void popNextFailParams(); - ReturnValue_t sendSuccessReport(VerifSuccessParams params) override { return 0; } - ReturnValue_t sendFailureReport(VerifFailureParams params) override { return 0; } + ReturnValue_t sendSuccessReport(VerifSuccessParams params) override; + ReturnValue_t sendFailureReport(VerifFailureParams params) override; }; #endif // FSFW_TESTS_PUSVERIFICATIONREPORTERMOCK_H diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index 53fe763d..78ae775e 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -1,7 +1,9 @@ #include #include "fsfw/ipc/QueueFactory.h" +#include "fsfw/storagemanager/LocalPool.h" #include "mocks/AcceptsTmMock.h" +#include "mocks/CdsShortTimestamperMock.h" #include "mocks/MessageQueueMock.h" #include "mocks/PusServiceBaseMock.h" #include "mocks/PusVerificationReporterMock.h" @@ -11,13 +13,26 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { auto msgQueue = MessageQueueMock(1); auto tmReceiver = AcceptsTmMock(2); auto psbParams = PsbParams(0, 0x02, 17); + + LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; + LocalPool pool(objects::NO_OBJECT, cfg); + psbParams.verifReporter = &verificationReporter; psbParams.reqQueue = &msgQueue; psbParams.tmReceiver = &tmReceiver; + psbParams.tcPool = &pool; auto psb = PsbMock(psbParams); - store_address_t dummyId(1); - auto reqQueue = psb.getRequestQueue(); - TmTcMessage tmtcMsg(dummyId); + + store_address_t storeId; + TmTcMessage tmtcMsg; + + // Components to create valid PUS packets + auto packetId = PacketId(ccsds::PacketType::TC, true, 0x02); + auto spParams = + SpacePacketParams(packetId, PacketSeqCtrl(ccsds::SequenceFlags::UNSEGMENTED, 0x34), 0x00); + auto pusParams = PusTcParams(17, 1); + PusTcCreator creator(spParams, pusParams); + REQUIRE(psb.initialize() == HasReturnvaluesIF::RETURN_OK); SECTION("State") { @@ -25,8 +40,51 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { REQUIRE(psb.getObjectId() == 0); } - SECTION("Send Request") { + SECTION("Perform Service") { + REQUIRE(psb.performServiceCallCnt == 0); + REQUIRE(psb.performOperation(0) == retval::OK); + REQUIRE(psb.performServiceCallCnt == 1); + } + + SECTION("Send Request with Successful Handling") { + REQUIRE(psb.performServiceCallCnt == 0); + uint8_t* dataPtr; + REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == retval::OK); + REQUIRE(creator.serializeBe(dataPtr, creator.getSerializedSize()) == retval::OK); + tmtcMsg.setStorageId(storeId); msgQueue.addReceivedMessage(tmtcMsg); REQUIRE(psb.performOperation(0) == retval::OK); + uint8_t subservice = 0; + REQUIRE(psb.getAndPopNextSubservice(subservice)); + REQUIRE(subservice == 1); + REQUIRE(psb.performServiceCallCnt == 1); + // PSB should take care of freeing the pool slot + REQUIRE(not pool.hasDataAtId(storeId)); + REQUIRE(verificationReporter.successCallCount() == 1); + REQUIRE(verificationReporter.failCallCount() == 0); + auto verifParams = verificationReporter.getNextSuccessCallParams(); + REQUIRE(verifParams.tcPacketId == creator.getPacketIdRaw()); + REQUIRE(verifParams.tcPsc == creator.getPacketSeqCtrlRaw()); } -} \ No newline at end of file + + SECTION("Send Request with Failed Handling") { + uint8_t* dataPtr; + REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == retval::OK); + REQUIRE(creator.serializeBe(dataPtr, creator.getSerializedSize()) == retval::OK); + tmtcMsg.setStorageId(storeId); + msgQueue.addReceivedMessage(tmtcMsg); + psb.makeNextHandleReqCallFail(3); + REQUIRE(psb.performOperation(0) == retval::OK); + uint8_t subservice = 0; + REQUIRE(psb.getAndPopNextSubservice(subservice)); + REQUIRE(subservice == 1); + REQUIRE(psb.performServiceCallCnt == 1); + // PSB should take care of freeing the pool slot + REQUIRE(not pool.hasDataAtId(storeId)); + REQUIRE(verificationReporter.successCallCount() == 0); + REQUIRE(verificationReporter.failCallCount() == 1); + auto verifParams = verificationReporter.getNextFailCallParams(); + REQUIRE(verifParams.tcPacketId == creator.getPacketIdRaw()); + REQUIRE(verifParams.tcPsc == creator.getPacketSeqCtrlRaw()); + } +} From 8bf0fb98851a890c81b935b94a406263b9cf4170 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 18:46:28 +0200 Subject: [PATCH 127/532] test auto-initializers --- .../fsfwconfig/objects/FsfwFactory.cpp | 2 +- .../tmtcservices/CommandingServiceBase.cpp | 5 +- src/fsfw/tmtcservices/CommandingServiceBase.h | 4 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 45 +++---- src/fsfw/tmtcservices/PusServiceBase.h | 26 ++--- src/fsfw/tmtcservices/TmSendHelper.cpp | 4 +- src/fsfw/tmtcservices/TmSendHelper.h | 2 +- unittests/CatchFactory.cpp | 4 +- unittests/mocks/AcceptsTmMock.cpp | 6 +- unittests/mocks/AcceptsTmMock.h | 4 +- unittests/mocks/CMakeLists.txt | 1 + unittests/mocks/DeviceHandlerMock.cpp | 2 +- unittests/mocks/PusDistributorMock.cpp | 12 ++ unittests/mocks/PusDistributorMock.h | 16 +++ unittests/mocks/PusServiceBaseMock.cpp | 12 ++ unittests/mocks/PusServiceBaseMock.h | 7 ++ unittests/tmtcservices/testPsb.cpp | 110 +++++++++++++++++- unittests/tmtcservices/testSendHelper.cpp | 5 +- 18 files changed, 215 insertions(+), 52 deletions(-) create mode 100644 unittests/mocks/PusDistributorMock.cpp create mode 100644 unittests/mocks/PusDistributorMock.h diff --git a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp index 5aef4980..4670c7e7 100644 --- a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp +++ b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp @@ -36,7 +36,7 @@ void Factory::produceFsfwObjects(void) { void Factory::setStaticFrameworkObjectIds() { PusServiceBase::packetSource = objects::NO_OBJECT; - PusServiceBase::packetDestination = objects::NO_OBJECT; + PusServiceBase::PACKET_DESTINATION = objects::NO_OBJECT; CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 0815c838..214adbfa 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -104,9 +104,12 @@ ReturnValue_t CommandingServiceBase::initialize() { errReporter = ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); if (errReporter != nullptr) { - tmSendHelper.setInternalErrorReporter(errReporter); + tmSendHelper.setInternalErrorReporter(*errReporter); } + } else { + tmSendHelper.setInternalErrorReporter(*errReporter); } + if (verificationReporter == nullptr) { verificationReporter = ObjectManager::instance()->get(objects::TC_VERIFICATOR); diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 202dd862..20b7d992 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -18,7 +18,7 @@ namespace Factory { void setStaticFrameworkObjectIds(); -} +}; /** * @brief This class is the basis for all PUS Services, which have to @@ -38,7 +38,7 @@ class CommandingServiceBase : public SystemObject, public AcceptsTelecommandsIF, public ExecutableObjectIF, public HasReturnvaluesIF { - friend void(Factory::setStaticFrameworkObjectIds)(); + friend void Factory::setStaticFrameworkObjectIds(); public: // We could make this configurable via preprocessor and the FSFWConfig file. diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index c283d655..9390dd19 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -9,8 +9,8 @@ #include "fsfw/tmtcservices/TmTcMessage.h" #include "fsfw/tmtcservices/tcHelpers.h" -object_id_t PusServiceBase::packetDestination = 0; -object_id_t PusServiceBase::pusDistributor = 0; +object_id_t PusServiceBase::PACKET_DESTINATION = 0; +object_id_t PusServiceBase::PUS_DISTRIBUTOR = 0; PusServiceBase::PusServiceBase(PsbParams params) : SystemObject(params.objectId), psbParams(params) {} @@ -83,7 +83,12 @@ void PusServiceBase::handleRequestQueue() { uint16_t PusServiceBase::getIdentifier() { return psbParams.serviceId; } -MessageQueueId_t PusServiceBase::getRequestQueue() { return psbParams.reqQueue->getId(); } +MessageQueueId_t PusServiceBase::getRequestQueue() { + if (psbParams.reqQueue == nullptr) { + return MessageQueueIF::NO_QUEUE; + } + return psbParams.reqQueue->getId(); +} ReturnValue_t PusServiceBase::initialize() { ReturnValue_t result = SystemObject::initialize(); @@ -96,15 +101,16 @@ ReturnValue_t PusServiceBase::initialize() { } else { ownedQueue = false; } + if (psbParams.tmReceiver == nullptr) { - psbParams.tmReceiver = ObjectManager::instance()->get(packetDestination); + psbParams.tmReceiver = ObjectManager::instance()->get(PACKET_DESTINATION); if (psbParams.tmReceiver != nullptr) { psbParams.reqQueue->setDefaultDestination(psbParams.tmReceiver->getReportReceptionQueue()); } } - if (psbParams.pusDistributor != nullptr) { - psbParams.pusDistributor = ObjectManager::instance()->get(pusDistributor); + if (psbParams.pusDistributor == nullptr) { + psbParams.pusDistributor = ObjectManager::instance()->get(PUS_DISTRIBUTOR); if (psbParams.pusDistributor != nullptr) { registerService(*psbParams.pusDistributor); } @@ -127,17 +133,10 @@ ReturnValue_t PusServiceBase::initialize() { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PusServiceBase::initializeAfterTaskCreation() { - // If task parameters, for example task frequency are required, this - // function should be overriden and the system object task IF can - // be used to get those parameters. - return HasReturnvaluesIF::RETURN_OK; -} +void PusServiceBase::setTcPool(StorageManagerIF& tcPool) { psbParams.tcPool = &tcPool; } -void PusServiceBase::setCustomTcStore(StorageManagerIF* tcPool) { psbParams.tcPool = tcPool; } - -void PusServiceBase::setCustomErrorReporter(InternalErrorReporterIF* errReporter_) { - psbParams.errReporter = errReporter_; +void PusServiceBase::setErrorReporter(InternalErrorReporterIF& errReporter_) { + psbParams.errReporter = &errReporter_; } void PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper) { @@ -155,8 +154,10 @@ void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { psbParams.errReporter = ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); if (psbParams.errReporter != nullptr) { - tmSendHelper.setInternalErrorReporter(psbParams.errReporter); + tmSendHelper.setInternalErrorReporter(*psbParams.errReporter); } + } else { + tmSendHelper.setInternalErrorReporter(*psbParams.errReporter); } } @@ -164,16 +165,16 @@ void PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const tmStoreHelper.setApid(psbParams.apid); } -void PusServiceBase::setVerificationReporter(VerificationReporterIF* reporter) { - psbParams.verifReporter = reporter; +void PusServiceBase::setVerificationReporter(VerificationReporterIF& reporter) { + psbParams.verifReporter = &reporter; } ReturnValue_t PusServiceBase::registerService(PUSDistributorIF& distributor) { return distributor.registerService(this); } -void PusServiceBase::setTmReceiver(AcceptsTelemetryIF* tmReceiver_) { - psbParams.tmReceiver = tmReceiver_; +void PusServiceBase::setTmReceiver(AcceptsTelemetryIF& tmReceiver_) { + psbParams.tmReceiver = &tmReceiver_; } -void PusServiceBase::setRequestQueue(MessageQueueIF* reqQueue) { psbParams.reqQueue = reqQueue; } +void PusServiceBase::setRequestQueue(MessageQueueIF& reqQueue) { psbParams.reqQueue = &reqQueue; } diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 1c1c417d..9c75870a 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -14,10 +14,6 @@ #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tcdistribution/PUSDistributorIF.h" -namespace Factory { -void setStaticFrameworkObjectIds(); -} - class StorageManagerIF; /** @@ -71,6 +67,10 @@ struct PsbParams { PUSDistributorIF* pusDistributor = nullptr; }; +namespace Factory { +void setStaticFrameworkObjectIds(); +} + /** * @defgroup pus_services PUS Service Framework * These group contains all implementations of PUS Services in the OBSW. @@ -93,7 +93,7 @@ class PusServiceBase : public ExecutableObjectIF, public AcceptsTelecommandsIF, public SystemObject, public HasReturnvaluesIF { - friend void(Factory::setStaticFrameworkObjectIds)(); + friend void Factory::setStaticFrameworkObjectIds(); public: /** @@ -121,11 +121,11 @@ class PusServiceBase : public ExecutableObjectIF, * function will create one * @param reqQueue */ - void setRequestQueue(MessageQueueIF* reqQueue); - void setTmReceiver(AcceptsTelemetryIF* tmReceiver); - void setCustomTcStore(StorageManagerIF* tcStore); - void setVerificationReporter(VerificationReporterIF* reporter); - void setCustomErrorReporter(InternalErrorReporterIF* errReporter); + void setRequestQueue(MessageQueueIF& reqQueue); + void setTmReceiver(AcceptsTelemetryIF& tmReceiver); + void setTcPool(StorageManagerIF& tcStore); + void setVerificationReporter(VerificationReporterIF& reporter); + void setErrorReporter(InternalErrorReporterIF& errReporter); /** * Helper methods if the implementing class wants to send telemetry @@ -190,7 +190,6 @@ class PusServiceBase : public ExecutableObjectIF, ReturnValue_t initialize() override; void setTaskIF(PeriodicTaskIF* taskHandle) override; - ReturnValue_t initializeAfterTaskCreation() override; protected: /** @@ -215,9 +214,8 @@ class PusServiceBase : public ExecutableObjectIF, PusTcReader currentPacket; bool ownedQueue = true; - static object_id_t packetDestination; - static object_id_t pusDistributor; - VerifSuccessParams successParams; + static object_id_t PACKET_DESTINATION; + static object_id_t PUS_DISTRIBUTOR; private: void handleRequestQueue(); diff --git a/src/fsfw/tmtcservices/TmSendHelper.cpp b/src/fsfw/tmtcservices/TmSendHelper.cpp index 0b9d854c..ddbb86ba 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmSendHelper.cpp @@ -30,8 +30,8 @@ ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) { void TmSendHelper::setDefaultDestination(MessageQueueId_t msgDest) { defaultDest = msgDest; } -void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF *reporter) { - errReporter = reporter; +void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF &reporter) { + errReporter = &reporter; } void TmSendHelper::setMsgQueue(MessageQueueIF &queue_) { queue = &queue_; } diff --git a/src/fsfw/tmtcservices/TmSendHelper.h b/src/fsfw/tmtcservices/TmSendHelper.h index 244e7900..a9feab75 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.h +++ b/src/fsfw/tmtcservices/TmSendHelper.h @@ -23,7 +23,7 @@ class TmSendHelper { [[nodiscard]] bool areFaultsIgnored() const; void ignoreFaults(); void dontIgnoreFaults(); - void setInternalErrorReporter(InternalErrorReporterIF* reporter); + void setInternalErrorReporter(InternalErrorReporterIF& reporter); [[nodiscard]] InternalErrorReporterIF* getInternalErrorReporter() const; ReturnValue_t sendPacket(MessageQueueId_t dest, const store_address_t& storeId); ReturnValue_t sendPacket(const store_address_t& storeId); diff --git a/unittests/CatchFactory.cpp b/unittests/CatchFactory.cpp index 1d10c582..d1d3ea1c 100644 --- a/unittests/CatchFactory.cpp +++ b/unittests/CatchFactory.cpp @@ -54,7 +54,7 @@ void Factory::produceFrameworkObjects(void* args) { // like this. Instead, this should be more like a general struct containing all important // object IDs which are then explicitely passed in the object constructor void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetDestination = objects::NO_OBJECT; + PusServiceBase::PACKET_DESTINATION = objects::NO_OBJECT; CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; @@ -62,9 +62,7 @@ void Factory::setStaticFrameworkObjectIds() { DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT; - // TODO: Incredibly ugly, get rid of it LocalDataPoolManager::defaultHkDestination = objects::NO_OBJECT; - DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT; } diff --git a/unittests/mocks/AcceptsTmMock.cpp b/unittests/mocks/AcceptsTmMock.cpp index 9142308d..5b1e0d05 100644 --- a/unittests/mocks/AcceptsTmMock.cpp +++ b/unittests/mocks/AcceptsTmMock.cpp @@ -1,6 +1,10 @@ #include "AcceptsTmMock.h" -AcceptsTmMock::AcceptsTmMock(MessageQueueId_t queueToReturn) : returnedQueue(queueToReturn) {} +AcceptsTmMock::AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToReturn) + : SystemObject(registeredId), returnedQueue(queueToReturn) {} + +AcceptsTmMock::AcceptsTmMock(MessageQueueId_t queueToReturn) + : SystemObject(objects::NO_OBJECT, false), returnedQueue(queueToReturn) {} MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) { return returnedQueue; diff --git a/unittests/mocks/AcceptsTmMock.h b/unittests/mocks/AcceptsTmMock.h index b0ccc9a7..a9422eb4 100644 --- a/unittests/mocks/AcceptsTmMock.h +++ b/unittests/mocks/AcceptsTmMock.h @@ -1,10 +1,12 @@ #ifndef FSFW_TESTS_ACCEPTSTMMOCK_H #define FSFW_TESTS_ACCEPTSTMMOCK_H +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -class AcceptsTmMock : public AcceptsTelemetryIF { +class AcceptsTmMock : public SystemObject, public AcceptsTelemetryIF { public: + AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToReturn); explicit AcceptsTmMock(MessageQueueId_t queueToReturn); MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override; diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 5bb37db4..f3b50f62 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -10,4 +10,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE PusVerificationReporterMock.cpp PusServiceBaseMock.cpp AcceptsTmMock.cpp + PusDistributorMock.cpp ) diff --git a/unittests/mocks/DeviceHandlerMock.cpp b/unittests/mocks/DeviceHandlerMock.cpp index ea30ff6a..1398c8e9 100644 --- a/unittests/mocks/DeviceHandlerMock.cpp +++ b/unittests/mocks/DeviceHandlerMock.cpp @@ -8,7 +8,7 @@ DeviceHandlerMock::DeviceHandlerMock(object_id_t objectId, object_id_t deviceCom mode = MODE_ON; } -DeviceHandlerMock::~DeviceHandlerMock() {} +DeviceHandlerMock::~DeviceHandlerMock() = default; void DeviceHandlerMock::doStartUp() { setMode(_MODE_TO_ON); } diff --git a/unittests/mocks/PusDistributorMock.cpp b/unittests/mocks/PusDistributorMock.cpp new file mode 100644 index 00000000..cb9aed32 --- /dev/null +++ b/unittests/mocks/PusDistributorMock.cpp @@ -0,0 +1,12 @@ +#include "PusDistributorMock.h" + +PusDistributorMock::PusDistributorMock() : SystemObject(objects::NO_OBJECT, false) {} + +PusDistributorMock::PusDistributorMock(object_id_t registeredId) + : SystemObject(registeredId, true) {} + +ReturnValue_t PusDistributorMock::registerService(AcceptsTelecommandsIF *service) { + registerCallCount++; + lastServiceArg = service; + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/unittests/mocks/PusDistributorMock.h b/unittests/mocks/PusDistributorMock.h new file mode 100644 index 00000000..d5c7d96f --- /dev/null +++ b/unittests/mocks/PusDistributorMock.h @@ -0,0 +1,16 @@ +#ifndef FSFW_TESTS_PUSDISTRIBUTORMOCK_H +#define FSFW_TESTS_PUSDISTRIBUTORMOCK_H + +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/tcdistribution/PUSDistributorIF.h" + +class PusDistributorMock : public SystemObject, public PUSDistributorIF { + public: + PusDistributorMock(); + explicit PusDistributorMock(object_id_t registeredId); + unsigned int registerCallCount = 0; + AcceptsTelecommandsIF* lastServiceArg = nullptr; + ReturnValue_t registerService(AcceptsTelecommandsIF* service) override; +}; + +#endif // FSFW_TESTS_PUSDISTRIBUTORMOCK_H diff --git a/unittests/mocks/PusServiceBaseMock.cpp b/unittests/mocks/PusServiceBaseMock.cpp index 21f6a360..5c20f0a1 100644 --- a/unittests/mocks/PusServiceBaseMock.cpp +++ b/unittests/mocks/PusServiceBaseMock.cpp @@ -39,3 +39,15 @@ bool PsbMock::getAndPopNextSubservice(uint8_t& subservice) { subserviceQueue.pop(); return true; } + +PsbParams& PsbMock::getParams() { return psbParams; } + +void PsbMock::setStaticPusDistributor(object_id_t pusDistributor) { + PUS_DISTRIBUTOR = pusDistributor; +} + +object_id_t PsbMock::getStaticPusDistributor() { return PUS_DISTRIBUTOR; } + +void PsbMock::setStaticTmDest(object_id_t tmDest) { PACKET_DESTINATION = tmDest; } + +object_id_t PsbMock::getStaticTmDest() { return PACKET_DESTINATION; } diff --git a/unittests/mocks/PusServiceBaseMock.h b/unittests/mocks/PusServiceBaseMock.h index 31ac43d3..0aa6b406 100644 --- a/unittests/mocks/PusServiceBaseMock.h +++ b/unittests/mocks/PusServiceBaseMock.h @@ -12,6 +12,13 @@ class PsbMock : public PusServiceBase { std::queue subserviceQueue; unsigned int performServiceCallCnt = 0; + static void setStaticPusDistributor(object_id_t pusDistributor); + static object_id_t getStaticPusDistributor(); + static void setStaticTmDest(object_id_t tmDest); + static object_id_t getStaticTmDest(); + + PsbParams& getParams(); + std::pair handleReqFailPair; std::pair performServiceFailPair; ReturnValue_t handleRequest(uint8_t subservice) override; diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index 78ae775e..53b84b3c 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -4,15 +4,18 @@ #include "fsfw/storagemanager/LocalPool.h" #include "mocks/AcceptsTmMock.h" #include "mocks/CdsShortTimestamperMock.h" +#include "mocks/InternalErrorReporterMock.h" #include "mocks/MessageQueueMock.h" +#include "mocks/PusDistributorMock.h" #include "mocks/PusServiceBaseMock.h" #include "mocks/PusVerificationReporterMock.h" TEST_CASE("Pus Service Base", "[pus-service-base]") { + uint16_t apid = 2; auto verificationReporter = PusVerificationReporterMock(); auto msgQueue = MessageQueueMock(1); auto tmReceiver = AcceptsTmMock(2); - auto psbParams = PsbParams(0, 0x02, 17); + auto psbParams = PsbParams(0, apid, 17); LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; LocalPool pool(objects::NO_OBJECT, cfg); @@ -38,6 +41,9 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { SECTION("State") { REQUIRE(psb.getIdentifier() == 17); REQUIRE(psb.getObjectId() == 0); + REQUIRE(psb.getRequestQueue() == msgQueue.getId()); + auto psbParamsLocal = psb.getParams(); + REQUIRE(psbParamsLocal.errReporter == nullptr); } SECTION("Perform Service") { @@ -87,4 +93,106 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { REQUIRE(verifParams.tcPacketId == creator.getPacketIdRaw()); REQUIRE(verifParams.tcPsc == creator.getPacketSeqCtrlRaw()); } + + SECTION("Invalid Packet Sent") { + tmtcMsg.setStorageId(store_address_t::invalid()); + msgQueue.addReceivedMessage(tmtcMsg); + REQUIRE(psb.performOperation(0) == retval::OK); + REQUIRE(verificationReporter.failCallCount() == 1); + auto verifParams = verificationReporter.getNextFailCallParams(); + REQUIRE(verifParams.tcPacketId == 0); + REQUIRE(verifParams.tcPsc == 0); + } + + SECTION("Set Verif Reporter") { + auto verificationReporter2 = PusVerificationReporterMock(); + psb.setVerificationReporter(verificationReporter2); + auto& p = psb.getParams(); + REQUIRE(p.verifReporter == &verificationReporter2); + } + + SECTION("Set Request Queue") { + auto msgQueueMock = MessageQueueMock(2); + psb.setRequestQueue(msgQueueMock); + auto& p = psb.getParams(); + REQUIRE(p.reqQueue == &msgQueueMock); + } + + SECTION("Set TM Receiver") { + auto tmReceiver2 = AcceptsTmMock(3); + psb.setTmReceiver(tmReceiver2); + auto& p = psb.getParams(); + REQUIRE(p.tmReceiver == &tmReceiver2); + } + + SECTION("Set TC Store") { + LocalPool tcStore2(5, cfg); + psb.setTcPool(tcStore2); + auto& p = psb.getParams(); + REQUIRE(p.tcPool == &tcStore2); + } + + SECTION("Set error reporter") { + auto errReporter = InternalErrorReporterMock(); + psb.setErrorReporter(errReporter); + auto& p = psb.getParams(); + REQUIRE(p.errReporter == &errReporter); + } + SECTION("Owner Queue") { + // This will cause the initialize function to create a new owner queue + psbParams.reqQueue = nullptr; + psbParams.objectId = 1; + auto mockWithOwnerQueue = PsbMock(psbParams); + REQUIRE(mockWithOwnerQueue.getRequestQueue() == MessageQueueIF::NO_QUEUE); + REQUIRE(mockWithOwnerQueue.initialize() == retval::OK); + REQUIRE(mockWithOwnerQueue.getRequestQueue() != MessageQueueIF::NO_QUEUE); + } + + SECTION("TM Store Helper Initializer") { + TmStoreHelper storeHelper(0); + psb.initializeTmStoreHelper(storeHelper); + REQUIRE(storeHelper.getApid() == apid); + } + + SECTION("TM Send Helper Initializer") { + TmSendHelper sendHelper; + psb.initializeTmSendHelper(sendHelper); + REQUIRE(sendHelper.getMsgQueue() == &msgQueue); + REQUIRE(sendHelper.getDefaultDestination() == msgQueue.getDefaultDestination()); + } + + SECTION("TM Send Helper Initializer With Error Reporter") { + TmSendHelper sendHelper; + auto errReporter = InternalErrorReporterMock(); + psb.setErrorReporter(errReporter); + psb.initializeTmSendHelper(sendHelper); + REQUIRE(sendHelper.getMsgQueue() == &msgQueue); + REQUIRE(sendHelper.getDefaultDestination() == msgQueue.getDefaultDestination()); + REQUIRE(sendHelper.getInternalErrorReporter() == &errReporter); + } + + SECTION("Auto Initialize PUS Distributor") { + psbParams.objectId = 1; + object_id_t distributorId = 3; + auto psb2 = PsbMock(psbParams); + auto pusDistrib = PusDistributorMock(distributorId); + PsbMock::setStaticPusDistributor(distributorId); + REQUIRE(PsbMock::getStaticPusDistributor() == distributorId); + REQUIRE(psb2.initialize() == retval::OK); + REQUIRE(pusDistrib.registerCallCount == 1); + REQUIRE(pusDistrib.lastServiceArg == &psb2); + } + + SECTION("Auto Initialize Packet Destination") { + psbParams.tmReceiver = nullptr; + psbParams.objectId = 1; + object_id_t destId = 3; + auto psb2 = PsbMock(psbParams); + auto packetDest = AcceptsTmMock(destId, 2); + PsbMock::setStaticTmDest(destId); + REQUIRE(PsbMock::getStaticTmDest() == destId); + REQUIRE(psb2.initialize() == retval::OK); + auto& p = psb2.getParams(); + REQUIRE(p.tmReceiver == &packetDest); + } } diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 82adc04b..b857776b 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -33,8 +33,9 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") { REQUIRE(sendHelper.getDefaultDestination() == destId); sendHelper.setDefaultDestination(destId + 1); REQUIRE(sendHelper.getDefaultDestination() == destId + 1); - sendHelper.setInternalErrorReporter(nullptr); - REQUIRE(sendHelper.getInternalErrorReporter() == nullptr); + auto errReporter2 = InternalErrorReporterMock(); + sendHelper.setInternalErrorReporter(errReporter2); + REQUIRE(sendHelper.getInternalErrorReporter() == &errReporter2); } SECTION("Default CTOR") { From 152c01b2ec18c94cf072065e5313aa92eb9ee7c0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 18:58:36 +0200 Subject: [PATCH 128/532] psb unittests almost complete --- .../tmtcservices/VerificationReporter.cpp | 1 + src/fsfw/tmtcservices/VerificationReporter.h | 9 ++++++- .../mocks/PusVerificationReporterMock.cpp | 8 +++++++ unittests/mocks/PusVerificationReporterMock.h | 6 +++-- unittests/tmtcservices/testPsb.cpp | 24 +++++++++++++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 25d7cd4a..9c38b3a7 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -5,6 +5,7 @@ #include "fsfw/tmtcservices/PusVerificationReport.h" object_id_t VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION; +object_id_t VerificationReporter::DEFAULT_REPORTER = objects::TC_VERIFICATOR; VerificationReporter::VerificationReporter(AcceptsVerifyMessageIF* receiver, object_id_t objectId) : SystemObject(objectId) { diff --git a/src/fsfw/tmtcservices/VerificationReporter.h b/src/fsfw/tmtcservices/VerificationReporter.h index 8b224808..78c60962 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.h +++ b/src/fsfw/tmtcservices/VerificationReporter.h @@ -8,6 +8,10 @@ #include "fsfw/tmtcpacket/pus/tc/PusTcCreator.h" #include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h" +namespace Factory { +void setStaticFrameworkObjectIds(); +} + /** * @brief This helper object is used to forward verification messages * which are generated by the Flight Software Framework. @@ -20,9 +24,11 @@ * */ class VerificationReporter : public SystemObject, public VerificationReporterIF { + friend void Factory::setStaticFrameworkObjectIds(); + public: explicit VerificationReporter(AcceptsVerifyMessageIF* receiver, - object_id_t objectId = objects::TC_VERIFICATOR); + object_id_t objectId = DEFAULT_REPORTER); ~VerificationReporter() override; void setReceiver(AcceptsVerifyMessageIF& receiver); @@ -33,6 +39,7 @@ class VerificationReporter : public SystemObject, public VerificationReporterIF ReturnValue_t sendFailureReport(VerifFailureParams params) override; + static object_id_t DEFAULT_REPORTER; static object_id_t DEFAULT_RECEIVER; ReturnValue_t initialize() override; diff --git a/unittests/mocks/PusVerificationReporterMock.cpp b/unittests/mocks/PusVerificationReporterMock.cpp index 87b37a5a..c811d38e 100644 --- a/unittests/mocks/PusVerificationReporterMock.cpp +++ b/unittests/mocks/PusVerificationReporterMock.cpp @@ -1,5 +1,13 @@ #include "PusVerificationReporterMock.h" +#include "fsfw/objectmanager/frameworkObjects.h" + +PusVerificationReporterMock::PusVerificationReporterMock() + : SystemObject(objects::NO_OBJECT, false) {} + +PusVerificationReporterMock::PusVerificationReporterMock(object_id_t registeredId) + : SystemObject(registeredId) {} + size_t PusVerificationReporterMock::successCallCount() const { return successParams.size(); } size_t PusVerificationReporterMock::failCallCount() const { return failParams.size(); } diff --git a/unittests/mocks/PusVerificationReporterMock.h b/unittests/mocks/PusVerificationReporterMock.h index 5bbd36cc..dedfd30e 100644 --- a/unittests/mocks/PusVerificationReporterMock.h +++ b/unittests/mocks/PusVerificationReporterMock.h @@ -3,13 +3,15 @@ #include +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tmtcservices/VerificationReporterIF.h" -class PusVerificationReporterMock : public VerificationReporterIF { +class PusVerificationReporterMock : public SystemObject, public VerificationReporterIF { public: std::queue successParams; std::queue failParams; - + PusVerificationReporterMock(); + explicit PusVerificationReporterMock(object_id_t registeredId); [[nodiscard]] size_t successCallCount() const; VerifSuccessParams& getNextSuccessCallParams(); void popNextSuccessParams(); diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index 53b84b3c..ea1991f0 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -161,6 +161,15 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { REQUIRE(sendHelper.getDefaultDestination() == msgQueue.getDefaultDestination()); } + SECTION("TM Store And Send Helper Initializer") { + TmStoreHelper storeHelper(0); + TmSendHelper sendHelper; + psb.initializeTmHelpers(sendHelper, storeHelper); + REQUIRE(sendHelper.getMsgQueue() == &msgQueue); + REQUIRE(sendHelper.getDefaultDestination() == msgQueue.getDefaultDestination()); + REQUIRE(storeHelper.getApid() == apid); + } + SECTION("TM Send Helper Initializer With Error Reporter") { TmSendHelper sendHelper; auto errReporter = InternalErrorReporterMock(); @@ -195,4 +204,19 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { auto& p = psb2.getParams(); REQUIRE(p.tmReceiver == &packetDest); } + + SECTION("Auto Initialize Verification Reporter") { + psbParams.verifReporter = nullptr; + psbParams.objectId = 1; + object_id_t reporterId = objects::TC_VERIFICATOR; + PusVerificationReporterMock otherReporter(reporterId); + auto psb2 = PsbMock(psbParams); + REQUIRE(psb2.initialize() == retval::OK); + auto& p = psb2.getParams(); + REQUIRE(p.verifReporter == &otherReporter); + } + + SECTION("Auto Initialize TC Pool") {} + + SECTION("Invalid Verification Reporter") {} } From 681738dcc63f3d2d92eb24476b0bc7908c3bb582 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 19:08:12 +0200 Subject: [PATCH 129/532] PSB unittests complete --- unittests/CatchFactory.cpp | 5 ----- unittests/tmtcservices/testPsb.cpp | 25 +++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/unittests/CatchFactory.cpp b/unittests/CatchFactory.cpp index d1d3ea1c..0d855cb3 100644 --- a/unittests/CatchFactory.cpp +++ b/unittests/CatchFactory.cpp @@ -34,11 +34,6 @@ void Factory::produceFrameworkObjects(void* args) { new HealthTable(objects::HEALTH_TABLE); new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); - { - PoolManager::LocalPoolConfig poolCfg = {{100, 16}, {50, 32}, {25, 64}, {15, 128}, {5, 1024}}; - new PoolManager(objects::TC_STORE, poolCfg); - } - { PoolManager::LocalPoolConfig poolCfg = {{100, 16}, {50, 32}, {25, 64}, {15, 128}, {5, 1024}}; new PoolManager(objects::TM_STORE, poolCfg); diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index ea1991f0..e434607f 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -2,6 +2,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/storagemanager/LocalPool.h" +#include "fsfw/storagemanager/PoolManager.h" #include "mocks/AcceptsTmMock.h" #include "mocks/CdsShortTimestamperMock.h" #include "mocks/InternalErrorReporterMock.h" @@ -216,7 +217,27 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { REQUIRE(p.verifReporter == &otherReporter); } - SECTION("Auto Initialize TC Pool") {} + SECTION("Auto Initialize TC Pool") { + PoolManager tcStoreGlobal(objects::TC_STORE, cfg); + psbParams.tcPool = nullptr; + psbParams.objectId = 1; + auto psb2 = PsbMock(psbParams); + REQUIRE(psb2.initialize() == retval::OK); + auto& p = psb2.getParams(); + REQUIRE(p.tcPool == &tcStoreGlobal); + } - SECTION("Invalid Verification Reporter") {} + SECTION("Invalid Verification Reporter") { + psbParams.verifReporter = nullptr; + psbParams.objectId = 1; + auto psb2 = PsbMock(psbParams); + REQUIRE(psb2.initialize() == ObjectManagerIF::CHILD_INIT_FAILED); + } + + SECTION("Invalid TC Store") { + psbParams.tcPool = nullptr; + psbParams.objectId = 1; + auto psb2 = PsbMock(psbParams); + REQUIRE(psb2.initialize() == ObjectManagerIF::CHILD_INIT_FAILED); + } } From 9eb652e585c3eaf88c8e9a7778f3cfcd00562c51 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 10:49:49 +0200 Subject: [PATCH 130/532] some printout fixes --- src/fsfw/tcdistribution/PusDistributor.cpp | 11 ++++++----- src/fsfw/tmtcservices/PusServiceBase.cpp | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 1cef2b9f..981fca1c 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -1,5 +1,6 @@ #include "fsfw/tcdistribution/PusDistributor.h" +#include "definitions.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tcdistribution/CCSDSDistributorIF.h" @@ -42,15 +43,15 @@ PusDistributor::TcMqMapIter PusDistributor::selectDestination() { if (tcStatus != HasReturnvaluesIF::RETURN_OK) { #if FSFW_VERBOSE_LEVEL >= 1 const char* keyword = "unnamed error"; - if (tcStatus == TcPacketCheckPUS::INCORRECT_CHECKSUM) { + if (tcStatus == tcdistrib::INCORRECT_CHECKSUM) { keyword = "checksum"; - } else if (tcStatus == TcPacketCheckPUS::INCORRECT_PRIMARY_HEADER) { + } else if (tcStatus == tcdistrib::INCORRECT_PRIMARY_HEADER) { keyword = "incorrect primary header"; - } else if (tcStatus == TcPacketCheckPUS::ILLEGAL_APID) { + } else if (tcStatus == tcdistrib::INVALID_APID) { keyword = "illegal APID"; - } else if (tcStatus == TcPacketCheckPUS::INCORRECT_SECONDARY_HEADER) { + } else if (tcStatus == tcdistrib::INCORRECT_SECONDARY_HEADER) { keyword = "incorrect secondary header"; - } else if (tcStatus == TcPacketCheckPUS::INCOMPLETE_PACKET) { + } else if (tcStatus == tcdistrib::INCOMPLETE_PACKET) { keyword = "incomplete packet"; } #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 9390dd19..97f018e5 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -26,8 +26,8 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { ReturnValue_t result = performService(); if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PusService " << (uint16_t)this->serviceId << ": performService returned with " - << (int16_t)result << std::endl; + sif::error << "PusService " << psbParams.serviceId << ": performService returned with " + << static_cast(result) << std::endl; #endif return RETURN_FAILED; } @@ -45,7 +45,7 @@ void PusServiceBase::handleRequestQueue() { break; } else if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PusServiceBase::performOperation: Service " << this->serviceId + sif::error << "PusServiceBase::performOperation: Service " << psbParams.serviceId << ": Error receiving packet. Code: " << std::hex << status << std::dec << std::endl; #else From 18ee2ab9035ac2ab90da0bc2ab8fdef5b6d381df Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 11:26:47 +0200 Subject: [PATCH 131/532] example compiles again --- .../ProvidesDataPoolSubscriptionIF.h | 15 ++++++++++ src/fsfw/pus/Service11TelecommandScheduling.h | 5 ++-- .../pus/Service11TelecommandScheduling.tpp | 28 ++++++++----------- src/fsfw/returnvalues/HasReturnvaluesIF.h | 3 +- src/fsfw/tcdistribution/PusDistributor.cpp | 10 +++++-- src/fsfw/tcdistribution/PusDistributor.h | 4 +-- src/fsfw/tmtcpacket/ccsds/header.cpp | 7 ++++- src/fsfw/tmtcpacket/ccsds/header.h | 1 + src/fsfw/tmtcpacket/pus/tm.h | 1 + src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 11 ++++---- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmReader.h | 10 ++++--- src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp | 18 ++++++++++++ src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h | 14 ++++++++++ src/fsfw/tmtcservices/PusServiceBase.cpp | 2 +- .../integration/devices/TestDeviceHandler.cpp | 2 +- 17 files changed, 95 insertions(+), 40 deletions(-) create mode 100644 src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp create mode 100644 src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index e1aca321..3001ea10 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -70,6 +70,15 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams params) = 0; + [[deprecated( + "Please use the new API which takes all arguments as one wrapper " + "struct")]] virtual ReturnValue_t + subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval, + bool isDiagnostics) { + return subscribeForPeriodicPacket(sid, enableReporting, collectionInterval, isDiagnostics, + objects::NO_OBJECT); + } + [[deprecated( "Please use the new API which takes all arguments as one wrapper " "struct")]] virtual ReturnValue_t @@ -97,6 +106,12 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; + [[deprecated( + "Please use the new API which takes all arguments as one wrapper " + "struct")]] virtual ReturnValue_t + subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics) { + return subscribeForUpdatePacket(sid, reportingEnabled, isDiagnostics, objects::NO_OBJECT); + } [[deprecated( "Please use the new API which takes all arguments as one wrapper " "struct")]] virtual ReturnValue_t diff --git a/src/fsfw/pus/Service11TelecommandScheduling.h b/src/fsfw/pus/Service11TelecommandScheduling.h index 0fed8bca..2d855be1 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.h +++ b/src/fsfw/pus/Service11TelecommandScheduling.h @@ -74,8 +74,7 @@ class Service11TelecommandScheduling final : public PusServiceBase { TO_TIMETAG = 3 }; - Service11TelecommandScheduling(object_id_t objectId, uint16_t apid, uint8_t serviceId, - AcceptsTelecommandsIF* tcRecipient, + Service11TelecommandScheduling(PsbParams params, AcceptsTelecommandsIF* tcRecipient, uint16_t releaseTimeMarginSeconds = DEFAULT_RELEASE_TIME_MARGIN, bool debugMode = false); @@ -159,7 +158,7 @@ class Service11TelecommandScheduling final : public PusServiceBase { * @param data The Application data of the TC (get via getApplicationData()). * @return requestId */ - uint64_t getRequestIdFromDataTC(const uint8_t* data) const; + [[nodiscard]] uint64_t getRequestIdFromTc() const; /** * @brief Extracts the Request ID from the Application Data directly, assuming it is packed diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 968a59ff..15440a21 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -11,9 +11,9 @@ static constexpr auto DEF_END = SerializeIF::Endianness::BIG; template inline Service11TelecommandScheduling::Service11TelecommandScheduling( - object_id_t objectId, uint16_t apid, uint8_t serviceId, AcceptsTelecommandsIF *tcRecipient, - uint16_t releaseTimeMarginSeconds, bool debugMode) - : PusServiceBase(objectId, apid, serviceId), + PsbParams params, AcceptsTelecommandsIF *tcRecipient, uint16_t releaseTimeMarginSeconds, + bool debugMode) + : PusServiceBase(params), RELEASE_TIME_MARGIN_SECONDS(releaseTimeMarginSeconds), debugMode(debugMode), tcRecipient(tcRecipient) {} @@ -32,8 +32,8 @@ inline ReturnValue_t Service11TelecommandScheduling::handleRequest( #endif } // Get de-serialized Timestamp - const uint8_t *data = currentPacket.getApplicationData(); - size_t size = currentPacket.getApplicationDataSize(); + const uint8_t *data = currentPacket.getUserData(); + size_t size = currentPacket.getUserDataLen(); if (data == nullptr) { return handleInvalidData("handleRequest"); } @@ -82,7 +82,7 @@ inline ReturnValue_t Service11TelecommandScheduling::performService if (schedulingEnabled) { // release tc TmTcMessage releaseMsg(it->second.storeAddr); - auto sendRet = this->requestQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false); + auto sendRet = psbParams.reqQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false); if (sendRet != HasReturnvaluesIF::RETURN_OK) { return sendRet; @@ -175,7 +175,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi // store currentPacket and receive the store address store_address_t addr{}; if (tcStore->addData(&addr, data, size) != RETURN_OK || - addr.raw == storeId::INVALID_STORE_ADDRESS) { + addr.raw == store_address_t::INVALID_RAW) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed" << std::endl; @@ -190,8 +190,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi TelecommandStruct tc; tc.seconds = timestamp; tc.storeAddr = addr; - tc.requestId = - getRequestIdFromDataTC(data); // TODO: Missing sanity check of the returned request id + tc.requestId = getRequestIdFromTc(); // TODO: Missing sanity check of the returned request id auto it = telecommandMap.insert(std::pair(timestamp, tc)); if (it == telecommandMap.end()) { @@ -455,13 +454,10 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterTimesh } template -inline uint64_t Service11TelecommandScheduling::getRequestIdFromDataTC( - const uint8_t *data) const { - TcPacketPus mask(data); - - uint32_t sourceId = mask.getSourceId(); - uint16_t apid = mask.getAPID(); - uint16_t sequenceCount = mask.getPacketSequenceCount(); +inline uint64_t Service11TelecommandScheduling::getRequestIdFromTc() const { + uint32_t sourceId = currentPacket.getSourceId(); + uint16_t apid = currentPacket.getApid(); + uint16_t sequenceCount = currentPacket.getSequenceCount(); return buildRequestId(sourceId, apid, sequenceCount); } diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/HasReturnvaluesIF.h index 4d59c26b..caef5954 100644 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ b/src/fsfw/returnvalues/HasReturnvaluesIF.h @@ -33,8 +33,7 @@ class HasReturnvaluesIF { * @param number * @return */ - [[deprecated("Use retval::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode( - uint8_t classId, uint8_t number) { + static constexpr ReturnValue_t makeReturnCode(uint8_t classId, uint8_t number) { return retval::makeCode(classId, number); } }; diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 981fca1c..9b436dec 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -8,8 +8,8 @@ #define PUS_DISTRIBUTOR_DEBUGGING 0 -PusDistributor::PusDistributor(StorageManagerIF* store_, uint16_t setApid, object_id_t setObjectId, - object_id_t setPacketSource) +PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, + object_id_t setPacketSource, StorageManagerIF* store_) : TcDistributor(setObjectId), store(store_), checker(setApid, ccsds::PacketType::TC), @@ -151,5 +151,11 @@ ReturnValue_t PusDistributor::initialize() { #endif return RETURN_FAILED; } + if (store == nullptr) { + store = ObjectManager::instance()->get(objects::TC_STORE); + if (store == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + } return ccsdsDistributor->registerApplication(this); } diff --git a/src/fsfw/tcdistribution/PusDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h index 3849c793..b16f1478 100644 --- a/src/fsfw/tcdistribution/PusDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -27,8 +27,8 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc * @param setPacketSource Object ID of the source of TC packets. * Must implement CCSDSDistributorIF. */ - PusDistributor(StorageManagerIF* store, uint16_t setApid, object_id_t setObjectId, - object_id_t setPacketSource); + PusDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource, + StorageManagerIF* store = nullptr); /** * The destructor is empty. */ diff --git a/src/fsfw/tmtcpacket/ccsds/header.cpp b/src/fsfw/tmtcpacket/ccsds/header.cpp index b87ab5b3..6491d207 100644 --- a/src/fsfw/tmtcpacket/ccsds/header.cpp +++ b/src/fsfw/tmtcpacket/ccsds/header.cpp @@ -17,7 +17,7 @@ uint16_t ccsds::getPacketLen(const PrimaryHeader &header) { } void ccsds::setPacketId(PrimaryHeader &header, uint16_t packetId) { - header.packetIdHAndVersion = (packetId >> 8) & 0x1F; + header.packetIdHAndVersion |= (packetId >> 8) & 0x1F; header.packetIdL = packetId & 0xff; } @@ -27,3 +27,8 @@ void ccsds::setApid(PrimaryHeader &header, uint16_t apid) { packetIdRaw |= apid & 0x7FF; setPacketId(header, packetIdRaw); } + +void ccsds::setSequenceCount(PrimaryHeader &header, uint16_t seqCount) { + header.packetSeqCtrlH |= (seqCount >> 8) & 0x3F; + header.packetSeqCtrlL = seqCount & 0xFF; +} diff --git a/src/fsfw/tmtcpacket/ccsds/header.h b/src/fsfw/tmtcpacket/ccsds/header.h index d416f697..89e00601 100644 --- a/src/fsfw/tmtcpacket/ccsds/header.h +++ b/src/fsfw/tmtcpacket/ccsds/header.h @@ -24,6 +24,7 @@ uint16_t getPacketLen(const PrimaryHeader& header); void setPacketId(PrimaryHeader& header, uint16_t packetId); void setApid(PrimaryHeader& header, uint16_t apid); +void setSequenceCount(PrimaryHeader& header, uint16_t seqCount); } // namespace ccsds diff --git a/src/fsfw/tmtcpacket/pus/tm.h b/src/fsfw/tmtcpacket/pus/tm.h index 619f9e01..fc3f0b94 100644 --- a/src/fsfw/tmtcpacket/pus/tm.h +++ b/src/fsfw/tmtcpacket/pus/tm.h @@ -3,5 +3,6 @@ #include "tm/PusTmCreator.h" #include "tm/PusTmReader.h" +#include "tm/PusTmZcWriter.h" #endif /* FSFW_TMTCPACKET_PUS_TM_H_ */ diff --git a/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt b/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt index 57c45927..1395d927 100644 --- a/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/pus/tm/CMakeLists.txt @@ -1,2 +1,2 @@ target_sources(${LIB_FSFW_NAME} PRIVATE PusTmCreator.cpp PusTmReader.cpp - PusTmMinimal.cpp) + PusTmMinimal.cpp PusTmZcWriter.cpp) diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index ddcad33e..6e6eb686 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -83,8 +83,11 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max return result; } } - uint16_t crc16 = CRC::crc16ccitt(start, getFullPacketLen() - sizeof(ecss::PusChecksumT)); - return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness); + if (calculateCrcOnSerialization) { + uint16_t crc16 = CRC::crc16ccitt(start, getFullPacketLen() - sizeof(ecss::PusChecksumT)); + return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness); + } + return HasReturnvaluesIF::RETURN_OK; } size_t PusTmCreator::getSerializedSize() const { return getFullPacketLen(); } @@ -108,10 +111,6 @@ void PusTmCreator::updateSpLengthField() { void PusTmCreator::setApid(uint16_t apid) { spCreator.setApid(apid); } -ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize) const { - return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); -} - void PusTmCreator::setup() { updateSpLengthField(); spCreator.setPacketType(ccsds::PacketType::TM); diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 41f72c38..78414c37 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -63,7 +63,6 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF uint8_t getScTimeRefStatus() override; uint16_t getMessageTypeCounter() override; uint16_t getDestId() override; - ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize) const; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; @@ -76,6 +75,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF private: void setup(); PusTmParams pusParams{}; + bool calculateCrcOnSerialization = true; SpacePacketCreator spCreator; }; #endif // FSFW_TMTCPACKET_TMPACKETCREATOR_H diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h index e5a61aec..780b3e5f 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h @@ -38,13 +38,15 @@ class PusTmReader : public PusTmIF, uint16_t getMessageTypeCounter() override; uint16_t getDestId() override; - private: - ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override; - ReturnValue_t parseData(bool crcCheck); + protected: + ecss::PusPointers pointers{}; SpacePacketReader spReader{}; size_t sourceDataLen = 0; TimeReaderIF* timeReader{}; - ecss::PusPointers pointers{}; + ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override; + ReturnValue_t parseData(bool crcCheck); + + private: }; #endif // FSFW_TMTCPACKET_PUSTMREADER_H diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp new file mode 100644 index 00000000..4c6c56d3 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp @@ -0,0 +1,18 @@ +#include "PusTmZcWriter.h" + +#include "fsfw/globalfunctions/CRC.h" + +PusTmZeroCopyWriter::PusTmZeroCopyWriter(uint8_t* data, size_t size) : PusTmReader(data, size) {} + +void PusTmZeroCopyWriter::setSequenceCount(uint16_t seqCount) { + auto* spHeader = + reinterpret_cast(const_cast((pointers.spHeaderStart))); + ccsds::setSequenceCount(*spHeader, seqCount); +} +void PusTmZeroCopyWriter::updateErrorControl() { + auto* crcStart = reinterpret_cast(const_cast((pointers.spHeaderStart))); + uint16_t crc16 = + CRC::crc16ccitt(PusTmReader::getFullData(), getFullPacketLen() - sizeof(ecss::PusChecksumT)); + crcStart[0] = (crc16 >> 8) & 0xff; + crcStart[1] = crc16 & 0xff; +} diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h new file mode 100644 index 00000000..c3f5db35 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h @@ -0,0 +1,14 @@ +#ifndef FSFW_EXAMPLE_HOSTED_PUSTMZCWRITER_H +#define FSFW_EXAMPLE_HOSTED_PUSTMZCWRITER_H + +#include "PusTmReader.h" +class PusTmZeroCopyWriter : public PusTmReader { + public: + PusTmZeroCopyWriter(uint8_t* data, size_t size); + + void setSequenceCount(uint16_t seqCount); + void updateErrorControl(); + + private: +}; +#endif // FSFW_EXAMPLE_HOSTED_PUSTMZCWRITER_H diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 97f018e5..094a4156 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -27,7 +27,7 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PusService " << psbParams.serviceId << ": performService returned with " - << static_cast(result) << std::endl; + << static_cast(result) << std::endl; #endif return RETURN_FAILED; } diff --git a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp index 36f1ea8c..551e252f 100644 --- a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp +++ b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp @@ -645,7 +645,7 @@ ReturnValue_t TestDevice::initializeLocalDataPool(localpool::DataPool& localData sid_t sid(this->getObjectId(), td::TEST_SET_ID); /* Subscribe for periodic HK packets but do not enable reporting for now. Non-diangostic with a period of one second */ - poolManager.subscribeForPeriodicPacket(sid, false, 1.0, false); + poolManager.subscribeForRegularPeriodicPacket(subdp::RegularHkPeriodicParams(sid, false, 1.0)); return HasReturnvaluesIF::RETURN_OK; } From 064b195c752f2f6e7c0cb4660bb294cf8a8e6db1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 11:33:19 +0200 Subject: [PATCH 132/532] some of the deprecation warnings run amok --- src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h | 9 +++------ src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 9 +++++++++ src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 9 +++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index 3001ea10..682cfa5c 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -70,9 +70,7 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams params) = 0; - [[deprecated( - "Please use the new API which takes all arguments as one wrapper " - "struct")]] virtual ReturnValue_t + virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval, bool isDiagnostics) { return subscribeForPeriodicPacket(sid, enableReporting, collectionInterval, isDiagnostics, @@ -106,12 +104,11 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; - [[deprecated( - "Please use the new API which takes all arguments as one wrapper " - "struct")]] virtual ReturnValue_t + virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics) { return subscribeForUpdatePacket(sid, reportingEnabled, isDiagnostics, objects::NO_OBJECT); } + [[deprecated( "Please use the new API which takes all arguments as one wrapper " "struct")]] virtual ReturnValue_t diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 6e6eb686..850eb078 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -12,6 +12,14 @@ PusTmCreator::PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusPa PusTmCreator::PusTmCreator() { setup(); } +void PusTmCreator::disableCrcCalculation() { + calculateCrcOnSerialization = false; +} + +void PusTmCreator::enableCrcCalculation() { + calculateCrcOnSerialization = true; +} + uint16_t PusTmCreator::getPacketIdRaw() const { return spCreator.getPacketIdRaw(); } uint16_t PusTmCreator::getPacketSeqCtrlRaw() const { return spCreator.getPacketSeqCtrlRaw(); } @@ -138,3 +146,4 @@ void PusTmCreator::setService(uint8_t service) { pusParams.secHeader.service = s void PusTmCreator::setSubservice(uint8_t subservice) { pusParams.secHeader.subservice = subservice; } +bool PusTmCreator::crcCalculationEnabled() const { return calculateCrcOnSerialization; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 78414c37..0e7988f1 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -46,6 +46,15 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF ~PusTmCreator() override = default; void setTimeStamper(TimeStamperIF& timeStamper); + /** + * This function disables the CRC16 calculation on serialization. This is useful to avoid + * duplicate calculation if some lower level component needs to update fields like the sequence + * count, which would require a checksum update. + */ + void disableCrcCalculation(); + void enableCrcCalculation(); + [[nodiscard]] bool crcCalculationEnabled() const; + SpacePacketParams& getSpParams(); void setApid(uint16_t apid); void setDestId(uint16_t destId); From 86692e202dedd682e7cbc7476b4b0908668d2fd9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 11:35:35 +0200 Subject: [PATCH 133/532] this gets rid of some warnings --- .../ProvidesDataPoolSubscriptionIF.h | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index 682cfa5c..31067268 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -70,18 +70,12 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams params) = 0; - virtual ReturnValue_t - subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval, - bool isDiagnostics) { - return subscribeForPeriodicPacket(sid, enableReporting, collectionInterval, isDiagnostics, - objects::NO_OBJECT); - } - [[deprecated( "Please use the new API which takes all arguments as one wrapper " "struct")]] virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval, - bool isDiagnostics, object_id_t packetDestination) { + bool isDiagnostics, + object_id_t packetDestination = objects::NO_OBJECT) { if (isDiagnostics) { subdp::DiagnosticsHkPeriodicParams params(sid, enableReporting, collectionInterval); return subscribeForDiagPeriodicPacket(params); @@ -104,16 +98,16 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; - virtual ReturnValue_t - subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics) { - return subscribeForUpdatePacket(sid, reportingEnabled, isDiagnostics, objects::NO_OBJECT); - } +// virtual ReturnValue_t +// subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics) { +// return subscribeForUpdatePacket(sid, reportingEnabled, isDiagnostics, objects::NO_OBJECT); +// } [[deprecated( "Please use the new API which takes all arguments as one wrapper " "struct")]] virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics, - object_id_t packetDestination) { + object_id_t packetDestination = objects::NO_OBJECT) { if (isDiagnostics) { subdp::DiagnosticsHkUpdateParams params(sid, reportingEnabled); return subscribeForDiagUpdatePacket(params); From 059fb105583bd4ce072e1134ffbaa3aab8955d04 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 11:41:06 +0200 Subject: [PATCH 134/532] add helper methods to disable crc calculation --- src/fsfw/tmtcservices/CommandingServiceBase.cpp | 4 ++++ src/fsfw/tmtcservices/CommandingServiceBase.h | 6 +++++- src/fsfw/tmtcservices/TmStoreHelper.cpp | 4 ++++ src/fsfw/tmtcservices/TmStoreHelper.h | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 214adbfa..0be7c3c8 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -100,6 +100,10 @@ ReturnValue_t CommandingServiceBase::initialize() { } tmStoreHelper.setTmStore(*tmStore); } + // Generally, all TM packets will pass through a layer where the sequence count is set. + // This avoids duplicate calculation of the CRC16 + tmStoreHelper.disableCrcCalculation(); + if (errReporter == nullptr) { errReporter = ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 20b7d992..8017ecc8 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -25,12 +25,16 @@ void setStaticFrameworkObjectIds(); * relay Telecommands to software bus. * * It manages Telecommand reception and the generation of Verification Reports - * similar to PusServiceBase. This class is used if a telecommand can't be + * similar to @PusServiceBase. This class is used if a telecommand can't be * handled immediately and must be relayed to the internal software bus. * - isValidSubservice * - getMessageQueueAndObject * - prepareCommand * - handleReply + * + * Please note that the TM packets generated by this class will not have a valid CRC. It is + * generally assumed that all packets will pass through a layer where the sequence count is set + * and the CRC16 needs to be re-calculated anyway. * @author gaisser * @ingroup pus_services */ diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index a87ca01d..8b7e5948 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -74,3 +74,7 @@ uint16_t TmStoreHelper::getApid() const { return creator.getApid(); } void TmStoreHelper::setService(uint8_t service) { creator.setService(service); } void TmStoreHelper::setSubservice(uint8_t subservice) { creator.setSubservice(subservice); } + +void TmStoreHelper::disableCrcCalculation() { creator.disableCrcCalculation(); } + +bool TmStoreHelper::crcCalculationEnabled() const { return creator.crcCalculationEnabled(); } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index e5d9eb7d..449a2287 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -13,6 +13,9 @@ class TmStoreHelper { TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore); TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, TimeStamperIF& timeStamper); + void disableCrcCalculation(); + [[nodiscard]] bool crcCalculationEnabled() const; + ReturnValue_t preparePacket(uint8_t service, uint8_t subservice, uint16_t counter); PusTmCreator& getCreatorRef(); From 740644f2c8398227734fd4a4110b3d8ae09f3351 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 14:40:51 +0200 Subject: [PATCH 135/532] updates for PusDistributor --- src/fsfw/tcdistribution/PusDistributor.cpp | 28 +++++++++------------- src/fsfw/tcdistribution/PusDistributor.h | 12 ++++------ 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 9b436dec..36bcd34b 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -9,12 +9,12 @@ #define PUS_DISTRIBUTOR_DEBUGGING 0 PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, - object_id_t setPacketSource, StorageManagerIF* store_) + CCSDSDistributorIF* distributor, StorageManagerIF* store_) : TcDistributor(setObjectId), store(store_), checker(setApid, ccsds::PacketType::TC), - tcStatus(RETURN_FAILED), - packetSource(setPacketSource) {} + ccsdsDistributor(distributor), + tcStatus(RETURN_FAILED) {} PusDistributor::~PusDistributor() = default; @@ -25,7 +25,7 @@ PusDistributor::TcMqMapIter PusDistributor::selectDestination() { << storeId.packetIndex << std::endl; #endif auto queueMapIt = this->queueMap.end(); - if (this->currentPacket == nullptr) { + if (reader.isNull()) { return queueMapIt; } // TODO: Need to set the data @@ -135,13 +135,13 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { uint16_t PusDistributor::getIdentifier() { return checker.getApid(); } ReturnValue_t PusDistributor::initialize() { - if (currentPacket == nullptr) { - // Should not happen, memory allocation failed! - return ObjectManagerIF::CHILD_INIT_FAILED; + if (store == nullptr) { + store = ObjectManager::instance()->get(objects::TC_STORE); + if (store == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } } - - auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); - if (ccsdsDistributor == nullptr) { + if(ccsdsDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl; sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; @@ -149,13 +149,7 @@ ReturnValue_t PusDistributor::initialize() { sif::printError("PusDistributor::initialize: Packet source invalid\n"); sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); #endif - return RETURN_FAILED; - } - if (store == nullptr) { - store = ObjectManager::instance()->get(objects::TC_STORE); - if (store == nullptr) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + return ObjectManagerIF::CHILD_INIT_FAILED; } return ccsdsDistributor->registerApplication(this); } diff --git a/src/fsfw/tcdistribution/PusDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h index b16f1478..bb0c7a04 100644 --- a/src/fsfw/tcdistribution/PusDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -9,7 +9,7 @@ #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/VerificationReporter.h" -class PacketStorageHelper; +class CCSDSDistributorIF; /** * This class accepts PUS Telecommands and forwards them to Application @@ -27,7 +27,7 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc * @param setPacketSource Object ID of the source of TC packets. * Must implement CCSDSDistributorIF. */ - PusDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource, + PusDistributor(uint16_t setApid, object_id_t setObjectId, CCSDSDistributorIF* packetSource, StorageManagerIF* store = nullptr); /** * The destructor is empty. @@ -49,10 +49,8 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc * TC Verification service. */ VerificationReporterIF* verifyChannel = nullptr; - /** - * The currently handled packet is stored here. - */ - PacketStorageHelper* currentPacket = nullptr; + //! Cached for initialization + CCSDSDistributorIF* ccsdsDistributor = nullptr; PusTcReader reader; /** @@ -61,8 +59,6 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc */ ReturnValue_t tcStatus; - const object_id_t packetSource; - /** * This method reads the packet service, checks if such a service is * registered and forwards the packet to the destination. From 083d08ae2a3e294b20c31f8970f1faa47cb1c276 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 17:00:43 +0200 Subject: [PATCH 136/532] various bugs and improvements --- .../ProvidesDataPoolSubscriptionIF.h | 8 +- src/fsfw/osal/host/MessageQueue.h | 4 +- src/fsfw/osal/host/QueueMapManager.cpp | 2 +- .../pus/Service1TelecommandVerification.cpp | 34 ++++- .../pus/Service1TelecommandVerification.h | 1 + src/fsfw/tcdistribution/CCSDSDistributor.cpp | 22 +-- src/fsfw/tcdistribution/CCSDSDistributor.h | 18 ++- src/fsfw/tcdistribution/CFDPDistributor.cpp | 2 +- src/fsfw/tcdistribution/CMakeLists.txt | 2 +- src/fsfw/tcdistribution/CcsdsPacketCheckIF.h | 2 +- .../tcdistribution/CcsdsPacketChecker.cpp | 33 +++++ src/fsfw/tcdistribution/CcsdsPacketChecker.h | 20 +++ .../tcdistribution/CcsdsPacketCheckerBase.cpp | 22 --- .../tcdistribution/CcsdsPacketCheckerBase.h | 17 --- src/fsfw/tcdistribution/CfdpPacketChecker.h | 2 +- src/fsfw/tcdistribution/PusDistributor.cpp | 130 ++++++++++-------- src/fsfw/tcdistribution/PusDistributor.h | 2 + src/fsfw/tcdistribution/PusPacketChecker.cpp | 32 ++--- src/fsfw/tcdistribution/PusPacketChecker.h | 14 +- src/fsfw/tcdistribution/TcDistributor.cpp | 15 +- src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp | 3 +- src/fsfw/timemanager/TimeStamperIF.h | 2 + src/fsfw/tmtcpacket/ReadablePacketIF.h | 2 +- .../tmtcpacket/ccsds/SpacePacketReader.cpp | 2 +- src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcReader.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 17 ++- src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmReader.h | 2 +- .../tmtcservices/CommandingServiceBase.cpp | 6 + src/fsfw/tmtcservices/CommandingServiceBase.h | 1 + src/fsfw/tmtcservices/PusServiceBase.cpp | 7 + src/fsfw/tmtcservices/PusServiceBase.h | 5 +- src/fsfw/tmtcservices/TmSendHelper.cpp | 40 ++++-- src/fsfw/tmtcservices/TmSendHelper.h | 1 - 36 files changed, 276 insertions(+), 202 deletions(-) create mode 100644 src/fsfw/tcdistribution/CcsdsPacketChecker.cpp create mode 100644 src/fsfw/tcdistribution/CcsdsPacketChecker.h delete mode 100644 src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp delete mode 100644 src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index 31067268..c350bb60 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -98,10 +98,10 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; -// virtual ReturnValue_t -// subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics) { -// return subscribeForUpdatePacket(sid, reportingEnabled, isDiagnostics, objects::NO_OBJECT); -// } + // virtual ReturnValue_t + // subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics) { + // return subscribeForUpdatePacket(sid, reportingEnabled, isDiagnostics, objects::NO_OBJECT); + // } [[deprecated( "Please use the new API which takes all arguments as one wrapper " diff --git a/src/fsfw/osal/host/MessageQueue.h b/src/fsfw/osal/host/MessageQueue.h index 4020c6dc..7d60fb8e 100644 --- a/src/fsfw/osal/host/MessageQueue.h +++ b/src/fsfw/osal/host/MessageQueue.h @@ -68,7 +68,7 @@ class MessageQueue : public MessageQueueBase { * @details This is accomplished by using the delete call provided * by the operating system. */ - virtual ~MessageQueue(); + ~MessageQueue() override; // Implement non-generic MessageQueueIF functions not handled by MessageQueueBase virtual ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, @@ -111,8 +111,6 @@ class MessageQueue : public MessageQueueBase { size_t messageDepth = 0; MutexIF* queueLock; - - MessageQueueId_t defaultDestination = MessageQueueIF::NO_QUEUE; }; #endif /* FRAMEWORK_OSAL_HOST_MESSAGEQUEUE_H_ */ diff --git a/src/fsfw/osal/host/QueueMapManager.cpp b/src/fsfw/osal/host/QueueMapManager.cpp index 72c70baa..301ed131 100644 --- a/src/fsfw/osal/host/QueueMapManager.cpp +++ b/src/fsfw/osal/host/QueueMapManager.cpp @@ -54,7 +54,7 @@ MessageQueueIF* QueueMapManager::getMessageQueue(MessageQueueId_t messageQueueId } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "QueueMapManager::getQueueHandle: The ID " << messageQueueId - << " does not exists in the map!" << std::endl; + << " does not exist in the map" << std::endl; #else sif::printWarning("QueueMapManager::getQueueHandle: The ID %d does not exist in the map!\n", messageQueueId); diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 102ae5a0..6c1c2310 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -68,8 +68,15 @@ ReturnValue_t Service1TelecommandVerification::generateFailureReport( FailureReport report(message->getReportId(), message->getTcPacketId(), message->getTcSequenceControl(), message->getStep(), message->getErrorCode(), message->getParameter1(), message->getParameter2()); - storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); - storeHelper.setSourceDataSerializable(report); + ReturnValue_t result = + storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = storeHelper.setSourceDataSerializable(report); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } return tmHelper.storeAndSendTmPacket(); } @@ -77,8 +84,15 @@ ReturnValue_t Service1TelecommandVerification::generateSuccessReport( PusVerificationMessage* message) { SuccessReport report(message->getReportId(), message->getTcPacketId(), message->getTcSequenceControl(), message->getStep()); - storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); - storeHelper.setSourceDataSerializable(report); + ReturnValue_t result = + storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = storeHelper.setSourceDataSerializable(report); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } return tmHelper.storeAndSendTmPacket(); } @@ -94,6 +108,9 @@ ReturnValue_t Service1TelecommandVerification::initialize() { #endif return ObjectManagerIF::CHILD_INIT_FAILED; } + if (tmQueue == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } tmQueue->setDefaultDestination(funnel->getReportReceptionQueue()); if (tmStore == nullptr) { tmStore = ObjectManager::instance()->get(objects::TM_STORE); @@ -102,5 +119,14 @@ ReturnValue_t Service1TelecommandVerification::initialize() { } storeHelper.setTmStore(*tmStore); } + + sendHelper.setMsgQueue(*tmQueue); + if (errReporter == nullptr) { + errReporter = + ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); + if (errReporter != nullptr) { + sendHelper.setInternalErrorReporter(*errReporter); + } + } return SystemObject::initialize(); } diff --git a/src/fsfw/pus/Service1TelecommandVerification.h b/src/fsfw/pus/Service1TelecommandVerification.h index dcbb5017..2e121bbf 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.h +++ b/src/fsfw/pus/Service1TelecommandVerification.h @@ -86,6 +86,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, TmSendHelper sendHelper; TmStoreHelper storeHelper; TmStoreAndSendWrapper tmHelper; + InternalErrorReporterIF* errReporter = nullptr; StorageManagerIF* tmStore = nullptr; MessageQueueIF* tmQueue = nullptr; diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index 9601825c..4dad31aa 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -4,10 +4,11 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" -#define CCSDS_DISTRIBUTOR_DEBUGGING 0 +#define CCSDS_DISTRIBUTOR_DEBUGGING 1 -CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId) - : TcDistributor(setObjectId), defaultApid(setDefaultApid) {} +CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId, + CcsdsPacketCheckIF* packetChecker) + : TcDistributor(setObjectId), defaultApid(setDefaultApid), packetChecker(packetChecker) {} CCSDSDistributor::~CCSDSDistributor() = default; @@ -25,7 +26,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { #endif const uint8_t* packet = nullptr; size_t size = 0; - ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(), &packet, &size); + ReturnValue_t result = tcStore->getData(currentMessage.getStorageId(), &packet, &size); if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -41,10 +42,12 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { return queueMap.end(); } SpacePacketReader currentPacket(packet, size); - + result = packetChecker->checkPacket(currentPacket, size); + if (result != HasReturnvaluesIF::RETURN_OK) { + } #if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1 - sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex - << currentPacket.getAPID() << std::dec << std::endl; + sif::info << "CCSDSDistributor::selectDestination has packet with APID 0x" << std::hex + << currentPacket.getApid() << std::dec << std::endl; #endif auto position = this->queueMap.find(currentPacket.getApid()); if (position != this->queueMap.end()) { @@ -52,7 +55,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { } else { // The APID was not found. Forward packet to main SW-APID anyway to // create acceptance failure report. - return this->queueMap.find(this->defaultApid); + return queueMap.find(this->defaultApid); } } @@ -80,6 +83,9 @@ ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid, MessageQueueI uint16_t CCSDSDistributor::getIdentifier() { return 0; } ReturnValue_t CCSDSDistributor::initialize() { + if (packetChecker == nullptr) { + packetChecker = new CcsdsPacketChecker(ccsds::PacketType::TC); + } ReturnValue_t status = this->TcDistributor::initialize(); this->tcStore = ObjectManager::instance()->get(objects::TC_STORE); if (this->tcStore == nullptr) { diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.h b/src/fsfw/tcdistribution/CCSDSDistributor.h index b5cfc5a4..d6e4f0e7 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.h +++ b/src/fsfw/tcdistribution/CCSDSDistributor.h @@ -1,11 +1,12 @@ #ifndef FRAMEWORK_TCDISTRIBUTION_CCSDSDISTRIBUTOR_H_ #define FRAMEWORK_TCDISTRIBUTION_CCSDSDISTRIBUTOR_H_ -#include "../objectmanager/ObjectManagerIF.h" -#include "../storagemanager/StorageManagerIF.h" -#include "../tcdistribution/CCSDSDistributorIF.h" -#include "../tcdistribution/TcDistributor.h" -#include "../tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/objectmanager/ObjectManagerIF.h" +#include "fsfw/storagemanager/StorageManagerIF.h" +#include "fsfw/tcdistribution/CCSDSDistributorIF.h" +#include "fsfw/tcdistribution/CcsdsPacketChecker.h" +#include "fsfw/tcdistribution/TcDistributor.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" /** * @brief An instantiation of the CCSDSDistributorIF. @@ -24,10 +25,11 @@ class CCSDSDistributor : public TcDistributor, * TcDistributor ctor with a certain object id. * @details * @c tcStore is set in the @c initialize method. - * @param setDefaultApid The default APID, where packets with unknown + * @param unknownApid The default APID, where packets with unknown * destination are sent to. */ - CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId); + CCSDSDistributor(uint16_t unknownApid, object_id_t setObjectId, + CcsdsPacketCheckIF* packetChecker = nullptr); /** * The destructor is empty. */ @@ -63,6 +65,8 @@ class CCSDSDistributor : public TcDistributor, * pure Space Packets and there exists no SpacePacketStored class. */ StorageManagerIF* tcStore = nullptr; + + CcsdsPacketCheckIF* packetChecker = nullptr; }; #endif /* FRAMEWORK_TCDISTRIBUTION_CCSDSDISTRIBUTOR_H_ */ diff --git a/src/fsfw/tcdistribution/CFDPDistributor.cpp b/src/fsfw/tcdistribution/CFDPDistributor.cpp index 5aa84d44..0e6f968c 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.cpp +++ b/src/fsfw/tcdistribution/CFDPDistributor.cpp @@ -35,7 +35,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { } this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); if (currentPacket->getFullData() != nullptr) { - tcStatus = checker.checkPacket(currentPacket, currentPacket->getFullPacketLen()); + tcStatus = checker.checkPacket(*currentPacket, currentPacket->getFullPacketLen()); if (tcStatus != HasReturnvaluesIF::RETURN_OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/tcdistribution/CMakeLists.txt b/src/fsfw/tcdistribution/CMakeLists.txt index 9cc3d170..532ba2ca 100644 --- a/src/fsfw/tcdistribution/CMakeLists.txt +++ b/src/fsfw/tcdistribution/CMakeLists.txt @@ -6,4 +6,4 @@ target_sources( PusPacketChecker.cpp TcPacketCheckCFDP.cpp CFDPDistributor.cpp - CcsdsPacketCheckerBase.cpp) + CcsdsPacketChecker.cpp) diff --git a/src/fsfw/tcdistribution/CcsdsPacketCheckIF.h b/src/fsfw/tcdistribution/CcsdsPacketCheckIF.h index 55288ae4..6c83532e 100644 --- a/src/fsfw/tcdistribution/CcsdsPacketCheckIF.h +++ b/src/fsfw/tcdistribution/CcsdsPacketCheckIF.h @@ -26,7 +26,7 @@ class CcsdsPacketCheckIF { * - @c INCORRECT_CHECKSUM if checksum is invalid. * - @c ILLEGAL_APID if APID does not match. */ - virtual ReturnValue_t checkPacket(SpacePacketReader* currentPacket, size_t packetLen) = 0; + virtual ReturnValue_t checkPacket(const SpacePacketReader& currentPacket, size_t packetLen) = 0; }; #endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ */ diff --git a/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp b/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp new file mode 100644 index 00000000..394f5a57 --- /dev/null +++ b/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp @@ -0,0 +1,33 @@ +#include "CcsdsPacketChecker.h" + +#include "fsfw/tcdistribution/definitions.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" + +CcsdsPacketChecker::CcsdsPacketChecker(ccsds::PacketType packetType_, uint8_t ccsdsVersion_) + : packetType(packetType_), ccsdsVersion(ccsdsVersion_) {} + +ReturnValue_t CcsdsPacketChecker::checkPacket(const SpacePacketReader& currentPacket, + size_t packetLen) { + if (checkApid) { + if (currentPacket.getApid() != apid) { + return tcdistrib::INVALID_APID; + } + } + + if (currentPacket.getVersion() != ccsdsVersion) { + return tcdistrib::INVALID_CCSDS_VERSION; + } + if (currentPacket.getPacketType() != packetType) { + return tcdistrib::INVALID_PACKET_TYPE; + } + // This assumes that the getFullPacketLen version uses the space packet data length field + if (currentPacket.getFullPacketLen() != packetLen) { + return tcdistrib::INCOMPLETE_PACKET; + } + return HasReturnvaluesIF::RETURN_OK; +} + +void CcsdsPacketChecker::setApidToCheck(uint16_t apid_) { + apid = apid_; + checkApid = true; +} diff --git a/src/fsfw/tcdistribution/CcsdsPacketChecker.h b/src/fsfw/tcdistribution/CcsdsPacketChecker.h new file mode 100644 index 00000000..f910aac4 --- /dev/null +++ b/src/fsfw/tcdistribution/CcsdsPacketChecker.h @@ -0,0 +1,20 @@ +#ifndef FSFW_TESTS_CCSDSPACKETCHECKERBASE_H +#define FSFW_TESTS_CCSDSPACKETCHECKERBASE_H + +#include "CcsdsPacketCheckIF.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" + +class CcsdsPacketChecker : public CcsdsPacketCheckIF, public HasReturnvaluesIF { + public: + CcsdsPacketChecker(ccsds::PacketType packetType, uint8_t ccsdsVersion = 0b000); + + void setApidToCheck(uint16_t apid); + ReturnValue_t checkPacket(const SpacePacketReader& currentPacket, size_t packetLen) override; + + protected: + bool checkApid = false; + uint16_t apid = 0; + ccsds::PacketType packetType; + uint8_t ccsdsVersion; +}; +#endif // FSFW_TESTS_CCSDSPACKETCHECKERBASE_H diff --git a/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp b/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp deleted file mode 100644 index e1b6337f..00000000 --- a/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "CcsdsPacketCheckerBase.h" - -#include "fsfw/tcdistribution/definitions.h" -#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" - -CcsdsPacketCheckerBase::CcsdsPacketCheckerBase(uint16_t apid, ccsds::PacketType packetType_, - uint8_t ccsdsVersion_) - : apid(apid), packetType(packetType_), ccsdsVersion(ccsdsVersion_) {} - -ReturnValue_t CcsdsPacketCheckerBase::checkPacket(SpacePacketReader* currentPacket, - size_t packetLen) { - if (currentPacket->getApid() != apid) { - return tcdistrib::INVALID_APID; - } - if (currentPacket->getVersion() != ccsdsVersion) { - return tcdistrib::INVALID_CCSDS_VERSION; - } - if (currentPacket->getPacketType() != packetType) { - return tcdistrib::INVALID_PACKET_TYPE; - } - return HasReturnvaluesIF::RETURN_OK; -} \ No newline at end of file diff --git a/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h b/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h deleted file mode 100644 index 0f7f7e14..00000000 --- a/src/fsfw/tcdistribution/CcsdsPacketCheckerBase.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef FSFW_TESTS_CCSDSPACKETCHECKERBASE_H -#define FSFW_TESTS_CCSDSPACKETCHECKERBASE_H - -#include "CcsdsPacketCheckIF.h" -#include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" - -class CcsdsPacketCheckerBase : public CcsdsPacketCheckIF, public HasReturnvaluesIF { - public: - CcsdsPacketCheckerBase(uint16_t apid, ccsds::PacketType packetType, uint8_t ccsdsVersion = 0b000); - ReturnValue_t checkPacket(SpacePacketReader* currentPacket, size_t packetLen) override; - - protected: - uint16_t apid; - ccsds::PacketType packetType; - uint8_t ccsdsVersion; -}; -#endif // FSFW_TESTS_CCSDSPACKETCHECKERBASE_H diff --git a/src/fsfw/tcdistribution/CfdpPacketChecker.h b/src/fsfw/tcdistribution/CfdpPacketChecker.h index 0838efc2..5ad802f9 100644 --- a/src/fsfw/tcdistribution/CfdpPacketChecker.h +++ b/src/fsfw/tcdistribution/CfdpPacketChecker.h @@ -25,7 +25,7 @@ class CfdpPacketChecker : public CcsdsPacketCheckIF, public HasReturnvaluesIF { */ explicit CfdpPacketChecker(uint16_t setApid); - ReturnValue_t checkPacket(SpacePacketReader* currentPacket, size_t packetLen) override; + ReturnValue_t checkPacket(const SpacePacketReader& currentPacket, size_t packetLen) override; [[nodiscard]] uint16_t getApid() const; }; diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 36bcd34b..85672439 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -6,7 +6,7 @@ #include "fsfw/tcdistribution/CCSDSDistributorIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" -#define PUS_DISTRIBUTOR_DEBUGGING 0 +#define PUS_DISTRIBUTOR_DEBUGGING 1 PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, CCSDSDistributorIF* distributor, StorageManagerIF* store_) @@ -20,71 +20,56 @@ PusDistributor::~PusDistributor() = default; PusDistributor::TcMqMapIter PusDistributor::selectDestination() { #if FSFW_CPP_OSTREAM_ENABLED == 1 && PUS_DISTRIBUTOR_DEBUGGING == 1 - store_address_t storeId = this->currentMessage.getStorageId()); - sif::debug << "PUSDistributor::handlePacket received: " << storeId.poolIndex << ", " - << storeId.packetIndex << std::endl; + store_address_t storeId = currentMessage.getStorageId(); + sif::debug << "PUSDistributor::handlePacket received: " << storeId.poolIndex << ", " + << storeId.packetIndex << std::endl; #endif - auto queueMapIt = this->queueMap.end(); - if (reader.isNull()) { - return queueMapIt; - } - // TODO: Need to set the data - const uint8_t* packetPtr = nullptr; - size_t packetLen = 0; - if (store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != - HasReturnvaluesIF::RETURN_OK) { - return queueMapIt; - } - reader.setReadOnlyData(packetPtr, packetLen); - // this->currentPacket->setStoreAddress(this->currentMessage.getStorageId(), currentPacket); - if (reader.getFullData() != nullptr) { - tcStatus = - checker.checkPacket(dynamic_cast(&reader), reader.getFullPacketLen()); - if (tcStatus != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 - const char* keyword = "unnamed error"; - if (tcStatus == tcdistrib::INCORRECT_CHECKSUM) { - keyword = "checksum"; - } else if (tcStatus == tcdistrib::INCORRECT_PRIMARY_HEADER) { - keyword = "incorrect primary header"; - } else if (tcStatus == tcdistrib::INVALID_APID) { - keyword = "illegal APID"; - } else if (tcStatus == tcdistrib::INCORRECT_SECONDARY_HEADER) { - keyword = "incorrect secondary header"; - } else if (tcStatus == tcdistrib::INCOMPLETE_PACKET) { - keyword = "incomplete packet"; - } -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "PUSDistributor::handlePacket: Packet format invalid, " << keyword - << " error" << std::endl; -#else - sif::printWarning("PUSDistributor::handlePacket: Packet format invalid, %s error\n", - keyword); -#endif -#endif - } - uint32_t queue_id = reader.getService(); - queueMapIt = this->queueMap.find(queue_id); - } else { - tcStatus = PACKET_LOST; + auto queueMapIt = queueMap.end(); + // TODO: Need to set the data + const uint8_t* packetPtr = nullptr; + size_t packetLen = 0; + if (store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != + HasReturnvaluesIF::RETURN_OK) { + return queueMapIt; + } + ReturnValue_t result = reader.setReadOnlyData(packetPtr, packetLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + tcStatus = PACKET_LOST; + return queueMapIt; + } + // CRC check done by checker + result = reader.parseDataWithoutCrcCheck(); + if (result != HasReturnvaluesIF::RETURN_OK) { + tcStatus = PACKET_LOST; + return queueMapIt; + } + if (reader.getFullData() != nullptr) { + tcStatus = checker.checkPacket(reader, reader.getFullPacketLen()); + if (tcStatus != HasReturnvaluesIF::RETURN_OK) { + checkerFailurePrinter(); } + uint32_t queue_id = reader.getService(); + queueMapIt = queueMap.find(queue_id); + } else { + tcStatus = PACKET_LOST; + } - if (queueMapIt == this->queueMap.end()) { - tcStatus = DESTINATION_NOT_FOUND; + if (queueMapIt == this->queueMap.end()) { + tcStatus = DESTINATION_NOT_FOUND; #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl; + sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl; #else - sif::printDebug("PUSDistributor::handlePacket: Destination not found\n"); + sif::printDebug("PUSDistributor::handlePacket: Destination not found\n"); #endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif - } + } - if (tcStatus != RETURN_OK) { - return this->queueMap.end(); - } else { - return queueMapIt; - } + if (tcStatus != RETURN_OK) { + return this->queueMap.end(); + } else { + return queueMapIt; + } } ReturnValue_t PusDistributor::registerService(AcceptsTelecommandsIF* service) { @@ -141,7 +126,7 @@ ReturnValue_t PusDistributor::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } } - if(ccsdsDistributor == nullptr) { + if (ccsdsDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl; sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; @@ -151,5 +136,34 @@ ReturnValue_t PusDistributor::initialize() { #endif return ObjectManagerIF::CHILD_INIT_FAILED; } + if (verifyChannel == nullptr) { + verifyChannel = ObjectManager::instance()->get(objects::TC_VERIFICATOR); + if (verifyChannel == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + } return ccsdsDistributor->registerApplication(this); } + +void PusDistributor::checkerFailurePrinter() const { +#if FSFW_VERBOSE_LEVEL >= 1 + const char* keyword = "unnamed error"; + if (tcStatus == tcdistrib::INCORRECT_CHECKSUM) { + keyword = "checksum"; + } else if (tcStatus == tcdistrib::INCORRECT_PRIMARY_HEADER) { + keyword = "incorrect primary header"; + } else if (tcStatus == tcdistrib::INVALID_APID) { + keyword = "illegal APID"; + } else if (tcStatus == tcdistrib::INCORRECT_SECONDARY_HEADER) { + keyword = "incorrect secondary header"; + } else if (tcStatus == tcdistrib::INCOMPLETE_PACKET) { + keyword = "incomplete packet"; + } +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "PUSDistributor::handlePacket: Packet format invalid, " << keyword << " error" + << std::endl; +#else + sif::printWarning("PUSDistributor::handlePacket: Packet format invalid, %s error\n", keyword); +#endif +#endif +} diff --git a/src/fsfw/tcdistribution/PusDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h index bb0c7a04..7daf5d83 100644 --- a/src/fsfw/tcdistribution/PusDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -73,6 +73,8 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc * success/failure messages. */ ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override; + + void checkerFailurePrinter() const; }; #endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ */ diff --git a/src/fsfw/tcdistribution/PusPacketChecker.cpp b/src/fsfw/tcdistribution/PusPacketChecker.cpp index 828303b2..8ea8b6a8 100644 --- a/src/fsfw/tcdistribution/PusPacketChecker.cpp +++ b/src/fsfw/tcdistribution/PusPacketChecker.cpp @@ -5,40 +5,26 @@ #include "fsfw/tcdistribution/definitions.h" #include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" -PusPacketChecker::PusPacketChecker(uint16_t setApid, ccsds::PacketType packetType_, +PusPacketChecker::PusPacketChecker(uint16_t apid, ccsds::PacketType packetType_, ecss::PusVersion pusVersion_) - : CcsdsPacketCheckerBase(setApid, packetType_), pusVersion(pusVersion_) {} + : pusVersion(pusVersion_), apid(apid) {} -ReturnValue_t PusPacketChecker::checkPacket(PacketCheckIF* pusPacket, size_t packetLen) { - if (pusPacket == nullptr) { - return RETURN_FAILED; - } +ReturnValue_t PusPacketChecker::checkPacket(const PusTcReader& pusPacket, size_t packetLen) { // Other primary header fields are checked by base class - if (not pusPacket->hasSecHeader()) { + if (not pusPacket.hasSecHeader()) { return tcdistrib::INVALID_SEC_HEADER_FIELD; } - uint16_t calculated_crc = - CRC::crc16ccitt(pusPacket->getFullData(), pusPacket->getFullPacketLen()); + uint16_t calculated_crc = CRC::crc16ccitt(pusPacket.getFullData(), pusPacket.getFullPacketLen()); if (calculated_crc != 0) { return tcdistrib::INCORRECT_CHECKSUM; } - - // This assumes that the getFullPacketLen version uses the space packet data length field - if (pusPacket->getFullPacketLen() != packetLen) { - return tcdistrib::INCOMPLETE_PACKET; + if (pusPacket.getApid() != apid) { + return tcdistrib::INVALID_APID; } - if (pusPacket->getPusVersion() != pusVersion) { + if (pusPacket.getPusVersion() != pusVersion) { return tcdistrib::INVALID_PUS_VERSION; } - return RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } uint16_t PusPacketChecker::getApid() const { return apid; } - -ReturnValue_t PusPacketChecker::checkPacket(SpacePacketReader* currentPacket, size_t packetLen) { - ReturnValue_t result = CcsdsPacketCheckerBase::checkPacket(currentPacket, packetLen); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - return checkPacket(dynamic_cast(currentPacket), packetLen); -} diff --git a/src/fsfw/tcdistribution/PusPacketChecker.h b/src/fsfw/tcdistribution/PusPacketChecker.h index 431ee5a8..ee56e1f8 100644 --- a/src/fsfw/tcdistribution/PusPacketChecker.h +++ b/src/fsfw/tcdistribution/PusPacketChecker.h @@ -1,38 +1,34 @@ #ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ #define FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ -#include "CcsdsPacketCheckIF.h" -#include "CcsdsPacketCheckerBase.h" #include "fsfw/FSFW.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tmtcpacket/pus/defs.h" #include "fsfw/tmtcservices/PusVerificationReport.h" -class PacketCheckIF : public ReadablePacketIF, public PusIF {}; - /** * This class performs a formal packet check for incoming PUS Telecommand Packets. * Currently, it only checks if the APID and CRC are correct. * @ingroup tc_distribution */ -class PusPacketChecker : public CcsdsPacketCheckerBase { +class PusPacketChecker { public: /** * The constructor only sets the APID attribute. * @param set_apid The APID to set. */ - PusPacketChecker(uint16_t setApid, ccsds::PacketType packetType, - ecss::PusVersion = ecss::PusVersion::PUS_C); + explicit PusPacketChecker(uint16_t apid, ccsds::PacketType packetType, + ecss::PusVersion = ecss::PusVersion::PUS_C); - ReturnValue_t checkPacket(PacketCheckIF* currentPacket, size_t packetLen); + ReturnValue_t checkPacket(const PusTcReader& currentPacket, size_t packetLen); [[nodiscard]] uint16_t getApid() const; protected: ecss::PusVersion pusVersion; + uint16_t apid; private: - ReturnValue_t checkPacket(SpacePacketReader* currentPacket, size_t packetLen) override; }; #endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ */ diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index 600b3ca9..4ec85ed9 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -11,25 +11,24 @@ TcDistributor::TcDistributor(object_id_t objectId) : SystemObject(objectId) { TcDistributor::~TcDistributor() { QueueFactory::instance()->deleteMessageQueue(tcQueue); } ReturnValue_t TcDistributor::performOperation(uint8_t opCode) { - ReturnValue_t status = RETURN_OK; + ReturnValue_t status; for (status = tcQueue->receiveMessage(¤tMessage); status == RETURN_OK; status = tcQueue->receiveMessage(¤tMessage)) { status = handlePacket(); } if (status == MessageQueueIF::EMPTY) { return RETURN_OK; - } else { - return status; } + return status; } ReturnValue_t TcDistributor::handlePacket() { - auto queueMapIt = this->selectDestination(); - ReturnValue_t returnValue = RETURN_FAILED; - if (queueMapIt != this->queueMap.end()) { - returnValue = this->tcQueue->sendMessage(queueMapIt->second, &this->currentMessage); + auto queueMapIt = selectDestination(); + ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + if (queueMapIt != queueMap.end()) { + result = tcQueue->sendMessage(queueMapIt->second, ¤tMessage); } - return this->callbackAfterSending(returnValue); + return callbackAfterSending(result); } void TcDistributor::print() { diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp index 555c85b4..9a0b89bd 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp @@ -3,7 +3,8 @@ CfdpPacketChecker::CfdpPacketChecker(uint16_t setApid) : apid(setApid) {} -ReturnValue_t CfdpPacketChecker::checkPacket(SpacePacketReader* currentPacket, size_t packetLen) { +ReturnValue_t CfdpPacketChecker::checkPacket(const SpacePacketReader& currentPacket, + size_t packetLen) { return RETURN_OK; } diff --git a/src/fsfw/timemanager/TimeStamperIF.h b/src/fsfw/timemanager/TimeStamperIF.h index df680b6c..44cf0212 100644 --- a/src/fsfw/timemanager/TimeStamperIF.h +++ b/src/fsfw/timemanager/TimeStamperIF.h @@ -26,6 +26,8 @@ class TimeStamperIF : public SerializeIF { virtual ReturnValue_t addTimeStamp(uint8_t* buffer, uint8_t maxSize) = 0; ~TimeStamperIF() override = default; + + protected: }; #endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */ diff --git a/src/fsfw/tmtcpacket/ReadablePacketIF.h b/src/fsfw/tmtcpacket/ReadablePacketIF.h index bbffbe10..4f2f09e8 100644 --- a/src/fsfw/tmtcpacket/ReadablePacketIF.h +++ b/src/fsfw/tmtcpacket/ReadablePacketIF.h @@ -10,6 +10,6 @@ class ReadablePacketIF { /** * This method returns a raw uint8_t pointer to the readable data */ - virtual const uint8_t* getFullData() = 0; + [[nodiscard]] virtual const uint8_t* getFullData() const = 0; }; #endif // FSFW_TMTCPACKET_SPACEPACKETREADERIF_H diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp index 76f92107..b6f03de9 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp @@ -42,7 +42,7 @@ ReturnValue_t SpacePacketReader::setInternalFields(const uint8_t* data, size_t m return checkSize(); } -const uint8_t* SpacePacketReader::getFullData() { +const uint8_t* SpacePacketReader::getFullData() const { return reinterpret_cast(spHeader); } size_t SpacePacketReader::getBufSize() const { return bufSize; } diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h index 0d075bae..dbffa7bf 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h @@ -66,7 +66,7 @@ class SpacePacketReader : public SpacePacketIF, [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; - const uint8_t* getFullData() override; + [[nodiscard]] const uint8_t* getFullData() const override; // Helper methods: [[nodiscard]] ReturnValue_t checkSize() const; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp index f50affa7..31bb1011 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp @@ -67,7 +67,7 @@ uint16_t PusTcReader::getPacketSeqCtrlRaw() const { return spReader.getPacketSeq uint16_t PusTcReader::getPacketDataLen() const { return spReader.getPacketDataLen(); } -const uint8_t* PusTcReader::getFullData() { return pointers.spHeaderStart; } +const uint8_t* PusTcReader::getFullData() const { return pointers.spHeaderStart; } ReturnValue_t PusTcReader::setData(uint8_t* pData, size_t size_, void* args) { pointers.spHeaderStart = pData; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h index 1b9eea49..03af43a9 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.h @@ -54,7 +54,7 @@ class PusTcReader : public PusTcIF, [[nodiscard]] uint8_t getSubService() const override; [[nodiscard]] uint16_t getSourceId() const override; [[nodiscard]] uint16_t getErrorControl() const; - const uint8_t* getFullData() override; + const uint8_t* getFullData() const override; ReturnValue_t setReadOnlyData(const uint8_t* data, size_t size); [[nodiscard]] const uint8_t* getUserData() const override; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 850eb078..348308d1 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -12,13 +12,9 @@ PusTmCreator::PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusPa PusTmCreator::PusTmCreator() { setup(); } -void PusTmCreator::disableCrcCalculation() { - calculateCrcOnSerialization = false; -} +void PusTmCreator::disableCrcCalculation() { calculateCrcOnSerialization = false; } -void PusTmCreator::enableCrcCalculation() { - calculateCrcOnSerialization = true; -} +void PusTmCreator::enableCrcCalculation() { calculateCrcOnSerialization = true; } uint16_t PusTmCreator::getPacketIdRaw() const { return spCreator.getPacketIdRaw(); } @@ -74,10 +70,13 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - result = pusParams.secHeader.timeStamper->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; + if (getTimestamper() != nullptr) { + result = pusParams.secHeader.timeStamper->serialize(buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } } + if (pusParams.dataWrapper.type == ecss::DataTypes::RAW and pusParams.dataWrapper.dataUnion.raw.data != nullptr) { std::memcpy(*buffer, pusParams.dataWrapper.dataUnion.raw.data, userDataLen); diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp index 0dfab4ce..a3dbb7b0 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp @@ -15,7 +15,7 @@ ReturnValue_t PusTmReader::parseDataWithCrcCheck() { return parseData(true); } ReturnValue_t PusTmReader::parseDataWithoutCrcCheck() { return parseData(false); } -const uint8_t *PusTmReader::getFullData() { return spReader.getFullData(); } +const uint8_t *PusTmReader::getFullData() const { return spReader.getFullData(); } ReturnValue_t PusTmReader::setReadOnlyData(const uint8_t *data, size_t size) { return setData(const_cast(data), size, nullptr); diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h index 780b3e5f..fdad1b6c 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h @@ -19,7 +19,7 @@ class PusTmReader : public PusTmIF, ReturnValue_t parseDataWithoutCrcCheck(); ReturnValue_t parseDataWithCrcCheck(); - const uint8_t* getFullData() override; + const uint8_t* getFullData() const override; explicit operator bool() const; [[nodiscard]] bool isNull() const; diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 0be7c3c8..08ba599a 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -103,6 +103,12 @@ ReturnValue_t CommandingServiceBase::initialize() { // Generally, all TM packets will pass through a layer where the sequence count is set. // This avoids duplicate calculation of the CRC16 tmStoreHelper.disableCrcCalculation(); + if (tmTimeStamper == nullptr) { + auto timerStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); + if (timerStamper != nullptr) { + tmStoreHelper.setTimeStamper(*timerStamper); + } + } if (errReporter == nullptr) { errReporter = diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 8017ecc8..f9070d17 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -267,6 +267,7 @@ class CommandingServiceBase : public SystemObject, MessageQueueIF* commandQueue = nullptr; MessageQueueIF* requestQueue = nullptr; + TimeStamperIF* tmTimeStamper = nullptr; VerificationReporterIF* verificationReporter; InternalErrorReporterIF* errReporter = nullptr; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 094a4156..d3d23ed7 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -4,6 +4,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tcdistribution/PUSDistributorIF.h" +#include "fsfw/timemanager/CdsShortTimeStamper.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" #include "fsfw/tmtcservices/TmTcMessage.h" @@ -163,6 +164,12 @@ void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { void PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { tmStoreHelper.setApid(psbParams.apid); + if (psbParams.timeStamper == nullptr) { + auto timerStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); + if (timerStamper != nullptr) { + tmStoreHelper.setTimeStamper(*timerStamper); + } + } } void PusServiceBase::setVerificationReporter(VerificationReporterIF& reporter) { diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 9c75870a..43a2c0d4 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -65,6 +65,7 @@ struct PsbParams { * register itself at that object. */ PUSDistributorIF* pusDistributor = nullptr; + TimeStamperIF* timeStamper = nullptr; }; namespace Factory { @@ -133,7 +134,9 @@ class PusServiceBase : public ExecutableObjectIF, */ void initializeTmSendHelper(TmSendHelper& tmSendHelper); /** - * Helper methods if the implementing class wants to store telemetry + * Helper methods if the implementing class wants to store telemetry. It will set the correct APID + * and it will also attempt to set a valid time stamper. If the manually specified time stamper is + * null, it will attempt to find a suitable one using @objects::TIME_STAMPER * @param tmSendHelper */ void initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const; diff --git a/src/fsfw/tmtcservices/TmSendHelper.cpp b/src/fsfw/tmtcservices/TmSendHelper.cpp index ddbb86ba..a8e23186 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmSendHelper.cpp @@ -5,8 +5,10 @@ TmSendHelper::TmSendHelper() = default; TmSendHelper::TmSendHelper(MessageQueueIF &queue, InternalErrorReporterIF &reporter, - MessageQueueId_t tmtcMsgDest) - : defaultDest(tmtcMsgDest), queue(&queue), errReporter(&reporter) {} + MessageQueueId_t defaultDest) + : queue(&queue), errReporter(&reporter) { + queue.setDefaultDestination(defaultDest); +} TmSendHelper::TmSendHelper(MessageQueueIF &queue, InternalErrorReporterIF &reporter) : queue(&queue), errReporter(&reporter) {} @@ -14,11 +16,26 @@ TmSendHelper::TmSendHelper(MessageQueueIF &queue, InternalErrorReporterIF &repor TmSendHelper::TmSendHelper(InternalErrorReporterIF &reporter) : errReporter(&reporter) {} ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) { + return sendPacket(getDefaultDestination(), storeId); +} + +void TmSendHelper::setDefaultDestination(MessageQueueId_t msgDest) { + if (queue != nullptr) { + queue->setDefaultDestination(msgDest); + }; +} + +void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF &reporter) { + errReporter = &reporter; +} +void TmSendHelper::setMsgQueue(MessageQueueIF &queue_) { queue = &queue_; } + +ReturnValue_t TmSendHelper::sendPacket(MessageQueueId_t dest, const store_address_t &storeId) { if (queue == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } TmTcMessage message(storeId); - ReturnValue_t result = queue->sendMessage(defaultDest, &message, ignoreFault); + ReturnValue_t result = queue->sendMessage(dest, &message, ignoreFault); if (result != HasReturnvaluesIF::RETURN_OK) { if (errReporter != nullptr and not ignoreFault) { errReporter->lostTm(); @@ -28,19 +45,12 @@ ReturnValue_t TmSendHelper::sendPacket(const store_address_t &storeId) { return result; } -void TmSendHelper::setDefaultDestination(MessageQueueId_t msgDest) { defaultDest = msgDest; } - -void TmSendHelper::setInternalErrorReporter(InternalErrorReporterIF &reporter) { - errReporter = &reporter; +MessageQueueId_t TmSendHelper::getDefaultDestination() const { + if (queue != nullptr) { + return queue->getDefaultDestination(); + }; + return MessageQueueIF::NO_QUEUE; } -void TmSendHelper::setMsgQueue(MessageQueueIF &queue_) { queue = &queue_; } - -ReturnValue_t TmSendHelper::sendPacket(MessageQueueId_t dest, const store_address_t &storeId) { - setDefaultDestination(dest); - return sendPacket(storeId); -} - -MessageQueueId_t TmSendHelper::getDefaultDestination() const { return defaultDest; } bool TmSendHelper::areFaultsIgnored() const { return ignoreFault; } void TmSendHelper::ignoreFaults() { ignoreFault = true; } diff --git a/src/fsfw/tmtcservices/TmSendHelper.h b/src/fsfw/tmtcservices/TmSendHelper.h index a9feab75..5d39d5d1 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.h +++ b/src/fsfw/tmtcservices/TmSendHelper.h @@ -29,7 +29,6 @@ class TmSendHelper { ReturnValue_t sendPacket(const store_address_t& storeId); private: - MessageQueueId_t defaultDest = MessageQueueIF::NO_QUEUE; bool ignoreFault = false; MessageQueueIF* queue = nullptr; InternalErrorReporterIF* errReporter = nullptr; From c5ad9b5fa928858930d3a33efdf87e677c574a7c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 17:13:42 +0200 Subject: [PATCH 137/532] switch off debugging switches --- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 2 +- src/fsfw/tcdistribution/PusDistributor.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index 4dad31aa..7c2974a4 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -4,7 +4,7 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" -#define CCSDS_DISTRIBUTOR_DEBUGGING 1 +#define CCSDS_DISTRIBUTOR_DEBUGGING 0 CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId, CcsdsPacketCheckIF* packetChecker) diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 85672439..ade49201 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -6,7 +6,7 @@ #include "fsfw/tcdistribution/CCSDSDistributorIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" -#define PUS_DISTRIBUTOR_DEBUGGING 1 +#define PUS_DISTRIBUTOR_DEBUGGING 0 PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, CCSDSDistributorIF* distributor, StorageManagerIF* store_) From f591b9793cf777c974afaa4b73ee764b0769654a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 17:33:39 +0200 Subject: [PATCH 138/532] pass timeReader to Pus ZC writer --- src/fsfw/timemanager/CcsdsTimeStampReader.h | 2 -- src/fsfw/timemanager/CdsShortTimeStamper.cpp | 10 ++++++++++ src/fsfw/timemanager/CdsShortTimeStamper.h | 8 +++++++- src/fsfw/timemanager/TimeReaderIF.h | 9 +++------ src/fsfw/timemanager/TimeStampIF.h | 20 ++++++++++++++++++++ src/fsfw/timemanager/TimeStamperIF.h | 16 +++------------- src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmReader.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp | 3 ++- src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h | 2 +- 10 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 src/fsfw/timemanager/TimeStampIF.h diff --git a/src/fsfw/timemanager/CcsdsTimeStampReader.h b/src/fsfw/timemanager/CcsdsTimeStampReader.h index f323c87e..0bec2553 100644 --- a/src/fsfw/timemanager/CcsdsTimeStampReader.h +++ b/src/fsfw/timemanager/CcsdsTimeStampReader.h @@ -7,8 +7,6 @@ class CcsdsTimestampReader : public TimeReaderIF { public: - ReturnValue_t readTimeStamp(const uint8_t* buffer, uint8_t maxSize) override; - size_t getTimestampLen() override; timeval& getTime() override; private: diff --git a/src/fsfw/timemanager/CdsShortTimeStamper.cpp b/src/fsfw/timemanager/CdsShortTimeStamper.cpp index af0344e3..cdce62c1 100644 --- a/src/fsfw/timemanager/CdsShortTimeStamper.cpp +++ b/src/fsfw/timemanager/CdsShortTimeStamper.cpp @@ -36,4 +36,14 @@ ReturnValue_t CdsShortTimeStamper::deSerialize(const uint8_t **buffer, size_t *s return HasReturnvaluesIF::RETURN_FAILED; } +ReturnValue_t CdsShortTimeStamper::readTimeStamp(const uint8_t *buffer, size_t maxSize) { + if (maxSize < getTimestampSize()) { + return SerializeIF::STREAM_TOO_SHORT; + } + size_t foundLen = 0; + return CCSDSTime::convertFromCcsds(&readTime, buffer, &foundLen, maxSize); +} + +timeval &CdsShortTimeStamper::getTime() { return readTime; } + size_t CdsShortTimeStamper::getTimestampSize() const { return TIMESTAMP_LEN; } diff --git a/src/fsfw/timemanager/CdsShortTimeStamper.h b/src/fsfw/timemanager/CdsShortTimeStamper.h index d392c1a6..4b1f6c28 100644 --- a/src/fsfw/timemanager/CdsShortTimeStamper.h +++ b/src/fsfw/timemanager/CdsShortTimeStamper.h @@ -2,6 +2,7 @@ #define FSFW_TIMEMANAGER_TIMESTAMPER_H_ #include "CCSDSTime.h" +#include "TimeReaderIF.h" #include "TimeStamperIF.h" #include "fsfw/objectmanager/SystemObject.h" @@ -14,7 +15,7 @@ * overriding the #addTimeStamp function. * @ingroup utility */ -class CdsShortTimeStamper : public TimeStamperIF, public SystemObject { +class CdsShortTimeStamper : public TimeStamperIF, public TimeReaderIF, public SystemObject { public: static constexpr size_t TIMESTAMP_LEN = 7; /** @@ -37,7 +38,12 @@ class CdsShortTimeStamper : public TimeStamperIF, public SystemObject { [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; + ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override; + timeval &getTime() override; [[nodiscard]] size_t getTimestampSize() const override; + + private: + timeval readTime{}; }; #endif /* FSFW_TIMEMANAGER_TIMESTAMPER_H_ */ diff --git a/src/fsfw/timemanager/TimeReaderIF.h b/src/fsfw/timemanager/TimeReaderIF.h index cfad90ff..289a0058 100644 --- a/src/fsfw/timemanager/TimeReaderIF.h +++ b/src/fsfw/timemanager/TimeReaderIF.h @@ -3,16 +3,13 @@ #include +#include "TimeStampIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" -class TimeReaderIF { +class TimeReaderIF : public TimeStampIF { public: - virtual ~TimeReaderIF() = default; + ~TimeReaderIF() override = default; virtual ReturnValue_t readTimeStamp(const uint8_t* buffer, size_t maxSize) = 0; - // Would be nice to have this, but the clock backend needs to be redesigned - // virtual ReturnValue_t readTimestampLen(const uint8_t* buffer, uint8_t maxSize, size_t& - // timestampLen) = 0; - virtual size_t getTimestampLen() = 0; virtual timeval& getTime() = 0; }; diff --git a/src/fsfw/timemanager/TimeStampIF.h b/src/fsfw/timemanager/TimeStampIF.h new file mode 100644 index 00000000..805cf3b1 --- /dev/null +++ b/src/fsfw/timemanager/TimeStampIF.h @@ -0,0 +1,20 @@ +#ifndef FSFW_TIMEMANAGER_TIMESTAMPIF_H +#define FSFW_TIMEMANAGER_TIMESTAMPIF_H + +#include + +#include "fsfw/retval.h" + +class TimeStampIF { + public: + static const uint8_t INTERFACE_ID = CLASS_ID::TIME_STAMPER_IF; + static const ReturnValue_t BAD_TIMESTAMP = MAKE_RETURN_CODE(1); + + // I am going to assume there are no larger timestamps + static constexpr size_t MAXIMUM_TIMESTAMP_LEN = 16; + + virtual ~TimeStampIF() = default; + [[nodiscard]] virtual size_t getTimestampSize() const = 0; +}; + +#endif // FSFW_TIMEMANAGER_TIMESTAMPIF_H diff --git a/src/fsfw/timemanager/TimeStamperIF.h b/src/fsfw/timemanager/TimeStamperIF.h index 44cf0212..9f1ed940 100644 --- a/src/fsfw/timemanager/TimeStamperIF.h +++ b/src/fsfw/timemanager/TimeStamperIF.h @@ -1,6 +1,7 @@ #ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ #define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ +#include "TimeStampIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/serialize/SerializeIF.h" @@ -10,22 +11,11 @@ * Implementors need to ensure that calling the method is thread-safe, i.e. * addTimeStamp may be called in parallel from a different context. */ -class TimeStamperIF : public SerializeIF { +class TimeStamperIF : public SerializeIF, public TimeStampIF { public: - static const uint8_t INTERFACE_ID = CLASS_ID::TIME_STAMPER_IF; - static const ReturnValue_t BAD_TIMESTAMP = MAKE_RETURN_CODE(1); - - // I am going to assume there are no larger timestamps - static constexpr size_t MAXIMUM_TIMESTAMP_LEN = 16; - - //! This is a mission-specific constant and determines the total - //! size reserved for timestamps. - // static const uint8_t MISSION_TIMESTAMP_SIZE = fsfwconfig::FSFW_MISSION_TIMESTAMP_SIZE; - - [[nodiscard]] virtual size_t getTimestampSize() const { return getSerializedSize(); } - virtual ReturnValue_t addTimeStamp(uint8_t* buffer, uint8_t maxSize) = 0; ~TimeStamperIF() override = default; + size_t getTimestampSize() const override { return getSerializedSize(); } protected: }; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp index a3dbb7b0..2aea80fe 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp @@ -66,7 +66,7 @@ ReturnValue_t PusTmReader::parseData(bool crcCheck) { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - size_t timestampLen = timeReader->getTimestampLen(); + size_t timestampLen = timeReader->getTimestampSize(); if (currentOffset + timestampLen > spReader.getBufSize()) { return SerializeIF::STREAM_TOO_SHORT; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h index fdad1b6c..c95fefae 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h @@ -19,7 +19,7 @@ class PusTmReader : public PusTmIF, ReturnValue_t parseDataWithoutCrcCheck(); ReturnValue_t parseDataWithCrcCheck(); - const uint8_t* getFullData() const override; + [[nodiscard]] const uint8_t* getFullData() const override; explicit operator bool() const; [[nodiscard]] bool isNull() const; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp index 4c6c56d3..47bb749f 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp @@ -2,7 +2,8 @@ #include "fsfw/globalfunctions/CRC.h" -PusTmZeroCopyWriter::PusTmZeroCopyWriter(uint8_t* data, size_t size) : PusTmReader(data, size) {} +PusTmZeroCopyWriter::PusTmZeroCopyWriter(TimeReaderIF* timeReader, uint8_t* data, size_t size) + : PusTmReader(timeReader, data, size) {} void PusTmZeroCopyWriter::setSequenceCount(uint16_t seqCount) { auto* spHeader = diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h index c3f5db35..d3a0e5f2 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h @@ -4,7 +4,7 @@ #include "PusTmReader.h" class PusTmZeroCopyWriter : public PusTmReader { public: - PusTmZeroCopyWriter(uint8_t* data, size_t size); + PusTmZeroCopyWriter(TimeReaderIF* timeReader, uint8_t* data, size_t size); void setSequenceCount(uint16_t seqCount); void updateErrorControl(); From 234ccdf7640c74d0053a994b6786010301ab36e6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 17:48:59 +0200 Subject: [PATCH 139/532] send time stampers properly now --- src/fsfw/pus/Service1TelecommandVerification.cpp | 11 ++++++++++- src/fsfw/pus/Service1TelecommandVerification.h | 4 +++- src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp | 5 ++--- src/fsfw/tmtcservices/CommandingServiceBase.cpp | 7 ++++--- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 6c1c2310..4e314254 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -10,7 +10,8 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t objectId, uint16_t apid, uint8_t serviceId, object_id_t targetDestination, - uint16_t messageQueueDepth) + uint16_t messageQueueDepth, + TimeStamperIF* timeStamper) : SystemObject(objectId), apid(apid), serviceId(serviceId), @@ -119,6 +120,14 @@ ReturnValue_t Service1TelecommandVerification::initialize() { } storeHelper.setTmStore(*tmStore); } + if(timeStamper == nullptr) { + timeStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); + if(timeStamper == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + } else { + } + storeHelper.setTimeStamper(*timeStamper); sendHelper.setMsgQueue(*tmQueue); if (errReporter == nullptr) { diff --git a/src/fsfw/pus/Service1TelecommandVerification.h b/src/fsfw/pus/Service1TelecommandVerification.h index 2e121bbf..01bd9714 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.h +++ b/src/fsfw/pus/Service1TelecommandVerification.h @@ -47,7 +47,8 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_1; Service1TelecommandVerification(object_id_t objectId, uint16_t apid, uint8_t serviceId, - object_id_t targetDestination, uint16_t messageQueueDepth); + object_id_t targetDestination, uint16_t messageQueueDepth, + TimeStamperIF* timeStamper = nullptr); ~Service1TelecommandVerification() override; /** @@ -87,6 +88,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, TmStoreHelper storeHelper; TmStoreAndSendWrapper tmHelper; InternalErrorReporterIF* errReporter = nullptr; + TimeStamperIF* timeStamper = nullptr; StorageManagerIF* tmStore = nullptr; MessageQueueIF* tmQueue = nullptr; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp index 2aea80fe..ca40562b 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp @@ -60,9 +60,8 @@ ReturnValue_t PusTmReader::parseData(bool crcCheck) { size_t currentOffset = SpacePacketReader::getHeaderLen(); pointers.secHeaderStart = pointers.spHeaderStart + currentOffset; currentOffset += PusTmIF::MIN_SEC_HEADER_LEN; - size_t minTimestampLen = spReader.getBufSize() - currentOffset; - result = timeReader->readTimeStamp(pointers.secHeaderStart + PusTmIF::MIN_SEC_HEADER_LEN, - minTimestampLen); + size_t minTimestampLen = spReader.getFullPacketLen() - currentOffset; + result = timeReader->readTimeStamp(pointers.spHeaderStart + currentOffset, minTimestampLen); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 08ba599a..b7edc0cb 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -104,11 +104,12 @@ ReturnValue_t CommandingServiceBase::initialize() { // This avoids duplicate calculation of the CRC16 tmStoreHelper.disableCrcCalculation(); if (tmTimeStamper == nullptr) { - auto timerStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); - if (timerStamper != nullptr) { - tmStoreHelper.setTimeStamper(*timerStamper); + tmTimeStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); + if (tmTimeStamper == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; } } + tmStoreHelper.setTimeStamper(*tmTimeStamper); if (errReporter == nullptr) { errReporter = From 0a38d2e22d75fdfc6b2ea40449eb706055246b03 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 17:56:16 +0200 Subject: [PATCH 140/532] small bugfix --- src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp index 47bb749f..bcbdba03 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp @@ -10,8 +10,9 @@ void PusTmZeroCopyWriter::setSequenceCount(uint16_t seqCount) { reinterpret_cast(const_cast((pointers.spHeaderStart))); ccsds::setSequenceCount(*spHeader, seqCount); } + void PusTmZeroCopyWriter::updateErrorControl() { - auto* crcStart = reinterpret_cast(const_cast((pointers.spHeaderStart))); + auto* crcStart = const_cast((pointers.crcStart)); uint16_t crc16 = CRC::crc16ccitt(PusTmReader::getFullData(), getFullPacketLen() - sizeof(ecss::PusChecksumT)); crcStart[0] = (crc16 >> 8) & 0xff; From 356d7787437e3926fb9dd9cb067d91351c9b7ae5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 18:03:17 +0200 Subject: [PATCH 141/532] afmt --- src/fsfw/pus/Service1TelecommandVerification.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 4e314254..46d7237c 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -120,9 +120,9 @@ ReturnValue_t Service1TelecommandVerification::initialize() { } storeHelper.setTmStore(*tmStore); } - if(timeStamper == nullptr) { + if (timeStamper == nullptr) { timeStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); - if(timeStamper == nullptr) { + if (timeStamper == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } } else { From 4e571e508280555cc96932991e125fd8ebc38df7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 19:40:54 +0200 Subject: [PATCH 142/532] some more minor fixes --- .../tmtcservices/CommandingServiceBase.cpp | 3 ++- src/fsfw/tmtcservices/PusServiceBase.cpp | 26 +++++++++++++++---- src/fsfw/tmtcservices/PusServiceBase.h | 6 ++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index b7edc0cb..88004b0a 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -263,7 +263,8 @@ void CommandingServiceBase::handleRequestQueue() { object_id_t objectId; for (result = requestQueue->receiveMessage(&message); result == RETURN_OK; result = requestQueue->receiveMessage(&message)) { - result = setUpTcReader(message.getStorageId()); + address = message.getStorageId(); + result = setUpTcReader(address); if (result != HasReturnvaluesIF::RETURN_OK) { // TODO: Warning? rejectPacket(tcverif::START_FAILURE, address, result); diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index d3d23ed7..f8cc7cb8 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -140,12 +140,15 @@ void PusServiceBase::setErrorReporter(InternalErrorReporterIF& errReporter_) { psbParams.errReporter = &errReporter_; } -void PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper) { - initializeTmSendHelper(tmSendHelper); - initializeTmStoreHelper(tmStoreHelper); +ReturnValue_t PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper) { + ReturnValue_t result = initializeTmSendHelper(tmSendHelper); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return initializeTmStoreHelper(tmStoreHelper); } -void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { +ReturnValue_t PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { if (psbParams.reqQueue != nullptr) { tmSendHelper.setMsgQueue(*psbParams.reqQueue); tmSendHelper.setDefaultDestination(psbParams.reqQueue->getDefaultDestination()); @@ -160,16 +163,29 @@ void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { } else { tmSendHelper.setInternalErrorReporter(*psbParams.errReporter); } + return RETURN_OK; } -void PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { +ReturnValue_t PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { tmStoreHelper.setApid(psbParams.apid); + if(tmStoreHelper.getTmStore() == nullptr) { + auto* tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if(tmStore == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + tmStoreHelper.setTmStore(*tmStore); + } + if (psbParams.timeStamper == nullptr) { auto timerStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); if (timerStamper != nullptr) { tmStoreHelper.setTimeStamper(*timerStamper); } } + // Generally, all TM packets will pass through a layer where the sequence count is set. + // This avoids duplicate calculation of the CRC16 + tmStoreHelper.disableCrcCalculation(); + return RETURN_OK; } void PusServiceBase::setVerificationReporter(VerificationReporterIF& reporter) { diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 43a2c0d4..86d8ea1a 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -132,19 +132,19 @@ class PusServiceBase : public ExecutableObjectIF, * Helper methods if the implementing class wants to send telemetry * @param tmSendHelper */ - void initializeTmSendHelper(TmSendHelper& tmSendHelper); + ReturnValue_t initializeTmSendHelper(TmSendHelper& tmSendHelper); /** * Helper methods if the implementing class wants to store telemetry. It will set the correct APID * and it will also attempt to set a valid time stamper. If the manually specified time stamper is * null, it will attempt to find a suitable one using @objects::TIME_STAMPER * @param tmSendHelper */ - void initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const; + ReturnValue_t initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const; /** * Helper methods if the implementing class wants to both send and store telemetry * @param tmSendHelper */ - void initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper); + ReturnValue_t initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper); /** * @brief The handleRequest method shall handle any kind of Telecommand From d641d6353121f26695fe52647d7e0887ac6ede99 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 19:56:11 +0200 Subject: [PATCH 143/532] set queue of tm send helper --- src/fsfw/tmtcservices/CommandingServiceBase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 88004b0a..5278fc6c 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -120,6 +120,7 @@ ReturnValue_t CommandingServiceBase::initialize() { } else { tmSendHelper.setInternalErrorReporter(*errReporter); } + tmSendHelper.setMsgQueue(*requestQueue); if (verificationReporter == nullptr) { verificationReporter = From f03b7cd6600fcabe6e1969630e942e4e85e80b09 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 20:10:15 +0200 Subject: [PATCH 144/532] another bugfix in CSB --- src/fsfw/pus/Service1TelecommandVerification.cpp | 11 +++++++++++ src/fsfw/tmtcservices/CommandingServiceBase.cpp | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 46d7237c..9d8ca111 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -49,6 +49,17 @@ ReturnValue_t Service1TelecommandVerification::performOperation(uint8_t operatio ReturnValue_t Service1TelecommandVerification::sendVerificationReport( PusVerificationMessage* message) { ReturnValue_t result; + uint8_t reportId = message->getReportId(); + if(reportId == 0 or reportId > 8) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "Service1TelecommandVerification::sendVerificationReport: Invalid report ID " << + static_cast(reportId) << " detected" << std::endl; +#else + sif::printError("Service1TelecommandVerification::sendVerificationReport: Invalid report ID " + "%d detected\n", reportId); +#endif + return HasReturnvaluesIF::RETURN_FAILED; + } if (message->getReportId() % 2 == 0) { result = generateFailureReport(message); } else { diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 5278fc6c..c12a47b2 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -457,8 +457,8 @@ void CommandingServiceBase::prepareVerificationFailureWithFullInfo(uint8_t repor } void CommandingServiceBase::prepareVerificationSuccessWithFullInfo( uint8_t reportId, CommandingServiceBase::CommandInfo::TcInfo& tcInfo) { - failParams.reportId = reportId; - failParams.tcPacketId = tcInfo.tcPacketId; - failParams.tcPsc = tcInfo.tcSequenceControl; - failParams.ackFlags = tcInfo.ackFlags; + successParams.reportId = reportId; + successParams.tcPacketId = tcInfo.tcPacketId; + successParams.tcPsc = tcInfo.tcSequenceControl; + successParams.ackFlags = tcInfo.ackFlags; } From 7e8afcc12f413d8199f086521e1e7a6d0db21259 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 20:37:21 +0200 Subject: [PATCH 145/532] remove nullptr check --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 15440a21..83713266 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -34,9 +34,6 @@ inline ReturnValue_t Service11TelecommandScheduling::handleRequest( // Get de-serialized Timestamp const uint8_t *data = currentPacket.getUserData(); size_t size = currentPacket.getUserDataLen(); - if (data == nullptr) { - return handleInvalidData("handleRequest"); - } switch (subservice) { case Subservice::ENABLE_SCHEDULING: { schedulingEnabled = true; From 93acac02f561fe61dfe05904261d15ee715f1249 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 21:06:23 +0200 Subject: [PATCH 146/532] tests running again --- src/fsfw/pus/Service1TelecommandVerification.cpp | 12 +++++++----- src/fsfw/serialize/SerializeIF.h | 4 ++-- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 8 ++++++++ src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 3 +++ src/fsfw/tmtcservices/PusServiceBase.cpp | 11 ++++++----- unittests/mocks/CdsShortTimestamperMock.h | 1 - unittests/tmtcpacket/testCcsds.cpp | 2 +- unittests/tmtcpacket/testPusTmCreator.cpp | 9 ++++++--- unittests/tmtcpacket/testPusTmReader.cpp | 2 +- unittests/tmtcservices/testSendHelper.cpp | 2 +- 10 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 9d8ca111..0e6e302c 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -50,13 +50,15 @@ ReturnValue_t Service1TelecommandVerification::sendVerificationReport( PusVerificationMessage* message) { ReturnValue_t result; uint8_t reportId = message->getReportId(); - if(reportId == 0 or reportId > 8) { + if (reportId == 0 or reportId > 8) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "Service1TelecommandVerification::sendVerificationReport: Invalid report ID " << - static_cast(reportId) << " detected" << std::endl; + sif::error << "Service1TelecommandVerification::sendVerificationReport: Invalid report ID " + << static_cast(reportId) << " detected" << std::endl; #else - sif::printError("Service1TelecommandVerification::sendVerificationReport: Invalid report ID " - "%d detected\n", reportId); + sif::printError( + "Service1TelecommandVerification::sendVerificationReport: Invalid report ID " + "%d detected\n", + reportId); #endif return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 136bd419..e33adb96 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -64,13 +64,13 @@ class SerializeIF { /** * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t serializeBe(uint8_t **buffer, size_t *size, size_t maxSize) { + virtual ReturnValue_t serializeBe(uint8_t **buffer, size_t *size, size_t maxSize) const { return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) { + virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const { return serialize(buffer, size, maxSize, SerializeIF::Endianness::MACHINE); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 348308d1..6253bc24 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -146,3 +146,11 @@ void PusTmCreator::setSubservice(uint8_t subservice) { pusParams.secHeader.subservice = subservice; } bool PusTmCreator::crcCalculationEnabled() const { return calculateCrcOnSerialization; } + +ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize) const { + return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); +} + +ReturnValue_t PusTmCreator::serialize(uint8_t* buffer, size_t maxSize) const { + return SerializeIF::serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); +} \ No newline at end of file diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 0e7988f1..75760968 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -72,6 +72,9 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF uint8_t getScTimeRefStatus() override; uint16_t getMessageTypeCounter() override; uint16_t getDestId() override; + // Override these to use default big endianness + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize) const override; + ReturnValue_t serialize(uint8_t* buffer, size_t maxSize) const override; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index f8cc7cb8..b555449b 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -140,9 +140,10 @@ void PusServiceBase::setErrorReporter(InternalErrorReporterIF& errReporter_) { psbParams.errReporter = &errReporter_; } -ReturnValue_t PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper) { +ReturnValue_t PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, + TmStoreHelper& tmStoreHelper) { ReturnValue_t result = initializeTmSendHelper(tmSendHelper); - if(result != HasReturnvaluesIF::RETURN_OK) { + if (result != HasReturnvaluesIF::RETURN_OK) { return result; } return initializeTmStoreHelper(tmStoreHelper); @@ -166,11 +167,11 @@ ReturnValue_t PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) return RETURN_OK; } -ReturnValue_t PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { +ReturnValue_t PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { tmStoreHelper.setApid(psbParams.apid); - if(tmStoreHelper.getTmStore() == nullptr) { + if (tmStoreHelper.getTmStore() == nullptr) { auto* tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if(tmStore == nullptr) { + if (tmStore == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } tmStoreHelper.setTmStore(*tmStore); diff --git a/unittests/mocks/CdsShortTimestamperMock.h b/unittests/mocks/CdsShortTimestamperMock.h index 784ef7f4..d19385cd 100644 --- a/unittests/mocks/CdsShortTimestamperMock.h +++ b/unittests/mocks/CdsShortTimestamperMock.h @@ -78,7 +78,6 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override { return deSerialize(&buffer, &maxSize, SerializeIF::Endianness::NETWORK); } - size_t getTimestampLen() override { return getSerializedSize(); } timeval &getTime() override { return dummyTime; } private: diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp index e40db1c6..9be2b8af 100644 --- a/unittests/tmtcpacket/testCcsds.cpp +++ b/unittests/tmtcpacket/testCcsds.cpp @@ -24,7 +24,7 @@ TEST_CASE("CCSDS Low Level", "[ccsds-ll]") { uint16_t packetIdRaw = 0x3ff; ccsds::setPacketId(header, packetIdRaw); ccsds::setApid(header, 0x1ff); - REQUIRE(ccsds::getPacketId(header) == 0x1ff); + REQUIRE(ccsds::getPacketId(header) == 0x3ff); } SECTION("Lowlevel Packet Length Test") { diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index ad8a1d4d..97f3d893 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -44,7 +44,8 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { } SECTION("Serialization") { - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.SerializeIF::serializeBe(&dataPtr, &serLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[0] == 0x08); REQUIRE(buf[1] == 0xef); // Unsegmented is the default @@ -105,7 +106,8 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { std::array data{1, 2, 3}; creator.setRawUserData(data.data(), data.size()); REQUIRE(creator.getFullPacketLen() == 25); - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.SerializeIF::serialize(&dataPtr, &serLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[20] == 1); REQUIRE(buf[21] == 2); REQUIRE(buf[22] == 3); @@ -139,7 +141,8 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { for (size_t maxSize = 0; maxSize < reqSize; maxSize++) { dataPtr = buf.data(); serLen = 0; - REQUIRE(creator.serialize(&dataPtr, &serLen, maxSize) == SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(creator.SerializeIF::serialize(&dataPtr, &serLen, maxSize) == + SerializeIF::BUFFER_TOO_SHORT); } } } \ No newline at end of file diff --git a/unittests/tmtcpacket/testPusTmReader.cpp b/unittests/tmtcpacket/testPusTmReader.cpp index 7a61b731..3914db48 100644 --- a/unittests/tmtcpacket/testPusTmReader.cpp +++ b/unittests/tmtcpacket/testPusTmReader.cpp @@ -22,7 +22,7 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { bool deleteReader = false; dataPtr = buf.data(); serLen = 0; - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(not(*readerPtr)); REQUIRE(readerPtr->isNull()); diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index b857776b..78ca9f0e 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -57,7 +57,7 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") { SECTION("Two Arg CTOR") { TmSendHelper helper(msgQueue, errReporter); REQUIRE(helper.getInternalErrorReporter() == &errReporter); - REQUIRE(helper.getDefaultDestination() == MessageQueueIF::NO_QUEUE); + REQUIRE(helper.getDefaultDestination() == 2); REQUIRE(helper.getMsgQueue() == &msgQueue); } SECTION("Send") { From 85dbef20b066d707b95804e0642dee34d7cef9d1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 21:07:34 +0200 Subject: [PATCH 147/532] update serialize IF --- src/fsfw/serialize/SerializeIF.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index e33adb96..47212ab1 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -59,18 +59,20 @@ class SerializeIF { * - @c RETURN_FAILED Generic error * - @c RETURN_OK Successful serialization */ - virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const = 0; + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const = 0; /** * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t serializeBe(uint8_t **buffer, size_t *size, size_t maxSize) const { + [[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t **buffer, size_t *size, + size_t maxSize) const { return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const { + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, + size_t maxSize) const { return serialize(buffer, size, maxSize, SerializeIF::Endianness::MACHINE); } @@ -123,21 +125,21 @@ class SerializeIF { * @param streamEndianness * @return */ - virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize, - Endianness streamEndianness) const { + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize, + Endianness streamEndianness) const { size_t tmpSize = 0; return serialize(&buffer, &tmpSize, maxSize, streamEndianness); } /** * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t serializeBe(uint8_t *buffer, size_t maxSize) const { + [[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t *buffer, size_t maxSize) const { return serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize) const { + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize) const { return serialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); } From 5bb7023ff30823575187da06eba50a8acec78254 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 21:11:12 +0200 Subject: [PATCH 148/532] improvements for creator API --- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 12 ++++++++---- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 9 ++++++--- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 5 +++-- unittests/tmtcpacket/testPusTcCreator.cpp | 3 ++- unittests/tmtcpacket/testPusTmCreator.cpp | 3 ++- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index d6748619..f509717b 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -90,10 +90,6 @@ PusTcParams &PusTcCreator::getPusParams() { return pusParams; } SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } -ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize) { - return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); -} - ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { // TODO: Check length field? pusParams.dataWrapper.setRawData({data, len}); @@ -107,3 +103,11 @@ ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF &serializable) { updateSpLengthField(); return HasReturnvaluesIF::RETURN_OK; } + +ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize) const { + return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); +} + +ReturnValue_t PusTcCreator::serialize(uint8_t *buffer, size_t maxSize) const { + return SerializeIF::serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); +} diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 0f903e7b..b41ad940 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -34,10 +34,10 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF PusTcParams &getPusParams(); SpacePacketParams &getSpParams(); - ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize); + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const override; + ReturnValue_t serialize(uint8_t *buffer, size_t maxSize) const override; [[nodiscard]] size_t getSerializedSize() const override; - ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, - Endianness streamEndianness) override; + [[nodiscard]] uint16_t getPacketIdRaw() const override; [[nodiscard]] uint16_t getPacketSeqCtrlRaw() const override; [[nodiscard]] uint16_t getPacketDataLen() const override; @@ -52,6 +52,9 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF private: ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; + // Forbidden to use + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override; SpacePacketCreator spCreator; PusTcParams pusParams; }; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 75760968..c8de3428 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -78,13 +78,14 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) override; [[nodiscard]] TimeStamperIF* getTimestamper() const; ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override; ReturnValue_t setSerializableUserData(SerializeIF& serializable) override; private: + // Forbidden to use + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override; void setup(); PusTmParams pusParams{}; bool calculateCrcOnSerialization = true; diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index c5b0743b..fdda717f 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -95,9 +95,10 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { } SECTION("Deserialization Fails") { + SerializeIF& deser = creator; size_t deserLen = buf.size(); const uint8_t* roPtr = buf.data(); - REQUIRE(creator.deSerialize(&roPtr, &deserLen, SerializeIF::Endianness::NETWORK) == + REQUIRE(deser.deSerialize(&roPtr, &deserLen, SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_FAILED); } diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index 97f3d893..99c16550 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -97,8 +97,9 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { } SECTION("Deserialization fails") { + SerializeIF& deser = creator; const uint8_t* roDataPtr = nullptr; - REQUIRE(creator.deSerialize(&roDataPtr, &serLen, SerializeIF::Endianness::NETWORK) == + REQUIRE(deser.deSerialize(&roDataPtr, &serLen, SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_FAILED); } From b485afea5786b44bd9a7b6206c306eb3ac502457 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 21:29:05 +0200 Subject: [PATCH 149/532] Simple SerializeIF adaptions - Returns serialized or deserialized size --- src/fsfw/serialize/SerializeIF.h | 31 +++++++++------ src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 4 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 7 +++- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 2 +- unittests/serialize/testSerializeIF.cpp | 43 ++++++++++++++------- unittests/tmtcpacket/testCcsds.cpp | 41 ++++++++++++++------ unittests/tmtcpacket/testPusTcCreator.cpp | 12 ++++++ unittests/tmtcservices/testPsb.cpp | 6 ++- 9 files changed, 101 insertions(+), 47 deletions(-) diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 47212ab1..5e7a2fb9 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -125,22 +125,26 @@ class SerializeIF { * @param streamEndianness * @return */ - [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize, + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t &serLen, size_t maxSize, Endianness streamEndianness) const { size_t tmpSize = 0; - return serialize(&buffer, &tmpSize, maxSize, streamEndianness); + ReturnValue_t result = serialize(&buffer, &tmpSize, maxSize, streamEndianness); + serLen = tmpSize; + return result; } /** * Forwards to regular @serialize call with big (network) endianness */ - [[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t *buffer, size_t maxSize) const { - return serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); + [[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t *buffer, size_t &serLen, + size_t maxSize) const { + return serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize) const { - return serialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t &serLen, + size_t maxSize) const { + return serialize(buffer, serLen, maxSize, SerializeIF::Endianness::MACHINE); } /** @@ -151,21 +155,24 @@ class SerializeIF { * @param streamEndianness * @return */ - virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t maxSize, + virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t &deserSize, size_t maxSize, Endianness streamEndianness) { - return deSerialize(&buffer, &maxSize, streamEndianness); + size_t deserLen = maxSize; + ReturnValue_t result = deSerialize(&buffer, &deserLen, streamEndianness); + deserSize = maxSize - deserLen; + return result; } /** * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t deSerializeBe(const uint8_t *buffer, size_t maxSize) { - return deSerialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); + virtual ReturnValue_t deSerializeBe(const uint8_t *buffer, size_t &deserSize, size_t maxSize) { + return deSerialize(buffer, deserSize, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t maxSize) { - return deSerialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); + virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t &deserSize, size_t maxSize) { + return deSerialize(buffer, deserSize, maxSize, SerializeIF::Endianness::MACHINE); } }; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index f509717b..be472051 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -108,6 +108,6 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } -ReturnValue_t PusTcCreator::serialize(uint8_t *buffer, size_t maxSize) const { - return SerializeIF::serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); +ReturnValue_t PusTcCreator::serialize(uint8_t *buffer, size_t &serLen, size_t maxSize) const { + return SerializeIF::serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK); } diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index b41ad940..63a5d45f 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -35,7 +35,7 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF SpacePacketParams &getSpParams(); ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const override; - ReturnValue_t serialize(uint8_t *buffer, size_t maxSize) const override; + ReturnValue_t serialize(uint8_t *buffer, size_t &serLen, size_t maxSize) const override; [[nodiscard]] size_t getSerializedSize() const override; [[nodiscard]] uint16_t getPacketIdRaw() const override; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 6253bc24..d80182ed 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -94,6 +94,9 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max uint16_t crc16 = CRC::crc16ccitt(start, getFullPacketLen() - sizeof(ecss::PusChecksumT)); return SerializeAdapter::serialize(&crc16, buffer, size, maxSize, streamEndianness); } + // Even if no CRC is calculated, account for the space taken by it + *size += 2; + *buffer += 2; return HasReturnvaluesIF::RETURN_OK; } @@ -151,6 +154,6 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } -ReturnValue_t PusTmCreator::serialize(uint8_t* buffer, size_t maxSize) const { - return SerializeIF::serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); +ReturnValue_t PusTmCreator::serialize(uint8_t* buffer, size_t& serLen, size_t maxSize) const { + return SerializeIF::serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK); } \ No newline at end of file diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index c8de3428..a7905858 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -74,7 +74,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF uint16_t getDestId() override; // Override these to use default big endianness ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize) const override; - ReturnValue_t serialize(uint8_t* buffer, size_t maxSize) const override; + ReturnValue_t serialize(uint8_t* buffer, size_t& serLen, size_t maxSize) const override; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index ecd61357..5200f8b7 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -24,12 +24,14 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { } SECTION("Little Endian Simple") { - REQUIRE( - simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::LITTLE) == - HasReturnvaluesIF::RETURN_OK); + size_t serLen = 0xff; + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), + SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); + CHECK(serLen == 3); } SECTION("Big Endian Normal") { @@ -54,23 +56,25 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { } SECTION("Big Endian Simple") { + size_t serLen = 0xff; SECTION("Explicit") { - REQUIRE( - simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), + SerializeIF::Endianness::BIG) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::serializeBe(buf.data(), buf.size()) == + REQUIRE(simpleSer.SerializeIF::serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); } CHECK(buf[0] == 1); CHECK(buf[1] == 2); CHECK(buf[2] == 3); + CHECK(serLen == 3); } SECTION("Machine Endian Implicit") { @@ -90,7 +94,8 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { } SECTION("Machine Endian Simple Implicit") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size()) == + size_t serLen = 0xff; + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 1); #if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN @@ -100,6 +105,7 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { CHECK(buf[1] == 2); CHECK(buf[2] == 3); #endif + CHECK(serLen == 3); } } @@ -119,10 +125,13 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { } SECTION("Little Endian Simple") { - REQUIRE(simpleSer.SerializeIF::deSerialize(ptr, len, SerializeIF::Endianness::LITTLE) == - HasReturnvaluesIF::RETURN_OK); + size_t deserLen = 0xff; + REQUIRE( + simpleSer.SerializeIF::deSerialize(ptr, deserLen, len, SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); + CHECK(deserLen == 3); } SECTION("Big Endian Normal") { @@ -144,22 +153,24 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { } SECTION("Big Endian Simple") { + size_t deserLen = 0xff; SECTION("Explicit") { - REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size(), SerializeIF::Endianness::BIG) == HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::deSerializeBe(buf.data(), buf.size()) == + REQUIRE(simpleSer.SerializeIF::deSerializeBe(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); } CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 1); + CHECK(deserLen == 3); } SECTION("Machine Endian Implicit") { @@ -176,7 +187,8 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { } SECTION("Machine Endian Simple Implicit") { - REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size()) == + size_t deserLen = 0xff; + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(simpleSer.getU8() == 5); #if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN @@ -184,5 +196,6 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { #else CHECK(simpleSer.getU16() == 1); #endif + CHECK(deserLen == 3); } } \ No newline at end of file diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp index 9be2b8af..095020ae 100644 --- a/unittests/tmtcpacket/testCcsds.cpp +++ b/unittests/tmtcpacket/testCcsds.cpp @@ -42,21 +42,28 @@ TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { packetId.apid = 0x1ff; packetId.secHeaderFlag = false; packetId.packetType = ccsds::PacketType::TM; + size_t serLen = 0; REQUIRE(packetId.raw() == 0x1ff); - REQUIRE(packetId.SerializeIF::serializeBe(buf.data(), buf.size()) == + REQUIRE(packetId.SerializeIF::serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 0x1); CHECK(buf[1] == 0xff); } SECTION("Invalid Ser") { - REQUIRE(packetId.SerializeIF::serializeBe(buf.data(), 0) == SerializeIF::BUFFER_TOO_SHORT); - REQUIRE(packetId.SerializeIF::serializeBe(buf.data(), 1) == SerializeIF::BUFFER_TOO_SHORT); + size_t serLen = 0; + REQUIRE(packetId.SerializeIF::serializeBe(buf.data(), serLen, 0) == + SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(packetId.SerializeIF::serializeBe(buf.data(), serLen, 1) == + SerializeIF::BUFFER_TOO_SHORT); } SECTION("Invalid Deser") { - REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), 1) == SerializeIF::STREAM_TOO_SHORT); - REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), 0) == SerializeIF::STREAM_TOO_SHORT); + size_t deserLen = 0; + REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), deserLen, 1) == + SerializeIF::STREAM_TOO_SHORT); + REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), deserLen, 0) == + SerializeIF::STREAM_TOO_SHORT); } SECTION("From Raw") { @@ -69,9 +76,11 @@ TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { SECTION("Deserialize") { buf[0] = 0x1a; buf[1] = 0xff; - REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), buf.size()) == + size_t deserLen = 0xff; + REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(packetId.apid == 0x2ff); + CHECK(deserLen == 2); CHECK(packetId.packetType == ccsds::PacketType::TC); CHECK(packetId.secHeaderFlag == true); } @@ -81,12 +90,15 @@ TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") { PacketSeqCtrl psc; std::array buf{}; SECTION("Basic") { + size_t serLen = 0xff; psc.seqFlags = ccsds::SequenceFlags::FIRST_SEGMENT; psc.seqCount = static_cast(std::round(std::pow(2, 14) - 1)); REQUIRE(psc.raw() == 0x7fff); - REQUIRE(psc.SerializeIF::serializeBe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(psc.SerializeIF::serializeBe(buf.data(), serLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 0x7f); CHECK(buf[1] == 0xff); + CHECK(serLen == 2); } SECTION("From Raw") { @@ -100,18 +112,23 @@ TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") { SECTION("Deserialize") { buf[0] = 0xbf; buf[1] = 0xfe; - REQUIRE(psc.SerializeIF::deSerialize(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + size_t deserLen = 0xff; + REQUIRE(psc.SerializeIF::deSerialize(buf.data(), deserLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); CHECK(psc.seqFlags == ccsds::SequenceFlags::LAST_SEGMENT); + CHECK(deserLen == 2); CHECK(psc.seqCount == static_cast(std::round(std::pow(2, 14) - 2))); } SECTION("Invalid Ser") { - REQUIRE(psc.SerializeIF::serializeBe(buf.data(), 0) == SerializeIF::BUFFER_TOO_SHORT); - REQUIRE(psc.SerializeIF::serializeBe(buf.data(), 1) == SerializeIF::BUFFER_TOO_SHORT); + size_t deserLen = 0; + REQUIRE(psc.SerializeIF::serializeBe(buf.data(), deserLen, 0) == SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(psc.SerializeIF::serializeBe(buf.data(), deserLen, 1) == SerializeIF::BUFFER_TOO_SHORT); } SECTION("Invalid Deser") { - REQUIRE(psc.SerializeIF::deSerialize(buf.data(), 1) == SerializeIF::STREAM_TOO_SHORT); - REQUIRE(psc.SerializeIF::deSerialize(buf.data(), 0) == SerializeIF::STREAM_TOO_SHORT); + size_t deserLen = 0; + REQUIRE(psc.SerializeIF::deSerialize(buf.data(), deserLen, 1) == SerializeIF::STREAM_TOO_SHORT); + REQUIRE(psc.SerializeIF::deSerialize(buf.data(), deserLen, 0) == SerializeIF::STREAM_TOO_SHORT); } } diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index fdda717f..ff9b6399 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -94,6 +94,18 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { REQUIRE(buf[13] == 3); } + SECTION("Test with Application Data Serializable Simple Ser API") { + auto& params = creator.getPusParams(); + auto simpleSer = SimpleSerializable(); + creator.setSerializableUserData(simpleSer); + REQUIRE(creator.getSerializedSize() == 16); + REQUIRE(creator.serialize(dataPtr, serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(serLen == 16); + REQUIRE(buf[11] == 1); + REQUIRE(buf[12] == 2); + REQUIRE(buf[13] == 3); + } + SECTION("Deserialization Fails") { SerializeIF& deser = creator; size_t deserLen = buf.size(); diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index e434607f..9404c401 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -57,7 +57,8 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { REQUIRE(psb.performServiceCallCnt == 0); uint8_t* dataPtr; REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == retval::OK); - REQUIRE(creator.serializeBe(dataPtr, creator.getSerializedSize()) == retval::OK); + size_t serLen = 0; + REQUIRE(creator.serializeBe(dataPtr, serLen, creator.getSerializedSize()) == retval::OK); tmtcMsg.setStorageId(storeId); msgQueue.addReceivedMessage(tmtcMsg); REQUIRE(psb.performOperation(0) == retval::OK); @@ -77,7 +78,8 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { SECTION("Send Request with Failed Handling") { uint8_t* dataPtr; REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == retval::OK); - REQUIRE(creator.serializeBe(dataPtr, creator.getSerializedSize()) == retval::OK); + size_t serLen = 0; + REQUIRE(creator.serializeBe(dataPtr, serLen, creator.getSerializedSize()) == retval::OK); tmtcMsg.setStorageId(storeId); msgQueue.addReceivedMessage(tmtcMsg); psb.makeNextHandleReqCallFail(3); From dc31358d525a9a8aed2eed855a68176c288c36dd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 21:31:09 +0200 Subject: [PATCH 150/532] adaption for SerializeIF - Returns serialized and deserialized size now --- src/fsfw/serialize/SerializeIF.h | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 47212ab1..5e7a2fb9 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -125,22 +125,26 @@ class SerializeIF { * @param streamEndianness * @return */ - [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize, + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t &serLen, size_t maxSize, Endianness streamEndianness) const { size_t tmpSize = 0; - return serialize(&buffer, &tmpSize, maxSize, streamEndianness); + ReturnValue_t result = serialize(&buffer, &tmpSize, maxSize, streamEndianness); + serLen = tmpSize; + return result; } /** * Forwards to regular @serialize call with big (network) endianness */ - [[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t *buffer, size_t maxSize) const { - return serialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); + [[nodiscard]] virtual ReturnValue_t serializeBe(uint8_t *buffer, size_t &serLen, + size_t maxSize) const { + return serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t maxSize) const { - return serialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); + [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t &serLen, + size_t maxSize) const { + return serialize(buffer, serLen, maxSize, SerializeIF::Endianness::MACHINE); } /** @@ -151,21 +155,24 @@ class SerializeIF { * @param streamEndianness * @return */ - virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t maxSize, + virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t &deserSize, size_t maxSize, Endianness streamEndianness) { - return deSerialize(&buffer, &maxSize, streamEndianness); + size_t deserLen = maxSize; + ReturnValue_t result = deSerialize(&buffer, &deserLen, streamEndianness); + deserSize = maxSize - deserLen; + return result; } /** * Forwards to regular @serialize call with big (network) endianness */ - virtual ReturnValue_t deSerializeBe(const uint8_t *buffer, size_t maxSize) { - return deSerialize(buffer, maxSize, SerializeIF::Endianness::NETWORK); + virtual ReturnValue_t deSerializeBe(const uint8_t *buffer, size_t &deserSize, size_t maxSize) { + return deSerialize(buffer, deserSize, maxSize, SerializeIF::Endianness::NETWORK); } /** * If endianness is not explicitly specified, use machine endianness */ - virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t maxSize) { - return deSerialize(buffer, maxSize, SerializeIF::Endianness::MACHINE); + virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t &deserSize, size_t maxSize) { + return deSerialize(buffer, deserSize, maxSize, SerializeIF::Endianness::MACHINE); } }; From b11cdf618405574ec1e603f79cae1166f7579a79 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 21:32:22 +0200 Subject: [PATCH 151/532] update unittests --- unittests/serialize/testSerializeIF.cpp | 59 ++++++++++++++++++------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index 694f6d7f..5200f8b7 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -13,7 +13,8 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { size_t len = 0; SECTION("Little Endian Normal") { - REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); @@ -23,10 +24,14 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { } SECTION("Little Endian Simple") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + size_t serLen = 0xff; + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), + SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); + CHECK(serLen == 3); } SECTION("Big Endian Normal") { @@ -35,7 +40,8 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { REQUIRE(simpleSer.serializeBe(&ptr, &len, buf.size()) == HasReturnvaluesIF::RETURN_OK); @@ -50,19 +56,25 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { } SECTION("Big Endian Simple") { + size_t serLen = 0xff; SECTION("Explicit") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::BIG) == + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), + SerializeIF::Endianness::BIG) == HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), + SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::serializeBe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::serializeBe(buf.data(), serLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); } CHECK(buf[0] == 1); CHECK(buf[1] == 2); CHECK(buf[2] == 3); + CHECK(serLen == 3); } SECTION("Machine Endian Implicit") { @@ -82,7 +94,8 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { } SECTION("Machine Endian Simple Implicit") { - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), buf.size()) == + size_t serLen = 0xff; + REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 1); #if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN @@ -92,6 +105,7 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { CHECK(buf[1] == 2); CHECK(buf[2] == 3); #endif + CHECK(serLen == 3); } } @@ -102,7 +116,8 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { size_t len = buf.size(); SECTION("Little Endian Normal") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); CHECK(ptr == buf.data() + 3); @@ -110,17 +125,23 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { } SECTION("Little Endian Simple") { - REQUIRE(simpleSer.SerializeIF::deSerialize(ptr, len, SerializeIF::Endianness::LITTLE) == HasReturnvaluesIF::RETURN_OK); + size_t deserLen = 0xff; + REQUIRE( + simpleSer.SerializeIF::deSerialize(ptr, deserLen, len, SerializeIF::Endianness::LITTLE) == + HasReturnvaluesIF::RETURN_OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); + CHECK(deserLen == 3); } SECTION("Big Endian Normal") { SECTION("Explicit") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { REQUIRE(simpleSer.SerializeIF::deSerializeBe(&ptr, &len) == HasReturnvaluesIF::RETURN_OK); @@ -132,18 +153,24 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { } SECTION("Big Endian Simple") { + size_t deserLen = 0xff; SECTION("Explicit") { - REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), SerializeIF::Endianness::BIG) == + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size(), + SerializeIF::Endianness::BIG) == HasReturnvaluesIF::RETURN_OK); } SECTION("Network 0") { - REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size(), + SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::deSerializeBe(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerializeBe(buf.data(), deserLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); } CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 1); + CHECK(deserLen == 3); } SECTION("Machine Endian Implicit") { @@ -160,7 +187,8 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { } SECTION("Machine Endian Simple Implicit") { - REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), buf.size()) == + size_t deserLen = 0xff; + REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(simpleSer.getU8() == 5); #if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN @@ -168,5 +196,6 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { #else CHECK(simpleSer.getU16() == 1); #endif + CHECK(deserLen == 3); } } \ No newline at end of file From 5355e637114f5160439aadf64b2d455adf1d06f6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 21:43:32 +0200 Subject: [PATCH 152/532] use result instead of retval --- src/fsfw/cfdp/definitions.h | 18 +-- src/fsfw/osal/common/TcpTmTcServer.h | 2 +- src/fsfw/returnvalues/HasReturnvaluesIF.h | 12 +- src/fsfw/tasks/FixedTimeslotTaskIF.h | 2 +- src/fsfw_tests/internal/osal/testMq.cpp | 8 +- .../serialize/IntTestSerialization.cpp | 14 +- unittests/CatchDefinitions.h | 5 - unittests/action/TestActionHelper.cpp | 10 +- unittests/cfdp/testCfdp.cpp | 28 ++-- unittests/container/RingBufferTest.cpp | 148 +++++++++--------- unittests/datapoollocal/DataSetTest.cpp | 46 +++--- .../datapoollocal/LocalPoolManagerTest.cpp | 140 ++++++++--------- .../datapoollocal/LocalPoolVariableTest.cpp | 20 +-- .../datapoollocal/LocalPoolVectorTest.cpp | 16 +- unittests/globalfunctions/testDleEncoder.cpp | 4 +- .../TestInternalErrorReporter.cpp | 2 +- unittests/osal/TestMessageQueue.cpp | 16 +- unittests/osal/TestSemaphore.cpp | 4 +- .../serialize/TestSerialBufferAdapter.cpp | 2 +- .../serialize/TestSerialLinkedPacket.cpp | 4 +- unittests/storagemanager/TestNewAccessor.cpp | 42 ++--- unittests/storagemanager/TestPool.cpp | 58 +++---- 22 files changed, 298 insertions(+), 303 deletions(-) diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 93d15bcb..7e023881 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -16,27 +16,27 @@ static constexpr uint8_t VERSION_BITS = 0b00100000; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; static constexpr ReturnValue_t INVALID_TLV_TYPE = - retval::makeCode(CFDP_CLASS_ID, 1); + result::makeCode(CFDP_CLASS_ID, 1); static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = - retval::makeCode(CFDP_CLASS_ID, 2); + result::makeCode(CFDP_CLASS_ID, 2); static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = - retval::makeCode(CFDP_CLASS_ID, 3); + result::makeCode(CFDP_CLASS_ID, 3); static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = - retval::makeCode(CFDP_CLASS_ID, 4); + result::makeCode(CFDP_CLASS_ID, 4); //! Can not parse options. This can also occur because there are options //! available but the user did not pass a valid options array static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = - retval::makeCode(CFDP_CLASS_ID, 5); + result::makeCode(CFDP_CLASS_ID, 5); static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = - retval::makeCode(CFDP_CLASS_ID, 6); + result::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES = - retval::makeCode(CFDP_CLASS_ID, 6); + result::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = - retval::makeCode(CFDP_CLASS_ID, 8); + result::makeCode(CFDP_CLASS_ID, 8); //! Can not parse filestore response because user did not pass a valid instance //! or remaining size is invalid static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE = - retval::makeCode(CFDP_CLASS_ID, 9); + result::makeCode(CFDP_CLASS_ID, 9); //! Checksum types according to the SANA Checksum Types registry //! https://sanaregistry.org/r/checksum_identifiers/ diff --git a/src/fsfw/osal/common/TcpTmTcServer.h b/src/fsfw/osal/common/TcpTmTcServer.h index ae3fce39..1181ff10 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.h +++ b/src/fsfw/osal/common/TcpTmTcServer.h @@ -108,7 +108,7 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb StorageManagerIF* tmStore = nullptr; private: - static constexpr ReturnValue_t CONN_BROKEN = retval::makeCode(1, 0); + static constexpr ReturnValue_t CONN_BROKEN = result::makeCode(1, 0); //! TMTC bridge is cached. object_id_t tmtcBridgeId = objects::NO_OBJECT; TcpTmTcBridge* tmtcBridge = nullptr; diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/HasReturnvaluesIF.h index 4d59c26b..20c10e0b 100644 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ b/src/fsfw/returnvalues/HasReturnvaluesIF.h @@ -10,19 +10,19 @@ #define MAKE_RETURN_CODE(number) ((INTERFACE_ID << 8) + (number)) typedef uint16_t ReturnValue_t; -namespace retval { +namespace result { static constexpr ReturnValue_t OK = 0; static constexpr ReturnValue_t FAILED = 1; static constexpr ReturnValue_t makeCode(uint8_t classId, uint8_t number) { return (static_cast(classId) << 8) + number; } -} // namespace retval +} // namespace result class HasReturnvaluesIF { public: - static const ReturnValue_t RETURN_OK = retval::OK; - static const ReturnValue_t RETURN_FAILED = retval::FAILED; + static const ReturnValue_t RETURN_OK = result::OK; + static const ReturnValue_t RETURN_FAILED = result::FAILED; virtual ~HasReturnvaluesIF() = default; @@ -33,9 +33,9 @@ class HasReturnvaluesIF { * @param number * @return */ - [[deprecated("Use retval::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode( + [[deprecated("Use result::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode( uint8_t classId, uint8_t number) { - return retval::makeCode(classId, number); + return result::makeCode(classId, number); } }; diff --git a/src/fsfw/tasks/FixedTimeslotTaskIF.h b/src/fsfw/tasks/FixedTimeslotTaskIF.h index 6a552d81..c7b90ec3 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskIF.h +++ b/src/fsfw/tasks/FixedTimeslotTaskIF.h @@ -15,7 +15,7 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF { ~FixedTimeslotTaskIF() override = default; static constexpr ReturnValue_t SLOT_LIST_EMPTY = - retval::makeCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0); + result::makeCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0); /** * Add an object with a slot time and the execution step to the task. diff --git a/src/fsfw_tests/internal/osal/testMq.cpp b/src/fsfw_tests/internal/osal/testMq.cpp index 30b46d63..3d8e1034 100644 --- a/src/fsfw_tests/internal/osal/testMq.cpp +++ b/src/fsfw_tests/internal/osal/testMq.cpp @@ -20,22 +20,22 @@ void testmq::testMq() { testSenderMq->setDefaultDestination(testReceiverMqId); auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - if (result != retval::OK) { + if (result != result::OK) { unitt::put_error(id); } MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - if (result != retval::OK or recvMessage.getData()[0] != 42) { + if (result != result::OK or recvMessage.getData()[0] != 42) { unitt::put_error(id); } result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - if (result != retval::OK) { + if (result != result::OK) { unitt::put_error(id); } MessageQueueId_t senderId = 0; result = testReceiverMq->receiveMessage(&recvMessage, &senderId); - if (result != retval::OK or recvMessage.getData()[0] != 42) { + if (result != result::OK or recvMessage.getData()[0] != 42) { unitt::put_error(id); } if (senderId != testSenderMqId) { diff --git a/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp b/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp index 1e2a385c..5865f8fc 100644 --- a/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp +++ b/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp @@ -13,18 +13,18 @@ std::array testserialize::test_array = {0}; ReturnValue_t testserialize::test_serialization() { // Here, we test all serialization tools. First test basic cases. ReturnValue_t result = test_endianness_tools(); - if (result != retval::OK) { + if (result != result::OK) { return result; } result = test_autoserialization(); - if (result != retval::OK) { + if (result != result::OK) { return result; } result = test_serial_buffer_adapter(); - if (result != retval::OK) { + if (result != result::OK) { return result; } - return retval::OK; + return result::OK; } ReturnValue_t testserialize::test_endianness_tools() { @@ -48,7 +48,7 @@ ReturnValue_t testserialize::test_endianness_tools() { if (test_array[0] != 0 and test_array[1] != 1) { return unitt::put_error(id); } - return retval::OK; + return result::OK; } ReturnValue_t testserialize::test_autoserialization() { @@ -152,7 +152,7 @@ ReturnValue_t testserialize::test_autoserialization() { } // Check overflow - return retval::OK; + return result::OK; } // TODO: Also test for constant buffers. @@ -205,5 +205,5 @@ ReturnValue_t testserialize::test_serial_buffer_adapter() { if (testUint16 != 16) { return unitt::put_error(id); } - return retval::OK; + return result::OK; } diff --git a/unittests/CatchDefinitions.h b/unittests/CatchDefinitions.h index f0189602..dbe3848b 100644 --- a/unittests/CatchDefinitions.h +++ b/unittests/CatchDefinitions.h @@ -5,11 +5,6 @@ #include #include -namespace retval { -static constexpr int CATCH_OK = static_cast(HasReturnvaluesIF::RETURN_OK); -static constexpr int CATCH_FAILED = static_cast(HasReturnvaluesIF::RETURN_FAILED); -} // namespace retval - namespace tconst { static constexpr MessageQueueId_t testQueueId = 42; } diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index 6461a195..0d160c6f 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -19,12 +19,12 @@ TEST_CASE("Action Helper", "[ActionHelper]") { StorageManagerIF* ipcStore = tglob::getIpcStoreHandle(); REQUIRE(ipcStore != nullptr); ipcStore->addData(¶mAddress, testParams.data(), 3); - REQUIRE(actionHelper.initialize() == retval::CATCH_OK); + REQUIRE(actionHelper.initialize() == result::OK); SECTION("Simple tests") { ActionMessage::setCommand(&actionMessage, testActionId, paramAddress); CHECK(not testDhMock.executeActionCalled); - REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK); CHECK(testDhMock.executeActionCalled); // No message is sent if everything is alright. CHECK(not testMqMock.wasMessageSent()); @@ -82,10 +82,10 @@ TEST_CASE("Action Helper", "[ActionHelper]") { SECTION("Handle failed") { store_address_t toLongParamAddress = StorageManagerIF::INVALID_ADDRESS; std::array toLongData = {5, 4, 3, 2, 1}; - REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == retval::CATCH_OK); + REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == result::OK); ActionMessage::setCommand(&actionMessage, testActionId, toLongParamAddress); CHECK(not testDhMock.executeActionCalled); - REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK); REQUIRE(ipcStore->getData(toLongParamAddress).first == static_cast(StorageManagerIF::DATA_DOES_NOT_EXIST)); CommandMessage testMessage; @@ -100,7 +100,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { SECTION("Missing IPC Data") { ActionMessage::setCommand(&actionMessage, testActionId, StorageManagerIF::INVALID_ADDRESS); CHECK(not testDhMock.executeActionCalled); - REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK); CommandMessage testMessage; REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(HasReturnvaluesIF::RETURN_OK)); diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 78ef618b..e7acab01 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -29,10 +29,10 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { const uint8_t** dummyPtr = nullptr; ReturnValue_t deserResult = headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK); - REQUIRE(deserResult == retval::CATCH_FAILED); + REQUIRE(deserResult == result::FAILED); deserResult = headerSerializer.serialize(nullptr, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(deserResult == retval::CATCH_FAILED); + REQUIRE(deserResult == result::FAILED); REQUIRE(seqNum.getSerializedSize() == 1); REQUIRE(headerSerializer.getPduDataFieldLen() == 0); @@ -62,7 +62,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); REQUIRE(serSize == 7); // Only version bits are set REQUIRE(serBuf[0] == 0b00100000); @@ -155,11 +155,11 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { REQUIRE(entityId == 0x00ff00ff); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff); - REQUIRE(result == retval::CATCH_FAILED); + REQUIRE(result == result::FAILED); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff); - REQUIRE(result == retval::CATCH_FAILED); + REQUIRE(result == result::FAILED); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff); - REQUIRE(result == retval::CATCH_FAILED); + REQUIRE(result == result::FAILED); uint8_t oneByteSourceId = 32; serTarget = &oneByteSourceId; size_t deserLen = 1; @@ -197,7 +197,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); ReturnValue_t result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); REQUIRE(serBuf[1] == 0); REQUIRE(serBuf[2] == 0); // Entity and Transaction Sequence number are 1 byte large @@ -207,7 +207,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { auto headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); ReturnValue_t serResult = headerDeser.parseData(); - REQUIRE(serResult == retval::CATCH_OK); + REQUIRE(serResult == result::OK); REQUIRE(headerDeser.getPduDataFieldLen() == 0); REQUIRE(headerDeser.getHeaderSize() == 7); REQUIRE(headerDeser.getWholePduSize() == 7); @@ -230,11 +230,11 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { headerSerializer.setPduType(cfdp::PduType::FILE_DATA); headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); serTarget = serBuf.data(); serSize = 0; result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), @@ -242,7 +242,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); result = headerDeser.parseData(); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Everything except version bit flipped to one now REQUIRE(serBuf[0] == 0x3f); REQUIRE(serBuf[3] == 0b11001010); @@ -274,7 +274,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { serTarget = serBuf.data(); const uint8_t** serTargetConst = const_cast(&serTarget); result = headerDeser.parseData(); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); headerDeser.setData(nullptr, -1); REQUIRE(headerDeser.getHeaderSize() == 0); @@ -286,7 +286,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48); result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); REQUIRE(headerDeser.getWholePduSize() == 8); headerDeser.setData(serBuf.data(), serBuf.size()); diff --git a/unittests/container/RingBufferTest.cpp b/unittests/container/RingBufferTest.cpp index f4f111a6..edabfd55 100644 --- a/unittests/container/RingBufferTest.cpp +++ b/unittests/container/RingBufferTest.cpp @@ -12,42 +12,42 @@ TEST_CASE("Ring Buffer Test", "[RingBufferTest]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK); - REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_FAILED); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == result::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == retval::CATCH_OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 1024) == retval::CATCH_FAILED); - REQUIRE(ringBuffer.writeData(nullptr, 5) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.writeData(testData, 1024) == result::FAILED); + REQUIRE(ringBuffer.writeData(nullptr, 5) == result::FAILED); } SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED); REQUIRE(ringBuffer.writeTillWrap() == 2); // too many excess bytes. - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == retval::CATCH_FAILED); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == retval::CATCH_OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK); REQUIRE(ringBuffer.getExcessBytes() == 3); std::memcpy(testPtr, testData, 5); ringBuffer.confirmBytesWritten(5); @@ -59,19 +59,19 @@ TEST_CASE("Ring Buffer Test", "[RingBufferTest]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == retval::CATCH_OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == retval::CATCH_OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); REQUIRE(trueSize == 3); } } @@ -84,21 +84,21 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == retval::CATCH_OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } @@ -106,17 +106,17 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED); REQUIRE(ringBuffer.writeTillWrap() == 2); // too many excess bytes. - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == retval::CATCH_FAILED); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == retval::CATCH_OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK); REQUIRE(ringBuffer.getExcessBytes() == 3); std::memcpy(testPtr, testData, 5); ringBuffer.confirmBytesWritten(5); @@ -128,19 +128,19 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == retval::CATCH_OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == retval::CATCH_OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); REQUIRE(trueSize == 3); } @@ -148,17 +148,17 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { REQUIRE(ringBuffer.availableWriteSpace() == 9); // We don't allow writing of Data that is larger than the ring buffer in total REQUIRE(ringBuffer.getMaxSize() == 9); - REQUIRE(ringBuffer.writeData(testData, 13) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.writeData(testData, 13) == result::FAILED); REQUIRE(ringBuffer.getAvailableReadData() == 0); ringBuffer.clear(); uint8_t *ptr = nullptr; // With excess Bytes 13 Bytes can be written to this Buffer - REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == retval::CATCH_OK); + REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == result::OK); REQUIRE(ptr != nullptr); memcpy(ptr, testData, 13); ringBuffer.confirmBytesWritten(13); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 3, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.readData(readBuffer, 3, true) == result::OK); for (auto i = 0; i < 3; i++) { REQUIRE(readBuffer[i] == testData[i + 10]); } @@ -173,21 +173,21 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == retval::CATCH_OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } @@ -195,19 +195,19 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == retval::CATCH_OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::OK); REQUIRE(ringBuffer.getExcessBytes() == 8); REQUIRE(ringBuffer.writeTillWrap() == 2); // too many excess bytes. - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED); // Less Execss bytes overwrites before - REQUIRE(ringBuffer.getFreeElement(&testPtr, 3) == retval::CATCH_OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 3) == result::OK); REQUIRE(ringBuffer.getExcessBytes() == 1); std::memcpy(testPtr, testData, 3); ringBuffer.confirmBytesWritten(3); @@ -219,19 +219,19 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == retval::CATCH_OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == retval::CATCH_OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); REQUIRE(trueSize == 3); } @@ -239,18 +239,18 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { REQUIRE(ringBuffer.availableWriteSpace() == 9); // Writing more than the buffer is large. // This write will be rejected and is seen as a configuration mistake - REQUIRE(ringBuffer.writeData(testData, 13) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.writeData(testData, 13) == result::FAILED); REQUIRE(ringBuffer.getAvailableReadData() == 0); ringBuffer.clear(); // Using FreeElement allows the usage of excessBytes but // should be used with caution uint8_t *ptr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == retval::CATCH_OK); + REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == result::OK); REQUIRE(ptr != nullptr); memcpy(ptr, testData, 13); ringBuffer.confirmBytesWritten(13); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 3, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.readData(readBuffer, 3, true) == result::OK); for (auto i = 0; i < 3; i++) { REQUIRE(readBuffer[i] == testData[i + 10]); } @@ -264,22 +264,22 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK); - REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_FAILED); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == result::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == retval::CATCH_OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == retval::CATCH_OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } @@ -287,16 +287,16 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") { SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == retval::CATCH_OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED); REQUIRE(ringBuffer.writeTillWrap() == 2); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == retval::CATCH_OK); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == retval::CATCH_OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK); REQUIRE(ringBuffer.getExcessBytes() == 3); std::memcpy(testPtr, testData, 5); ringBuffer.confirmBytesWritten(5); @@ -308,19 +308,19 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == retval::CATCH_OK); + REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == retval::CATCH_OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == retval::CATCH_FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == retval::CATCH_OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); REQUIRE(trueSize == 3); } } diff --git a/unittests/datapoollocal/DataSetTest.cpp b/unittests/datapoollocal/DataSetTest.cpp index c9f023ef..45085eaf 100644 --- a/unittests/datapoollocal/DataSetTest.cpp +++ b/unittests/datapoollocal/DataSetTest.cpp @@ -16,8 +16,8 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + REQUIRE(poolOwner->initializeHkManager() == result::OK); + REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == result::OK); LocalPoolStaticTestDataSet localSet; SECTION("BasicTest") { @@ -36,7 +36,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Test local pool ID serialization */ CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + SerializeIF::Endianness::MACHINE) == result::OK); CHECK(serSize == maxSize); CHECK(localPoolIdBuff[0] == 3); CHECK(lpIds[0] == localSet.localPoolVarUint8.getDataPoolId()); @@ -48,7 +48,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { serSize = 0; CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE, - false) == retval::CATCH_OK); + false) == result::OK); CHECK(serSize == maxSize - sizeof(uint8_t)); CHECK(lpIds[0] == localSet.localPoolVarUint8.getDataPoolId()); CHECK(lpIds[1] == localSet.localPoolVarFloat.getDataPoolId()); @@ -57,7 +57,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { { /* Test read operation. Values should be all zeros */ PoolReadGuard readHelper(&localSet); - REQUIRE(readHelper.getReadResult() == retval::CATCH_OK); + REQUIRE(readHelper.getReadResult() == result::OK); CHECK(not localSet.isValid()); CHECK(localSet.localPoolVarUint8.value == 0); CHECK(not localSet.localPoolVarUint8.isValid()); @@ -90,7 +90,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Now we read again and check whether our zeroed values were overwritten with the values in the pool */ PoolReadGuard readHelper(&localSet); - REQUIRE(readHelper.getReadResult() == retval::CATCH_OK); + REQUIRE(readHelper.getReadResult() == result::OK); CHECK(localSet.isValid()); CHECK(localSet.localPoolVarUint8.value == 232); CHECK(localSet.localPoolVarUint8.isValid()); @@ -110,7 +110,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { uint8_t buffer[maxSize + 1]; uint8_t* buffPtr = buffer; CHECK(localSet.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); uint8_t rawUint8 = buffer[0]; CHECK(rawUint8 == 232); float rawFloat = 0.0; @@ -128,7 +128,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { std::memset(buffer, 0, sizeof(buffer)); const uint8_t* constBuffPtr = buffer; CHECK(localSet.deSerialize(&constBuffPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + SerializeIF::Endianness::MACHINE) == result::OK); /* Check whether deserialization was successfull */ CHECK(localSet.localPoolVarUint8.value == 0); CHECK(localSet.localPoolVarFloat.value == Catch::Approx(0.0)); @@ -156,7 +156,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { serSize = 0; buffPtr = buffer; CHECK(localSet.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(rawUint8 == 232); std::memcpy(&rawFloat, buffer + sizeof(uint8_t), sizeof(float)); CHECK(rawFloat == Catch::Approx(-2324.322)); @@ -186,7 +186,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { sizeToDeserialize = maxSize; constBuffPtr = buffer; CHECK(localSet.deSerialize(&constBuffPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + SerializeIF::Endianness::MACHINE) == result::OK); /* Check whether deserialization was successfull */ CHECK(localSet.localPoolVarUint8.value == 0); CHECK(localSet.localPoolVarFloat.value == Catch::Approx(0.0)); @@ -213,10 +213,10 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Register same variables again to get more than 8 registered variables */ for (uint8_t idx = 0; idx < 8; idx++) { - REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == retval::CATCH_OK); + REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == result::OK); } - REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == retval::CATCH_OK); - REQUIRE(set.registerVariable(&localSet.localPoolUint16Vec) == retval::CATCH_OK); + REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == result::OK); + REQUIRE(set.registerVariable(&localSet.localPoolUint16Vec) == result::OK); set.setValidityBufferGeneration(true); { @@ -233,7 +233,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { uint8_t buffer[maxSize + 1]; uint8_t* buffPtr = buffer; CHECK(set.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); std::array validityBuffer; std::memcpy(validityBuffer.data(), buffer + 9 + sizeof(uint16_t) * 3, 2); /* The first 9 variables should be valid */ @@ -251,7 +251,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { const uint8_t* constBuffPtr = buffer; size_t sizeToDeSerialize = serSize; CHECK(set.deSerialize(&constBuffPtr, &sizeToDeSerialize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(localSet.localPoolVarUint8.isValid() == false); CHECK(localSet.localPoolUint16Vec.isValid() == true); } @@ -261,20 +261,20 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { SharedLocalDataSet sharedSet(sharedSetId, poolOwner, lpool::testSetId, 5); localSet.localPoolVarUint8.setReadWriteMode(pool_rwm_t::VAR_WRITE); localSet.localPoolUint16Vec.setReadWriteMode(pool_rwm_t::VAR_WRITE); - CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == retval::CATCH_OK); - CHECK(sharedSet.registerVariable(&localSet.localPoolUint16Vec) == retval::CATCH_OK); - CHECK(sharedSet.initialize() == retval::CATCH_OK); - CHECK(sharedSet.lockDataset() == retval::CATCH_OK); - CHECK(sharedSet.unlockDataset() == retval::CATCH_OK); + CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == result::OK); + CHECK(sharedSet.registerVariable(&localSet.localPoolUint16Vec) == result::OK); + CHECK(sharedSet.initialize() == result::OK); + CHECK(sharedSet.lockDataset() == result::OK); + CHECK(sharedSet.unlockDataset() == result::OK); { // PoolReadGuard rg(&sharedSet); - // CHECK(rg.getReadResult() == retval::CATCH_OK); + // CHECK(rg.getReadResult() == result::OK); localSet.localPoolVarUint8.value = 5; localSet.localPoolUint16Vec.value[0] = 1; localSet.localPoolUint16Vec.value[1] = 2; localSet.localPoolUint16Vec.value[2] = 3; - CHECK(sharedSet.commit() == retval::CATCH_OK); + CHECK(sharedSet.commit() == result::OK); } sharedSet.setReadCommitProtectionBehaviour(true); @@ -282,5 +282,5 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* we need to reset the subscription list because the pool owner is a global object. */ - CHECK(poolOwner->reset() == retval::CATCH_OK); + CHECK(poolOwner->reset() == result::OK); } diff --git a/unittests/datapoollocal/LocalPoolManagerTest.cpp b/unittests/datapoollocal/LocalPoolManagerTest.cpp index 58a6065e..4fc67c97 100644 --- a/unittests/datapoollocal/LocalPoolManagerTest.cpp +++ b/unittests/datapoollocal/LocalPoolManagerTest.cpp @@ -18,8 +18,8 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + REQUIRE(poolOwner->initializeHkManager() == result::OK); + REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == result::OK); MessageQueueMockBase* poolOwnerMock = poolOwner->getMockQueueHandle(); REQUIRE(poolOwnerMock != nullptr); @@ -38,14 +38,14 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { CHECK(owner->getObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE); /* Subscribe for message generation on update. */ - REQUIRE(poolOwner->subscribeWrapperSetUpdate() == retval::CATCH_OK); + REQUIRE(poolOwner->subscribeWrapperSetUpdate() == result::OK); /* Subscribe for an update message. */ poolOwner->dataset.setChanged(true); /* Now the update message should be generated. */ - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); REQUIRE(poolOwnerMock->wasMessageSent() == true); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); @@ -53,27 +53,27 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { CHECK(poolOwner->dataset.hasChanged() == false); /* Set changed again, result should be the same. */ poolOwner->dataset.setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); /* Now subscribe for set update HK as well. */ - REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK); + REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == result::OK); poolOwner->dataset.setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 2); /* first message sent should be the update notification, considering the internal list is a vector checked in insertion order. */ - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); /* Clear message to avoid memory leak, our mock won't do it for us (yet) */ CommandMessageCleaner::clearCommandMessage(&messageSent); @@ -83,7 +83,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { /* Set the variables in the set to certain values. These are checked later. */ { PoolReadGuard readHelper(&poolOwner->dataset); - REQUIRE(readHelper.getReadResult() == retval::CATCH_OK); + REQUIRE(readHelper.getReadResult() == result::OK); poolOwner->dataset.localPoolVarUint8.value = 5; poolOwner->dataset.localPoolVarFloat.value = -12.242; poolOwner->dataset.localPoolUint16Vec.value[0] = 2; @@ -92,7 +92,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { } /* Subscribe for snapshot generation on update. */ - REQUIRE(poolOwner->subscribeWrapperSetUpdateSnapshot() == retval::CATCH_OK); + REQUIRE(poolOwner->subscribeWrapperSetUpdateSnapshot() == result::OK); poolOwner->dataset.setChanged(true); /* Store current time, we are going to check the (approximate) time equality later */ @@ -100,10 +100,10 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { Clock::getClock_timeval(&now); /* Trigger generation of snapshot */ - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); /* Check that snapshot was generated */ CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_SET)); /* Now we deserialize the snapshot into a new dataset instance */ @@ -113,7 +113,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { store_address_t storeId; HousekeepingMessage::getUpdateSnapshotSetCommand(&messageSent, &storeId); ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); - REQUIRE(accessorPair.first == retval::CATCH_OK); + REQUIRE(accessorPair.first == result::OK); const uint8_t* readOnlyPtr = accessorPair.second.data(); size_t sizeToDeserialize = accessorPair.second.size(); CHECK(newSet.localPoolVarFloat.value == 0); @@ -123,7 +123,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { CHECK(newSet.localPoolUint16Vec.value[2] == 0); /* Fill the dataset and timestamp */ REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + SerializeIF::Endianness::MACHINE) == result::OK); /* Now we check that the snapshot is actually correct */ CHECK(newSet.localPoolVarFloat.value == Catch::Approx(-12.242)); CHECK(newSet.localPoolVarUint8 == 5); @@ -145,14 +145,14 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { REQUIRE(subscriptionIF != nullptr); /* Subscribe for variable snapshot */ - REQUIRE(poolOwner->subscribeWrapperVariableSnapshot(lpool::uint8VarId) == retval::CATCH_OK); + REQUIRE(poolOwner->subscribeWrapperVariableSnapshot(lpool::uint8VarId) == result::OK); auto poolVar = dynamic_cast*>(poolOwner->getPoolObjectHandle(lpool::uint8VarId)); REQUIRE(poolVar != nullptr); { PoolReadGuard rg(poolVar); - CHECK(rg.getReadResult() == retval::CATCH_OK); + CHECK(rg.getReadResult() == result::OK); poolVar->value = 25; } @@ -161,7 +161,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { CCSDSTime::CDS_short timeCdsNow; timeval now; Clock::getClock_timeval(&now); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); /* Check update snapshot was sent. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); @@ -169,7 +169,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { /* Should have been reset. */ CHECK(poolVar->hasChanged() == false); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE)); /* Now we deserialize the snapshot into a new dataset instance */ @@ -179,13 +179,13 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { store_address_t storeId; HousekeepingMessage::getUpdateSnapshotVariableCommand(&messageSent, &storeId); ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); - REQUIRE(accessorPair.first == retval::CATCH_OK); + REQUIRE(accessorPair.first == result::OK); const uint8_t* readOnlyPtr = accessorPair.second.data(); size_t sizeToDeserialize = accessorPair.second.size(); CHECK(varCopy.value == 0); /* Fill the dataset and timestamp */ REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + SerializeIF::Endianness::MACHINE) == result::OK); CHECK(varCopy.value == 25); /* Now we check that both times are equal */ @@ -202,30 +202,30 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { REQUIRE(subscriptionIF != nullptr); /* Subscribe for variable update */ - REQUIRE(poolOwner->subscribeWrapperVariableUpdate(lpool::uint8VarId) == retval::CATCH_OK); + REQUIRE(poolOwner->subscribeWrapperVariableUpdate(lpool::uint8VarId) == result::OK); lp_var_t* poolVar = dynamic_cast*>(poolOwner->getPoolObjectHandle(lpool::uint8VarId)); REQUIRE(poolVar != nullptr); poolVar->setChanged(true); REQUIRE(poolVar->hasChanged() == true); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); /* Check update notification was sent. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); /* Should have been reset. */ CHECK(poolVar->hasChanged() == false); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); /* Now subscribe for the dataset update (HK and update) again with subscription interface */ REQUIRE(subscriptionIF->subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT, objects::HK_RECEIVER_MOCK, - false) == retval::CATCH_OK); - REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK); + false) == result::OK); + REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == result::OK); poolOwner->dataset.setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); /* Now two messages should be sent. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 2); @@ -233,17 +233,17 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { poolOwner->dataset.setChanged(true); poolVar->setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); /* Now three messages should be sent. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 3); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); CommandMessageCleaner::clearCommandMessage(&messageSent); REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == static_cast(MessageQueueIF::EMPTY)); @@ -254,70 +254,70 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { the temporal behaviour correctly the HK manager should generate a HK packet immediately and the periodic helper depends on HK op function calls anyway instead of using the clock, so we could also just call performHkOperation multiple times */ - REQUIRE(poolOwner->subscribePeriodicHk(true) == retval::CATCH_OK); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner->subscribePeriodicHk(true) == result::OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); /* Now HK packet should be sent as message immediately. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); LocalPoolDataSetBase* setHandle = poolOwner->getDataSetHandle(lpool::testSid); REQUIRE(setHandle != nullptr); CHECK(poolOwner->poolManager.generateHousekeepingPacket(lpool::testSid, setHandle, false) == - retval::CATCH_OK); + result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); CHECK(setHandle->getReportingEnabled() == true); CommandMessage hkCmd; HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(setHandle->getReportingEnabled() == false); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(setHandle->getReportingEnabled() == true); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(setHandle->getReportingEnabled() == false); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); /* For non-diagnostics and a specified minimum frequency of 0.2 seconds, the resulting collection interval should be 1.0 second */ CHECK(poolOwner->dataset.getCollectionInterval() == 1.0); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); - REQUIRE(poolOwner->poolManager.performHkOperation() == retval::CATCH_OK); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); /* Now HK packet should be sent as message. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid); sid_t sidToCheck; store_address_t storeId; - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner->changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); CHECK(sidToCheck == lpool::testSid); @@ -330,7 +330,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { /* We still expect a failure message being sent */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, false); @@ -338,68 +338,68 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock->popMessage() == result::OK); HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid); gp_id_t gpidToCheck; - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner->changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); CHECK(gpidToCheck == lpool::uint8VarGpid); HousekeepingMessage::setUpdateSnapshotSetCommand(&hkCmd, lpool::testSid, storeId::INVALID_STORE_ADDRESS); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner->changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); CHECK(sidToCheck == lpool::testSid); HousekeepingMessage::setUpdateSnapshotVariableCommand(&hkCmd, lpool::uint8VarGpid, storeId::INVALID_STORE_ADDRESS); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner->changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); CHECK(gpidToCheck == lpool::uint8VarGpid); @@ -408,6 +408,6 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { /* we need to reset the subscription list because the pool owner is a global object. */ - CHECK(poolOwner->reset() == retval::CATCH_OK); + CHECK(poolOwner->reset() == result::OK); poolOwnerMock->clearMessages(true); } diff --git a/unittests/datapoollocal/LocalPoolVariableTest.cpp b/unittests/datapoollocal/LocalPoolVariableTest.cpp index 3479cdbe..e9bed9ed 100644 --- a/unittests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittests/datapoollocal/LocalPoolVariableTest.cpp @@ -11,23 +11,23 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { auto* poolOwner = ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + REQUIRE(poolOwner->initializeHkManager() == result::OK); + REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == result::OK); SECTION("Basic Tests") { /* very basic test. */ lp_var_t testVariable = lp_var_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); - REQUIRE(testVariable.read() == retval::CATCH_OK); + REQUIRE(testVariable.read() == result::OK); CHECK(testVariable.value == 0); testVariable.value = 5; - REQUIRE(testVariable.commit() == retval::CATCH_OK); - REQUIRE(testVariable.read() == retval::CATCH_OK); + REQUIRE(testVariable.commit() == result::OK); + REQUIRE(testVariable.read() == result::OK); REQUIRE(testVariable.value == 5); CHECK(not testVariable.isValid()); testVariable.setValid(true); CHECK(testVariable.isValid()); - CHECK(testVariable.commit(true) == retval::CATCH_OK); + CHECK(testVariable.commit(true) == result::OK); testVariable.setReadWriteMode(pool_rwm_t::VAR_READ); CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ); @@ -43,7 +43,7 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); lp_var_t testVariable2 = lp_var_t(globPoolId); - REQUIRE(testVariable2.read() == retval::CATCH_OK); + REQUIRE(testVariable2.read() == result::OK); CHECK(testVariable2 == 5); CHECK(testVariable == testVariable2); testVariable = 10; @@ -55,12 +55,12 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { CHECK(maxSize == 1); size_t serSize = 0; CHECK(testVariable.serialize(&varPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(variableRaw == 10); const uint8_t* varConstPtr = &variableRaw; testVariable = 5; CHECK(testVariable.deSerialize(&varConstPtr, &serSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(testVariable == 10); CHECK(testVariable != testVariable2); CHECK(testVariable2 < testVariable); @@ -107,5 +107,5 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { lp_var_t invalidObjectVar3 = lp_var_t(nullptr, lpool::uint8VarId); } - CHECK(poolOwner->reset() == retval::CATCH_OK); + CHECK(poolOwner->reset() == result::OK); } diff --git a/unittests/datapoollocal/LocalPoolVectorTest.cpp b/unittests/datapoollocal/LocalPoolVectorTest.cpp index 2235ad39..ddf6da9b 100644 --- a/unittests/datapoollocal/LocalPoolVectorTest.cpp +++ b/unittests/datapoollocal/LocalPoolVectorTest.cpp @@ -11,26 +11,26 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + REQUIRE(poolOwner->initializeHkManager() == result::OK); + REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == result::OK); SECTION("BasicTest") { // very basic test. lp_vec_t testVector = lp_vec_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id); - REQUIRE(testVector.read() == retval::CATCH_OK); + REQUIRE(testVector.read() == result::OK); testVector.value[0] = 5; testVector.value[1] = 232; testVector.value[2] = 32023; - REQUIRE(testVector.commit(true) == retval::CATCH_OK); + REQUIRE(testVector.commit(true) == result::OK); CHECK(testVector.isValid()); testVector.value[0] = 0; testVector.value[1] = 0; testVector.value[2] = 0; - CHECK(testVector.read() == retval::CATCH_OK); + CHECK(testVector.read() == result::OK); CHECK(testVector.value[0] == 5); CHECK(testVector.value[1] == 232); CHECK(testVector.value[2] == 32023); @@ -41,7 +41,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { (we can't throw exceptions) */ testVector[4] = 12; CHECK(testVector[2] == 12); - CHECK(testVector.commit() == retval::CATCH_OK); + CHECK(testVector.commit() == result::OK); /* Use read-only reference. */ const lp_vec_t& roTestVec = testVector; @@ -58,7 +58,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { uint8_t* vecPtr = reinterpret_cast(serializedVector); size_t serSize = 0; REQUIRE(testVector.serialize(&vecPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(serSize == 6); CHECK(serializedVector[0] == 5); @@ -75,7 +75,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { const uint8_t* constVecPtr = reinterpret_cast(serializedVector); REQUIRE(testVector.deSerialize(&constVecPtr, &serSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(testVector[0] == 16); CHECK(testVector[1] == 7832); CHECK(testVector[2] == 39232); diff --git a/unittests/globalfunctions/testDleEncoder.cpp b/unittests/globalfunctions/testDleEncoder.cpp index 0c707f4c..fc4d79bf 100644 --- a/unittests/globalfunctions/testDleEncoder.cpp +++ b/unittests/globalfunctions/testDleEncoder.cpp @@ -60,7 +60,7 @@ TEST_CASE("DleEncoder", "[DleEncoder]") { const std::vector& expectedVec) { result = encoder.encode(vecToEncode.data(), vecToEncode.size(), buffer.data(), buffer.size(), &encodedLen); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); for (size_t idx = 0; idx < expectedVec.size(); idx++) { REQUIRE(buffer[idx] == expectedVec[idx]); } @@ -71,7 +71,7 @@ TEST_CASE("DleEncoder", "[DleEncoder]") { const std::vector& expectedVec) { result = encoder.decode(testVecEncoded.data(), testVecEncoded.size(), &readLen, buffer.data(), buffer.size(), &decodedLen); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); REQUIRE(readLen == testVecEncoded.size()); REQUIRE(decodedLen == expectedVec.size()); for (size_t idx = 0; idx < decodedLen; idx++) { diff --git a/unittests/internalerror/TestInternalErrorReporter.cpp b/unittests/internalerror/TestInternalErrorReporter.cpp index 2b999fae..b61a6203 100644 --- a/unittests/internalerror/TestInternalErrorReporter.cpp +++ b/unittests/internalerror/TestInternalErrorReporter.cpp @@ -38,7 +38,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { CommandMessage message; ActionMessage::setCompletionReply(&message, 10, true); auto result = hkQueue->sendMessage(testQueue->getId(), &message); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); uint32_t queueHits = 0; uint32_t lostTm = 0; uint32_t storeHits = 0; diff --git a/unittests/osal/TestMessageQueue.cpp b/unittests/osal/TestMessageQueue.cpp index df15b33d..b1792a9c 100644 --- a/unittests/osal/TestMessageQueue.cpp +++ b/unittests/osal/TestMessageQueue.cpp @@ -19,17 +19,17 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { SECTION("Simple Tests") { auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(recvMessage.getData()[0] == 42); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); MessageQueueId_t senderId = 0; result = testReceiverMq->receiveMessage(&recvMessage, &senderId); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(recvMessage.getData()[0] == 42); CHECK(senderId == testSenderMqId); senderId = testReceiverMq->getLastPartner(); @@ -37,7 +37,7 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { } SECTION("Test Full") { auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); REQUIRE(result == MessageQueueIF::FULL); // We try another message @@ -45,12 +45,12 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { REQUIRE(result == MessageQueueIF::FULL); MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(recvMessage.getData()[0] == 42); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(recvMessage.getData()[0] == 42); } // We have to clear MQs ourself ATM diff --git a/unittests/osal/TestSemaphore.cpp b/unittests/osal/TestSemaphore.cpp index 6988af5b..376b08db 100644 --- a/unittests/osal/TestSemaphore.cpp +++ b/unittests/osal/TestSemaphore.cpp @@ -19,7 +19,7 @@ TEST_CASE("Binary Semaphore Test" , "[BinSemaphore]") { REQUIRE(binSemaph->release() == static_cast(SemaphoreIF::SEMAPHORE_NOT_OWNED)); REQUIRE(binSemaph->acquire(SemaphoreIF::POLLING) == - retval::CATCH_OK); + result::OK); { // not precise enough on linux.. should use clock instead.. //Stopwatch stopwatch(false); @@ -29,7 +29,7 @@ TEST_CASE("Binary Semaphore Test" , "[BinSemaphore]") { //CHECK(time == 5); } REQUIRE(binSemaph->getSemaphoreCounter() == 0); - REQUIRE(binSemaph->release() == retval::CATCH_OK); + REQUIRE(binSemaph->release() == result::OK); } SemaphoreFactory::instance()->deleteSemaphore(binSemaph); // perform tear-down here diff --git a/unittests/serialize/TestSerialBufferAdapter.cpp b/unittests/serialize/TestSerialBufferAdapter.cpp index 2aa76ec8..2a8fe68c 100644 --- a/unittests/serialize/TestSerialBufferAdapter.cpp +++ b/unittests/serialize/TestSerialBufferAdapter.cpp @@ -102,7 +102,7 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") { size_t size = 6; auto result = tv_serial_buffer_adapter3.deSerialize(const_cast(&arrayPtr), &size, SerializeIF::Endianness::MACHINE); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(test_recv_array[0] == 1); CHECK(test_recv_array[1] == 1); CHECK(test_recv_array[2] == 1); diff --git a/unittests/serialize/TestSerialLinkedPacket.cpp b/unittests/serialize/TestSerialLinkedPacket.cpp index 2d6e476f..863c77a9 100644 --- a/unittests/serialize/TestSerialLinkedPacket.cpp +++ b/unittests/serialize/TestSerialLinkedPacket.cpp @@ -41,7 +41,7 @@ TEST_CASE("Serial Linked Packet", "[SerLinkPacket]") { // Deserialize big endian packet by setting bigEndian to true. ReturnValue_t result = testClass.deSerialize(&readOnlyPointer, &packetLen, SerializeIF::Endianness::BIG); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testClass.getHeader() == 42); // Equivalent check. // CHECK(testClass.getBuffer()[0] == 1); @@ -60,7 +60,7 @@ TEST_CASE("Serial Linked Packet", "[SerLinkPacket]") { // serialize for ground: bigEndian = true. ReturnValue_t result = testClass.serialize(&packetPointer, &serializedSize, packetMaxSize, SerializeIF::Endianness::BIG); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Result should be big endian now. CHECK(packet[3] == 42); CHECK(packet[4] == 1); diff --git a/unittests/storagemanager/TestNewAccessor.cpp b/unittests/storagemanager/TestNewAccessor.cpp index 2cc2e469..311ba44d 100644 --- a/unittests/storagemanager/TestNewAccessor.cpp +++ b/unittests/storagemanager/TestNewAccessor.cpp @@ -12,7 +12,7 @@ TEST_CASE("New Accessor", "[NewAccessor]") { std::array testDataArray; std::array receptionArray; store_address_t testStoreId; - ReturnValue_t result = retval::CATCH_FAILED; + ReturnValue_t result = result::FAILED; for (size_t i = 0; i < testDataArray.size(); i++) { testDataArray[i] = i; @@ -21,9 +21,9 @@ TEST_CASE("New Accessor", "[NewAccessor]") { SECTION("Simple tests getter functions") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); auto resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); resultPair.second.getDataCopy(receptionArray.data(), 20); CHECK(resultPair.second.getId() == testStoreId); CHECK(resultPair.second.size() == 10); @@ -39,18 +39,18 @@ TEST_CASE("New Accessor", "[NewAccessor]") { { auto resultPairLoc = SimplePool.getData(testStoreId); - REQUIRE(resultPairLoc.first == retval::CATCH_OK); + REQUIRE(resultPairLoc.first == result::OK); // data should be deleted when accessor goes out of scope. } resultPair = SimplePool.getData(testStoreId); REQUIRE(resultPair.first == (int)StorageManagerIF::DATA_DOES_NOT_EXIST); result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); { ConstStorageAccessor constAccessor(testStoreId); result = SimplePool.getData(testStoreId, constAccessor); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); constAccessor.getDataCopy(receptionArray.data(), 20); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -63,12 +63,12 @@ TEST_CASE("New Accessor", "[NewAccessor]") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); { resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); resultPair.second.release(); // now data should not be deleted anymore } resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); resultPair.second.getDataCopy(receptionArray.data(), 20); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -77,11 +77,11 @@ TEST_CASE("New Accessor", "[NewAccessor]") { SECTION("Simple tests modify functions") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); { StorageAccessor accessor(testStoreId); result = SimplePool.modifyData(testStoreId, accessor); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(accessor.getId() == testStoreId); CHECK(accessor.size() == 10); accessor.getDataCopy(receptionArray.data(), 20); @@ -98,10 +98,10 @@ TEST_CASE("New Accessor", "[NewAccessor]") { REQUIRE(resultPair.first == (int)StorageManagerIF::DATA_DOES_NOT_EXIST); result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); { auto resultPairLoc = SimplePool.modifyData(testStoreId); - REQUIRE(resultPairLoc.first == retval::CATCH_OK); + REQUIRE(resultPairLoc.first == result::OK); CHECK(resultPairLoc.second.getId() == testStoreId); CHECK(resultPairLoc.second.size() == 10); resultPairLoc.second.getDataCopy(receptionArray.data(), 20); @@ -117,22 +117,22 @@ TEST_CASE("New Accessor", "[NewAccessor]") { // data should not be deleted when accessor goes out of scope } resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); } SECTION("Write tests") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); { auto resultPair = SimplePool.modifyData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); testDataArray[9] = 42; resultPair.second.write(testDataArray.data(), 10, 0); // now data should not be deleted resultPair.second.release(); } auto resultConstPair = SimplePool.getData(testStoreId); - REQUIRE(resultConstPair.first == retval::CATCH_OK); + REQUIRE(resultConstPair.first == result::OK); resultConstPair.second.getDataCopy(receptionArray.data(), 10); for (size_t i = 0; i < size - 1; i++) { @@ -141,15 +141,15 @@ TEST_CASE("New Accessor", "[NewAccessor]") { CHECK(receptionArray[9] == 42); auto resultPair = SimplePool.modifyData(testStoreId); - REQUIRE(resultPair.first == retval::CATCH_OK); + REQUIRE(resultPair.first == result::OK); result = resultPair.second.write(testDataArray.data(), 20, 0); - REQUIRE(result == retval::CATCH_FAILED); + REQUIRE(result == result::FAILED); result = resultPair.second.write(testDataArray.data(), 10, 5); - REQUIRE(result == retval::CATCH_FAILED); + REQUIRE(result == result::FAILED); std::memset(testDataArray.data(), 42, 5); result = resultPair.second.write(testDataArray.data(), 5, 5); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); resultConstPair = SimplePool.getData(testStoreId); resultPair.second.getDataCopy(receptionArray.data(), 20); for (size_t i = 5; i < 10; i++) { @@ -159,7 +159,7 @@ TEST_CASE("New Accessor", "[NewAccessor]") { SECTION("Operators") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); { StorageAccessor accessor(testStoreId); StorageAccessor accessor2(0); diff --git a/unittests/storagemanager/TestPool.cpp b/unittests/storagemanager/TestPool.cpp index e37c6934..f3c4f330 100644 --- a/unittests/storagemanager/TestPool.cpp +++ b/unittests/storagemanager/TestPool.cpp @@ -13,7 +13,7 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { std::array testDataArray; std::array receptionArray; store_address_t testStoreId; - ReturnValue_t result = retval::CATCH_FAILED; + ReturnValue_t result = result::FAILED; uint8_t* pointer = nullptr; const uint8_t* constPointer = nullptr; @@ -24,9 +24,9 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Basic tests") { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -34,12 +34,12 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { memset(receptionArray.data(), 0, size); result = simplePool.modifyData(testStoreId, &pointer, &size); memcpy(receptionArray.data(), pointer, size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); } result = simplePool.deleteData(testStoreId); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), 15); CHECK(result == (int)StorageManagerIF::DATA_TOO_LARGE); } @@ -47,12 +47,12 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Reservation Tests ") { pointer = nullptr; result = simplePool.getFreeElement(&testStoreId, size, &pointer); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(pointer, testDataArray.data(), size); constPointer = nullptr; result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -61,21 +61,21 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Add, delete, add, add when full") { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); } result = simplePool.deleteData(testStoreId); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -102,20 +102,20 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Initialize and clear store, delete with pointer") { result = simplePool.initialize(); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); simplePool.clearStore(); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.modifyData(testStoreId, &pointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); store_address_t newId; result = simplePool.deleteData(pointer, size, &testStoreId); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); REQUIRE(testStoreId.raw != (uint32_t)StorageManagerIF::INVALID_ADDRESS); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); } } @@ -141,7 +141,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { std::array testDataArray; std::array receptionArray; store_address_t testStoreId; - ReturnValue_t result = retval::CATCH_FAILED; + ReturnValue_t result = result::FAILED; for (size_t i = 0; i < testDataArray.size(); i++) { testDataArray[i] = i; } @@ -150,20 +150,20 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { SECTION("Basic tests") { size = 8; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should be on second page of the pool now for 8 bytes CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == 0); size = 15; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should be on third page of the pool now for 15 bytes CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == 0); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should be on third page of the pool now for 15 bytes CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == 1); @@ -174,7 +174,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 8; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should still work CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == 1); @@ -182,7 +182,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { // fill the rest of the pool for (uint8_t idx = 2; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } @@ -203,21 +203,21 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 5; for (uint8_t idx = 0; idx < 10; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 0); CHECK(testStoreId.packetIndex == idx); } size = 10; for (uint8_t idx = 0; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } size = 20; for (uint8_t idx = 0; idx < 2; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == idx); } @@ -244,7 +244,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 5; for (uint8_t idx = 0; idx < 10; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 0); CHECK(testStoreId.packetIndex == idx); } @@ -261,7 +261,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 10; for (uint8_t idx = 0; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } From 72bc5d4d609fc5222955068e3a51195b7839dd59 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 28 Jul 2022 12:52:20 +0200 Subject: [PATCH 153/532] add tm zc test --- unittests/tmtcpacket/CMakeLists.txt | 1 + unittests/tmtcpacket/testZcTmWriter.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 unittests/tmtcpacket/testZcTmWriter.cpp diff --git a/unittests/tmtcpacket/CMakeLists.txt b/unittests/tmtcpacket/CMakeLists.txt index dd0100a6..5b53328f 100644 --- a/unittests/tmtcpacket/CMakeLists.txt +++ b/unittests/tmtcpacket/CMakeLists.txt @@ -6,4 +6,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testPusTmCreator.cpp testPusTmReader.cpp testCcsds.cpp + testZcTmWriter.cpp ) diff --git a/unittests/tmtcpacket/testZcTmWriter.cpp b/unittests/tmtcpacket/testZcTmWriter.cpp new file mode 100644 index 00000000..366697d1 --- /dev/null +++ b/unittests/tmtcpacket/testZcTmWriter.cpp @@ -0,0 +1,23 @@ +#include + +#include "fsfw/tmtcpacket/pus/tm.h" +#include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" +#include "mocks/CdsShortTimestamperMock.h" + +TEST_CASE("TM ZC Helper", "[tm-zc-helper]") { + auto packetId = PacketId(ccsds::PacketType::TC, true, 0xef); + auto spParams = + SpacePacketParams(packetId, PacketSeqCtrl(ccsds::SequenceFlags::UNSEGMENTED, 22), 0x00); + auto timeStamper = CdsShortTimestamperMock(); + auto pusTmParams = PusTmParams(17, 2, &timeStamper); + timeStamper.valueToStamp = {1, 2, 3, 4, 5, 6, 7}; + PusTmCreator creator(spParams, pusTmParams); + std::array buf{}; + uint8_t* dataPtr = buf.data(); + size_t serLen = 0; + + SECTION("Basic") { + REQUIRE(creator.serialize(dataPtr, serLen, buf.size()) == result::OK); + PusTmZeroCopyWriter() + } +} \ No newline at end of file From 30ba9ab91627518f3e9f69ab3af03322d2e90790 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 28 Jul 2022 13:00:53 +0200 Subject: [PATCH 154/532] some more fixes --- src/fsfw/cfdp/definitions.h | 21 +-- src/fsfw/pus/Service2DeviceAccess.cpp | 4 +- src/fsfw/returnvalues/HasReturnvaluesIF.h | 3 +- src/fsfw/tmtcpacket/pus/PusIF.h | 4 +- src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h | 2 +- .../tmtcservices/CommandingServiceBase.cpp | 6 +- .../tmtcservices/VerificationReporter.cpp | 2 +- .../tmtcservices/VerificationReporterIF.h | 2 +- src/fsfw/tmtcservices/tmHelpers.h | 10 +- src/fsfw_hal/linux/CommandExecutor.h | 12 +- unittests/datapoollocal/testDataSet.cpp | 45 ++++--- .../datapoollocal/testLocalPoolManager.cpp | 122 +++++++++--------- .../datapoollocal/testLocalPoolVariable.cpp | 18 +-- .../datapoollocal/testLocalPoolVector.cpp | 16 +-- unittests/storagemanager/testPool.cpp | 60 ++++----- unittests/tmtcpacket/testZcTmWriter.cpp | 2 +- unittests/tmtcservices/testPsb.cpp | 26 ++-- .../tmtcservices/testStoreAndSendHelper.cpp | 10 +- 19 files changed, 180 insertions(+), 189 deletions(-) diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 7e023881..772b3ae3 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -15,24 +15,17 @@ static constexpr uint8_t VERSION_BITS = 0b00100000; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; -static constexpr ReturnValue_t INVALID_TLV_TYPE = - result::makeCode(CFDP_CLASS_ID, 1); -static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = - result::makeCode(CFDP_CLASS_ID, 2); -static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = - result::makeCode(CFDP_CLASS_ID, 3); -static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = - result::makeCode(CFDP_CLASS_ID, 4); +static constexpr ReturnValue_t INVALID_TLV_TYPE = result::makeCode(CFDP_CLASS_ID, 1); +static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = result::makeCode(CFDP_CLASS_ID, 2); +static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = result::makeCode(CFDP_CLASS_ID, 3); +static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = result::makeCode(CFDP_CLASS_ID, 4); //! Can not parse options. This can also occur because there are options //! available but the user did not pass a valid options array -static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = - result::makeCode(CFDP_CLASS_ID, 5); -static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = - result::makeCode(CFDP_CLASS_ID, 6); +static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = result::makeCode(CFDP_CLASS_ID, 5); +static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = result::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES = result::makeCode(CFDP_CLASS_ID, 6); -static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = - result::makeCode(CFDP_CLASS_ID, 8); +static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = result::makeCode(CFDP_CLASS_ID, 8); //! Can not parse filestore response because user did not pass a valid instance //! or remaining size is invalid static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE = diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index 817a372e..414f0812 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -136,7 +136,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs const uint8_t* data = nullptr; size_t size = 0; ReturnValue_t result = ipcStore->getData(storeAddress, &data, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in " "handleUnrequestedReply with failure ID " @@ -149,7 +149,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs // sending it back. WiretappingPacket tmPacket(DeviceHandlerMessage::getDeviceObjectId(reply), data); result = sendTmPacket(subservice, tmPacket.objectId, tmPacket.data, size); - if (result != retval::OK) { + if (result != RETURN_OK) { // TODO: Warning return; } diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/HasReturnvaluesIF.h index 4a4cbeb6..e5e42047 100644 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ b/src/fsfw/returnvalues/HasReturnvaluesIF.h @@ -33,8 +33,7 @@ class HasReturnvaluesIF { * @param number * @return */ - static constexpr ReturnValue_t makeReturnCode( - uint8_t classId, uint8_t number) { + static constexpr ReturnValue_t makeReturnCode(uint8_t classId, uint8_t number) { return result::makeCode(classId, number); } }; diff --git a/src/fsfw/tmtcpacket/pus/PusIF.h b/src/fsfw/tmtcpacket/pus/PusIF.h index 5f27846e..3c802cfa 100644 --- a/src/fsfw/tmtcpacket/pus/PusIF.h +++ b/src/fsfw/tmtcpacket/pus/PusIF.h @@ -9,8 +9,8 @@ class PusIF : public SpacePacketIF { public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::PUS_IF; - static constexpr ReturnValue_t INVALID_PUS_VERSION = retval::makeCode(INTERFACE_ID, 0); - static constexpr ReturnValue_t INVALID_CRC_16 = retval::makeCode(INTERFACE_ID, 1); + static constexpr ReturnValue_t INVALID_PUS_VERSION = result::makeCode(INTERFACE_ID, 0); + static constexpr ReturnValue_t INVALID_CRC_16 = result::makeCode(INTERFACE_ID, 1); ~PusIF() override = default; /** diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp index bcbdba03..6ca78378 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp @@ -2,8 +2,8 @@ #include "fsfw/globalfunctions/CRC.h" -PusTmZeroCopyWriter::PusTmZeroCopyWriter(TimeReaderIF* timeReader, uint8_t* data, size_t size) - : PusTmReader(timeReader, data, size) {} +PusTmZeroCopyWriter::PusTmZeroCopyWriter(TimeReaderIF& timeReader, uint8_t* data, size_t size) + : PusTmReader(&timeReader, data, size) {} void PusTmZeroCopyWriter::setSequenceCount(uint16_t seqCount) { auto* spHeader = diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h index d3a0e5f2..331bda7f 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h @@ -4,7 +4,7 @@ #include "PusTmReader.h" class PusTmZeroCopyWriter : public PusTmReader { public: - PusTmZeroCopyWriter(TimeReaderIF* timeReader, uint8_t* data, size_t size); + PusTmZeroCopyWriter(TimeReaderIF& timeReader, uint8_t* data, size_t size); void setSequenceCount(uint16_t seqCount); void updateErrorControl(); diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index c12a47b2..ded92926 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -309,7 +309,7 @@ void CommandingServiceBase::handleRequestQueue() { ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen) { ReturnValue_t result = tmHelper.prepareTmPacket(subservice, sourceData, sourceDataLen); - if (result != retval::OK) { + if (result != result::OK) { return result; } return tmHelper.storeAndSendTmPacket(); @@ -319,7 +319,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_ const uint8_t* data, size_t dataLen) { telemetry::DataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); ReturnValue_t result = tmHelper.prepareTmPacket(subservice, dataWithObjId); - if (result != retval::OK) { + if (result != result::OK) { return result; } return tmHelper.storeAndSendTmPacket(); @@ -327,7 +327,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeIF& sourceData) { ReturnValue_t result = tmHelper.prepareTmPacket(subservice, sourceData); - if (result != retval::OK) { + if (result != result::OK) { return result; } return tmHelper.storeAndSendTmPacket(); diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 9c38b3a7..2eb0c771 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -36,7 +36,7 @@ ReturnValue_t VerificationReporter::sendFailureReport(VerifFailureParams params) ReturnValue_t VerificationReporter::sendSuccessReport(VerifSuccessParams params) { PusVerificationMessage message(params.reportId, params.ackFlags, params.tcPacketId, params.tcPsc, - retval::OK, params.step); + result::OK, params.step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/tmtcservices/VerificationReporterIF.h b/src/fsfw/tmtcservices/VerificationReporterIF.h index 14b6012f..6678c630 100644 --- a/src/fsfw/tmtcservices/VerificationReporterIF.h +++ b/src/fsfw/tmtcservices/VerificationReporterIF.h @@ -41,7 +41,7 @@ struct VerifFailureParams : public VerifParamsBase { VerifFailureParams(uint8_t reportId, PusTcIF& tc) : VerifParamsBase(reportId, tc.getPacketIdRaw(), tc.getPacketSeqCtrlRaw()) {} - ReturnValue_t errorCode = retval::OK; + ReturnValue_t errorCode = result::OK; uint8_t step = 0; uint32_t errorParam1 = 0; uint32_t errorParam2 = 0; diff --git a/src/fsfw/tmtcservices/tmHelpers.h b/src/fsfw/tmtcservices/tmHelpers.h index ad333eb2..2cb39c78 100644 --- a/src/fsfw/tmtcservices/tmHelpers.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -28,16 +28,16 @@ class DataWithObjectIdPrefix : public SerializeIF { } if (dataWrapper.type != ecss::DataTypes::RAW) { if ((dataWrapper.dataUnion.raw.data == nullptr) and (dataWrapper.dataUnion.raw.len > 0)) { - return retval::FAILED; + return result::FAILED; } } else if (dataWrapper.type == ecss::DataTypes::SERIALIZABLE) { if (dataWrapper.dataUnion.serializable == nullptr) { - return retval::FAILED; + return result::FAILED; } } ReturnValue_t result = SerializeAdapter::serialize(&objectId, buffer, size, maxSize, streamEndianness); - if (result != retval::OK) { + if (result != result::OK) { return result; } if (dataWrapper.type != ecss::DataTypes::RAW) { @@ -47,7 +47,7 @@ class DataWithObjectIdPrefix : public SerializeIF { } else { return dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, streamEndianness); } - return retval::OK; + return result::OK; } [[nodiscard]] size_t getSerializedSize() const override { @@ -58,7 +58,7 @@ class DataWithObjectIdPrefix : public SerializeIF { Endianness streamEndianness) override { // As long as there is no way to know how long the expected data will be, this function // does not make sense - return retval::FAILED; + return result::FAILED; } private: diff --git a/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h index 27e78260..1696e229 100644 --- a/src/fsfw_hal/linux/CommandExecutor.h +++ b/src/fsfw_hal/linux/CommandExecutor.h @@ -31,18 +31,18 @@ class CommandExecutor { static constexpr uint8_t CLASS_ID = CLASS_ID::LINUX_OSAL; //! [EXPORT] : [COMMENT] Execution of the current command has finished - static constexpr ReturnValue_t EXECUTION_FINISHED = retval::makeCode(CLASS_ID, 0); + static constexpr ReturnValue_t EXECUTION_FINISHED = result::makeCode(CLASS_ID, 0); //! [EXPORT] : [COMMENT] Command is pending. This will also be returned if the user tries //! to load another command but a command is still pending - static constexpr ReturnValue_t COMMAND_PENDING = retval::makeCode(CLASS_ID, 1); + static constexpr ReturnValue_t COMMAND_PENDING = result::makeCode(CLASS_ID, 1); //! [EXPORT] : [COMMENT] Some bytes have been read from the executing process - static constexpr ReturnValue_t BYTES_READ = retval::makeCode(CLASS_ID, 2); + static constexpr ReturnValue_t BYTES_READ = result::makeCode(CLASS_ID, 2); //! [EXPORT] : [COMMENT] Command execution failed - static constexpr ReturnValue_t COMMAND_ERROR = retval::makeCode(CLASS_ID, 3); + static constexpr ReturnValue_t COMMAND_ERROR = result::makeCode(CLASS_ID, 3); //! [EXPORT] : [COMMENT] - static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = retval::makeCode(CLASS_ID, 4); - static constexpr ReturnValue_t PCLOSE_CALL_ERROR = retval::makeCode(CLASS_ID, 6); + static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = result::makeCode(CLASS_ID, 4); + static constexpr ReturnValue_t PCLOSE_CALL_ERROR = result::makeCode(CLASS_ID, 6); /** * Constructor. Is initialized with maximum size of internal buffer to read data from the diff --git a/unittests/datapoollocal/testDataSet.cpp b/unittests/datapoollocal/testDataSet.cpp index 532208f5..67e17d97 100644 --- a/unittests/datapoollocal/testDataSet.cpp +++ b/unittests/datapoollocal/testDataSet.cpp @@ -16,8 +16,8 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { auto queue = MessageQueueMock(1); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + REQUIRE(poolOwner.initializeHkManager() == result::OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == result::OK); LocalPoolStaticTestDataSet localSet; SECTION("BasicTest") { @@ -36,7 +36,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Test local pool ID serialization */ CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + SerializeIF::Endianness::MACHINE) == result::OK); CHECK(serSize == maxSize); CHECK(localPoolIdBuff[0] == 3); CHECK(lpIds[0] == localSet.localPoolVarUint8.getDataPoolId()); @@ -47,8 +47,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { localPoolIdBuffPtr = localPoolIdBuff; serSize = 0; CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize, - SerializeIF::Endianness::MACHINE, - false) == retval::CATCH_OK); + SerializeIF::Endianness::MACHINE, false) == result::OK); CHECK(serSize == maxSize - sizeof(uint8_t)); CHECK(lpIds[0] == localSet.localPoolVarUint8.getDataPoolId()); CHECK(lpIds[1] == localSet.localPoolVarFloat.getDataPoolId()); @@ -57,7 +56,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { { /* Test read operation. Values should be all zeros */ PoolReadGuard readHelper(&localSet); - REQUIRE(readHelper.getReadResult() == retval::CATCH_OK); + REQUIRE(readHelper.getReadResult() == result::OK); CHECK(not localSet.isValid()); CHECK(localSet.localPoolVarUint8.value == 0); CHECK(not localSet.localPoolVarUint8.isValid()); @@ -90,7 +89,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Now we read again and check whether our zeroed values were overwritten with the values in the pool */ PoolReadGuard readHelper(&localSet); - REQUIRE(readHelper.getReadResult() == retval::CATCH_OK); + REQUIRE(readHelper.getReadResult() == result::OK); CHECK(localSet.isValid()); CHECK(localSet.localPoolVarUint8.value == 232); CHECK(localSet.localPoolVarUint8.isValid()); @@ -110,7 +109,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { uint8_t buffer[maxSize + 1]; uint8_t* buffPtr = buffer; CHECK(localSet.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); uint8_t rawUint8 = buffer[0]; CHECK(rawUint8 == 232); float rawFloat = 0.0; @@ -128,7 +127,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { std::memset(buffer, 0, sizeof(buffer)); const uint8_t* constBuffPtr = buffer; CHECK(localSet.deSerialize(&constBuffPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + SerializeIF::Endianness::MACHINE) == result::OK); /* Check whether deserialization was successfull */ CHECK(localSet.localPoolVarUint8.value == 0); CHECK(localSet.localPoolVarFloat.value == Catch::Approx(0.0)); @@ -156,7 +155,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { serSize = 0; buffPtr = buffer; CHECK(localSet.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(rawUint8 == 232); std::memcpy(&rawFloat, buffer + sizeof(uint8_t), sizeof(float)); CHECK(rawFloat == Catch::Approx(-2324.322)); @@ -186,7 +185,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { sizeToDeserialize = maxSize; constBuffPtr = buffer; CHECK(localSet.deSerialize(&constBuffPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + SerializeIF::Endianness::MACHINE) == result::OK); /* Check whether deserialization was successfull */ CHECK(localSet.localPoolVarUint8.value == 0); CHECK(localSet.localPoolVarFloat.value == Catch::Approx(0.0)); @@ -213,10 +212,10 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Register same variables again to get more than 8 registered variables */ for (uint8_t idx = 0; idx < 8; idx++) { - REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == retval::CATCH_OK); + REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == result::OK); } - REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == retval::CATCH_OK); - REQUIRE(set.registerVariable(&localSet.localPoolUint16Vec) == retval::CATCH_OK); + REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == result::OK); + REQUIRE(set.registerVariable(&localSet.localPoolUint16Vec) == result::OK); set.setValidityBufferGeneration(true); { @@ -233,7 +232,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { uint8_t buffer[maxSize + 1]; uint8_t* buffPtr = buffer; CHECK(set.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); std::array validityBuffer{}; std::memcpy(validityBuffer.data(), buffer + 9 + sizeof(uint16_t) * 3, 2); /* The first 9 variables should be valid */ @@ -251,7 +250,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { const uint8_t* constBuffPtr = buffer; size_t sizeToDeSerialize = serSize; CHECK(set.deSerialize(&constBuffPtr, &sizeToDeSerialize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(localSet.localPoolVarUint8.isValid() == false); CHECK(localSet.localPoolUint16Vec.isValid() == true); } @@ -261,20 +260,20 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { SharedLocalDataSet sharedSet(sharedSetId, &poolOwner, lpool::testSetId, 5); localSet.localPoolVarUint8.setReadWriteMode(pool_rwm_t::VAR_WRITE); localSet.localPoolUint16Vec.setReadWriteMode(pool_rwm_t::VAR_WRITE); - CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == retval::CATCH_OK); - CHECK(sharedSet.registerVariable(&localSet.localPoolUint16Vec) == retval::CATCH_OK); - CHECK(sharedSet.initialize() == retval::CATCH_OK); - CHECK(sharedSet.lockDataset() == retval::CATCH_OK); - CHECK(sharedSet.unlockDataset() == retval::CATCH_OK); + CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == result::OK); + CHECK(sharedSet.registerVariable(&localSet.localPoolUint16Vec) == result::OK); + CHECK(sharedSet.initialize() == result::OK); + CHECK(sharedSet.lockDataset() == result::OK); + CHECK(sharedSet.unlockDataset() == result::OK); { // PoolReadGuard rg(&sharedSet); - // CHECK(rg.getReadResult() == retval::CATCH_OK); + // CHECK(rg.getReadResult() == result::OK); localSet.localPoolVarUint8.value = 5; localSet.localPoolUint16Vec.value[0] = 1; localSet.localPoolUint16Vec.value[1] = 2; localSet.localPoolUint16Vec.value[2] = 3; - CHECK(sharedSet.commit() == retval::CATCH_OK); + CHECK(sharedSet.commit() == result::OK); } sharedSet.setReadCommitProtectionBehaviour(true); diff --git a/unittests/datapoollocal/testLocalPoolManager.cpp b/unittests/datapoollocal/testLocalPoolManager.cpp index bdeec8c0..dfb72ec1 100644 --- a/unittests/datapoollocal/testLocalPoolManager.cpp +++ b/unittests/datapoollocal/testLocalPoolManager.cpp @@ -22,8 +22,8 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { auto hkReceiver = HkReceiverMock(hkDest); auto queue = MessageQueueMock(3); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + REQUIRE(poolOwner.initializeHkManager() == result::OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == result::OK); MessageQueueMock& poolOwnerMock = poolOwner.getMockQueueHandle(); @@ -46,14 +46,14 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { CHECK(owner->getObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE); /* Subscribe for message generation on update. */ - REQUIRE(poolOwner.subscribeWrapperSetUpdate(subscriberId) == retval::CATCH_OK); + REQUIRE(poolOwner.subscribeWrapperSetUpdate(subscriberId) == result::OK); /* Subscribe for an update message. */ poolOwner.dataset.setChanged(true); /* Now the update message should be generated. */ - REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); @@ -62,26 +62,26 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { poolOwnerMock.clearMessages(true); /* Set changed again, result should be the same. */ poolOwner.dataset.setChanged(true); - REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); REQUIRE(poolOwnerMock.wasMessageSent() == true); CHECK(poolOwnerMock.numberOfSentMessages() == 1); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); poolOwnerMock.clearMessages(true); /* Now subscribe for set update HK as well. */ - REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == retval::CATCH_OK); + REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == result::OK); poolOwner.dataset.setChanged(true); - REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); REQUIRE(poolOwnerMock.wasMessageSent() == true); CHECK(poolOwnerMock.numberOfSentMessages() == 2); // first message sent should be the update notification - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); /* Clear message to avoid memory leak, our mock won't do it for us (yet) */ CommandMessageCleaner::clearCommandMessage(&messageSent); @@ -91,7 +91,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Set the variables in the set to certain values. These are checked later. */ { PoolReadGuard readHelper(&poolOwner.dataset); - REQUIRE(readHelper.getReadResult() == retval::CATCH_OK); + REQUIRE(readHelper.getReadResult() == result::OK); poolOwner.dataset.localPoolVarUint8.value = 5; poolOwner.dataset.localPoolVarFloat.value = -12.242; poolOwner.dataset.localPoolUint16Vec.value[0] = 2; @@ -100,7 +100,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { } /* Subscribe for snapshot generation on update. */ - REQUIRE(poolOwner.subscribeWrapperSetUpdateSnapshot(subscriberId) == retval::CATCH_OK); + REQUIRE(poolOwner.subscribeWrapperSetUpdateSnapshot(subscriberId) == result::OK); poolOwner.dataset.setChanged(true); /* Store current time, we are going to check the (approximate) time equality later */ @@ -108,10 +108,10 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { Clock::getClock_timeval(&now); /* Trigger generation of snapshot */ - REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 1); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); /* Check that snapshot was generated */ CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_SET)); /* Now we deserialize the snapshot into a new dataset instance */ @@ -121,7 +121,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { store_address_t storeId; HousekeepingMessage::getUpdateSnapshotSetCommand(&messageSent, &storeId); ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); - REQUIRE(accessorPair.first == retval::CATCH_OK); + REQUIRE(accessorPair.first == result::OK); const uint8_t* readOnlyPtr = accessorPair.second.data(); size_t sizeToDeserialize = accessorPair.second.size(); CHECK(newSet.localPoolVarFloat.value == 0); @@ -131,7 +131,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { CHECK(newSet.localPoolUint16Vec.value[2] == 0); /* Fill the dataset and timestamp */ REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + SerializeIF::Endianness::MACHINE) == result::OK); /* Now we check that the snapshot is actually correct */ CHECK(newSet.localPoolVarFloat.value == Catch::Approx(-12.242)); CHECK(newSet.localPoolVarUint8 == 5); @@ -154,14 +154,14 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Subscribe for variable snapshot */ REQUIRE(poolOwner.subscribeWrapperVariableSnapshot(subscriberId, lpool::uint8VarId) == - retval::CATCH_OK); + result::OK); auto poolVar = dynamic_cast*>(poolOwner.getPoolObjectHandle(lpool::uint8VarId)); REQUIRE(poolVar != nullptr); { PoolReadGuard rg(poolVar); - CHECK(rg.getReadResult() == retval::CATCH_OK); + CHECK(rg.getReadResult() == result::OK); poolVar->value = 25; } @@ -170,7 +170,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { CCSDSTime::CDS_short timeCdsNow{}; timeval now{}; Clock::getClock_timeval(&now); - REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); /* Check update snapshot was sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); @@ -178,7 +178,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Should have been reset. */ CHECK(poolVar->hasChanged() == false); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE)); /* Now we deserialize the snapshot into a new dataset instance */ @@ -188,13 +188,13 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { store_address_t storeId; HousekeepingMessage::getUpdateSnapshotVariableCommand(&messageSent, &storeId); ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); - REQUIRE(accessorPair.first == retval::CATCH_OK); + REQUIRE(accessorPair.first == result::OK); const uint8_t* readOnlyPtr = accessorPair.second.data(); size_t sizeToDeserialize = accessorPair.second.size(); CHECK(varCopy.value == 0); /* Fill the dataset and timestamp */ REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + SerializeIF::Endianness::MACHINE) == result::OK); CHECK(varCopy.value == 25); /* Now we check that both times are equal */ @@ -212,30 +212,30 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Subscribe for variable update */ REQUIRE(poolOwner.subscribeWrapperVariableUpdate(subscriberId, lpool::uint8VarId) == - retval::CATCH_OK); + result::OK); auto* poolVar = dynamic_cast*>(poolOwner.getPoolObjectHandle(lpool::uint8VarId)); REQUIRE(poolVar != nullptr); poolVar->setChanged(true); REQUIRE(poolVar->hasChanged() == true); - REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); /* Check update notification was sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 1); /* Should have been reset. */ CHECK(poolVar->hasChanged() == false); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); /* Now subscribe for the dataset update (HK and update) again with subscription interface */ REQUIRE(subscriptionIF->subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT, - subscriberId, false) == retval::CATCH_OK); - REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == retval::CATCH_OK); + subscriberId, false) == result::OK); + REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == result::OK); poolOwner.dataset.setChanged(true); poolOwnerMock.clearMessages(); - REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); /* Now two messages should be sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 2); @@ -244,13 +244,13 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { poolOwner.dataset.setChanged(true); poolOwnerMock.clearMessages(true); poolVar->setChanged(true); - REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); /* Now three messages should be sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 3); CHECK(poolOwnerMock.numberOfSentMessagesToDest(subscriberId) == 2); CHECK(poolOwnerMock.numberOfSentMessagesToDest(hkDest) == 1); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); REQUIRE(poolOwnerMock.clearLastSentMessage(subscriberId) == HasReturnvaluesIF::RETURN_OK); @@ -259,7 +259,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); REQUIRE(poolOwnerMock.clearLastSentMessage(subscriberId) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == retval::CATCH_OK); + REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == result::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); REQUIRE(poolOwnerMock.clearLastSentMessage() == HasReturnvaluesIF::RETURN_OK); REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == MessageQueueIF::EMPTY); @@ -271,62 +271,62 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { the temporal behaviour correctly the HK manager should generate a HK packet immediately and the periodic helper depends on HK op function calls anyway instead of using the clock, so we could also just call performHkOperation multiple times */ - REQUIRE(poolOwner.subscribePeriodicHk(true) == retval::CATCH_OK); - REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); + REQUIRE(poolOwner.subscribePeriodicHk(true) == result::OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); /* Now HK packet should be sent as message immediately. */ REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); LocalPoolDataSetBase* setHandle = poolOwner.getDataSetHandle(lpool::testSid); REQUIRE(setHandle != nullptr); CHECK(poolOwner.poolManager.generateHousekeepingPacket(lpool::testSid, setHandle, false) == - retval::CATCH_OK); + result::OK); REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); CHECK(setHandle->getReportingEnabled() == true); CommandMessage hkCmd; HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(setHandle->getReportingEnabled() == false); REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, false); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(setHandle->getReportingEnabled() == true); REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(setHandle->getReportingEnabled() == false); REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, false); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); /* For non-diagnostics and a specified minimum frequency of 0.2 seconds, the resulting collection interval should be 1.0 second */ CHECK(poolOwner.dataset.getCollectionInterval() == 1.0); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); - REQUIRE(poolOwner.poolManager.performHkOperation() == retval::CATCH_OK); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); /* Now HK packet should be sent as message. */ REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); @@ -334,7 +334,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid); sid_t sidToCheck; store_address_t storeId; - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner.changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); CHECK(sidToCheck == lpool::testSid); @@ -347,7 +347,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* We still expect a failure message being sent */ REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, false); @@ -355,36 +355,36 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == retval::CATCH_OK); + CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, true); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, true); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, true); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); @@ -397,26 +397,26 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { poolOwnerMock.clearMessages(); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid); gp_id_t gpidToCheck; - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner.changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); CHECK(gpidToCheck == lpool::uint8VarGpid); HousekeepingMessage::setUpdateSnapshotSetCommand(&hkCmd, lpool::testSid, store_address_t::invalid()); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner.changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); CHECK(sidToCheck == lpool::testSid); HousekeepingMessage::setUpdateSnapshotVariableCommand(&hkCmd, lpool::uint8VarGpid, store_address_t::invalid()); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == retval::CATCH_OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); CHECK(poolOwner.changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); CHECK(gpidToCheck == lpool::uint8VarGpid); @@ -425,6 +425,6 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* we need to reset the subscription list because the pool owner is a global object. */ - CHECK(poolOwner.reset() == retval::CATCH_OK); + CHECK(poolOwner.reset() == result::OK); poolOwnerMock.clearMessages(true); } diff --git a/unittests/datapoollocal/testLocalPoolVariable.cpp b/unittests/datapoollocal/testLocalPoolVariable.cpp index b3ae07e0..78b1ccde 100644 --- a/unittests/datapoollocal/testLocalPoolVariable.cpp +++ b/unittests/datapoollocal/testLocalPoolVariable.cpp @@ -10,23 +10,23 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { auto queue = MessageQueueMock(1); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + REQUIRE(poolOwner.initializeHkManager() == result::OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == result::OK); SECTION("Basic Tests") { /* very basic test. */ lp_var_t testVariable = lp_var_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); - REQUIRE(testVariable.read() == retval::CATCH_OK); + REQUIRE(testVariable.read() == result::OK); CHECK(testVariable.value == 0); testVariable.value = 5; - REQUIRE(testVariable.commit() == retval::CATCH_OK); - REQUIRE(testVariable.read() == retval::CATCH_OK); + REQUIRE(testVariable.commit() == result::OK); + REQUIRE(testVariable.read() == result::OK); REQUIRE(testVariable.value == 5); CHECK(not testVariable.isValid()); testVariable.setValid(true); CHECK(testVariable.isValid()); - CHECK(testVariable.commit(true) == retval::CATCH_OK); + CHECK(testVariable.commit(true) == result::OK); testVariable.setReadWriteMode(pool_rwm_t::VAR_READ); CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ); @@ -42,7 +42,7 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); lp_var_t testVariable2 = lp_var_t(globPoolId); - REQUIRE(testVariable2.read() == retval::CATCH_OK); + REQUIRE(testVariable2.read() == result::OK); CHECK(testVariable2 == 5); CHECK(testVariable == testVariable2); testVariable = 10; @@ -54,12 +54,12 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { CHECK(maxSize == 1); size_t serSize = 0; CHECK(testVariable.serialize(&varPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(variableRaw == 10); const uint8_t* varConstPtr = &variableRaw; testVariable = 5; CHECK(testVariable.deSerialize(&varConstPtr, &serSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(testVariable == 10); CHECK(testVariable != testVariable2); CHECK(testVariable2 < testVariable); diff --git a/unittests/datapoollocal/testLocalPoolVector.cpp b/unittests/datapoollocal/testLocalPoolVector.cpp index e04bf643..9ebfd3a0 100644 --- a/unittests/datapoollocal/testLocalPoolVector.cpp +++ b/unittests/datapoollocal/testLocalPoolVector.cpp @@ -10,26 +10,26 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { auto queue = MessageQueueMock(1); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); + REQUIRE(poolOwner.initializeHkManager() == result::OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == result::OK); SECTION("BasicTest") { // very basic test. lp_vec_t testVector = lp_vec_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id); - REQUIRE(testVector.read() == retval::CATCH_OK); + REQUIRE(testVector.read() == result::OK); testVector.value[0] = 5; testVector.value[1] = 232; testVector.value[2] = 32023; - REQUIRE(testVector.commit(true) == retval::CATCH_OK); + REQUIRE(testVector.commit(true) == result::OK); CHECK(testVector.isValid()); testVector.value[0] = 0; testVector.value[1] = 0; testVector.value[2] = 0; - CHECK(testVector.read() == retval::CATCH_OK); + CHECK(testVector.read() == result::OK); CHECK(testVector.value[0] == 5); CHECK(testVector.value[1] == 232); CHECK(testVector.value[2] == 32023); @@ -40,7 +40,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { (we can't throw exceptions) */ testVector[4] = 12; CHECK(testVector[2] == 12); - CHECK(testVector.commit() == retval::CATCH_OK); + CHECK(testVector.commit() == result::OK); /* Use read-only reference. */ const lp_vec_t& roTestVec = testVector; @@ -57,7 +57,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { uint8_t* vecPtr = reinterpret_cast(serializedVector); size_t serSize = 0; REQUIRE(testVector.serialize(&vecPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(serSize == 6); CHECK(serializedVector[0] == 5); @@ -74,7 +74,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { const uint8_t* constVecPtr = reinterpret_cast(serializedVector); REQUIRE(testVector.deSerialize(&constVecPtr, &serSize, SerializeIF::Endianness::MACHINE) == - retval::CATCH_OK); + result::OK); CHECK(testVector[0] == 16); CHECK(testVector[1] == 7832); CHECK(testVector[2] == 39232); diff --git a/unittests/storagemanager/testPool.cpp b/unittests/storagemanager/testPool.cpp index 03cac72a..c3eadf1d 100644 --- a/unittests/storagemanager/testPool.cpp +++ b/unittests/storagemanager/testPool.cpp @@ -25,10 +25,10 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Basic tests") { REQUIRE(not simplePool.hasDataAtId(testStoreId)); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); REQUIRE(simplePool.hasDataAtId(testStoreId)); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -36,12 +36,12 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { memset(receptionArray.data(), 0, size); result = simplePool.modifyData(testStoreId, &pointer, &size); memcpy(receptionArray.data(), pointer, size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); } result = simplePool.deleteData(testStoreId); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); REQUIRE(not simplePool.hasDataAtId(testStoreId)); result = simplePool.addData(&testStoreId, testDataArray.data(), 15); CHECK(result == (int)StorageManagerIF::DATA_TOO_LARGE); @@ -50,12 +50,12 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Reservation Tests ") { pointer = nullptr; result = simplePool.getFreeElement(&testStoreId, size, &pointer); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(pointer, testDataArray.data(), size); constPointer = nullptr; result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -64,21 +64,21 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Add, delete, add, add when full") { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); } result = simplePool.deleteData(testStoreId); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -105,20 +105,20 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Initialize and clear store, delete with pointer") { result = simplePool.initialize(); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); simplePool.clearStore(); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); result = simplePool.modifyData(testStoreId, &pointer, &size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); store_address_t newId; result = simplePool.deleteData(pointer, size, &testStoreId); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); REQUIRE(testStoreId.raw != (uint32_t)StorageManagerIF::INVALID_ADDRESS); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); } } @@ -141,10 +141,10 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { runIdx++; LocalPool simplePool(0, *config); - std::array testDataArray; - std::array receptionArray; + std::array testDataArray{}; + std::array receptionArray{}; store_address_t testStoreId; - ReturnValue_t result = retval::CATCH_FAILED; + ReturnValue_t result = result::FAILED; for (size_t i = 0; i < testDataArray.size(); i++) { testDataArray[i] = i; } @@ -153,20 +153,20 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { SECTION("Basic tests") { size = 8; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should be on second page of the pool now for 8 bytes CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == 0); size = 15; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should be on third page of the pool now for 15 bytes CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == 0); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should be on third page of the pool now for 15 bytes CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == 1); @@ -177,7 +177,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 8; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); // Should still work CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == 1); @@ -185,7 +185,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { // fill the rest of the pool for (uint8_t idx = 2; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } @@ -206,21 +206,21 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 5; for (uint8_t idx = 0; idx < 10; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 0); CHECK(testStoreId.packetIndex == idx); } size = 10; for (uint8_t idx = 0; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } size = 20; for (uint8_t idx = 0; idx < 2; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == idx); } @@ -247,7 +247,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 5; for (uint8_t idx = 0; idx < 10; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 0); CHECK(testStoreId.packetIndex == idx); } @@ -264,7 +264,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 10; for (uint8_t idx = 0; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == retval::CATCH_OK); + REQUIRE(result == result::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } diff --git a/unittests/tmtcpacket/testZcTmWriter.cpp b/unittests/tmtcpacket/testZcTmWriter.cpp index 366697d1..c26b0069 100644 --- a/unittests/tmtcpacket/testZcTmWriter.cpp +++ b/unittests/tmtcpacket/testZcTmWriter.cpp @@ -18,6 +18,6 @@ TEST_CASE("TM ZC Helper", "[tm-zc-helper]") { SECTION("Basic") { REQUIRE(creator.serialize(dataPtr, serLen, buf.size()) == result::OK); - PusTmZeroCopyWriter() + PusTmZeroCopyWriter(timeStamper, dataPtr, serLen); } } \ No newline at end of file diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index 9404c401..464fb3da 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -49,19 +49,19 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { SECTION("Perform Service") { REQUIRE(psb.performServiceCallCnt == 0); - REQUIRE(psb.performOperation(0) == retval::OK); + REQUIRE(psb.performOperation(0) == result::OK); REQUIRE(psb.performServiceCallCnt == 1); } SECTION("Send Request with Successful Handling") { REQUIRE(psb.performServiceCallCnt == 0); uint8_t* dataPtr; - REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == retval::OK); + REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == result::OK); size_t serLen = 0; - REQUIRE(creator.serializeBe(dataPtr, serLen, creator.getSerializedSize()) == retval::OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, creator.getSerializedSize()) == result::OK); tmtcMsg.setStorageId(storeId); msgQueue.addReceivedMessage(tmtcMsg); - REQUIRE(psb.performOperation(0) == retval::OK); + REQUIRE(psb.performOperation(0) == result::OK); uint8_t subservice = 0; REQUIRE(psb.getAndPopNextSubservice(subservice)); REQUIRE(subservice == 1); @@ -77,13 +77,13 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { SECTION("Send Request with Failed Handling") { uint8_t* dataPtr; - REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == retval::OK); + REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == result::OK); size_t serLen = 0; - REQUIRE(creator.serializeBe(dataPtr, serLen, creator.getSerializedSize()) == retval::OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, creator.getSerializedSize()) == result::OK); tmtcMsg.setStorageId(storeId); msgQueue.addReceivedMessage(tmtcMsg); psb.makeNextHandleReqCallFail(3); - REQUIRE(psb.performOperation(0) == retval::OK); + REQUIRE(psb.performOperation(0) == result::OK); uint8_t subservice = 0; REQUIRE(psb.getAndPopNextSubservice(subservice)); REQUIRE(subservice == 1); @@ -100,7 +100,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { SECTION("Invalid Packet Sent") { tmtcMsg.setStorageId(store_address_t::invalid()); msgQueue.addReceivedMessage(tmtcMsg); - REQUIRE(psb.performOperation(0) == retval::OK); + REQUIRE(psb.performOperation(0) == result::OK); REQUIRE(verificationReporter.failCallCount() == 1); auto verifParams = verificationReporter.getNextFailCallParams(); REQUIRE(verifParams.tcPacketId == 0); @@ -147,7 +147,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { psbParams.objectId = 1; auto mockWithOwnerQueue = PsbMock(psbParams); REQUIRE(mockWithOwnerQueue.getRequestQueue() == MessageQueueIF::NO_QUEUE); - REQUIRE(mockWithOwnerQueue.initialize() == retval::OK); + REQUIRE(mockWithOwnerQueue.initialize() == result::OK); REQUIRE(mockWithOwnerQueue.getRequestQueue() != MessageQueueIF::NO_QUEUE); } @@ -190,7 +190,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { auto pusDistrib = PusDistributorMock(distributorId); PsbMock::setStaticPusDistributor(distributorId); REQUIRE(PsbMock::getStaticPusDistributor() == distributorId); - REQUIRE(psb2.initialize() == retval::OK); + REQUIRE(psb2.initialize() == result::OK); REQUIRE(pusDistrib.registerCallCount == 1); REQUIRE(pusDistrib.lastServiceArg == &psb2); } @@ -203,7 +203,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { auto packetDest = AcceptsTmMock(destId, 2); PsbMock::setStaticTmDest(destId); REQUIRE(PsbMock::getStaticTmDest() == destId); - REQUIRE(psb2.initialize() == retval::OK); + REQUIRE(psb2.initialize() == result::OK); auto& p = psb2.getParams(); REQUIRE(p.tmReceiver == &packetDest); } @@ -214,7 +214,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { object_id_t reporterId = objects::TC_VERIFICATOR; PusVerificationReporterMock otherReporter(reporterId); auto psb2 = PsbMock(psbParams); - REQUIRE(psb2.initialize() == retval::OK); + REQUIRE(psb2.initialize() == result::OK); auto& p = psb2.getParams(); REQUIRE(p.verifReporter == &otherReporter); } @@ -224,7 +224,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { psbParams.tcPool = nullptr; psbParams.objectId = 1; auto psb2 = PsbMock(psbParams); - REQUIRE(psb2.initialize() == retval::OK); + REQUIRE(psb2.initialize() == result::OK); auto& p = psb2.getParams(); REQUIRE(p.tcPool == &tcStoreGlobal); } diff --git a/unittests/tmtcservices/testStoreAndSendHelper.cpp b/unittests/tmtcservices/testStoreAndSendHelper.cpp index 73051f8e..048ee092 100644 --- a/unittests/tmtcservices/testStoreAndSendHelper.cpp +++ b/unittests/tmtcservices/testStoreAndSendHelper.cpp @@ -41,13 +41,13 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(params.dataWrapper.dataUnion.raw.data == nullptr); REQUIRE(params.dataWrapper.dataUnion.raw.len == 0); REQUIRE(tmHelper.sendCounter == 0); - REQUIRE(tmHelper.storeAndSendTmPacket() == retval::OK); + REQUIRE(tmHelper.storeAndSendTmPacket() == result::OK); REQUIRE(tmHelper.sendCounter == 1); auto storeId = storeHelper.getCurrentAddr(); REQUIRE(msgQueue.wasMessageSent()); REQUIRE(msgQueue.numberOfSentMessagesToDefault() == 1); TmTcMessage msg; - REQUIRE(msgQueue.getNextSentMessage(msg) == retval::OK); + REQUIRE(msgQueue.getNextSentMessage(msg) == result::OK); REQUIRE(msg.getStorageId() == storeId); REQUIRE(pool.hasDataAtId(msg.getStorageId())); storeHelper.deletePacket(); @@ -55,7 +55,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { SECTION("Raw Data Helper") { std::array data = {1, 2, 3}; - REQUIRE(tmHelper.prepareTmPacket(2, data.data(), data.size()) == retval::OK); + REQUIRE(tmHelper.prepareTmPacket(2, data.data(), data.size()) == result::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); REQUIRE(params.dataWrapper.type == ecss::DataTypes::RAW); @@ -65,7 +65,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { SECTION("Serializable Helper") { auto simpleSer = SimpleSerializable(); - REQUIRE(tmHelper.prepareTmPacket(2, simpleSer) == retval::OK); + REQUIRE(tmHelper.prepareTmPacket(2, simpleSer) == result::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); REQUIRE(params.dataWrapper.type == ecss::DataTypes::SERIALIZABLE); @@ -76,7 +76,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { uint32_t objectId = 0x01020304; std::array data = {1, 2, 3}; telemetry::DataWithObjectIdPrefix dataWithObjId(objectId, data.data(), data.size()); - REQUIRE(tmHelper.prepareTmPacket(2, dataWithObjId) == retval::OK); + REQUIRE(tmHelper.prepareTmPacket(2, dataWithObjId) == result::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); REQUIRE(params.dataWrapper.type == ecss::DataTypes::SERIALIZABLE); From cb118176a02ac536bd94173548732319fac11ae8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 28 Jul 2022 13:24:50 +0200 Subject: [PATCH 155/532] completed ZcWriter unittests --- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 6 ++++ src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 10 +++++++ src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmReader.h | 31 ++++++++++++++++++++ src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp | 6 ++++ src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h | 7 +++++ unittests/tmtcpacket/testZcTmWriter.cpp | 21 ++++++++++++- 7 files changed, 81 insertions(+), 2 deletions(-) diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 63a5d45f..3a51fb68 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -19,6 +19,12 @@ struct PusTcParams { uint8_t pusVersion = ecss::PusVersion::PUS_C; }; +/** + * This class provides a high-level interface to create PUS TC packets and then @serialize + * them into a raw byte format. It implements @SerializeIF for that purpose. + * A custom time stamper can be set, with the implementation of @TimeStamperIF as the only + * requirement. + */ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF { public: PusTcCreator(SpacePacketParams initSpParams, PusTcParams initPusParams); diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index a7905858..9f3dcd24 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -39,8 +39,18 @@ struct PusTmParams { class TimeStamperIF; +/** + * This class provides a high-level interface to create PUS TM packets and then @serialize + * them into a raw byte format. It implements @SerializeIF for that purpose. + * A custom time stamper can be set, with the implementation of @TimeStamperIF as the only + * requirement. + */ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF { public: + /** + * Empty creator with all-default parameters. Please note that serializing this will + * generate an invalid PUS packet with no timestamp. + */ PusTmCreator(); PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams); ~PusTmCreator() override = default; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp index ca40562b..75abdbf6 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp @@ -86,6 +86,6 @@ ReturnValue_t PusTmReader::parseData(bool crcCheck) { } return HasReturnvaluesIF::RETURN_OK; } -bool PusTmReader::isNull() const { return spReader.isNull(); } +bool PusTmReader::isNull() const { return spReader.isNull() or pointers.secHeaderStart == nullptr; } PusTmReader::operator bool() const { return not isNull(); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h index c95fefae..c12bb4c8 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.h @@ -8,6 +8,18 @@ #include "fsfw/tmtcpacket/pus/RawUserDataReaderIF.h" #include "fsfw/tmtcpacket/pus/tm/PusTmIF.h" +/** + * This object can be used to read existing PUS TM packets in raw byte format. + * It is a zero-copy object, so reading a TM packet with will not copy anything. + * + * Please note that a parser function must be called after the constructor. This will also check + * the packet for validity. + * + * There are two parser function, where one does not perform the CRC check. This is useful + * if the CRC calculation will is performed in a separate step. + * This object also requires an explicit time stamp reader to allow flexibility in the used + * timestamp. + */ class PusTmReader : public PusTmIF, public RawUserDataReaderIF, public ReadablePacketIF, @@ -17,11 +29,30 @@ class PusTmReader : public PusTmIF, PusTmReader(const uint8_t* data, size_t size); PusTmReader(TimeReaderIF* timeReader, const uint8_t* data, size_t size); + /** + * No CRC check will be performed + * @return + */ ReturnValue_t parseDataWithoutCrcCheck(); + /** + * Performs a CRC check on the data as well + * @return + * - HasReturnvaluesIF::RETURN_OK: Successfully parsed the packet + * - SerializeIF::STREAM_TOO_SHORT: Stream too short for detected packet size + * - PusIF::INVALID_CRC_16 on invalid CRC + */ ReturnValue_t parseDataWithCrcCheck(); [[nodiscard]] const uint8_t* getFullData() const override; + /** + * Returns @isNull + * @return + */ explicit operator bool() const; + /** + * No (valid) data was set yet or the parse function was not called yet. + * @return + */ [[nodiscard]] bool isNull() const; void setTimeReader(TimeReaderIF* timeReader); TimeReaderIF* getTimeReader(); diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp index 6ca78378..6a9f6235 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.cpp @@ -6,12 +6,18 @@ PusTmZeroCopyWriter::PusTmZeroCopyWriter(TimeReaderIF& timeReader, uint8_t* data : PusTmReader(&timeReader, data, size) {} void PusTmZeroCopyWriter::setSequenceCount(uint16_t seqCount) { + if (isNull()) { + return; + } auto* spHeader = reinterpret_cast(const_cast((pointers.spHeaderStart))); ccsds::setSequenceCount(*spHeader, seqCount); } void PusTmZeroCopyWriter::updateErrorControl() { + if (isNull()) { + return; + } auto* crcStart = const_cast((pointers.crcStart)); uint16_t crc16 = CRC::crc16ccitt(PusTmReader::getFullData(), getFullPacketLen() - sizeof(ecss::PusChecksumT)); diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h index 331bda7f..36c43f51 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h @@ -2,6 +2,13 @@ #define FSFW_EXAMPLE_HOSTED_PUSTMZCWRITER_H #include "PusTmReader.h" + +/** + * This packet allows to update specific fields of a PUS TM packet where it is useful or necessary + * to update them in a second step. Otherwise, it offers the same interface as @PusTmReader. + * + * Right now, this class supports updating the CCSDS Sequence Count and the Error Control. + */ class PusTmZeroCopyWriter : public PusTmReader { public: PusTmZeroCopyWriter(TimeReaderIF& timeReader, uint8_t* data, size_t size); diff --git a/unittests/tmtcpacket/testZcTmWriter.cpp b/unittests/tmtcpacket/testZcTmWriter.cpp index c26b0069..fc013590 100644 --- a/unittests/tmtcpacket/testZcTmWriter.cpp +++ b/unittests/tmtcpacket/testZcTmWriter.cpp @@ -1,5 +1,6 @@ #include +#include "fsfw/globalfunctions/CRC.h" #include "fsfw/tmtcpacket/pus/tm.h" #include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" #include "mocks/CdsShortTimestamperMock.h" @@ -16,8 +17,26 @@ TEST_CASE("TM ZC Helper", "[tm-zc-helper]") { uint8_t* dataPtr = buf.data(); size_t serLen = 0; + SECTION("No Crash For Uninitialized Object") { + REQUIRE(creator.serialize(dataPtr, serLen, buf.size()) == result::OK); + PusTmZeroCopyWriter writer(timeStamper, dataPtr, serLen); + REQUIRE(writer.getSequenceCount() == 22); + writer.setSequenceCount(23); + // Can't set anything, parse function was not called + REQUIRE(writer.getSequenceCount() == 22); + writer.updateErrorControl(); + } + SECTION("Basic") { REQUIRE(creator.serialize(dataPtr, serLen, buf.size()) == result::OK); - PusTmZeroCopyWriter(timeStamper, dataPtr, serLen); + PusTmZeroCopyWriter writer(timeStamper, dataPtr, serLen); + REQUIRE(writer.parseDataWithoutCrcCheck() == result::OK); + REQUIRE(writer.getSequenceCount() == 22); + writer.setSequenceCount(23); + REQUIRE(writer.getSequenceCount() == 23); + // CRC is invalid now + REQUIRE(CRC::crc16ccitt(dataPtr, serLen) != 0); + writer.updateErrorControl(); + REQUIRE(CRC::crc16ccitt(dataPtr, serLen) == 0); } } \ No newline at end of file From 1b5fa2a8fa4692f83738aa76a06b123b3874f91d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 28 Jul 2022 13:37:07 +0200 Subject: [PATCH 156/532] test no crc generation --- unittests/tmtcpacket/testPusTmCreator.cpp | 9 +++++++++ unittests/tmtcpacket/testPusTmReader.cpp | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index 99c16550..4561a022 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -146,4 +146,13 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { SerializeIF::BUFFER_TOO_SHORT); } } + + SECTION("No CRC Generation") { + creator.disableCrcCalculation(); + REQUIRE(not creator.crcCalculationEnabled()); + REQUIRE(creator.serialize(dataPtr, serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(serLen == 22); + REQUIRE(buf[20] == 0x00); + REQUIRE(buf[21] == 0x00); + } } \ No newline at end of file diff --git a/unittests/tmtcpacket/testPusTmReader.cpp b/unittests/tmtcpacket/testPusTmReader.cpp index 3914db48..7967dba6 100644 --- a/unittests/tmtcpacket/testPusTmReader.cpp +++ b/unittests/tmtcpacket/testPusTmReader.cpp @@ -38,9 +38,10 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { readerPtr->setTimeReader(&timeStamperAndReader); deleteReader = true; } - REQUIRE(readerPtr); - REQUIRE(not readerPtr->isNull()); + REQUIRE(not *readerPtr); + REQUIRE(readerPtr->isNull()); REQUIRE(readerPtr->parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(not readerPtr->isNull()); REQUIRE(readerPtr->getService() == 17); REQUIRE(readerPtr->getSubService() == 2); REQUIRE(readerPtr->getApid() == 0xef); From 8f6f0e1d458236219f6570e0212d58dbc5de14da Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 28 Jul 2022 13:42:34 +0200 Subject: [PATCH 157/532] some more fail tests --- src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp | 6 ++++++ unittests/tmtcservices/testStoreAndSendHelper.cpp | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp index cab6db44..7d4c61d6 100644 --- a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp @@ -6,6 +6,12 @@ TmStoreAndSendWrapper::TmStoreAndSendWrapper(uint8_t defaultService, TmStoreHelp TmSendHelper& sendHelper) : storeHelper(storeHelper), sendHelper(sendHelper), defaultService(defaultService) {} +/** + * Helper wrapper which stores the TM packet into the store and then sends it. + * @return + * - StorageManagerIF returnvalue if storage fails + * - MessageQueueIF returnvalue if sending fails + */ ReturnValue_t TmStoreAndSendWrapper::storeAndSendTmPacket() { ReturnValue_t result = storeHelper.addPacketToStore(); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/unittests/tmtcservices/testStoreAndSendHelper.cpp b/unittests/tmtcservices/testStoreAndSendHelper.cpp index 048ee092..1163c33d 100644 --- a/unittests/tmtcservices/testStoreAndSendHelper.cpp +++ b/unittests/tmtcservices/testStoreAndSendHelper.cpp @@ -31,6 +31,13 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { CHECK(&tmHelper.storeHelper == &storeHelper); } + SECTION("Storage Fails") { + // Too large to fit in store + std::array data{}; + REQUIRE(storeHelper.setSourceDataRaw(data.data(), data.size()) == result::OK); + REQUIRE(tmHelper.storeAndSendTmPacket() == StorageManagerIF::DATA_TOO_LARGE); + } + SECTION("Base Test") { tmHelper.prepareTmPacket(2); auto& creator = storeHelper.getCreatorRef(); From fc3412fa35eb16fb8544c3c99bd202cbee463a1e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 28 Jul 2022 15:13:27 +0200 Subject: [PATCH 158/532] set sec header flag and add unit test for it --- src/fsfw/cfdp/CFDPMessage.cpp | 17 ------------- src/fsfw/cfdp/CMakeLists.txt | 2 +- .../cfdp/{CFDPHandler.cpp => CfdpHandler.cpp} | 24 +++++++++--------- .../cfdp/{CFDPHandler.h => CfdpHandler.h} | 6 ++--- src/fsfw/cfdp/CfdpMessage.cpp | 17 +++++++++++++ .../cfdp/{CFDPMessage.h => CfdpMessage.h} | 6 ++--- src/fsfw/storagemanager/PoolManager.cpp | 4 +-- src/fsfw/tcdistribution/CFDPDistributor.cpp | 2 +- .../tmtcpacket/ccsds/SpacePacketCreator.cpp | 2 ++ .../tmtcpacket/ccsds/SpacePacketCreator.h | 1 + src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 8 ++++-- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 1 + src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 1 + unittests/tmtcpacket/testPusTcCreator.cpp | 23 +++++++++-------- unittests/tmtcpacket/testPusTmCreator.cpp | 25 ++++++++++--------- 15 files changed, 75 insertions(+), 64 deletions(-) delete mode 100644 src/fsfw/cfdp/CFDPMessage.cpp rename src/fsfw/cfdp/{CFDPHandler.cpp => CfdpHandler.cpp} (66%) rename src/fsfw/cfdp/{CFDPHandler.h => CfdpHandler.h} (92%) create mode 100644 src/fsfw/cfdp/CfdpMessage.cpp rename src/fsfw/cfdp/{CFDPMessage.h => CfdpMessage.h} (89%) diff --git a/src/fsfw/cfdp/CFDPMessage.cpp b/src/fsfw/cfdp/CFDPMessage.cpp deleted file mode 100644 index da6fe15b..00000000 --- a/src/fsfw/cfdp/CFDPMessage.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "CFDPMessage.h" - -CFDPMessage::CFDPMessage() {} - -CFDPMessage::~CFDPMessage() {} - -void CFDPMessage::setCommand(CommandMessage *message, store_address_t cfdpPacket) { - message->setParameter(cfdpPacket.raw); -} - -store_address_t CFDPMessage::getStoreId(const CommandMessage *message) { - store_address_t storeAddressCFDPPacket; - storeAddressCFDPPacket = static_cast(message->getParameter()); - return storeAddressCFDPPacket; -} - -void CFDPMessage::clear(CommandMessage *message) {} diff --git a/src/fsfw/cfdp/CMakeLists.txt b/src/fsfw/cfdp/CMakeLists.txt index 0b926a9a..f2affbb4 100644 --- a/src/fsfw/cfdp/CMakeLists.txt +++ b/src/fsfw/cfdp/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE CFDPHandler.cpp CFDPMessage.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE CfdpHandler.cpp CfdpMessage.cpp) add_subdirectory(pdu) add_subdirectory(tlv) diff --git a/src/fsfw/cfdp/CFDPHandler.cpp b/src/fsfw/cfdp/CfdpHandler.cpp similarity index 66% rename from src/fsfw/cfdp/CFDPHandler.cpp rename to src/fsfw/cfdp/CfdpHandler.cpp index 96baa98c..caa64f56 100644 --- a/src/fsfw/cfdp/CFDPHandler.cpp +++ b/src/fsfw/cfdp/CfdpHandler.cpp @@ -1,24 +1,24 @@ -#include "fsfw/cfdp/CFDPHandler.h" +#include "fsfw/cfdp/CfdpHandler.h" -#include "fsfw/cfdp/CFDPMessage.h" +#include "fsfw/cfdp/CfdpMessage.h" #include "fsfw/ipc/CommandMessage.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/storagemanager/storeAddress.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -object_id_t CFDPHandler::packetSource = 0; -object_id_t CFDPHandler::packetDestination = 0; +object_id_t CfdpHandler::packetSource = 0; +object_id_t CfdpHandler::packetDestination = 0; -CFDPHandler::CFDPHandler(object_id_t setObjectId, CFDPDistributor* dist) +CfdpHandler::CfdpHandler(object_id_t setObjectId, CFDPDistributor* dist) : SystemObject(setObjectId) { requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION); distributor = dist; } -CFDPHandler::~CFDPHandler() {} +CfdpHandler::~CfdpHandler() = default; -ReturnValue_t CFDPHandler::initialize() { +ReturnValue_t CfdpHandler::initialize() { ReturnValue_t result = SystemObject::initialize(); if (result != RETURN_OK) { return result; @@ -27,7 +27,7 @@ ReturnValue_t CFDPHandler::initialize() { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) { +ReturnValue_t CfdpHandler::handleRequest(store_address_t storeId) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "CFDPHandler::handleRequest" << std::endl; @@ -41,17 +41,17 @@ ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) { return RETURN_OK; } -ReturnValue_t CFDPHandler::performOperation(uint8_t opCode) { +ReturnValue_t CfdpHandler::performOperation(uint8_t opCode) { ReturnValue_t status = RETURN_OK; CommandMessage currentMessage; for (status = this->requestQueue->receiveMessage(¤tMessage); status == RETURN_OK; status = this->requestQueue->receiveMessage(¤tMessage)) { - store_address_t storeId = CFDPMessage::getStoreId(¤tMessage); + store_address_t storeId = CfdpMessage::getStoreId(¤tMessage); this->handleRequest(storeId); } return RETURN_OK; } -uint16_t CFDPHandler::getIdentifier() { return 0; } +uint16_t CfdpHandler::getIdentifier() { return 0; } -MessageQueueId_t CFDPHandler::getRequestQueue() { return this->requestQueue->getId(); } +MessageQueueId_t CfdpHandler::getRequestQueue() { return this->requestQueue->getId(); } diff --git a/src/fsfw/cfdp/CFDPHandler.h b/src/fsfw/cfdp/CfdpHandler.h similarity index 92% rename from src/fsfw/cfdp/CFDPHandler.h rename to src/fsfw/cfdp/CfdpHandler.h index 3e6f0429..01399e98 100644 --- a/src/fsfw/cfdp/CFDPHandler.h +++ b/src/fsfw/cfdp/CfdpHandler.h @@ -12,18 +12,18 @@ namespace Factory { void setStaticFrameworkObjectIds(); } -class CFDPHandler : public ExecutableObjectIF, +class CfdpHandler : public ExecutableObjectIF, public AcceptsTelecommandsIF, public SystemObject, public HasReturnvaluesIF { friend void(Factory::setStaticFrameworkObjectIds)(); public: - CFDPHandler(object_id_t setObjectId, CFDPDistributor* distributor); + CfdpHandler(object_id_t setObjectId, CFDPDistributor* distributor); /** * The destructor is empty. */ - virtual ~CFDPHandler(); + virtual ~CfdpHandler(); virtual ReturnValue_t handleRequest(store_address_t storeId); diff --git a/src/fsfw/cfdp/CfdpMessage.cpp b/src/fsfw/cfdp/CfdpMessage.cpp new file mode 100644 index 00000000..ea4e2c98 --- /dev/null +++ b/src/fsfw/cfdp/CfdpMessage.cpp @@ -0,0 +1,17 @@ +#include "CfdpMessage.h" + +CfdpMessage::CfdpMessage() = default; + +CfdpMessage::~CfdpMessage() = default; + +void CfdpMessage::setCommand(CommandMessage *message, store_address_t cfdpPacket) { + message->setParameter(cfdpPacket.raw); +} + +store_address_t CfdpMessage::getStoreId(const CommandMessage *message) { + store_address_t storeId; + storeId = static_cast(message->getParameter()); + return storeId; +} + +void CfdpMessage::clear(CommandMessage *message) {} diff --git a/src/fsfw/cfdp/CFDPMessage.h b/src/fsfw/cfdp/CfdpMessage.h similarity index 89% rename from src/fsfw/cfdp/CFDPMessage.h rename to src/fsfw/cfdp/CfdpMessage.h index 3de723eb..a3ee9421 100644 --- a/src/fsfw/cfdp/CFDPMessage.h +++ b/src/fsfw/cfdp/CfdpMessage.h @@ -5,14 +5,14 @@ #include "fsfw/objectmanager/ObjectManagerIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" -class CFDPMessage { +class CfdpMessage { private: - CFDPMessage(); + CfdpMessage(); public: static const uint8_t MESSAGE_ID = messagetypes::CFDP; - virtual ~CFDPMessage(); + virtual ~CfdpMessage(); static void setCommand(CommandMessage* message, store_address_t cfdpPacket); static store_address_t getStoreId(const CommandMessage* message); diff --git a/src/fsfw/storagemanager/PoolManager.cpp b/src/fsfw/storagemanager/PoolManager.cpp index 92de1dfe..41e140b2 100644 --- a/src/fsfw/storagemanager/PoolManager.cpp +++ b/src/fsfw/storagemanager/PoolManager.cpp @@ -7,7 +7,7 @@ PoolManager::PoolManager(object_id_t setObjectId, const LocalPoolConfig& localPo mutex = MutexFactory::instance()->createMutex(); } -PoolManager::~PoolManager(void) { MutexFactory::instance()->deleteMutex(mutex); } +PoolManager::~PoolManager() { MutexFactory::instance()->deleteMutex(mutex); } ReturnValue_t PoolManager::reserveSpace(const size_t size, store_address_t* address, bool ignoreFault) { @@ -17,7 +17,7 @@ ReturnValue_t PoolManager::reserveSpace(const size_t size, store_address_t* addr } ReturnValue_t PoolManager::deleteData(store_address_t storeId) { -#if FSFW_VERBOSE_LEVEL >= 2 +#if FSFW_VERBOSE_LEVEL >= 2 && FSFW_OBJ_EVENT_TRANSLATION == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "PoolManager( " << translateObject(getObjectId()) << " )::deleteData from store " << storeId.poolIndex << ". id is " << storeId.packetIndex << std::endl; diff --git a/src/fsfw/tcdistribution/CFDPDistributor.cpp b/src/fsfw/tcdistribution/CFDPDistributor.cpp index 0e6f968c..d7a02793 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.cpp +++ b/src/fsfw/tcdistribution/CFDPDistributor.cpp @@ -72,7 +72,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) { uint16_t handlerId = - handler->getIdentifier(); // should be 0, because CFDPHandler does not set a set a service-ID + handler->getIdentifier(); // should be 0, because CfdpHandler does not set a set a service-ID #if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast(handlerId) diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp index 20c9341f..ee27cc9b 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp @@ -83,3 +83,5 @@ void SpacePacketCreator::setPacketType(ccsds::PacketType type) { bool SpacePacketCreator::operator==(const SpacePacketCreator &other) const { return false; } SpacePacketCreator::operator bool() const { return isValid(); } + +void SpacePacketCreator::setSecHeaderFlag() { params.packetId.secHeaderFlag = true; } diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h index 9c13bd5a..5869560d 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h @@ -39,6 +39,7 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF { SpacePacketParams &getParams(); void setParams(SpacePacketParams params); + void setSecHeaderFlag(); void setPacketType(ccsds::PacketType type); void setApid(uint16_t apid); void setSeqCount(uint16_t seqCount); diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index be472051..2e786e6e 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -8,8 +8,7 @@ PusTcCreator::PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams) : spCreator(std::move(spParams)), pusParams(pusParams) { - spCreator.setPacketType(ccsds::PacketType::TC); - updateSpLengthField(); + setup(); } ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, @@ -111,3 +110,8 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max ReturnValue_t PusTcCreator::serialize(uint8_t *buffer, size_t &serLen, size_t maxSize) const { return SerializeIF::serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK); } +void PusTcCreator::setup() { + spCreator.setPacketType(ccsds::PacketType::TC); + spCreator.setSecHeaderFlag(); + updateSpLengthField(); +} diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 3a51fb68..ea6c1d58 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -61,6 +61,7 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF // Forbidden to use ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; + void setup(); SpacePacketCreator spCreator; PusTcParams pusParams; }; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index d80182ed..64dbbfeb 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -124,6 +124,7 @@ void PusTmCreator::setApid(uint16_t apid) { spCreator.setApid(apid); } void PusTmCreator::setup() { updateSpLengthField(); spCreator.setPacketType(ccsds::PacketType::TM); + spCreator.setSecHeaderFlag(); } void PusTmCreator::setMessageTypeCounter(uint16_t messageTypeCounter) { diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index ff9b6399..5bc349a6 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -16,20 +16,21 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { size_t serLen = 0; SECTION("State") { - REQUIRE(creator.isTc()); - REQUIRE(creator.getService() == 17); - REQUIRE(creator.getSubService() == 1); - REQUIRE(creator.getApid() == 0x02); - REQUIRE(creator.getPusVersion() == 2); - REQUIRE(creator.getAcknowledgeFlags() == 0b1111); - REQUIRE(creator.getSourceId() == 0x00); - REQUIRE(creator.getPacketSeqCtrlRaw() == 0xc034); + CHECK(creator.isTc()); + CHECK(creator.hasSecHeader()); + CHECK(creator.getService() == 17); + CHECK(creator.getSubService() == 1); + CHECK(creator.getApid() == 0x02); + CHECK(creator.getPusVersion() == 2); + CHECK(creator.getAcknowledgeFlags() == 0b1111); + CHECK(creator.getSourceId() == 0x00); + CHECK(creator.getPacketSeqCtrlRaw() == 0xc034); // bytes CCSDS header, 5 bytes secondary header, 2 bytes CRC, 3 bytes app data - REQUIRE(creator.getFullPacketLen() == 13); + CHECK(creator.getFullPacketLen() == 13); // The data length field is the full packet length minus the primary header minus 1 - REQUIRE(creator.getPacketDataLen() == 6); + CHECK(creator.getPacketDataLen() == 6); auto& paramsLocal = creator.getSpParams(); - REQUIRE(paramsLocal.packetId == packetId); + CHECK(paramsLocal.packetId == packetId); } SECTION("Serialized") { diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index 4561a022..f32e060f 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -19,22 +19,23 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { size_t serLen = 0; SECTION("State") { - REQUIRE(creator.isTm()); - REQUIRE(creator.getApid() == 0xef); - REQUIRE(creator.getPusVersion() == 2); - REQUIRE(creator.getScTimeRefStatus() == 0); - REQUIRE(creator.getService() == 17); - REQUIRE(creator.getSubService() == 2); - REQUIRE(creator.getTimestamper() == &timeStamper); - REQUIRE(creator.getSequenceFlags() == ccsds::SequenceFlags::UNSEGMENTED); - REQUIRE(creator.getSequenceCount() == 22); + CHECK(creator.isTm()); + CHECK(creator.hasSecHeader()); + CHECK(creator.getApid() == 0xef); + CHECK(creator.getPusVersion() == 2); + CHECK(creator.getScTimeRefStatus() == 0); + CHECK(creator.getService() == 17); + CHECK(creator.getSubService() == 2); + CHECK(creator.getTimestamper() == &timeStamper); + CHECK(creator.getSequenceFlags() == ccsds::SequenceFlags::UNSEGMENTED); + CHECK(creator.getSequenceCount() == 22); // 6 bytes CCSDS header, 7 bytes secondary header, 7 bytes CDS short timestamp, // 0 bytes application data, 2 bytes CRC - REQUIRE(creator.getFullPacketLen() == 22); + CHECK(creator.getFullPacketLen() == 22); // As specified in standard, the data length fields is the total size of the packet without // the primary header minus 1 - REQUIRE(creator.getPacketDataLen() == 15); - REQUIRE(timeStamper.getSizeCallCount == 1); + CHECK(creator.getPacketDataLen() == 15); + CHECK(timeStamper.getSizeCallCount == 1); } SECTION("SP Params") { From da106fd96ffc9e59d95b514eb5d7eaf281f013ae Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 29 Jul 2022 10:23:59 +0200 Subject: [PATCH 159/532] do not use TC info for failed TC retrieval --- .../tmtcservices/CommandingServiceBase.cpp | 43 +++++++++++++++---- src/fsfw/tmtcservices/CommandingServiceBase.h | 20 +++++++-- .../tmtcservices/VerificationReporterIF.h | 22 +++++++--- 3 files changed, 69 insertions(+), 16 deletions(-) diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index ded92926..d7e3b514 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -267,8 +267,7 @@ void CommandingServiceBase::handleRequestQueue() { address = message.getStorageId(); result = setUpTcReader(address); if (result != HasReturnvaluesIF::RETURN_OK) { - // TODO: Warning? - rejectPacket(tcverif::START_FAILURE, address, result); + rejectPacketInvalidTc(result, address); continue; } if ((tcReader.getSubService() == 0) or @@ -384,15 +383,29 @@ void CommandingServiceBase::startExecution(store_address_t storeId, CommandMapIt } } -void CommandingServiceBase::rejectPacket(uint8_t reportId, store_address_t tcStoreId, - ReturnValue_t errorCode) { - verificationReporter->sendFailureReport(VerifFailureParams(reportId, tcReader, errorCode)); - tcStore->deleteData(tcStoreId); +ReturnValue_t CommandingServiceBase::rejectPacketInvalidTc(ReturnValue_t errorCode, + store_address_t tcStoreId) { + failureParameter1 = INVALID_TC; + prepareVerificationFailureWithNoTcInfo(tcverif::START_FAILURE, errorCode, true); + if (tcStoreId != store_address_t::invalid()) { + tcStore->deleteData(tcStoreId); + } + return verificationReporter->sendFailureReport(failParams); } -void CommandingServiceBase::acceptPacket(uint8_t reportId, store_address_t tcStoreId) { - verificationReporter->sendSuccessReport(VerifSuccessParams(reportId, tcReader)); +ReturnValue_t CommandingServiceBase::rejectPacket(uint8_t reportId, store_address_t tcStoreId, + ReturnValue_t errorCode) { + ReturnValue_t result = + verificationReporter->sendFailureReport(VerifFailureParams(reportId, tcReader, errorCode)); tcStore->deleteData(tcStoreId); + return result; +} + +ReturnValue_t CommandingServiceBase::acceptPacket(uint8_t reportId, store_address_t tcStoreId) { + ReturnValue_t result = + verificationReporter->sendSuccessReport(VerifSuccessParams(reportId, tcReader)); + tcStore->deleteData(tcStoreId); + return result; } void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) { @@ -437,10 +450,23 @@ void CommandingServiceBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = t void CommandingServiceBase::setCustomTmStore(StorageManagerIF& store) { tmStoreHelper.setTmStore(store); } + ReturnValue_t CommandingServiceBase::setUpTcReader(store_address_t storeId) { return tc::prepareTcReader(*tcStore, storeId, tcReader); } +void CommandingServiceBase::prepareVerificationFailureWithNoTcInfo(uint8_t reportId, + ReturnValue_t errorCode, + bool setCachedFailParams) { + failParams.resetTcFields(); + failParams.resetFailParams(); + failParams.reportId = reportId; + failParams.errorCode = errorCode; + if (setCachedFailParams) { + failParams.errorParam1 = failureParameter1; + failParams.errorParam2 = failureParameter2; + } +} void CommandingServiceBase::prepareVerificationFailureWithFullInfo(uint8_t reportId, CommandInfo::TcInfo& tcInfo, ReturnValue_t errorCode, @@ -449,6 +475,7 @@ void CommandingServiceBase::prepareVerificationFailureWithFullInfo(uint8_t repor failParams.tcPacketId = tcInfo.tcPacketId; failParams.tcPsc = tcInfo.tcSequenceControl; failParams.ackFlags = tcInfo.ackFlags; + failParams.resetFailParams(); failParams.errorCode = errorCode; if (setCachedFailParams) { failParams.errorParam1 = failureParameter1; diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index f9070d17..c16d9ded 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -52,7 +52,13 @@ class CommandingServiceBase : public SystemObject, static const ReturnValue_t EXECUTION_COMPLETE = MAKE_RETURN_CODE(1); static const ReturnValue_t NO_STEP_MESSAGE = MAKE_RETURN_CODE(2); + /** + * Target object has too many pending requests + */ static const ReturnValue_t OBJECT_BUSY = MAKE_RETURN_CODE(3); + /** + * Command map is full + */ static const ReturnValue_t BUSY = MAKE_RETURN_CODE(4); static const ReturnValue_t INVALID_TC = MAKE_RETURN_CODE(5); static const ReturnValue_t INVALID_OBJECT = MAKE_RETURN_CODE(6); @@ -330,16 +336,24 @@ class CommandingServiceBase : public SystemObject, ReturnValue_t setUpTcReader(store_address_t storeId); - void rejectPacket(uint8_t reportId, store_address_t tcStoreId, ReturnValue_t errorCode); + /** + * The TC format is invalid or there was an issue retrieving a TC packet from the store. + * @param errorCode Result of the failed operation, will be sent with the verification failure + * message + * @return + */ + ReturnValue_t rejectPacketInvalidTc(ReturnValue_t errorCode, store_address_t tcStoreId); + ReturnValue_t rejectPacket(uint8_t reportId, store_address_t tcStoreId, ReturnValue_t errorCode); - void acceptPacket(uint8_t reportId, store_address_t tcStoreId); + ReturnValue_t acceptPacket(uint8_t reportId, store_address_t tcStoreId); void startExecution(store_address_t storeId, CommandMapIter& iter); void handleCommandMessage(CommandMessage* reply); void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter, CommandMessage* nextCommand, CommandMessage* reply, bool& isStep); - + void prepareVerificationFailureWithNoTcInfo(uint8_t reportId, ReturnValue_t errorCode, + bool setCachedFailParams); void prepareVerificationFailureWithFullInfo(uint8_t reportId, CommandInfo::TcInfo& tcInfo, ReturnValue_t errorCode, bool setCachedFailParams); void prepareVerificationSuccessWithFullInfo(uint8_t reportId, CommandInfo::TcInfo& tcInfo); diff --git a/src/fsfw/tmtcservices/VerificationReporterIF.h b/src/fsfw/tmtcservices/VerificationReporterIF.h index 6678c630..df0d5a38 100644 --- a/src/fsfw/tmtcservices/VerificationReporterIF.h +++ b/src/fsfw/tmtcservices/VerificationReporterIF.h @@ -13,6 +13,12 @@ struct VerifParamsBase { uint16_t tcPsc; uint8_t ackFlags = ecss::ACK_ALL; uint8_t step = 0; + + void resetTcFields() { + tcPacketId = 0; + tcPsc = 0; + ackFlags = 0; + } }; struct VerifSuccessParams : public VerifParamsBase { @@ -27,10 +33,10 @@ struct VerifFailureParams : public VerifParamsBase { VerifFailureParams() = default; VerifFailureParams(uint8_t reportId, uint16_t tcPacketId, uint16_t tcPsc, ReturnValue_t errorCode, uint32_t errorParam1, uint32_t errorParams2) - : VerifParamsBase(reportId, tcPacketId, tcPsc), errorCode(errorCode) { - errorParam1 = errorParam1; - errorParams2 = errorParams2; - } + : VerifParamsBase(reportId, tcPacketId, tcPsc), + errorCode(errorCode), + errorParam1(errorParam1), + errorParam2(errorParams2) {} VerifFailureParams(uint8_t reportId, uint16_t tcPacketId, uint16_t tcPsc, ReturnValue_t errorCode) : VerifParamsBase(reportId, tcPacketId, tcPsc), errorCode(errorCode) {} VerifFailureParams(uint8_t reportId, uint16_t tcPacketId, uint16_t tcPsc) @@ -41,7 +47,13 @@ struct VerifFailureParams : public VerifParamsBase { VerifFailureParams(uint8_t reportId, PusTcIF& tc) : VerifParamsBase(reportId, tc.getPacketIdRaw(), tc.getPacketSeqCtrlRaw()) {} - ReturnValue_t errorCode = result::OK; + void resetFailParams() { + errorCode = result::FAILED; + errorParam1 = 0; + errorParam2 = 0; + } + + ReturnValue_t errorCode = result::FAILED; uint8_t step = 0; uint32_t errorParam1 = 0; uint32_t errorParam2 = 0; From 6c5bbfa080ad9bf70d714d686095d08478340502 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 29 Jul 2022 12:03:14 +0200 Subject: [PATCH 160/532] some renaming --- src/fsfw/cfdp/CfdpHandler.cpp | 2 +- src/fsfw/cfdp/CfdpHandler.h | 6 ++--- src/fsfw/tcdistribution/CMakeLists.txt | 4 ++-- ...DSDistributor.cpp => CcsdsDistributor.cpp} | 20 ++++++++--------- ...{CCSDSDistributor.h => CcsdsDistributor.h} | 12 +++++----- ...DSDistributorIF.h => CcsdsDistributorIF.h} | 4 ++-- ...FDPDistributor.cpp => CfdpDistributor.cpp} | 22 +++++++++---------- .../{CFDPDistributor.h => CfdpDistributor.h} | 12 +++++----- ...FDPDistributorIF.h => CfdpDistributorIF.h} | 4 ++-- src/fsfw/tcdistribution/PusDistributor.cpp | 6 ++--- src/fsfw/tcdistribution/PusDistributor.h | 12 +++++----- ...{PUSDistributorIF.h => PusDistributorIF.h} | 4 ++-- src/fsfw/tcdistribution/TcDistributor.h | 14 ++++++------ .../tmtcservices/CommandingServiceBase.cpp | 4 ++-- src/fsfw/tmtcservices/PusServiceBase.cpp | 6 ++--- src/fsfw/tmtcservices/PusServiceBase.h | 6 ++--- unittests/mocks/PusDistributorMock.h | 4 ++-- 17 files changed, 71 insertions(+), 71 deletions(-) rename src/fsfw/tcdistribution/{CCSDSDistributor.cpp => CcsdsDistributor.cpp} (85%) rename src/fsfw/tcdistribution/{CCSDSDistributor.h => CcsdsDistributor.h} (88%) rename src/fsfw/tcdistribution/{CCSDSDistributorIF.h => CcsdsDistributorIF.h} (95%) rename src/fsfw/tcdistribution/{CFDPDistributor.cpp => CfdpDistributor.cpp} (87%) rename src/fsfw/tcdistribution/{CFDPDistributor.h => CfdpDistributor.h} (88%) rename src/fsfw/tcdistribution/{CFDPDistributorIF.h => CfdpDistributorIF.h} (91%) rename src/fsfw/tcdistribution/{PUSDistributorIF.h => PusDistributorIF.h} (91%) diff --git a/src/fsfw/cfdp/CfdpHandler.cpp b/src/fsfw/cfdp/CfdpHandler.cpp index caa64f56..cb13bca6 100644 --- a/src/fsfw/cfdp/CfdpHandler.cpp +++ b/src/fsfw/cfdp/CfdpHandler.cpp @@ -10,7 +10,7 @@ object_id_t CfdpHandler::packetSource = 0; object_id_t CfdpHandler::packetDestination = 0; -CfdpHandler::CfdpHandler(object_id_t setObjectId, CFDPDistributor* dist) +CfdpHandler::CfdpHandler(object_id_t setObjectId, CfdpDistributor* dist) : SystemObject(setObjectId) { requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION); distributor = dist; diff --git a/src/fsfw/cfdp/CfdpHandler.h b/src/fsfw/cfdp/CfdpHandler.h index 01399e98..03424d64 100644 --- a/src/fsfw/cfdp/CfdpHandler.h +++ b/src/fsfw/cfdp/CfdpHandler.h @@ -5,7 +5,7 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/tcdistribution/CFDPDistributor.h" +#include "fsfw/tcdistribution/CfdpDistributor.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" namespace Factory { @@ -19,7 +19,7 @@ class CfdpHandler : public ExecutableObjectIF, friend void(Factory::setStaticFrameworkObjectIds)(); public: - CfdpHandler(object_id_t setObjectId, CFDPDistributor* distributor); + CfdpHandler(object_id_t setObjectId, CfdpDistributor* distributor); /** * The destructor is empty. */ @@ -39,7 +39,7 @@ class CfdpHandler : public ExecutableObjectIF, */ MessageQueueIF* requestQueue = nullptr; - CFDPDistributor* distributor = nullptr; + CfdpDistributor* distributor = nullptr; /** * The current CFDP packet to be processed. diff --git a/src/fsfw/tcdistribution/CMakeLists.txt b/src/fsfw/tcdistribution/CMakeLists.txt index 532ba2ca..f1762ff4 100644 --- a/src/fsfw/tcdistribution/CMakeLists.txt +++ b/src/fsfw/tcdistribution/CMakeLists.txt @@ -1,9 +1,9 @@ target_sources( ${LIB_FSFW_NAME} - PRIVATE CCSDSDistributor.cpp + PRIVATE CcsdsDistributor.cpp PusDistributor.cpp TcDistributor.cpp PusPacketChecker.cpp TcPacketCheckCFDP.cpp - CFDPDistributor.cpp + CfdpDistributor.cpp CcsdsPacketChecker.cpp) diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp similarity index 85% rename from src/fsfw/tcdistribution/CCSDSDistributor.cpp rename to src/fsfw/tcdistribution/CcsdsDistributor.cpp index 7c2974a4..d263d68a 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -1,4 +1,4 @@ -#include "fsfw/tcdistribution/CCSDSDistributor.h" +#include "fsfw/tcdistribution/CcsdsDistributor.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" @@ -6,13 +6,13 @@ #define CCSDS_DISTRIBUTOR_DEBUGGING 0 -CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId, +CcsdsDistributor::CcsdsDistributor(uint16_t setDefaultApid, object_id_t setObjectId, CcsdsPacketCheckIF* packetChecker) : TcDistributor(setObjectId), defaultApid(setDefaultApid), packetChecker(packetChecker) {} -CCSDSDistributor::~CCSDSDistributor() = default; +CcsdsDistributor::~CcsdsDistributor() = default; -TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { +TcDistributor::TcMqMapIter CcsdsDistributor::selectDestination() { #if CCSDS_DISTRIBUTOR_DEBUGGING == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "CCSDSDistributor::selectDestination received: " @@ -59,9 +59,9 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { } } -MessageQueueId_t CCSDSDistributor::getRequestQueue() { return tcQueue->getId(); } +MessageQueueId_t CcsdsDistributor::getRequestQueue() { return tcQueue->getId(); } -ReturnValue_t CCSDSDistributor::registerApplication(AcceptsTelecommandsIF* application) { +ReturnValue_t CcsdsDistributor::registerApplication(AcceptsTelecommandsIF* application) { ReturnValue_t returnValue = RETURN_OK; auto insertPair = this->queueMap.emplace(application->getIdentifier(), application->getRequestQueue()); @@ -71,7 +71,7 @@ ReturnValue_t CCSDSDistributor::registerApplication(AcceptsTelecommandsIF* appli return returnValue; } -ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid, MessageQueueId_t id) { +ReturnValue_t CcsdsDistributor::registerApplication(uint16_t apid, MessageQueueId_t id) { ReturnValue_t returnValue = RETURN_OK; auto insertPair = this->queueMap.emplace(apid, id); if (not insertPair.second) { @@ -80,9 +80,9 @@ ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid, MessageQueueI return returnValue; } -uint16_t CCSDSDistributor::getIdentifier() { return 0; } +uint16_t CcsdsDistributor::getIdentifier() { return 0; } -ReturnValue_t CCSDSDistributor::initialize() { +ReturnValue_t CcsdsDistributor::initialize() { if (packetChecker == nullptr) { packetChecker = new CcsdsPacketChecker(ccsds::PacketType::TC); } @@ -105,7 +105,7 @@ ReturnValue_t CCSDSDistributor::initialize() { return status; } -ReturnValue_t CCSDSDistributor::callbackAfterSending(ReturnValue_t queueStatus) { +ReturnValue_t CcsdsDistributor::callbackAfterSending(ReturnValue_t queueStatus) { if (queueStatus != RETURN_OK) { tcStore->deleteData(currentMessage.getStorageId()); } diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.h b/src/fsfw/tcdistribution/CcsdsDistributor.h similarity index 88% rename from src/fsfw/tcdistribution/CCSDSDistributor.h rename to src/fsfw/tcdistribution/CcsdsDistributor.h index d6e4f0e7..ea7ad7e2 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.h +++ b/src/fsfw/tcdistribution/CcsdsDistributor.h @@ -3,21 +3,21 @@ #include "fsfw/objectmanager/ObjectManagerIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/tcdistribution/CCSDSDistributorIF.h" +#include "fsfw/tcdistribution/CcsdsDistributorIF.h" #include "fsfw/tcdistribution/CcsdsPacketChecker.h" #include "fsfw/tcdistribution/TcDistributor.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" /** - * @brief An instantiation of the CCSDSDistributorIF. + * @brief An instantiation of the CcsdsDistributorIF. * @details * It receives Space Packets, and selects a destination depending on the * APID of the telecommands. * The Secondary Header (with Service/Subservice) is ignored. * @ingroup tc_distribution */ -class CCSDSDistributor : public TcDistributor, - public CCSDSDistributorIF, +class CcsdsDistributor : public TcDistributor, + public CcsdsDistributorIF, public AcceptsTelecommandsIF { public: /** @@ -28,12 +28,12 @@ class CCSDSDistributor : public TcDistributor, * @param unknownApid The default APID, where packets with unknown * destination are sent to. */ - CCSDSDistributor(uint16_t unknownApid, object_id_t setObjectId, + CcsdsDistributor(uint16_t unknownApid, object_id_t setObjectId, CcsdsPacketCheckIF* packetChecker = nullptr); /** * The destructor is empty. */ - ~CCSDSDistributor() override; + ~CcsdsDistributor() override; MessageQueueId_t getRequestQueue() override; ReturnValue_t registerApplication(uint16_t apid, MessageQueueId_t id) override; diff --git a/src/fsfw/tcdistribution/CCSDSDistributorIF.h b/src/fsfw/tcdistribution/CcsdsDistributorIF.h similarity index 95% rename from src/fsfw/tcdistribution/CCSDSDistributorIF.h rename to src/fsfw/tcdistribution/CcsdsDistributorIF.h index da4a943f..d5a26bef 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributorIF.h +++ b/src/fsfw/tcdistribution/CcsdsDistributorIF.h @@ -11,7 +11,7 @@ * to route the TC's to. * @ingroup tc_distribution */ -class CCSDSDistributorIF { +class CcsdsDistributorIF { public: /** * With this call, a class implementing the CCSDSApplicationIF can register @@ -34,7 +34,7 @@ class CCSDSDistributorIF { /** * The empty virtual destructor. */ - virtual ~CCSDSDistributorIF() = default; + virtual ~CcsdsDistributorIF() = default; }; #endif /* FSFW_TCDISTRIBUTION_CCSDSDISTRIBUTORIF_H_ */ diff --git a/src/fsfw/tcdistribution/CFDPDistributor.cpp b/src/fsfw/tcdistribution/CfdpDistributor.cpp similarity index 87% rename from src/fsfw/tcdistribution/CFDPDistributor.cpp rename to src/fsfw/tcdistribution/CfdpDistributor.cpp index d7a02793..1f380530 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.cpp +++ b/src/fsfw/tcdistribution/CfdpDistributor.cpp @@ -1,14 +1,14 @@ -#include "fsfw/tcdistribution/CFDPDistributor.h" +#include "fsfw/tcdistribution/CfdpDistributor.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/tcdistribution/CCSDSDistributorIF.h" +#include "fsfw/tcdistribution/CcsdsDistributorIF.h" #include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h" #ifndef FSFW_CFDP_DISTRIBUTOR_DEBUGGING #define FSFW_CFDP_DISTRIBUTOR_DEBUGGING 1 #endif -CFDPDistributor::CFDPDistributor(uint16_t setApid, object_id_t setObjectId, +CfdpDistributor::CfdpDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource) : TcDistributor(setObjectId), apid(setApid), @@ -16,9 +16,9 @@ CFDPDistributor::CFDPDistributor(uint16_t setApid, object_id_t setObjectId, tcStatus(RETURN_FAILED), packetSource(setPacketSource) {} -CFDPDistributor::~CFDPDistributor() = default; +CfdpDistributor::~CfdpDistributor() = default; -CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { +CfdpDistributor::TcMqMapIter CfdpDistributor::selectDestination() { #if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 store_address_t storeId = this->currentMessage.getStorageId(); #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -70,7 +70,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { } } -ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) { +ReturnValue_t CfdpDistributor::registerHandler(AcceptsTelecommandsIF* handler) { uint16_t handlerId = handler->getIdentifier(); // should be 0, because CfdpHandler does not set a set a service-ID #if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 @@ -98,7 +98,7 @@ ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) { return HasReturnvaluesIF::RETURN_OK; } -MessageQueueId_t CFDPDistributor::getRequestQueue() { return tcQueue->getId(); } +MessageQueueId_t CfdpDistributor::getRequestQueue() { return tcQueue->getId(); } // ReturnValue_t CFDPDistributor::callbackAfterSending(ReturnValue_t queueStatus) { // if (queueStatus != RETURN_OK) { @@ -118,23 +118,23 @@ MessageQueueId_t CFDPDistributor::getRequestQueue() { return tcQueue->getId(); } // } // } -uint16_t CFDPDistributor::getIdentifier() { return this->apid; } +uint16_t CfdpDistributor::getIdentifier() { return this->apid; } -ReturnValue_t CFDPDistributor::initialize() { +ReturnValue_t CfdpDistributor::initialize() { currentPacket = new CfdpPacketStored(); if (currentPacket == nullptr) { // Should not happen, memory allocation failed! return ObjectManagerIF::CHILD_INIT_FAILED; } - auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); + auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); if (ccsdsDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl; sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; #else sif::printError("CFDPDistributor::initialize: Packet source invalid\n"); - sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); + sif::printError("Make sure it exists and implements CcsdsDistributorIF\n"); #endif return RETURN_FAILED; } diff --git a/src/fsfw/tcdistribution/CFDPDistributor.h b/src/fsfw/tcdistribution/CfdpDistributor.h similarity index 88% rename from src/fsfw/tcdistribution/CFDPDistributor.h rename to src/fsfw/tcdistribution/CfdpDistributor.h index e7776f1b..181d3613 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.h +++ b/src/fsfw/tcdistribution/CfdpDistributor.h @@ -7,7 +7,7 @@ #include "../tmtcpacket/cfdp/CfdpPacketStored.h" #include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../tmtcservices/VerificationReporter.h" -#include "CFDPDistributorIF.h" +#include "CfdpDistributorIF.h" #include "TcDistributor.h" /** @@ -15,8 +15,8 @@ * services. * @ingroup tc_distribution */ -class CFDPDistributor : public TcDistributor, - public CFDPDistributorIF, +class CfdpDistributor : public TcDistributor, + public CfdpDistributorIF, public AcceptsTelecommandsIF { public: /** @@ -25,13 +25,13 @@ class CFDPDistributor : public TcDistributor, * @param setApid The APID of this receiving Application. * @param setObjectId Object ID of the distributor itself * @param setPacketSource Object ID of the source of TC packets. - * Must implement CCSDSDistributorIF. + * Must implement CcsdsDistributorIF. */ - CFDPDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource); + CfdpDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource); /** * The destructor is empty. */ - ~CFDPDistributor() override; + ~CfdpDistributor() override; ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) override; MessageQueueId_t getRequestQueue() override; ReturnValue_t initialize() override; diff --git a/src/fsfw/tcdistribution/CFDPDistributorIF.h b/src/fsfw/tcdistribution/CfdpDistributorIF.h similarity index 91% rename from src/fsfw/tcdistribution/CFDPDistributorIF.h rename to src/fsfw/tcdistribution/CfdpDistributorIF.h index 3f048bbf..660a9709 100644 --- a/src/fsfw/tcdistribution/CFDPDistributorIF.h +++ b/src/fsfw/tcdistribution/CfdpDistributorIF.h @@ -8,12 +8,12 @@ * This interface allows CFDP Services to register themselves at a CFDP Distributor. * @ingroup tc_distribution */ -class CFDPDistributorIF { +class CfdpDistributorIF { public: /** * The empty virtual destructor. */ - virtual ~CFDPDistributorIF() = default; + virtual ~CfdpDistributorIF() = default; /** * With this method, Handlers can register themselves at the CFDP Distributor. * @param handler A pointer to the registering Handler. diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index ade49201..8a9ebb89 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -3,13 +3,13 @@ #include "definitions.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tcdistribution/CCSDSDistributorIF.h" +#include "fsfw/tcdistribution/CcsdsDistributorIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" #define PUS_DISTRIBUTOR_DEBUGGING 0 PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, - CCSDSDistributorIF* distributor, StorageManagerIF* store_) + CcsdsDistributorIF* distributor, StorageManagerIF* store_) : TcDistributor(setObjectId), store(store_), checker(setApid, ccsds::PacketType::TC), @@ -132,7 +132,7 @@ ReturnValue_t PusDistributor::initialize() { sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; #else sif::printError("PusDistributor::initialize: Packet source invalid\n"); - sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); + sif::printError("Make sure it exists and implements CcsdsDistributorIF\n"); #endif return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/src/fsfw/tcdistribution/PusDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h index 7daf5d83..6acefd02 100644 --- a/src/fsfw/tcdistribution/PusDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -1,7 +1,7 @@ #ifndef FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ #define FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ -#include "PUSDistributorIF.h" +#include "PusDistributorIF.h" #include "PusPacketChecker.h" #include "TcDistributor.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" @@ -9,7 +9,7 @@ #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/VerificationReporter.h" -class CCSDSDistributorIF; +class CcsdsDistributorIF; /** * This class accepts PUS Telecommands and forwards them to Application @@ -17,7 +17,7 @@ class CCSDSDistributorIF; * sends acceptance success or failure messages. * @ingroup tc_distribution */ -class PusDistributor : public TcDistributor, public PUSDistributorIF, public AcceptsTelecommandsIF { +class PusDistributor : public TcDistributor, public PusDistributorIF, public AcceptsTelecommandsIF { public: /** * The ctor passes @c set_apid to the checker class and calls the @@ -25,9 +25,9 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc * @param setApid The APID of this receiving Application. * @param setObjectId Object ID of the distributor itself * @param setPacketSource Object ID of the source of TC packets. - * Must implement CCSDSDistributorIF. + * Must implement CcsdsDistributorIF. */ - PusDistributor(uint16_t setApid, object_id_t setObjectId, CCSDSDistributorIF* packetSource, + PusDistributor(uint16_t setApid, object_id_t setObjectId, CcsdsDistributorIF* packetSource, StorageManagerIF* store = nullptr); /** * The destructor is empty. @@ -50,7 +50,7 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc */ VerificationReporterIF* verifyChannel = nullptr; //! Cached for initialization - CCSDSDistributorIF* ccsdsDistributor = nullptr; + CcsdsDistributorIF* ccsdsDistributor = nullptr; PusTcReader reader; /** diff --git a/src/fsfw/tcdistribution/PUSDistributorIF.h b/src/fsfw/tcdistribution/PusDistributorIF.h similarity index 91% rename from src/fsfw/tcdistribution/PUSDistributorIF.h rename to src/fsfw/tcdistribution/PusDistributorIF.h index da6db283..45a5571f 100644 --- a/src/fsfw/tcdistribution/PUSDistributorIF.h +++ b/src/fsfw/tcdistribution/PusDistributorIF.h @@ -8,12 +8,12 @@ * This interface allows PUS Services to register themselves at a PUS Distributor. * @ingroup tc_distribution */ -class PUSDistributorIF { +class PusDistributorIF { public: /** * The empty virtual destructor. */ - virtual ~PUSDistributorIF() {} + virtual ~PusDistributorIF() = default; /** * With this method, Services can register themselves at the PUS Distributor. * @param service A pointer to the registering Service. diff --git a/src/fsfw/tcdistribution/TcDistributor.h b/src/fsfw/tcdistribution/TcDistributor.h index 1b783ff4..e9e1fc97 100644 --- a/src/fsfw/tcdistribution/TcDistributor.h +++ b/src/fsfw/tcdistribution/TcDistributor.h @@ -18,11 +18,11 @@ */ /** - * This is the base class to implement distributors for Space Packets. - * Typically, the distribution is required to forward Telecommand packets + * This is the base class to implement distributors for telecommands. + * Typically, the distribution is required to forward telecommand packets * over the satellite applications and services. The class receives - * Space Packets over a message queue and holds a map that links other - * message queue ids to some identifier. The process of unpacking the + * TC packets over a message queue and holds a map that links other + * message queue IDs to some identifier. The process of unpacking the * destination information from the packet is handled by the child class * implementations. * @ingroup tc_distribution @@ -43,12 +43,12 @@ class TcDistributor : public SystemObject, public ExecutableObjectIF, public Has * @param set_object_id This id is assigned to the distributor * implementation. */ - TcDistributor(object_id_t objectId); + explicit TcDistributor(object_id_t objectId); /** * The destructor is empty, the message queues are not in the vicinity of * this class. */ - virtual ~TcDistributor(); + ~TcDistributor() override; /** * The method is called cyclically and fetches new incoming packets from * the message queue. @@ -56,7 +56,7 @@ class TcDistributor : public SystemObject, public ExecutableObjectIF, public Has * with distribution. * @return The error code of the message queue call. */ - ReturnValue_t performOperation(uint8_t opCode); + ReturnValue_t performOperation(uint8_t opCode) override; /** * A simple debug print, that prints all distribution information stored in * queueMap. diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index d7e3b514..37810fca 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -3,7 +3,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tcdistribution/PUSDistributorIF.h" +#include "fsfw/tcdistribution/PusDistributorIF.h" #include "fsfw/tmtcpacket/pus/tc.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/TmTcMessage.h" @@ -68,7 +68,7 @@ ReturnValue_t CommandingServiceBase::initialize() { if (packetSource == objects::NO_OBJECT) { packetSource = defaultPacketSource; } - auto* distributor = ObjectManager::instance()->get(packetSource); + auto* distributor = ObjectManager::instance()->get(packetSource); if (packetForwarding == nullptr or distributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index b555449b..aabe2192 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -3,7 +3,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tcdistribution/PUSDistributorIF.h" +#include "fsfw/tcdistribution/PusDistributorIF.h" #include "fsfw/timemanager/CdsShortTimeStamper.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" @@ -111,7 +111,7 @@ ReturnValue_t PusServiceBase::initialize() { } if (psbParams.pusDistributor == nullptr) { - psbParams.pusDistributor = ObjectManager::instance()->get(PUS_DISTRIBUTOR); + psbParams.pusDistributor = ObjectManager::instance()->get(PUS_DISTRIBUTOR); if (psbParams.pusDistributor != nullptr) { registerService(*psbParams.pusDistributor); } @@ -193,7 +193,7 @@ void PusServiceBase::setVerificationReporter(VerificationReporterIF& reporter) { psbParams.verifReporter = &reporter; } -ReturnValue_t PusServiceBase::registerService(PUSDistributorIF& distributor) { +ReturnValue_t PusServiceBase::registerService(PusDistributorIF& distributor) { return distributor.registerService(this); } diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 86d8ea1a..829ff03c 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -12,7 +12,7 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/tcdistribution/PUSDistributorIF.h" +#include "fsfw/tcdistribution/PusDistributorIF.h" class StorageManagerIF; @@ -64,7 +64,7 @@ struct PsbParams { * a suitable global distributor with the static ID @PusServiceBase::pusDistributor and * register itself at that object. */ - PUSDistributorIF* pusDistributor = nullptr; + PusDistributorIF* pusDistributor = nullptr; TimeStamperIF* timeStamper = nullptr; }; @@ -116,7 +116,7 @@ class PusServiceBase : public ExecutableObjectIF, */ ~PusServiceBase() override; - ReturnValue_t registerService(PUSDistributorIF& distributor); + ReturnValue_t registerService(PusDistributorIF& distributor); /** * Set the request queue which is used to receive requests. If none is set, the initialize * function will create one diff --git a/unittests/mocks/PusDistributorMock.h b/unittests/mocks/PusDistributorMock.h index d5c7d96f..e19820f3 100644 --- a/unittests/mocks/PusDistributorMock.h +++ b/unittests/mocks/PusDistributorMock.h @@ -2,9 +2,9 @@ #define FSFW_TESTS_PUSDISTRIBUTORMOCK_H #include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/tcdistribution/PUSDistributorIF.h" +#include "fsfw/tcdistribution/PusDistributorIF.h" -class PusDistributorMock : public SystemObject, public PUSDistributorIF { +class PusDistributorMock : public SystemObject, public PusDistributorIF { public: PusDistributorMock(); explicit PusDistributorMock(object_id_t registeredId); From 03e12a2388902cd178c4443fd17c9db789166a5d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 29 Jul 2022 14:15:05 +0200 Subject: [PATCH 161/532] new object ID type --- src/fsfw/objectmanager/SystemObjectIF.h | 2 +- src/fsfw/util/ObjectId.h | 57 ++++++++++++++++++ src/fsfw/util/UnsignedByteField.h | 52 +++++++++++++++++ unittests/CMakeLists.txt | 1 + unittests/util/CMakeLists.txt | 4 ++ unittests/util/testObjectId.cpp | 23 ++++++++ unittests/util/testUnsignedByteField.cpp | 74 ++++++++++++++++++++++++ 7 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 src/fsfw/util/ObjectId.h create mode 100644 src/fsfw/util/UnsignedByteField.h create mode 100644 unittests/util/CMakeLists.txt create mode 100644 unittests/util/testObjectId.cpp create mode 100644 unittests/util/testUnsignedByteField.cpp diff --git a/src/fsfw/objectmanager/SystemObjectIF.h b/src/fsfw/objectmanager/SystemObjectIF.h index 72fe9044..99e26b9c 100644 --- a/src/fsfw/objectmanager/SystemObjectIF.h +++ b/src/fsfw/objectmanager/SystemObjectIF.h @@ -16,7 +16,7 @@ * This is the typedef for object identifiers. * @ingroup system_objects */ -typedef uint32_t object_id_t; +using object_id_t = uint32_t; /** * This interface allows a class to be included in the object manager diff --git a/src/fsfw/util/ObjectId.h b/src/fsfw/util/ObjectId.h new file mode 100644 index 00000000..b51f63e6 --- /dev/null +++ b/src/fsfw/util/ObjectId.h @@ -0,0 +1,57 @@ +#ifndef FSFW_UTIL_OBJECTID_H +#define FSFW_UTIL_OBJECTID_H + +#include "fsfw/objectmanager.h" +#include "UnsignedByteField.h" + +#include + +class ObjectId: public UnsignedByteField { + public: + ObjectId(object_id_t id, const char* name): UnsignedByteField(id), name_(name) {} + + [[nodiscard]] const char* name() const { + return name_; + } + + [[nodiscard]] object_id_t id() const { + return getValue(); + } + + bool operator==(const ObjectId& other) const { + return id() == other.id(); + } + + bool operator!=(const ObjectId& other) const { + return id() != other.id(); + } + + bool operator<(const ObjectId& other) const { + return id() < other.id(); + } + + bool operator>(const ObjectId& other) const { + return id() > other.id(); + } + + bool operator>=(const ObjectId& other) const { + return id() >= other.id(); + } + + bool operator<=(const ObjectId& other) const { + return id() <= other.id(); + } + private: + const char* name_; +}; + +template<> +struct std::hash +{ + std::size_t operator()(ObjectId const& s) const noexcept + { + return std::hash{}(s.id()); + } +}; + +#endif // FSFW_UTIL_OBJECTID_H diff --git a/src/fsfw/util/UnsignedByteField.h b/src/fsfw/util/UnsignedByteField.h new file mode 100644 index 00000000..b02e8b3a --- /dev/null +++ b/src/fsfw/util/UnsignedByteField.h @@ -0,0 +1,52 @@ +#ifndef FSFW_UTIL_UNSIGNEDBYTEFIELD_H +#define FSFW_UTIL_UNSIGNEDBYTEFIELD_H + +#include "fsfw/serialize.h" + +template +class UnsignedByteField: public SerializeIF { + public: + static_assert(std::is_unsigned::value); + + explicit UnsignedByteField(T value): value(value) {} + [[nodiscard]] ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override { + return SerializeAdapter::serialize(&value, buffer, size, maxSize, streamEndianness); + } + + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override { + return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness); + } + + [[nodiscard]] size_t getSerializedSize() const override { + return sizeof(T); + } + + [[nodiscard]] T getValue() const { + return value; + } + + void setValue(T value_) { + value = value_; + } + private: + T value; +}; + +class U32ByteField: public UnsignedByteField { + public: + explicit U32ByteField(uint32_t value): UnsignedByteField(value) {} +}; + +class U16ByteField: public UnsignedByteField { + public: + explicit U16ByteField(uint16_t value): UnsignedByteField(value) {} +}; + +class U8ByteField: public UnsignedByteField { + public: + explicit U8ByteField(uint8_t value): UnsignedByteField(value) {} +}; + +#endif // FSFW_UTIL_UNSIGNEDBYTEFIELD_H diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index f32c6e08..8c7f2463 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -15,6 +15,7 @@ add_subdirectory(mocks) add_subdirectory(action) add_subdirectory(power) +add_subdirectory(util) add_subdirectory(container) add_subdirectory(osal) add_subdirectory(serialize) diff --git a/unittests/util/CMakeLists.txt b/unittests/util/CMakeLists.txt new file mode 100644 index 00000000..b79b77db --- /dev/null +++ b/unittests/util/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE + testUnsignedByteField.cpp + testObjectId.cpp +) diff --git a/unittests/util/testObjectId.cpp b/unittests/util/testObjectId.cpp new file mode 100644 index 00000000..f8dd48ea --- /dev/null +++ b/unittests/util/testObjectId.cpp @@ -0,0 +1,23 @@ +#include + +#include "fsfw/util/ObjectId.h" +#include + +TEST_CASE("Object Id", "[object-id]") { + auto objectId = ObjectId(10, "TEST_ID"); + std::map testMap; + + SECTION("State") { + CHECK(objectId.id() == 10); + CHECK(std::strcmp(objectId.name(), "TEST_ID") == 0); + } + + SECTION("ID as map key") { + auto insertPair = testMap.emplace(objectId, 10); + CHECK(insertPair.second); + auto iter = testMap.find(objectId); + CHECK(iter != testMap.end()); + CHECK(std::strcmp(iter->first.name(), "TEST_ID") == 0); + CHECK(iter->second == 10); + } +} \ No newline at end of file diff --git a/unittests/util/testUnsignedByteField.cpp b/unittests/util/testUnsignedByteField.cpp new file mode 100644 index 00000000..54757f8c --- /dev/null +++ b/unittests/util/testUnsignedByteField.cpp @@ -0,0 +1,74 @@ + +#include + +#include "fsfw/util/UnsignedByteField.h" + +#include + +TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { + auto testByteField = UnsignedByteField(10); + auto u32ByteField = U32ByteField(10); + auto u16ByteField = U16ByteField(5); + auto u8ByteField = U8ByteField(2); + std::array buf{}; + size_t serLen = 0; + SECTION("State") { + CHECK(testByteField.getValue() == 10); + CHECK(testByteField.getSerializedSize() == 4); + CHECK(u32ByteField.getValue() == 10); + CHECK(u32ByteField.getSerializedSize() == 4); + CHECK(u16ByteField.getValue() == 5); + CHECK(u8ByteField.getValue() == 2); + CHECK(u8ByteField.getSerializedSize() == 1); + } + + SECTION("Setter") { + u32ByteField.setValue(20); + REQUIRE(u32ByteField.getValue() == 20); + } + + SECTION("Serialize U32") { + CHECK(testByteField.serializeBe(buf.data(), serLen, buf.size()) == result::OK); + CHECK(serLen == 4); + CHECK(buf[0] == 0); + CHECK(buf[3] == 10); + } + + SECTION("Serialize U32 Concrete") { + CHECK(u32ByteField.serializeBe(buf.data(), serLen, buf.size()) == result::OK); + CHECK(serLen == 4); + CHECK(buf[0] == 0); + CHECK(buf[3] == 10); + } + + SECTION("Serialize U16 Concrete") { + CHECK(u16ByteField.serializeBe(buf.data(), serLen, buf.size()) == result::OK); + CHECK(serLen == 2); + CHECK(buf[0] == 0); + CHECK(buf[1] == 5); + } + + SECTION("Serialize U8 Concrete") { + CHECK(u8ByteField.serializeBe(buf.data(), serLen, buf.size()) == result::OK); + CHECK(serLen == 1); + CHECK(buf[0] == 2); + } + + SECTION("Deserialize") { + buf[0] = 0x50; + buf[1] = 0x40; + buf[2] = 0x30; + buf[3] = 0x20; + size_t deserLen = 0; + CHECK(testByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == result::OK); + CHECK(testByteField.getValue() == 0x50403020); + } + + SECTION("Deserialize U16") { + buf[0] = 0x50; + buf[1] = 0x40; + size_t deserLen = 0; + CHECK(u16ByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == result::OK); + CHECK(u16ByteField.getValue() == 0x5040); + } +} \ No newline at end of file From 47e148af8fd21898134d5a7d37848e8f3e8f8c04 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 29 Jul 2022 14:19:10 +0200 Subject: [PATCH 162/532] decoupling --- unittests/util/testUnsignedByteField.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/unittests/util/testUnsignedByteField.cpp b/unittests/util/testUnsignedByteField.cpp index 54757f8c..9a67c092 100644 --- a/unittests/util/testUnsignedByteField.cpp +++ b/unittests/util/testUnsignedByteField.cpp @@ -28,28 +28,28 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { } SECTION("Serialize U32") { - CHECK(testByteField.serializeBe(buf.data(), serLen, buf.size()) == result::OK); + CHECK(testByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(serLen == 4); CHECK(buf[0] == 0); CHECK(buf[3] == 10); } SECTION("Serialize U32 Concrete") { - CHECK(u32ByteField.serializeBe(buf.data(), serLen, buf.size()) == result::OK); + CHECK(u32ByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(serLen == 4); CHECK(buf[0] == 0); CHECK(buf[3] == 10); } SECTION("Serialize U16 Concrete") { - CHECK(u16ByteField.serializeBe(buf.data(), serLen, buf.size()) == result::OK); + CHECK(u16ByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(serLen == 2); CHECK(buf[0] == 0); CHECK(buf[1] == 5); } SECTION("Serialize U8 Concrete") { - CHECK(u8ByteField.serializeBe(buf.data(), serLen, buf.size()) == result::OK); + CHECK(u8ByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(serLen == 1); CHECK(buf[0] == 2); } @@ -60,7 +60,7 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { buf[2] = 0x30; buf[3] = 0x20; size_t deserLen = 0; - CHECK(testByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == result::OK); + CHECK(testByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(testByteField.getValue() == 0x50403020); } @@ -68,7 +68,7 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { buf[0] = 0x50; buf[1] = 0x40; size_t deserLen = 0; - CHECK(u16ByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == result::OK); + CHECK(u16ByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(u16ByteField.getValue() == 0x5040); } } \ No newline at end of file From 4a4d23573d11834d9575875a3c772cb9cc7bf1f9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 29 Jul 2022 14:24:16 +0200 Subject: [PATCH 163/532] verify correct key behaviour --- unittests/util/testObjectId.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/unittests/util/testObjectId.cpp b/unittests/util/testObjectId.cpp index f8dd48ea..cead2c15 100644 --- a/unittests/util/testObjectId.cpp +++ b/unittests/util/testObjectId.cpp @@ -19,5 +19,8 @@ TEST_CASE("Object Id", "[object-id]") { CHECK(iter != testMap.end()); CHECK(std::strcmp(iter->first.name(), "TEST_ID") == 0); CHECK(iter->second == 10); + auto otherIdSameName = ObjectId(12, "TEST_ID"); + insertPair = testMap.emplace(otherIdSameName, 10); + CHECK(insertPair.second); } } \ No newline at end of file From 96f092ef75a0b2209407d8faed5a11eae203c037 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 29 Jul 2022 14:30:58 +0200 Subject: [PATCH 164/532] type correction --- src/fsfw/util/ObjectId.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/util/ObjectId.h b/src/fsfw/util/ObjectId.h index b51f63e6..5b1cf461 100644 --- a/src/fsfw/util/ObjectId.h +++ b/src/fsfw/util/ObjectId.h @@ -50,7 +50,7 @@ struct std::hash { std::size_t operator()(ObjectId const& s) const noexcept { - return std::hash{}(s.id()); + return std::hash{}(s.id()); } }; From c7b4dc349a6c10154002df56672852aafcfa6c31 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 29 Jul 2022 15:53:39 +0200 Subject: [PATCH 165/532] using uint32_t for getIdentifier of AcceptsTcIF --- src/fsfw/cfdp/CfdpHandler.cpp | 2 +- src/fsfw/cfdp/CfdpHandler.h | 2 +- src/fsfw/tcdistribution/CMakeLists.txt | 3 ++- src/fsfw/tcdistribution/CcsdsDistributor.cpp | 2 +- src/fsfw/tcdistribution/CcsdsDistributor.h | 2 +- src/fsfw/tcdistribution/CcsdsUnpacker.cpp | 7 +++++++ src/fsfw/tcdistribution/CcsdsUnpacker.h | 16 ++++++++++++++++ src/fsfw/tcdistribution/CfdpDistributor.cpp | 2 +- src/fsfw/tcdistribution/CfdpDistributor.h | 2 +- src/fsfw/tcdistribution/PusDistributor.cpp | 2 +- src/fsfw/tcdistribution/PusDistributor.h | 2 +- src/fsfw/tmtcservices/AcceptsTelecommandsIF.h | 12 ++++++------ src/fsfw/tmtcservices/CommandingServiceBase.cpp | 2 +- src/fsfw/tmtcservices/CommandingServiceBase.h | 2 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 2 +- src/fsfw/tmtcservices/PusServiceBase.h | 2 +- src/fsfw/tmtcservices/TmTcBridge.cpp | 2 +- src/fsfw/tmtcservices/TmTcBridge.h | 2 +- 18 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 src/fsfw/tcdistribution/CcsdsUnpacker.cpp create mode 100644 src/fsfw/tcdistribution/CcsdsUnpacker.h diff --git a/src/fsfw/cfdp/CfdpHandler.cpp b/src/fsfw/cfdp/CfdpHandler.cpp index cb13bca6..5db6bed3 100644 --- a/src/fsfw/cfdp/CfdpHandler.cpp +++ b/src/fsfw/cfdp/CfdpHandler.cpp @@ -52,6 +52,6 @@ ReturnValue_t CfdpHandler::performOperation(uint8_t opCode) { return RETURN_OK; } -uint16_t CfdpHandler::getIdentifier() { return 0; } +uint32_t CfdpHandler::getIdentifier() { return 0; } MessageQueueId_t CfdpHandler::getRequestQueue() { return this->requestQueue->getId(); } diff --git a/src/fsfw/cfdp/CfdpHandler.h b/src/fsfw/cfdp/CfdpHandler.h index 03424d64..f55ebf73 100644 --- a/src/fsfw/cfdp/CfdpHandler.h +++ b/src/fsfw/cfdp/CfdpHandler.h @@ -28,7 +28,7 @@ class CfdpHandler : public ExecutableObjectIF, virtual ReturnValue_t handleRequest(store_address_t storeId); virtual ReturnValue_t initialize() override; - virtual uint16_t getIdentifier() override; + virtual uint32_t getIdentifier() override; MessageQueueId_t getRequestQueue() override; ReturnValue_t performOperation(uint8_t opCode) override; diff --git a/src/fsfw/tcdistribution/CMakeLists.txt b/src/fsfw/tcdistribution/CMakeLists.txt index f1762ff4..2d1a74f6 100644 --- a/src/fsfw/tcdistribution/CMakeLists.txt +++ b/src/fsfw/tcdistribution/CMakeLists.txt @@ -6,4 +6,5 @@ target_sources( PusPacketChecker.cpp TcPacketCheckCFDP.cpp CfdpDistributor.cpp - CcsdsPacketChecker.cpp) + CcsdsPacketChecker.cpp + CcsdsUnpacker.cpp) diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp index d263d68a..3a6d8729 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -80,7 +80,7 @@ ReturnValue_t CcsdsDistributor::registerApplication(uint16_t apid, MessageQueueI return returnValue; } -uint16_t CcsdsDistributor::getIdentifier() { return 0; } +uint32_t CcsdsDistributor::getIdentifier() { return 0; } ReturnValue_t CcsdsDistributor::initialize() { if (packetChecker == nullptr) { diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.h b/src/fsfw/tcdistribution/CcsdsDistributor.h index ea7ad7e2..f3af87e3 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.h +++ b/src/fsfw/tcdistribution/CcsdsDistributor.h @@ -38,7 +38,7 @@ class CcsdsDistributor : public TcDistributor, MessageQueueId_t getRequestQueue() override; ReturnValue_t registerApplication(uint16_t apid, MessageQueueId_t id) override; ReturnValue_t registerApplication(AcceptsTelecommandsIF* application) override; - uint16_t getIdentifier() override; + uint32_t getIdentifier() override; ReturnValue_t initialize() override; protected: diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.cpp b/src/fsfw/tcdistribution/CcsdsUnpacker.cpp new file mode 100644 index 00000000..2f8e9f27 --- /dev/null +++ b/src/fsfw/tcdistribution/CcsdsUnpacker.cpp @@ -0,0 +1,7 @@ +#include "CcsdsUnpacker.h" + +CcsdsUnpacker::CcsdsUnpacker() {} + +ReturnValue_t CcsdsUnpacker::performOperation(uint8_t operationCode) { return 0; } +uint32_t CcsdsUnpacker::getIdentifier() { return 0; } +MessageQueueId_t CcsdsUnpacker::getRequestQueue() { return 0; } diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.h b/src/fsfw/tcdistribution/CcsdsUnpacker.h new file mode 100644 index 00000000..b9b90d70 --- /dev/null +++ b/src/fsfw/tcdistribution/CcsdsUnpacker.h @@ -0,0 +1,16 @@ +#ifndef FSFW_TCDISTRIBUTION_CCSDSUNPACKER_H +#define FSFW_TCDISTRIBUTION_CCSDSUNPACKER_H + +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" + +class CcsdsUnpacker: public ExecutableObjectIF, public AcceptsTelecommandsIF { + public: + CcsdsUnpacker(); + ReturnValue_t performOperation(uint8_t operationCode) override; + uint32_t getIdentifier() override; + MessageQueueId_t getRequestQueue() override; + + private: +}; +#endif // FSFW_TCDISTRIBUTION_CCSDSUNPACKER_H diff --git a/src/fsfw/tcdistribution/CfdpDistributor.cpp b/src/fsfw/tcdistribution/CfdpDistributor.cpp index 1f380530..26d7948d 100644 --- a/src/fsfw/tcdistribution/CfdpDistributor.cpp +++ b/src/fsfw/tcdistribution/CfdpDistributor.cpp @@ -118,7 +118,7 @@ MessageQueueId_t CfdpDistributor::getRequestQueue() { return tcQueue->getId(); } // } // } -uint16_t CfdpDistributor::getIdentifier() { return this->apid; } +uint32_t CfdpDistributor::getIdentifier() { return this->apid; } ReturnValue_t CfdpDistributor::initialize() { currentPacket = new CfdpPacketStored(); diff --git a/src/fsfw/tcdistribution/CfdpDistributor.h b/src/fsfw/tcdistribution/CfdpDistributor.h index 181d3613..7a69b3d0 100644 --- a/src/fsfw/tcdistribution/CfdpDistributor.h +++ b/src/fsfw/tcdistribution/CfdpDistributor.h @@ -35,7 +35,7 @@ class CfdpDistributor : public TcDistributor, ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) override; MessageQueueId_t getRequestQueue() override; ReturnValue_t initialize() override; - uint16_t getIdentifier() override; + uint32_t getIdentifier() override; protected: uint16_t apid; diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 8a9ebb89..f8c28447 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -117,7 +117,7 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { } } -uint16_t PusDistributor::getIdentifier() { return checker.getApid(); } +uint32_t PusDistributor::getIdentifier() { return checker.getApid(); } ReturnValue_t PusDistributor::initialize() { if (store == nullptr) { diff --git a/src/fsfw/tcdistribution/PusDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h index 6acefd02..f9ade4e2 100644 --- a/src/fsfw/tcdistribution/PusDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -36,7 +36,7 @@ class PusDistributor : public TcDistributor, public PusDistributorIF, public Acc ReturnValue_t registerService(AcceptsTelecommandsIF* service) override; MessageQueueId_t getRequestQueue() override; ReturnValue_t initialize() override; - uint16_t getIdentifier() override; + uint32_t getIdentifier() override; protected: StorageManagerIF* store; diff --git a/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h b/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h index e18a4f3a..a0fb23d1 100644 --- a/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h +++ b/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h @@ -22,13 +22,13 @@ class AcceptsTelecommandsIF { */ virtual ~AcceptsTelecommandsIF() = default; /** - * @brief Getter for the service id. - * @details Any receiving service (at least any PUS service) shall have a - * service ID. If the receiver can handle Telecommands, but for - * some reason has no service id, it shall return 0. - * @return The service ID or 0. + * @brief Getter for a generic identifier ID. + * @details Any receiving service (at least any PUS service) shall have an identifier. For + * example, this could be the APID for a receiver expecting generic PUS packets, or a PUS + * service for a component expecting specific PUS service packets. + * @return The identifier. */ - virtual uint16_t getIdentifier() = 0; + virtual uint32_t getIdentifier() = 0; /** * @brief This method returns the message queue id of the telecommand * receiving message queue. diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 37810fca..fc9c0685 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -50,7 +50,7 @@ ReturnValue_t CommandingServiceBase::performOperation(uint8_t opCode) { return RETURN_OK; } -uint16_t CommandingServiceBase::getIdentifier() { return service; } +uint32_t CommandingServiceBase::getIdentifier() { return service; } MessageQueueId_t CommandingServiceBase::getRequestQueue() { return requestQueue->getId(); } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index c16d9ded..07f7179a 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -106,7 +106,7 @@ class CommandingServiceBase : public SystemObject, */ ReturnValue_t performOperation(uint8_t opCode) override; - uint16_t getIdentifier() override; + uint32_t getIdentifier() override; /** * Returns the requestQueue MessageQueueId_t diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index aabe2192..d777d03e 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -82,7 +82,7 @@ void PusServiceBase::handleRequestQueue() { } } -uint16_t PusServiceBase::getIdentifier() { return psbParams.serviceId; } +uint32_t PusServiceBase::getIdentifier() { return psbParams.serviceId; } MessageQueueId_t PusServiceBase::getRequestQueue() { if (psbParams.reqQueue == nullptr) { diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 829ff03c..34483fe7 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -188,7 +188,7 @@ class PusServiceBase : public ExecutableObjectIF, * @c RETURN_FAILED else. */ ReturnValue_t performOperation(uint8_t opCode) override; - uint16_t getIdentifier() override; + uint32_t getIdentifier() override; MessageQueueId_t getRequestQueue() override; ReturnValue_t initialize() override; diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index 6af03600..7190d771 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -247,7 +247,7 @@ MessageQueueId_t TmTcBridge::getReportReceptionQueue(uint8_t virtualChannel) { void TmTcBridge::printData(uint8_t* data, size_t dataLen) { arrayprinter::print(data, dataLen); } -uint16_t TmTcBridge::getIdentifier() { +uint32_t TmTcBridge::getIdentifier() { // This is no PUS service, so we just return 0 return 0; } diff --git a/src/fsfw/tmtcservices/TmTcBridge.h b/src/fsfw/tmtcservices/TmTcBridge.h index 237f1f3e..c4bc4062 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.h +++ b/src/fsfw/tmtcservices/TmTcBridge.h @@ -69,7 +69,7 @@ class TmTcBridge : public AcceptsTelemetryIF, virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; /** AcceptsTelecommandsIF override */ - virtual uint16_t getIdentifier() override; + virtual uint32_t getIdentifier() override; virtual MessageQueueId_t getRequestQueue() override; protected: From f4beef8c9f394085896204f64ce873c7676fd80c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 29 Jul 2022 15:54:17 +0200 Subject: [PATCH 166/532] run auto-formatter --- src/fsfw/tcdistribution/CcsdsUnpacker.h | 2 +- src/fsfw/util/ObjectId.h | 53 ++++++++---------------- src/fsfw/util/UnsignedByteField.h | 35 +++++++--------- unittests/util/testObjectId.cpp | 36 ++++++++-------- unittests/util/testUnsignedByteField.cpp | 12 +++--- 5 files changed, 58 insertions(+), 80 deletions(-) diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.h b/src/fsfw/tcdistribution/CcsdsUnpacker.h index b9b90d70..a134de33 100644 --- a/src/fsfw/tcdistribution/CcsdsUnpacker.h +++ b/src/fsfw/tcdistribution/CcsdsUnpacker.h @@ -4,7 +4,7 @@ #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -class CcsdsUnpacker: public ExecutableObjectIF, public AcceptsTelecommandsIF { +class CcsdsUnpacker : public ExecutableObjectIF, public AcceptsTelecommandsIF { public: CcsdsUnpacker(); ReturnValue_t performOperation(uint8_t operationCode) override; diff --git a/src/fsfw/util/ObjectId.h b/src/fsfw/util/ObjectId.h index b51f63e6..a6716fe8 100644 --- a/src/fsfw/util/ObjectId.h +++ b/src/fsfw/util/ObjectId.h @@ -1,57 +1,38 @@ #ifndef FSFW_UTIL_OBJECTID_H #define FSFW_UTIL_OBJECTID_H -#include "fsfw/objectmanager.h" -#include "UnsignedByteField.h" - #include -class ObjectId: public UnsignedByteField { +#include "UnsignedByteField.h" +#include "fsfw/objectmanager.h" + +class ObjectId : public UnsignedByteField { public: - ObjectId(object_id_t id, const char* name): UnsignedByteField(id), name_(name) {} + ObjectId(object_id_t id, const char* name) : UnsignedByteField(id), name_(name) {} - [[nodiscard]] const char* name() const { - return name_; - } + [[nodiscard]] const char* name() const { return name_; } - [[nodiscard]] object_id_t id() const { - return getValue(); - } + [[nodiscard]] object_id_t id() const { return getValue(); } - bool operator==(const ObjectId& other) const { - return id() == other.id(); - } + bool operator==(const ObjectId& other) const { return id() == other.id(); } - bool operator!=(const ObjectId& other) const { - return id() != other.id(); - } + bool operator!=(const ObjectId& other) const { return id() != other.id(); } - bool operator<(const ObjectId& other) const { - return id() < other.id(); - } + bool operator<(const ObjectId& other) const { return id() < other.id(); } - bool operator>(const ObjectId& other) const { - return id() > other.id(); - } + bool operator>(const ObjectId& other) const { return id() > other.id(); } - bool operator>=(const ObjectId& other) const { - return id() >= other.id(); - } + bool operator>=(const ObjectId& other) const { return id() >= other.id(); } + + bool operator<=(const ObjectId& other) const { return id() <= other.id(); } - bool operator<=(const ObjectId& other) const { - return id() <= other.id(); - } private: const char* name_; }; -template<> -struct std::hash -{ - std::size_t operator()(ObjectId const& s) const noexcept - { - return std::hash{}(s.id()); - } +template <> +struct std::hash { + std::size_t operator()(ObjectId const& s) const noexcept { return std::hash{}(s.id()); } }; #endif // FSFW_UTIL_OBJECTID_H diff --git a/src/fsfw/util/UnsignedByteField.h b/src/fsfw/util/UnsignedByteField.h index b02e8b3a..3f4ee791 100644 --- a/src/fsfw/util/UnsignedByteField.h +++ b/src/fsfw/util/UnsignedByteField.h @@ -3,50 +3,45 @@ #include "fsfw/serialize.h" -template -class UnsignedByteField: public SerializeIF { +template +class UnsignedByteField : public SerializeIF { public: static_assert(std::is_unsigned::value); - explicit UnsignedByteField(T value): value(value) {} + explicit UnsignedByteField(T value) : value(value) {} [[nodiscard]] ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const override { + Endianness streamEndianness) const override { return SerializeAdapter::serialize(&value, buffer, size, maxSize, streamEndianness); } ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, - Endianness streamEndianness) override { + Endianness streamEndianness) override { return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness); } - [[nodiscard]] size_t getSerializedSize() const override { - return sizeof(T); - } + [[nodiscard]] size_t getSerializedSize() const override { return sizeof(T); } - [[nodiscard]] T getValue() const { - return value; - } + [[nodiscard]] T getValue() const { return value; } + + void setValue(T value_) { value = value_; } - void setValue(T value_) { - value = value_; - } private: T value; }; -class U32ByteField: public UnsignedByteField { +class U32ByteField : public UnsignedByteField { public: - explicit U32ByteField(uint32_t value): UnsignedByteField(value) {} + explicit U32ByteField(uint32_t value) : UnsignedByteField(value) {} }; -class U16ByteField: public UnsignedByteField { +class U16ByteField : public UnsignedByteField { public: - explicit U16ByteField(uint16_t value): UnsignedByteField(value) {} + explicit U16ByteField(uint16_t value) : UnsignedByteField(value) {} }; -class U8ByteField: public UnsignedByteField { +class U8ByteField : public UnsignedByteField { public: - explicit U8ByteField(uint8_t value): UnsignedByteField(value) {} + explicit U8ByteField(uint8_t value) : UnsignedByteField(value) {} }; #endif // FSFW_UTIL_UNSIGNEDBYTEFIELD_H diff --git a/unittests/util/testObjectId.cpp b/unittests/util/testObjectId.cpp index cead2c15..ce8761f5 100644 --- a/unittests/util/testObjectId.cpp +++ b/unittests/util/testObjectId.cpp @@ -1,26 +1,26 @@ +#include #include #include "fsfw/util/ObjectId.h" -#include TEST_CASE("Object Id", "[object-id]") { - auto objectId = ObjectId(10, "TEST_ID"); - std::map testMap; + auto objectId = ObjectId(10, "TEST_ID"); + std::map testMap; - SECTION("State") { - CHECK(objectId.id() == 10); - CHECK(std::strcmp(objectId.name(), "TEST_ID") == 0); - } + SECTION("State") { + CHECK(objectId.id() == 10); + CHECK(std::strcmp(objectId.name(), "TEST_ID") == 0); + } - SECTION("ID as map key") { - auto insertPair = testMap.emplace(objectId, 10); - CHECK(insertPair.second); - auto iter = testMap.find(objectId); - CHECK(iter != testMap.end()); - CHECK(std::strcmp(iter->first.name(), "TEST_ID") == 0); - CHECK(iter->second == 10); - auto otherIdSameName = ObjectId(12, "TEST_ID"); - insertPair = testMap.emplace(otherIdSameName, 10); - CHECK(insertPair.second); - } + SECTION("ID as map key") { + auto insertPair = testMap.emplace(objectId, 10); + CHECK(insertPair.second); + auto iter = testMap.find(objectId); + CHECK(iter != testMap.end()); + CHECK(std::strcmp(iter->first.name(), "TEST_ID") == 0); + CHECK(iter->second == 10); + auto otherIdSameName = ObjectId(12, "TEST_ID"); + insertPair = testMap.emplace(otherIdSameName, 10); + CHECK(insertPair.second); + } } \ No newline at end of file diff --git a/unittests/util/testUnsignedByteField.cpp b/unittests/util/testUnsignedByteField.cpp index 9a67c092..83ffd3c6 100644 --- a/unittests/util/testUnsignedByteField.cpp +++ b/unittests/util/testUnsignedByteField.cpp @@ -1,10 +1,9 @@ +#include #include #include "fsfw/util/UnsignedByteField.h" -#include - TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { auto testByteField = UnsignedByteField(10); auto u32ByteField = U32ByteField(10); @@ -28,7 +27,8 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { } SECTION("Serialize U32") { - CHECK(testByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(testByteField.serializeBe(buf.data(), serLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); CHECK(serLen == 4); CHECK(buf[0] == 0); CHECK(buf[3] == 10); @@ -60,7 +60,8 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { buf[2] = 0x30; buf[3] = 0x20; size_t deserLen = 0; - CHECK(testByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(testByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); CHECK(testByteField.getValue() == 0x50403020); } @@ -68,7 +69,8 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { buf[0] = 0x50; buf[1] = 0x40; size_t deserLen = 0; - CHECK(u16ByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(u16ByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); CHECK(u16ByteField.getValue() == 0x5040); } } \ No newline at end of file From 83d71548ec52e5fdbeda55660de066a40c8bcb43 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 29 Jul 2022 16:32:50 +0200 Subject: [PATCH 167/532] CCSDS unpacker implementation --- src/fsfw/tcdistribution/CcsdsUnpacker.cpp | 59 +++++++++++++++++++++-- src/fsfw/tcdistribution/CcsdsUnpacker.h | 9 +++- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.cpp b/src/fsfw/tcdistribution/CcsdsUnpacker.cpp index 2f8e9f27..226b857b 100644 --- a/src/fsfw/tcdistribution/CcsdsUnpacker.cpp +++ b/src/fsfw/tcdistribution/CcsdsUnpacker.cpp @@ -1,7 +1,60 @@ #include "CcsdsUnpacker.h" -CcsdsUnpacker::CcsdsUnpacker() {} +#include "fsfw/tmtcservices/TmTcMessage.h" + +CcsdsUnpacker::CcsdsUnpacker(MessageQueueIF& msgQueue, AcceptsTelecommandsIF& receiver, + StorageManagerIF& sourceStore) + : sourceStore(sourceStore), msgQueue(msgQueue), receiver(receiver) { + msgQueue.setDefaultDestination(receiver.getRequestQueue()); +} + +ReturnValue_t CcsdsUnpacker::performOperation(uint8_t operationCode) { + TmTcMessage msg; + ReturnValue_t result; + for (result = msgQueue.receiveMessage(&msg); result == HasReturnvaluesIF::RETURN_OK; + result = msgQueue.receiveMessage(&msg)) { + auto resultPair = sourceStore.getData(msg.getStorageId()); + if(resultPair.first != HasReturnvaluesIF::RETURN_OK) { + continue; + } + if(resultPair.second.size() < 6) { + // TODO: This is a config error. Does it make sense to forward the message? + result = msgQueue.sendToDefault(&msg); + if(result != HasReturnvaluesIF::RETURN_OK) { + + } + continue; + } + StorageManagerIF* tgtStore; + if(targetStore != nullptr) { + tgtStore = targetStore; + } else { + tgtStore = &sourceStore; + } + store_address_t newId; + uint8_t* ptr; + result = tgtStore->getFreeElement(&newId, resultPair.second.size(), &ptr); + if(result != HasReturnvaluesIF::RETURN_OK) { + // TODO: Implement error handling + } + std::memcpy(ptr, resultPair.second.data() + 6, resultPair.second.size() - 6); + result = sourceStore.deleteData(msg.getStorageId()); + if(result != HasReturnvaluesIF::RETURN_OK) { + // TODO: Implement error handling (though this really should not happen) + } + TmTcMessage newMsg(newId); + result = msgQueue.sendToDefault(&newMsg); + if(result != HasReturnvaluesIF::RETURN_OK) { + + } + } + return result; +} -ReturnValue_t CcsdsUnpacker::performOperation(uint8_t operationCode) { return 0; } uint32_t CcsdsUnpacker::getIdentifier() { return 0; } -MessageQueueId_t CcsdsUnpacker::getRequestQueue() { return 0; } + +MessageQueueId_t CcsdsUnpacker::getRequestQueue() { return msgQueue.getId(); } + +void CcsdsUnpacker::setDifferentTargetStore(StorageManagerIF& otherTargetStore) { + targetStore = &otherTargetStore; +} diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.h b/src/fsfw/tcdistribution/CcsdsUnpacker.h index a134de33..c4eb7da4 100644 --- a/src/fsfw/tcdistribution/CcsdsUnpacker.h +++ b/src/fsfw/tcdistribution/CcsdsUnpacker.h @@ -1,16 +1,23 @@ #ifndef FSFW_TCDISTRIBUTION_CCSDSUNPACKER_H #define FSFW_TCDISTRIBUTION_CCSDSUNPACKER_H +#include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" class CcsdsUnpacker : public ExecutableObjectIF, public AcceptsTelecommandsIF { public: - CcsdsUnpacker(); + CcsdsUnpacker(MessageQueueIF& msgQueue, AcceptsTelecommandsIF& receiver, StorageManagerIF& sourceStore); + + void setDifferentTargetStore(StorageManagerIF& otherTargetStore); ReturnValue_t performOperation(uint8_t operationCode) override; uint32_t getIdentifier() override; MessageQueueId_t getRequestQueue() override; private: + StorageManagerIF& sourceStore; + StorageManagerIF* targetStore = nullptr; + MessageQueueIF& msgQueue; + AcceptsTelecommandsIF& receiver; }; #endif // FSFW_TCDISTRIBUTION_CCSDSUNPACKER_H From 458fe460eb7b330901cc7444c0c8d5981e269338 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 1 Aug 2022 11:00:36 +0200 Subject: [PATCH 168/532] TMTC Routing Refactoring 1. Make TcDistributor less powerful / more flexible and rename it to TcDistributorBase 2. Require AcceptsTelecommandsIF to have an abstract function returning the name 3. Allows the CCSDS distributor to remove the CCSDS header before rerouting. This is useful for protocols like CFDP which are CCSDS agnostic. WIP: Still need to implement the removal of the CCSDS header --- src/fsfw/cfdp/CfdpHandler.cpp | 4 +- src/fsfw/cfdp/CfdpHandler.h | 4 +- src/fsfw/osal/common/TcpTmTcBridge.cpp | 2 +- src/fsfw/osal/common/UdpTmTcBridge.cpp | 2 +- src/fsfw/pus/CService200ModeCommanding.cpp | 4 +- src/fsfw/pus/CService201HealthCommanding.cpp | 4 +- .../pus/Service11TelecommandScheduling.tpp | 4 +- src/fsfw/pus/Service17Test.cpp | 4 +- src/fsfw/pus/Service20ParameterManagement.cpp | 4 +- src/fsfw/pus/Service2DeviceAccess.cpp | 4 +- src/fsfw/pus/Service3Housekeeping.cpp | 2 +- src/fsfw/pus/Service5EventReporting.cpp | 1 + src/fsfw/pus/Service8FunctionManagement.cpp | 4 +- src/fsfw/pus/Service9TimeManagement.cpp | 4 +- src/fsfw/tcdistribution/CcsdsDistributor.cpp | 77 +++++-- src/fsfw/tcdistribution/CcsdsDistributor.h | 22 +- src/fsfw/tcdistribution/CcsdsDistributorIF.h | 46 +++-- src/fsfw/tcdistribution/CcsdsUnpacker.cpp | 4 +- src/fsfw/tcdistribution/CcsdsUnpacker.h | 4 +- src/fsfw/tcdistribution/CfdpDistributor.cpp | 192 +++++++++--------- src/fsfw/tcdistribution/CfdpDistributor.h | 10 +- src/fsfw/tcdistribution/PusDistributor.cpp | 89 ++++---- src/fsfw/tcdistribution/PusDistributor.h | 27 ++- src/fsfw/tcdistribution/PusDistributorIF.h | 2 +- src/fsfw/tcdistribution/TcDistributor.cpp | 34 ++-- .../{TcDistributor.h => TcDistributorBase.h} | 24 +-- src/fsfw/tmtcservices/AcceptsTelecommandsIF.h | 6 +- .../tmtcservices/CommandingServiceBase.cpp | 14 +- src/fsfw/tmtcservices/CommandingServiceBase.h | 9 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 8 +- src/fsfw/tmtcservices/PusServiceBase.h | 12 +- src/fsfw/tmtcservices/TmTcBridge.cpp | 14 +- src/fsfw/tmtcservices/TmTcBridge.h | 19 +- 33 files changed, 368 insertions(+), 292 deletions(-) rename src/fsfw/tcdistribution/{TcDistributor.h => TcDistributorBase.h} (83%) diff --git a/src/fsfw/cfdp/CfdpHandler.cpp b/src/fsfw/cfdp/CfdpHandler.cpp index 5db6bed3..35e5b2bc 100644 --- a/src/fsfw/cfdp/CfdpHandler.cpp +++ b/src/fsfw/cfdp/CfdpHandler.cpp @@ -52,6 +52,6 @@ ReturnValue_t CfdpHandler::performOperation(uint8_t opCode) { return RETURN_OK; } -uint32_t CfdpHandler::getIdentifier() { return 0; } +uint32_t CfdpHandler::getIdentifier() const { return 0; } -MessageQueueId_t CfdpHandler::getRequestQueue() { return this->requestQueue->getId(); } +MessageQueueId_t CfdpHandler::getRequestQueue() const { return this->requestQueue->getId(); } diff --git a/src/fsfw/cfdp/CfdpHandler.h b/src/fsfw/cfdp/CfdpHandler.h index f55ebf73..8730f3eb 100644 --- a/src/fsfw/cfdp/CfdpHandler.h +++ b/src/fsfw/cfdp/CfdpHandler.h @@ -28,8 +28,8 @@ class CfdpHandler : public ExecutableObjectIF, virtual ReturnValue_t handleRequest(store_address_t storeId); virtual ReturnValue_t initialize() override; - virtual uint32_t getIdentifier() override; - MessageQueueId_t getRequestQueue() override; + virtual uint32_t getIdentifier() const override; + MessageQueueId_t getRequestQueue() const override; ReturnValue_t performOperation(uint8_t opCode) override; protected: diff --git a/src/fsfw/osal/common/TcpTmTcBridge.cpp b/src/fsfw/osal/common/TcpTmTcBridge.cpp index 4b2bea73..7bd53380 100644 --- a/src/fsfw/osal/common/TcpTmTcBridge.cpp +++ b/src/fsfw/osal/common/TcpTmTcBridge.cpp @@ -18,7 +18,7 @@ TcpTmTcBridge::TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, object_id_t tcStoreId) - : TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { + : TmTcBridge("TCP TMTC Bridge", objectId, tcDestination, tmStoreId, tcStoreId) { mutex = MutexFactory::instance()->createMutex(); // Connection is always up, TM is requested by connecting to server and receiving packets registerCommConnect(); diff --git a/src/fsfw/osal/common/UdpTmTcBridge.cpp b/src/fsfw/osal/common/UdpTmTcBridge.cpp index e3cad58f..3f2d04b5 100644 --- a/src/fsfw/osal/common/UdpTmTcBridge.cpp +++ b/src/fsfw/osal/common/UdpTmTcBridge.cpp @@ -22,7 +22,7 @@ const std::string UdpTmTcBridge::DEFAULT_SERVER_PORT = tcpip::DEFAULT_SERVER_POR UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, const std::string &udpServerPort_, object_id_t tmStoreId, object_id_t tcStoreId) - : TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { + : TmTcBridge("UDP TMTC Bridge", objectId, tcDestination, tmStoreId, tcStoreId) { if (udpServerPort_.empty()) { udpServerPort = DEFAULT_SERVER_PORT; } else { diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index 9990280c..4a02ea3d 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -10,8 +10,8 @@ CService200ModeCommanding::CService200ModeCommanding(object_id_t objectId, uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands, uint16_t commandTimeoutSeconds) - : CommandingServiceBase(objectId, apid, serviceId, numParallelCommands, commandTimeoutSeconds) { -} + : CommandingServiceBase(objectId, apid, "PUS 200 Mode MGMT", serviceId, numParallelCommands, + commandTimeoutSeconds) {} CService200ModeCommanding::~CService200ModeCommanding() {} diff --git a/src/fsfw/pus/CService201HealthCommanding.cpp b/src/fsfw/pus/CService201HealthCommanding.cpp index c668ea52..a53a4ead 100644 --- a/src/fsfw/pus/CService201HealthCommanding.cpp +++ b/src/fsfw/pus/CService201HealthCommanding.cpp @@ -10,8 +10,8 @@ CService201HealthCommanding::CService201HealthCommanding(object_id_t objectId, u uint8_t serviceId, uint8_t numParallelCommands, uint16_t commandTimeoutSeconds) - : CommandingServiceBase(objectId, apid, serviceId, numParallelCommands, commandTimeoutSeconds) { -} + : CommandingServiceBase(objectId, apid, "PUS 201 Health MGMT", serviceId, numParallelCommands, + commandTimeoutSeconds) {} ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) { switch (subservice) { diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 83713266..1cc9b7fe 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -16,7 +16,9 @@ inline Service11TelecommandScheduling::Service11TelecommandScheduli : PusServiceBase(params), RELEASE_TIME_MARGIN_SECONDS(releaseTimeMarginSeconds), debugMode(debugMode), - tcRecipient(tcRecipient) {} + tcRecipient(tcRecipient) { + params.name = "PUS 11 TC Scheduling"; +} template inline Service11TelecommandScheduling::~Service11TelecommandScheduling() = default; diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index 14257334..0ef71fe1 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -8,7 +8,9 @@ Service17Test::Service17Test(PsbParams params) : PusServiceBase(params), storeHelper(params.apid), - tmHelper(params.serviceId, storeHelper, sendHelper) {} + tmHelper(params.serviceId, storeHelper, sendHelper) { + params.name = "PUS 17 Test"; +} Service17Test::~Service17Test() = default; diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index 6d6ca339..747c1ccf 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -11,8 +11,8 @@ Service20ParameterManagement::Service20ParameterManagement(object_id_t objectId, uint8_t serviceId, uint8_t numberOfParallelCommands, uint16_t commandTimeoutSeconds) - : CommandingServiceBase(objectId, apid, serviceId, numberOfParallelCommands, - commandTimeoutSeconds) {} + : CommandingServiceBase(objectId, apid, "PUS 20 Parameter MGMT", serviceId, + numberOfParallelCommands, commandTimeoutSeconds) {} Service20ParameterManagement::~Service20ParameterManagement() = default; diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index 414f0812..71fc4938 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -14,8 +14,8 @@ Service2DeviceAccess::Service2DeviceAccess(object_id_t objectId, uint16_t apid, uint8_t serviceId, uint8_t numberOfParallelCommands, uint16_t commandTimeoutSeconds) - : CommandingServiceBase(objectId, apid, serviceId, numberOfParallelCommands, - commandTimeoutSeconds) {} + : CommandingServiceBase(objectId, apid, "PUS 2 Raw Commanding", serviceId, + numberOfParallelCommands, commandTimeoutSeconds) {} Service2DeviceAccess::~Service2DeviceAccess() {} diff --git a/src/fsfw/pus/Service3Housekeeping.cpp b/src/fsfw/pus/Service3Housekeeping.cpp index 7ef5636d..6edd9d4b 100644 --- a/src/fsfw/pus/Service3Housekeeping.cpp +++ b/src/fsfw/pus/Service3Housekeeping.cpp @@ -5,7 +5,7 @@ #include "fsfw/pus/servicepackets/Service3Packets.h" Service3Housekeeping::Service3Housekeeping(object_id_t objectId, uint16_t apid, uint8_t serviceId) - : CommandingServiceBase(objectId, apid, serviceId, NUM_OF_PARALLEL_COMMANDS, + : CommandingServiceBase(objectId, apid, "PUS 3 HK", serviceId, NUM_OF_PARALLEL_COMMANDS, COMMAND_TIMEOUT_SECONDS) {} Service3Housekeeping::~Service3Housekeeping() {} diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index fa518d0f..adba396e 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -13,6 +13,7 @@ Service5EventReporting::Service5EventReporting(PsbParams params, size_t maxNumbe storeHelper(params.apid), tmHelper(params.serviceId, storeHelper, sendHelper), maxNumberReportsPerCycle(maxNumberReportsPerCycle) { + psbParams.name = "PUS 5 Event Reporting"; eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); } diff --git a/src/fsfw/pus/Service8FunctionManagement.cpp b/src/fsfw/pus/Service8FunctionManagement.cpp index c9da6d58..de0ec9cf 100644 --- a/src/fsfw/pus/Service8FunctionManagement.cpp +++ b/src/fsfw/pus/Service8FunctionManagement.cpp @@ -12,8 +12,8 @@ Service8FunctionManagement::Service8FunctionManagement(object_id_t objectId, uin uint8_t serviceId, uint8_t numParallelCommands, uint16_t commandTimeoutSeconds) - : CommandingServiceBase(objectId, apid, serviceId, numParallelCommands, commandTimeoutSeconds) { -} + : CommandingServiceBase(objectId, apid, "PUS 8 Functional Commanding", serviceId, + numParallelCommands, commandTimeoutSeconds) {} Service8FunctionManagement::~Service8FunctionManagement() {} diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 4a26f993..6e85e709 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -5,7 +5,9 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/CCSDSTime.h" -Service9TimeManagement::Service9TimeManagement(PsbParams params) : PusServiceBase(params) {} +Service9TimeManagement::Service9TimeManagement(PsbParams params) : PusServiceBase(params) { + params.name = "PUS 9 Time MGMT"; +} Service9TimeManagement::~Service9TimeManagement() = default; diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp index 3a6d8729..8e6f9eeb 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -1,5 +1,6 @@ #include "fsfw/tcdistribution/CcsdsDistributor.h" +#include "definitions.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" @@ -8,11 +9,11 @@ CcsdsDistributor::CcsdsDistributor(uint16_t setDefaultApid, object_id_t setObjectId, CcsdsPacketCheckIF* packetChecker) - : TcDistributor(setObjectId), defaultApid(setDefaultApid), packetChecker(packetChecker) {} + : TcDistributorBase(setObjectId), defaultApid(setDefaultApid), packetChecker(packetChecker) {} CcsdsDistributor::~CcsdsDistributor() = default; -TcDistributor::TcMqMapIter CcsdsDistributor::selectDestination() { +ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { #if CCSDS_DISTRIBUTOR_DEBUGGING == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "CCSDSDistributor::selectDestination received: " @@ -39,54 +40,72 @@ TcDistributor::TcMqMapIter CcsdsDistributor::selectDestination() { " store failed!\n"); #endif #endif - return queueMap.end(); + return result; } SpacePacketReader currentPacket(packet, size); result = packetChecker->checkPacket(currentPacket, size); if (result != HasReturnvaluesIF::RETURN_OK) { + handlePacketCheckFailure(result); + return result; } #if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1 sif::info << "CCSDSDistributor::selectDestination has packet with APID 0x" << std::hex << currentPacket.getApid() << std::dec << std::endl; #endif - auto position = this->queueMap.find(currentPacket.getApid()); - if (position != this->queueMap.end()) { - return position; + auto position = receiverMap.find(currentPacket.getApid()); + if (position != receiverMap.end()) { + destId = position->second.destId; } else { // The APID was not found. Forward packet to main SW-APID anyway to // create acceptance failure report. - return queueMap.find(this->defaultApid); + auto iter = receiverMap.find(defaultApid); + if (iter != receiverMap.end()) { + destId = iter->second.destId; + } else { + return DESTINATION_NOT_FOUND; + } } + return HasReturnvaluesIF::RETURN_OK; } -MessageQueueId_t CcsdsDistributor::getRequestQueue() { return tcQueue->getId(); } +void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) { + const char* reason = "Unknown reason"; + if (result == tcdistrib::INVALID_CCSDS_VERSION) { + reason = "Invalid CCSDS version"; + } else if (result == tcdistrib::INCOMPLETE_PACKET) { + reason = "Size missmatch between CCSDS data length and packet length"; + } else if (result == tcdistrib::INVALID_APID) { + reason = "No valid handler APID found"; + } else if (result == tcdistrib::INVALID_PACKET_TYPE) { + reason = "Invalid Packet Type TM detected"; + } +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "CCSDS packet check failed: " << reason << std::endl; +#else + sif::printWarning("CCSDS packet check failed: %s\n", reason); +#endif +#endif +} -ReturnValue_t CcsdsDistributor::registerApplication(AcceptsTelecommandsIF* application) { +MessageQueueId_t CcsdsDistributor::getRequestQueue() const { return tcQueue->getId(); } + +ReturnValue_t CcsdsDistributor::registerApplication(DestInfo info) { ReturnValue_t returnValue = RETURN_OK; - auto insertPair = - this->queueMap.emplace(application->getIdentifier(), application->getRequestQueue()); + auto insertPair = receiverMap.emplace(info.apid, info); if (not insertPair.second) { returnValue = RETURN_FAILED; } return returnValue; } -ReturnValue_t CcsdsDistributor::registerApplication(uint16_t apid, MessageQueueId_t id) { - ReturnValue_t returnValue = RETURN_OK; - auto insertPair = this->queueMap.emplace(apid, id); - if (not insertPair.second) { - returnValue = RETURN_FAILED; - } - return returnValue; -} - -uint32_t CcsdsDistributor::getIdentifier() { return 0; } +uint32_t CcsdsDistributor::getIdentifier() const { return 0; } ReturnValue_t CcsdsDistributor::initialize() { if (packetChecker == nullptr) { packetChecker = new CcsdsPacketChecker(ccsds::PacketType::TC); } - ReturnValue_t status = this->TcDistributor::initialize(); + ReturnValue_t status = this->TcDistributorBase::initialize(); this->tcStore = ObjectManager::instance()->get(objects::TC_STORE); if (this->tcStore == nullptr) { #if FSFW_VERBOSE_LEVEL >= 1 @@ -111,3 +130,17 @@ ReturnValue_t CcsdsDistributor::callbackAfterSending(ReturnValue_t queueStatus) } return RETURN_OK; } + +void CcsdsDistributor::print() { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::debug << "Distributor content is: " << std::endl << "ID\t| Message Queue ID" << std::endl; + sif::debug << std::setfill('0') << std::setw(8) << std::hex; + for (const auto& iter : receiverMap) { + sif::debug << iter.first << "\t| 0x" << iter.second.destId + << ", Header Removed: " << std::boolalpha << iter.second.removeHeader << std::endl; + } + sif::debug << std::setfill(' ') << std::dec; +#endif +} + +const char* CcsdsDistributor::getName() const { return "CCSDS Distributor"; } diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.h b/src/fsfw/tcdistribution/CcsdsDistributor.h index f3af87e3..cd010ad5 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.h +++ b/src/fsfw/tcdistribution/CcsdsDistributor.h @@ -1,11 +1,13 @@ #ifndef FRAMEWORK_TCDISTRIBUTION_CCSDSDISTRIBUTOR_H_ #define FRAMEWORK_TCDISTRIBUTION_CCSDSDISTRIBUTOR_H_ +#include + #include "fsfw/objectmanager/ObjectManagerIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/tcdistribution/CcsdsDistributorIF.h" #include "fsfw/tcdistribution/CcsdsPacketChecker.h" -#include "fsfw/tcdistribution/TcDistributor.h" +#include "fsfw/tcdistribution/TcDistributorBase.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" /** @@ -16,7 +18,7 @@ * The Secondary Header (with Service/Subservice) is ignored. * @ingroup tc_distribution */ -class CcsdsDistributor : public TcDistributor, +class CcsdsDistributor : public TcDistributorBase, public CcsdsDistributorIF, public AcceptsTelecommandsIF { public: @@ -35,13 +37,16 @@ class CcsdsDistributor : public TcDistributor, */ ~CcsdsDistributor() override; - MessageQueueId_t getRequestQueue() override; - ReturnValue_t registerApplication(uint16_t apid, MessageQueueId_t id) override; - ReturnValue_t registerApplication(AcceptsTelecommandsIF* application) override; - uint32_t getIdentifier() override; + MessageQueueId_t getRequestQueue() const override; + ReturnValue_t registerApplication(DestInfo info) override; + uint32_t getIdentifier() const override; ReturnValue_t initialize() override; + [[nodiscard]] const char* getName() const override; protected: + using CcsdsReceiverMap = std::map; + CcsdsReceiverMap receiverMap; + /** * This implementation checks if an application with fitting APID has * registered and forwards the packet to the according message queue. @@ -49,13 +54,16 @@ class CcsdsDistributor : public TcDistributor, * where a Acceptance Failure message should be generated. * @return Iterator to map entry of found APID or iterator to default APID. */ - TcMqMapIter selectDestination() override; + ReturnValue_t selectDestination(MessageQueueId_t& destId) override; /** * The callback here handles the generation of acceptance * success/failure messages. */ ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override; + static void handlePacketCheckFailure(ReturnValue_t result); + + void print(); /** * The default APID, where packets with unknown APID are sent to. */ diff --git a/src/fsfw/tcdistribution/CcsdsDistributorIF.h b/src/fsfw/tcdistribution/CcsdsDistributorIF.h index d5a26bef..aee9d46d 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributorIF.h +++ b/src/fsfw/tcdistribution/CcsdsDistributorIF.h @@ -1,8 +1,9 @@ #ifndef FSFW_TCDISTRIBUTION_CCSDSDISTRIBUTORIF_H_ #define FSFW_TCDISTRIBUTION_CCSDSDISTRIBUTORIF_H_ -#include "../ipc/MessageQueueSenderIF.h" -#include "../tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/ipc/MessageQueueSenderIF.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" + /** * This is the Interface to a CCSDS Distributor. * On a CCSDS Distributor, Applications (in terms of CCSDS) may register @@ -13,24 +14,37 @@ */ class CcsdsDistributorIF { public: - /** - * With this call, a class implementing the CCSDSApplicationIF can register - * at the distributor. - * @param application A pointer to the Application to register. - * @return - @c RETURN_OK on success, - * - @c RETURN_FAILED on failure. - */ - virtual ReturnValue_t registerApplication(AcceptsTelecommandsIF* application) = 0; + struct DestInfo { + DestInfo(const char* name, uint16_t apid, MessageQueueId_t destId, bool removeHeader) + : name(name), apid(apid), destId(destId), removeHeader(removeHeader) {} + DestInfo(const char* name, AcceptsTelecommandsIF& ccsdsReceiver, bool removeHeader_) + : name(name) { + apid = ccsdsReceiver.getIdentifier(); + destId = ccsdsReceiver.getRequestQueue(); + removeHeader = removeHeader_; + } + const char* name; + uint16_t apid; + MessageQueueId_t destId; + bool removeHeader; + }; + /** * With this call, other Applications can register to the CCSDS distributor. * This is done by passing an APID and a MessageQueueId to the method. - * @param apid The APID to register. - * @param id The MessageQueueId of the message queue to send the - * TC Packets to. - * @return - @c RETURN_OK on success, - * - @c RETURN_FAILED on failure. + * @param info Contains all necessary info to register an application. + * @return + * - @c RETURN_OK on success, + * - @c RETURN_FAILED or tcdistrib error code on failure. + * - @c tcdistrib::INVALID_CCSDS_VERSION + * - @c tcdistrib::INVALID_APID No APID available to handle this packet + * - @c tcdistrib::INVALID_PACKET_TYPE Packet type TM detected + * - @c tcdistrib::INCORRECT_PRIMARY_HEADER Something other wrong with primary header + * - @c tcdistrib::INCOMPLETE_PACKET Size missmatch between data length field and actual + * length */ - virtual ReturnValue_t registerApplication(uint16_t apid, MessageQueueId_t id) = 0; + virtual ReturnValue_t registerApplication(DestInfo info) = 0; + /** * The empty virtual destructor. */ diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.cpp b/src/fsfw/tcdistribution/CcsdsUnpacker.cpp index 2f8e9f27..289f601e 100644 --- a/src/fsfw/tcdistribution/CcsdsUnpacker.cpp +++ b/src/fsfw/tcdistribution/CcsdsUnpacker.cpp @@ -3,5 +3,5 @@ CcsdsUnpacker::CcsdsUnpacker() {} ReturnValue_t CcsdsUnpacker::performOperation(uint8_t operationCode) { return 0; } -uint32_t CcsdsUnpacker::getIdentifier() { return 0; } -MessageQueueId_t CcsdsUnpacker::getRequestQueue() { return 0; } +uint32_t CcsdsUnpacker::getIdentifier() const { return 0; } +MessageQueueId_t CcsdsUnpacker::getRequestQueue() const { return 0; } diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.h b/src/fsfw/tcdistribution/CcsdsUnpacker.h index a134de33..88545311 100644 --- a/src/fsfw/tcdistribution/CcsdsUnpacker.h +++ b/src/fsfw/tcdistribution/CcsdsUnpacker.h @@ -8,8 +8,8 @@ class CcsdsUnpacker : public ExecutableObjectIF, public AcceptsTelecommandsIF { public: CcsdsUnpacker(); ReturnValue_t performOperation(uint8_t operationCode) override; - uint32_t getIdentifier() override; - MessageQueueId_t getRequestQueue() override; + uint32_t getIdentifier() const override; + MessageQueueId_t getRequestQueue() const override; private: }; diff --git a/src/fsfw/tcdistribution/CfdpDistributor.cpp b/src/fsfw/tcdistribution/CfdpDistributor.cpp index 26d7948d..abbad748 100644 --- a/src/fsfw/tcdistribution/CfdpDistributor.cpp +++ b/src/fsfw/tcdistribution/CfdpDistributor.cpp @@ -10,7 +10,7 @@ CfdpDistributor::CfdpDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource) - : TcDistributor(setObjectId), + : TcDistributorBase(setObjectId), apid(setApid), checker(setApid), tcStatus(RETURN_FAILED), @@ -18,87 +18,89 @@ CfdpDistributor::CfdpDistributor(uint16_t setApid, object_id_t setObjectId, CfdpDistributor::~CfdpDistributor() = default; -CfdpDistributor::TcMqMapIter CfdpDistributor::selectDestination() { -#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 - store_address_t storeId = this->currentMessage.getStorageId(); -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "CFDPDistributor::handlePacket received: " << storeId.poolIndex << ", " - << storeId.packetIndex << std::endl; -#else - sif::printDebug("CFDPDistributor::handlePacket received: %d, %d\n", storeId.poolIndex, - storeId.packetIndex); -#endif -#endif - auto queueMapIt = this->queueMap.end(); - if (this->currentPacket == nullptr) { - return queueMapIt; - } - this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); - if (currentPacket->getFullData() != nullptr) { - tcStatus = checker.checkPacket(*currentPacket, currentPacket->getFullPacketLen()); - if (tcStatus != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "CFDPDistributor::handlePacket: Packet format invalid, code " - << static_cast(tcStatus) << std::endl; -#else - sif::printDebug("CFDPDistributor::handlePacket: Packet format invalid, code %d\n", - static_cast(tcStatus)); -#endif -#endif - } - queueMapIt = this->queueMap.find(0); - } else { - tcStatus = PACKET_LOST; - } - - if (queueMapIt == this->queueMap.end()) { - tcStatus = DESTINATION_NOT_FOUND; -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "CFDPDistributor::handlePacket: Destination not found" << std::endl; -#else - sif::printDebug("CFDPDistributor::handlePacket: Destination not found\n"); -#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif - } - - if (tcStatus != RETURN_OK) { - return this->queueMap.end(); - } else { - return queueMapIt; - } +ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { + //#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 + // store_address_t storeId = this->currentMessage.getStorageId(); + //#if FSFW_CPP_OSTREAM_ENABLED == 1 + // sif::debug << "CFDPDistributor::handlePacket received: " << storeId.poolIndex << ", " + // << storeId.packetIndex << std::endl; + //#else + // sif::printDebug("CFDPDistributor::handlePacket received: %d, %d\n", storeId.poolIndex, + // storeId.packetIndex); + //#endif + //#endif + // auto queueMapIt = this->queueMap.end(); + // if (this->currentPacket == nullptr) { + // return queueMapIt; + // } + // this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); + // if (currentPacket->getFullData() != nullptr) { + // tcStatus = checker.checkPacket(*currentPacket, currentPacket->getFullPacketLen()); + // if (tcStatus != HasReturnvaluesIF::RETURN_OK) { + //#if FSFW_VERBOSE_LEVEL >= 1 + //#if FSFW_CPP_OSTREAM_ENABLED == 1 + // sif::debug << "CFDPDistributor::handlePacket: Packet format invalid, code " + // << static_cast(tcStatus) << std::endl; + //#else + // sif::printDebug("CFDPDistributor::handlePacket: Packet format invalid, code %d\n", + // static_cast(tcStatus)); + //#endif + //#endif + // } + // queueMapIt = this->queueMap.find(0); + // } else { + // tcStatus = PACKET_LOST; + // } + // + // if (queueMapIt == this->queueMap.end()) { + // tcStatus = DESTINATION_NOT_FOUND; + //#if FSFW_VERBOSE_LEVEL >= 1 + //#if FSFW_CPP_OSTREAM_ENABLED == 1 + // sif::debug << "CFDPDistributor::handlePacket: Destination not found" << std::endl; + //#else + // sif::printDebug("CFDPDistributor::handlePacket: Destination not found\n"); + //#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ + //#endif + // } + // + // if (tcStatus != RETURN_OK) { + // return this->queueMap.end(); + // } else { + // return queueMapIt; + // } } ReturnValue_t CfdpDistributor::registerHandler(AcceptsTelecommandsIF* handler) { - uint16_t handlerId = - handler->getIdentifier(); // should be 0, because CfdpHandler does not set a set a service-ID -#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast(handlerId) - << std::endl; -#else - sif::printInfo("CFDPDistributor::registerHandler: Handler ID: %d\n", static_cast(handlerId)); -#endif -#endif - MessageQueueId_t queue = handler->getRequestQueue(); - auto returnPair = queueMap.emplace(handlerId, queue); - if (not returnPair.second) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CFDPDistributor::registerHandler: Service ID already" - " exists in map" - << std::endl; -#else - sif::printError("CFDPDistributor::registerHandler: Service ID already exists in map\n"); -#endif -#endif - return SERVICE_ID_ALREADY_EXISTS; - } + // uint16_t handlerId = + // handler->getIdentifier(); // should be 0, because CfdpHandler does not set a set a + // service-ID + //#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 + //#if FSFW_CPP_OSTREAM_ENABLED == 1 + // sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast(handlerId) + // << std::endl; + //#else + // sif::printInfo("CFDPDistributor::registerHandler: Handler ID: %d\n", + // static_cast(handlerId)); + //#endif + //#endif + // MessageQueueId_t queue = handler->getRequestQueue(); + // auto returnPair = queueMap.emplace(handlerId, queue); + // if (not returnPair.second) { + //#if FSFW_VERBOSE_LEVEL >= 1 + //#if FSFW_CPP_OSTREAM_ENABLED == 1 + // sif::error << "CFDPDistributor::registerHandler: Service ID already" + // " exists in map" + // << std::endl; + //#else + // sif::printError("CFDPDistributor::registerHandler: Service ID already exists in map\n"); + //#endif + //#endif + // return SERVICE_ID_ALREADY_EXISTS; + // } return HasReturnvaluesIF::RETURN_OK; } -MessageQueueId_t CfdpDistributor::getRequestQueue() { return tcQueue->getId(); } +MessageQueueId_t CfdpDistributor::getRequestQueue() const { return tcQueue->getId(); } // ReturnValue_t CFDPDistributor::callbackAfterSending(ReturnValue_t queueStatus) { // if (queueStatus != RETURN_OK) { @@ -118,25 +120,25 @@ MessageQueueId_t CfdpDistributor::getRequestQueue() { return tcQueue->getId(); } // } // } -uint32_t CfdpDistributor::getIdentifier() { return this->apid; } +uint32_t CfdpDistributor::getIdentifier() const { return this->apid; } ReturnValue_t CfdpDistributor::initialize() { - currentPacket = new CfdpPacketStored(); - if (currentPacket == nullptr) { - // Should not happen, memory allocation failed! - return ObjectManagerIF::CHILD_INIT_FAILED; - } - - auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); - if (ccsdsDistributor == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl; - sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; -#else - sif::printError("CFDPDistributor::initialize: Packet source invalid\n"); - sif::printError("Make sure it exists and implements CcsdsDistributorIF\n"); -#endif - return RETURN_FAILED; - } - return ccsdsDistributor->registerApplication(this); + // currentPacket = new CfdpPacketStored(); + // if (currentPacket == nullptr) { + // // Should not happen, memory allocation failed! + // return ObjectManagerIF::CHILD_INIT_FAILED; + // } + // + // auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); + // if (ccsdsDistributor == nullptr) { + //#if FSFW_CPP_OSTREAM_ENABLED == 1 + // sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl; + // sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; + //#else + // sif::printError("CFDPDistributor::initialize: Packet source invalid\n"); + // sif::printError("Make sure it exists and implements CcsdsDistributorIF\n"); + //#endif + // return RETURN_FAILED; + // } + // return ccsdsDistributor->registerApplication(this); } diff --git a/src/fsfw/tcdistribution/CfdpDistributor.h b/src/fsfw/tcdistribution/CfdpDistributor.h index 7a69b3d0..7bfaee7b 100644 --- a/src/fsfw/tcdistribution/CfdpDistributor.h +++ b/src/fsfw/tcdistribution/CfdpDistributor.h @@ -8,14 +8,14 @@ #include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../tmtcservices/VerificationReporter.h" #include "CfdpDistributorIF.h" -#include "TcDistributor.h" +#include "TcDistributorBase.h" /** * This class accepts CFDP Telecommands and forwards them to Application * services. * @ingroup tc_distribution */ -class CfdpDistributor : public TcDistributor, +class CfdpDistributor : public TcDistributorBase, public CfdpDistributorIF, public AcceptsTelecommandsIF { public: @@ -33,9 +33,9 @@ class CfdpDistributor : public TcDistributor, */ ~CfdpDistributor() override; ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) override; - MessageQueueId_t getRequestQueue() override; + MessageQueueId_t getRequestQueue() const override; ReturnValue_t initialize() override; - uint32_t getIdentifier() override; + uint32_t getIdentifier() const override; protected: uint16_t apid; @@ -60,7 +60,7 @@ class CfdpDistributor : public TcDistributor, * @return Iterator to map entry of found service id * or iterator to @c map.end(). */ - TcMqMapIter selectDestination() override; + ReturnValue_t selectDestination(MessageQueueId_t& destId) override; /** * The callback here handles the generation of acceptance * success/failure messages. diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index f8c28447..e85a6047 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -10,7 +10,7 @@ PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, CcsdsDistributorIF* distributor, StorageManagerIF* store_) - : TcDistributor(setObjectId), + : TcDistributorBase(setObjectId), store(store_), checker(setApid, ccsds::PacketType::TC), ccsdsDistributor(distributor), @@ -18,62 +18,59 @@ PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, PusDistributor::~PusDistributor() = default; -PusDistributor::TcMqMapIter PusDistributor::selectDestination() { +ReturnValue_t PusDistributor::selectDestination(MessageQueueId_t& destId) { #if FSFW_CPP_OSTREAM_ENABLED == 1 && PUS_DISTRIBUTOR_DEBUGGING == 1 store_address_t storeId = currentMessage.getStorageId(); sif::debug << "PUSDistributor::handlePacket received: " << storeId.poolIndex << ", " << storeId.packetIndex << std::endl; #endif - auto queueMapIt = queueMap.end(); // TODO: Need to set the data const uint8_t* packetPtr = nullptr; size_t packetLen = 0; - if (store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != - HasReturnvaluesIF::RETURN_OK) { - return queueMapIt; - } - ReturnValue_t result = reader.setReadOnlyData(packetPtr, packetLen); + ReturnValue_t result = store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != + HasReturnvaluesIF::RETURN_OK; if (result != HasReturnvaluesIF::RETURN_OK) { tcStatus = PACKET_LOST; - return queueMapIt; + return result; + } + result = reader.setReadOnlyData(packetPtr, packetLen); + if (result != HasReturnvaluesIF::RETURN_OK) { + tcStatus = PACKET_LOST; + return result; } // CRC check done by checker result = reader.parseDataWithoutCrcCheck(); if (result != HasReturnvaluesIF::RETURN_OK) { tcStatus = PACKET_LOST; - return queueMapIt; + return result; } + if (reader.getFullData() != nullptr) { tcStatus = checker.checkPacket(reader, reader.getFullPacketLen()); if (tcStatus != HasReturnvaluesIF::RETURN_OK) { checkerFailurePrinter(); } - uint32_t queue_id = reader.getService(); - queueMapIt = queueMap.find(queue_id); + uint8_t pusId = reader.getService(); + auto iter = receiverMap.find(pusId); + if (iter == receiverMap.end()) { + tcStatus = DESTINATION_NOT_FOUND; +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl; +#else + sif::printDebug("PUSDistributor::handlePacket: Destination not found\n"); +#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ +#endif + } + destId = iter->second.destId; } else { tcStatus = PACKET_LOST; } - - if (queueMapIt == this->queueMap.end()) { - tcStatus = DESTINATION_NOT_FOUND; -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl; -#else - sif::printDebug("PUSDistributor::handlePacket: Destination not found\n"); -#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif - } - - if (tcStatus != RETURN_OK) { - return this->queueMap.end(); - } else { - return queueMapIt; - } + return tcStatus; } -ReturnValue_t PusDistributor::registerService(AcceptsTelecommandsIF* service) { - uint16_t serviceId = service->getIdentifier(); +ReturnValue_t PusDistributor::registerService(const AcceptsTelecommandsIF& service) { + uint16_t serviceId = service.getIdentifier(); #if PUS_DISTRIBUTOR_DEBUGGING == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "Service ID: " << static_cast(serviceId) << std::endl; @@ -81,8 +78,8 @@ ReturnValue_t PusDistributor::registerService(AcceptsTelecommandsIF* service) { sif::printInfo("Service ID: %d\n", static_cast(serviceId)); #endif #endif - MessageQueueId_t queue = service->getRequestQueue(); - auto returnPair = queueMap.emplace(serviceId, queue); + MessageQueueId_t queue = service.getRequestQueue(); + auto returnPair = receiverMap.emplace(serviceId, ServiceInfo(service.getName(), queue)); if (not returnPair.second) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -98,7 +95,7 @@ ReturnValue_t PusDistributor::registerService(AcceptsTelecommandsIF* service) { return HasReturnvaluesIF::RETURN_OK; } -MessageQueueId_t PusDistributor::getRequestQueue() { return tcQueue->getId(); } +MessageQueueId_t PusDistributor::getRequestQueue() const { return tcQueue->getId(); } ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { if (queueStatus != RETURN_OK) { @@ -117,7 +114,7 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { } } -uint32_t PusDistributor::getIdentifier() { return checker.getApid(); } +uint32_t PusDistributor::getIdentifier() const { return checker.getApid(); } ReturnValue_t PusDistributor::initialize() { if (store == nullptr) { @@ -142,28 +139,30 @@ ReturnValue_t PusDistributor::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } } - return ccsdsDistributor->registerApplication(this); + return ccsdsDistributor->registerApplication( + CcsdsDistributorIF::DestInfo(getName(), *this, false)); } void PusDistributor::checkerFailurePrinter() const { #if FSFW_VERBOSE_LEVEL >= 1 - const char* keyword = "unnamed error"; + const char* reason = "Unknown reason"; if (tcStatus == tcdistrib::INCORRECT_CHECKSUM) { - keyword = "checksum"; + reason = "Checksum Error"; } else if (tcStatus == tcdistrib::INCORRECT_PRIMARY_HEADER) { - keyword = "incorrect primary header"; + reason = "Incorrect Primary Header"; } else if (tcStatus == tcdistrib::INVALID_APID) { - keyword = "illegal APID"; + reason = "Illegal APID"; } else if (tcStatus == tcdistrib::INCORRECT_SECONDARY_HEADER) { - keyword = "incorrect secondary header"; + reason = "Incorrect Secondary Header"; } else if (tcStatus == tcdistrib::INCOMPLETE_PACKET) { - keyword = "incomplete packet"; + reason = "Incomplete packet"; } #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "PUSDistributor::handlePacket: Packet format invalid, " << keyword << " error" - << std::endl; + sif::warning << "PUSDistributor::handlePacket: Check failed: " << reason << std::endl; #else - sif::printWarning("PUSDistributor::handlePacket: Packet format invalid, %s error\n", keyword); + sif::printWarning("PUSDistributor::handlePacket: Check failed: %s\n", reason); #endif #endif } + +const char* PusDistributor::getName() const { return "PUS Distributor"; } diff --git a/src/fsfw/tcdistribution/PusDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h index f9ade4e2..6b88ccad 100644 --- a/src/fsfw/tcdistribution/PusDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -1,9 +1,11 @@ #ifndef FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ #define FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ +#include + #include "PusDistributorIF.h" #include "PusPacketChecker.h" -#include "TcDistributor.h" +#include "TcDistributorBase.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tmtcpacket/pus/tc.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" @@ -17,7 +19,9 @@ class CcsdsDistributorIF; * sends acceptance success or failure messages. * @ingroup tc_distribution */ -class PusDistributor : public TcDistributor, public PusDistributorIF, public AcceptsTelecommandsIF { +class PusDistributor : public TcDistributorBase, + public PusDistributorIF, + public AcceptsTelecommandsIF { public: /** * The ctor passes @c set_apid to the checker class and calls the @@ -29,16 +33,27 @@ class PusDistributor : public TcDistributor, public PusDistributorIF, public Acc */ PusDistributor(uint16_t setApid, object_id_t setObjectId, CcsdsDistributorIF* packetSource, StorageManagerIF* store = nullptr); + [[nodiscard]] const char* getName() const override; /** * The destructor is empty. */ ~PusDistributor() override; - ReturnValue_t registerService(AcceptsTelecommandsIF* service) override; - MessageQueueId_t getRequestQueue() override; + ReturnValue_t registerService(const AcceptsTelecommandsIF& service) override; + [[nodiscard]] MessageQueueId_t getRequestQueue() const override; ReturnValue_t initialize() override; - uint32_t getIdentifier() override; + [[nodiscard]] uint32_t getIdentifier() const override; protected: + struct ServiceInfo { + ServiceInfo(const char* name, MessageQueueId_t destId) : name(name), destId(destId) {} + + const char* name; + MessageQueueId_t destId; + }; + /// PUS recipient map. The key value will generally be the PUS Service + using PusReceiverMap = std::map; + + PusReceiverMap receiverMap; StorageManagerIF* store; /** * This attribute contains the class, that performs a formal packet check. @@ -67,7 +82,7 @@ class PusDistributor : public TcDistributor, public PusDistributorIF, public Acc * @return Iterator to map entry of found service id * or iterator to @c map.end(). */ - TcMqMapIter selectDestination() override; + ReturnValue_t selectDestination(MessageQueueId_t& destId) override; /** * The callback here handles the generation of acceptance * success/failure messages. diff --git a/src/fsfw/tcdistribution/PusDistributorIF.h b/src/fsfw/tcdistribution/PusDistributorIF.h index 45a5571f..c8288cc9 100644 --- a/src/fsfw/tcdistribution/PusDistributorIF.h +++ b/src/fsfw/tcdistribution/PusDistributorIF.h @@ -20,7 +20,7 @@ class PusDistributorIF { * @return - @c RETURN_OK on success, * - @c RETURN_FAILED on failure. */ - virtual ReturnValue_t registerService(AcceptsTelecommandsIF* service) = 0; + virtual ReturnValue_t registerService(const AcceptsTelecommandsIF& service) = 0; }; #endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTORIF_H_ */ diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index 4ec85ed9..2133c961 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -1,16 +1,14 @@ -#include "fsfw/tcdistribution/TcDistributor.h" - #include "fsfw/ipc/QueueFactory.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/tcdistribution/TcDistributorBase.h" #include "fsfw/tmtcservices/TmTcMessage.h" -TcDistributor::TcDistributor(object_id_t objectId) : SystemObject(objectId) { +TcDistributorBase::TcDistributorBase(object_id_t objectId) : SystemObject(objectId) { tcQueue = QueueFactory::instance()->createMessageQueue(DISTRIBUTER_MAX_PACKETS); } -TcDistributor::~TcDistributor() { QueueFactory::instance()->deleteMessageQueue(tcQueue); } +TcDistributorBase::~TcDistributorBase() { QueueFactory::instance()->deleteMessageQueue(tcQueue); } -ReturnValue_t TcDistributor::performOperation(uint8_t opCode) { +ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) { ReturnValue_t status; for (status = tcQueue->receiveMessage(¤tMessage); status == RETURN_OK; status = tcQueue->receiveMessage(¤tMessage)) { @@ -22,24 +20,16 @@ ReturnValue_t TcDistributor::performOperation(uint8_t opCode) { return status; } -ReturnValue_t TcDistributor::handlePacket() { - auto queueMapIt = selectDestination(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; - if (queueMapIt != queueMap.end()) { - result = tcQueue->sendMessage(queueMapIt->second, ¤tMessage); +ReturnValue_t TcDistributorBase::handlePacket() { + MessageQueueId_t destId; + ReturnValue_t result = selectDestination(destId); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } + result = tcQueue->sendMessage(destId, ¤tMessage); return callbackAfterSending(result); } -void TcDistributor::print() { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Distributor content is: " << std::endl << "ID\t| Message Queue ID" << std::endl; - sif::debug << std::setfill('0') << std::setw(8) << std::hex; - for (const auto& queueMapIter : queueMap) { - sif::debug << queueMapIter.first << "\t| 0x" << queueMapIter.second << std::endl; - } - sif::debug << std::setfill(' ') << std::dec; -#endif +ReturnValue_t TcDistributorBase::callbackAfterSending(ReturnValue_t queueStatus) { + return RETURN_OK; } - -ReturnValue_t TcDistributor::callbackAfterSending(ReturnValue_t queueStatus) { return RETURN_OK; } diff --git a/src/fsfw/tcdistribution/TcDistributor.h b/src/fsfw/tcdistribution/TcDistributorBase.h similarity index 83% rename from src/fsfw/tcdistribution/TcDistributor.h rename to src/fsfw/tcdistribution/TcDistributorBase.h index e9e1fc97..c1fd4531 100644 --- a/src/fsfw/tcdistribution/TcDistributor.h +++ b/src/fsfw/tcdistribution/TcDistributorBase.h @@ -27,11 +27,8 @@ * implementations. * @ingroup tc_distribution */ -class TcDistributor : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { +class TcDistributorBase : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { public: - using TcMessageQueueMap = std::map; - using TcMqMapIter = std::map::iterator; - static constexpr uint8_t INTERFACE_ID = CLASS_ID::PACKET_DISTRIBUTION; static constexpr ReturnValue_t PACKET_LOST = MAKE_RETURN_CODE(1); static constexpr ReturnValue_t DESTINATION_NOT_FOUND = MAKE_RETURN_CODE(2); @@ -43,12 +40,12 @@ class TcDistributor : public SystemObject, public ExecutableObjectIF, public Has * @param set_object_id This id is assigned to the distributor * implementation. */ - explicit TcDistributor(object_id_t objectId); + explicit TcDistributorBase(object_id_t objectId); /** * The destructor is empty, the message queues are not in the vicinity of * this class. */ - ~TcDistributor() override; + ~TcDistributorBase() override; /** * The method is called cyclically and fetches new incoming packets from * the message queue. @@ -57,11 +54,6 @@ class TcDistributor : public SystemObject, public ExecutableObjectIF, public Has * @return The error code of the message queue call. */ ReturnValue_t performOperation(uint8_t opCode) override; - /** - * A simple debug print, that prints all distribution information stored in - * queueMap. - */ - void print(); protected: /** @@ -77,19 +69,13 @@ class TcDistributor : public SystemObject, public ExecutableObjectIF, public Has * is not tried to unpack the packet information within this class. */ TmTcMessage currentMessage; - /** - * The map that links certain packet information to a destination. - * The packet information may be the APID of the packet or the service - * identifier. Filling of the map is under control of the different child - * classes. - */ - TcMessageQueueMap queueMap; + /** * This method shall unpack the routing information from the incoming * packet and select the map entry which represents the packet's target. * @return An iterator to the map element to forward to or queuMap.end(). */ - virtual TcMqMapIter selectDestination() = 0; + virtual ReturnValue_t selectDestination(MessageQueueId_t& destId) = 0; /** * The handlePacket method calls the child class's selectDestination method * and forwards the packet to its destination, if found. diff --git a/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h b/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h index a0fb23d1..6c214b0f 100644 --- a/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h +++ b/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h @@ -21,6 +21,8 @@ class AcceptsTelecommandsIF { * @brief The virtual destructor as it is mandatory for C++ interfaces. */ virtual ~AcceptsTelecommandsIF() = default; + [[nodiscard]] virtual const char* getName() const = 0; + /** * @brief Getter for a generic identifier ID. * @details Any receiving service (at least any PUS service) shall have an identifier. For @@ -28,13 +30,13 @@ class AcceptsTelecommandsIF { * service for a component expecting specific PUS service packets. * @return The identifier. */ - virtual uint32_t getIdentifier() = 0; + [[nodiscard]] virtual uint32_t getIdentifier() const = 0; /** * @brief This method returns the message queue id of the telecommand * receiving message queue. * @return The telecommand reception message queue id. */ - virtual MessageQueueId_t getRequestQueue() = 0; + [[nodiscard]] virtual MessageQueueId_t getRequestQueue() const = 0; }; #endif /* FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_ */ diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index fc9c0685..b13c22b6 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -14,7 +14,8 @@ object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; object_id_t CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t apid, - uint8_t service, uint8_t numberOfParallelCommands, + const char* name, uint8_t service, + uint8_t numberOfParallelCommands, uint16_t commandTimeoutSeconds, size_t queueDepth, VerificationReporterIF* verificationReporter) : SystemObject(setObjectId), @@ -24,7 +25,8 @@ CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t a tmStoreHelper(apid), tmHelper(service, tmStoreHelper, tmSendHelper), verificationReporter(verificationReporter), - commandMap(numberOfParallelCommands) { + commandMap(numberOfParallelCommands), + name(name) { commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth); } @@ -50,9 +52,9 @@ ReturnValue_t CommandingServiceBase::performOperation(uint8_t opCode) { return RETURN_OK; } -uint32_t CommandingServiceBase::getIdentifier() { return service; } +uint32_t CommandingServiceBase::getIdentifier() const { return service; } -MessageQueueId_t CommandingServiceBase::getRequestQueue() { return requestQueue->getId(); } +MessageQueueId_t CommandingServiceBase::getRequestQueue() const { return requestQueue->getId(); } ReturnValue_t CommandingServiceBase::initialize() { ReturnValue_t result = SystemObject::initialize(); @@ -79,7 +81,7 @@ ReturnValue_t CommandingServiceBase::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - distributor->registerService(this); + distributor->registerService(*this); requestQueue->setDefaultDestination(packetForwarding->getReportReceptionQueue()); ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); @@ -489,3 +491,5 @@ void CommandingServiceBase::prepareVerificationSuccessWithFullInfo( successParams.tcPsc = tcInfo.tcSequenceControl; successParams.ackFlags = tcInfo.ackFlags; } + +const char* CommandingServiceBase::getName() const { return name; } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 07f7179a..3346939c 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -76,7 +76,7 @@ class CommandingServiceBase : public SystemObject, * @param setPacketDestination * @param queueDepth */ - CommandingServiceBase(object_id_t setObjectId, uint16_t apid, uint8_t service, + CommandingServiceBase(object_id_t setObjectId, uint16_t apid, const char* name, uint8_t service, uint8_t numberOfParallelCommands, uint16_t commandTimeoutSeconds, size_t queueDepth = 20, VerificationReporterIF* reporter = nullptr); ~CommandingServiceBase() override; @@ -106,7 +106,7 @@ class CommandingServiceBase : public SystemObject, */ ReturnValue_t performOperation(uint8_t opCode) override; - uint32_t getIdentifier() override; + uint32_t getIdentifier() const override; /** * Returns the requestQueue MessageQueueId_t @@ -115,7 +115,7 @@ class CommandingServiceBase : public SystemObject, * * @return requestQueue messageQueueId_t */ - MessageQueueId_t getRequestQueue() override; + MessageQueueId_t getRequestQueue() const override; /** * Returns the commandQueue MessageQueueId_t @@ -134,6 +134,7 @@ class CommandingServiceBase : public SystemObject, * @param task Pointer to the taskIF of this task */ void setTaskIF(PeriodicTaskIF* task) override; + const char* getName() const override; protected: /** @@ -284,6 +285,8 @@ class CommandingServiceBase : public SystemObject, uint32_t failureParameter1 = 0; uint32_t failureParameter2 = 0; + const char* name = ""; + static object_id_t defaultPacketSource; object_id_t packetSource = objects::NO_OBJECT; static object_id_t defaultPacketDestination; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index d777d03e..8fc340f4 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -82,9 +82,9 @@ void PusServiceBase::handleRequestQueue() { } } -uint32_t PusServiceBase::getIdentifier() { return psbParams.serviceId; } +uint32_t PusServiceBase::getIdentifier() const { return psbParams.serviceId; } -MessageQueueId_t PusServiceBase::getRequestQueue() { +MessageQueueId_t PusServiceBase::getRequestQueue() const { if (psbParams.reqQueue == nullptr) { return MessageQueueIF::NO_QUEUE; } @@ -194,7 +194,7 @@ void PusServiceBase::setVerificationReporter(VerificationReporterIF& reporter) { } ReturnValue_t PusServiceBase::registerService(PusDistributorIF& distributor) { - return distributor.registerService(this); + return distributor.registerService(*this); } void PusServiceBase::setTmReceiver(AcceptsTelemetryIF& tmReceiver_) { @@ -202,3 +202,5 @@ void PusServiceBase::setTmReceiver(AcceptsTelemetryIF& tmReceiver_) { } void PusServiceBase::setRequestQueue(MessageQueueIF& reqQueue) { psbParams.reqQueue = &reqQueue; } + +const char* PusServiceBase::getName() const { return psbParams.name; } diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 34483fe7..4622b175 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -22,9 +22,13 @@ class StorageManagerIF; struct PsbParams { PsbParams() = default; PsbParams(uint16_t apid, AcceptsTelemetryIF* tmReceiver) : apid(apid), tmReceiver(tmReceiver) {} + PsbParams(const char* name, uint16_t apid, AcceptsTelemetryIF* tmReceiver) + : name(name), apid(apid), tmReceiver(tmReceiver) {} PsbParams(object_id_t objectId, uint16_t apid, uint8_t serviceId) : objectId(objectId), apid(apid), serviceId(serviceId) {} - + PsbParams(const char* name, object_id_t objectId, uint16_t apid, uint8_t serviceId) + : name(name), objectId(objectId), apid(apid), serviceId(serviceId) {} + const char* name = ""; object_id_t objectId = objects::NO_OBJECT; uint16_t apid = 0; uint8_t serviceId = 0; @@ -188,11 +192,12 @@ class PusServiceBase : public ExecutableObjectIF, * @c RETURN_FAILED else. */ ReturnValue_t performOperation(uint8_t opCode) override; - uint32_t getIdentifier() override; - MessageQueueId_t getRequestQueue() override; + uint32_t getIdentifier() const override; + MessageQueueId_t getRequestQueue() const override; ReturnValue_t initialize() override; void setTaskIF(PeriodicTaskIF* taskHandle) override; + [[nodiscard]] const char* getName() const override; protected: /** @@ -201,6 +206,7 @@ class PusServiceBase : public ExecutableObjectIF, * Will be set by setTaskIF(), which is called on task creation. */ PeriodicTaskIF* taskHandle = nullptr; + /** * One of two error parameters for additional error information. */ diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index 7190d771..d1569af5 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -7,9 +7,10 @@ #define TMTCBRIDGE_WIRETAPPING 0 -TmTcBridge::TmTcBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, - object_id_t tcStoreId) +TmTcBridge::TmTcBridge(const char* name, object_id_t objectId, object_id_t tcDestination, + object_id_t tmStoreId, object_id_t tcStoreId) : SystemObject(objectId), + name(name), tmStoreId(tmStoreId), tcStoreId(tcStoreId), tcDestination(tcDestination) @@ -67,8 +68,7 @@ ReturnValue_t TmTcBridge::initialize() { #endif return ObjectManagerIF::CHILD_INIT_FAILED; } - AcceptsTelecommandsIF* tcDistributor = - ObjectManager::instance()->get(tcDestination); + auto* tcDistributor = ObjectManager::instance()->get(tcDestination); if (tcDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::initialize: TC Distributor invalid" << std::endl; @@ -247,14 +247,16 @@ MessageQueueId_t TmTcBridge::getReportReceptionQueue(uint8_t virtualChannel) { void TmTcBridge::printData(uint8_t* data, size_t dataLen) { arrayprinter::print(data, dataLen); } -uint32_t TmTcBridge::getIdentifier() { +uint32_t TmTcBridge::getIdentifier() const { // This is no PUS service, so we just return 0 return 0; } -MessageQueueId_t TmTcBridge::getRequestQueue() { +MessageQueueId_t TmTcBridge::getRequestQueue() const { // Default implementation: Relay TC messages to TC distributor directly. return tmTcReceptionQueue->getDefaultDestination(); } void TmTcBridge::setFifoToOverwriteOldData(bool overwriteOld) { this->overwriteOld = overwriteOld; } + +const char* TmTcBridge::getName() const { return name; } diff --git a/src/fsfw/tmtcservices/TmTcBridge.h b/src/fsfw/tmtcservices/TmTcBridge.h index c4bc4062..e0535585 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.h +++ b/src/fsfw/tmtcservices/TmTcBridge.h @@ -23,9 +23,9 @@ class TmTcBridge : public AcceptsTelemetryIF, static constexpr uint8_t DEFAULT_STORED_DATA_SENT_PER_CYCLE = 5; static constexpr uint8_t DEFAULT_DOWNLINK_PACKETS_STORED = 10; - TmTcBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, - object_id_t tcStoreId); - virtual ~TmTcBridge(); + TmTcBridge(const char* name, object_id_t objectId, object_id_t tcDestination, + object_id_t tmStoreId, object_id_t tcStoreId); + ~TmTcBridge() override; /** * Set number of packets sent per performOperation().Please note that this @@ -58,21 +58,24 @@ class TmTcBridge : public AcceptsTelemetryIF, * Initializes necessary FSFW components for the TMTC Bridge * @return */ - virtual ReturnValue_t initialize() override; + ReturnValue_t initialize() override; /** * @brief Handles TMTC reception */ - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t performOperation(uint8_t operationCode = 0) override; /** AcceptsTelemetryIF override */ - virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; /** AcceptsTelecommandsIF override */ - virtual uint32_t getIdentifier() override; - virtual MessageQueueId_t getRequestQueue() override; + uint32_t getIdentifier() const override; + MessageQueueId_t getRequestQueue() const override; + const char* getName() const override; protected: + const char* name = ""; + //! Cached for initialize function. object_id_t tmStoreId = objects::NO_OBJECT; object_id_t tcStoreId = objects::NO_OBJECT; From 4334106ad12b02323ed0b99a1b48e93e0306834f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 1 Aug 2022 11:05:46 +0200 Subject: [PATCH 169/532] applied auto-formatter --- src/fsfw/tcdistribution/CMakeLists.txt | 2 +- .../{TcDistributor.cpp => TcDistributorBase.cpp} | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) rename src/fsfw/tcdistribution/{TcDistributor.cpp => TcDistributorBase.cpp} (99%) diff --git a/src/fsfw/tcdistribution/CMakeLists.txt b/src/fsfw/tcdistribution/CMakeLists.txt index 2d1a74f6..5501f4af 100644 --- a/src/fsfw/tcdistribution/CMakeLists.txt +++ b/src/fsfw/tcdistribution/CMakeLists.txt @@ -2,7 +2,7 @@ target_sources( ${LIB_FSFW_NAME} PRIVATE CcsdsDistributor.cpp PusDistributor.cpp - TcDistributor.cpp + TcDistributorBase.cpp PusPacketChecker.cpp TcPacketCheckCFDP.cpp CfdpDistributor.cpp diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributorBase.cpp similarity index 99% rename from src/fsfw/tcdistribution/TcDistributor.cpp rename to src/fsfw/tcdistribution/TcDistributorBase.cpp index 2133c961..70388b99 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributorBase.cpp @@ -1,5 +1,6 @@ -#include "fsfw/ipc/QueueFactory.h" #include "fsfw/tcdistribution/TcDistributorBase.h" + +#include "fsfw/ipc/QueueFactory.h" #include "fsfw/tmtcservices/TmTcMessage.h" TcDistributorBase::TcDistributorBase(object_id_t objectId) : SystemObject(objectId) { From bf540ebb4967dfac1e0fb08789e39a5c6ded5fb7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 1 Aug 2022 14:23:52 +0200 Subject: [PATCH 170/532] use sanitized include file --- src/fsfw/datapoollocal/HasLocalDataPoolIF.h | 8 ++--- .../serviceinterface/ServiceInterfaceBuffer.h | 4 +-- .../serviceinterface/ServiceInterfaceStream.h | 2 +- src/fsfw/tcdistribution/CcsdsDistributor.cpp | 31 +++++++++++++++---- src/fsfw/tcdistribution/CcsdsDistributor.h | 5 +-- src/fsfw/tcdistribution/CcsdsDistributorIF.h | 2 +- src/fsfw/tcdistribution/CcsdsUnpacker.cpp | 2 +- src/fsfw/tcdistribution/TcDistributorBase.h | 7 +++-- unittests/CatchDefinitions.cpp | 1 + unittests/CatchDefinitions.h | 1 + unittests/CatchSetup.cpp | 1 + unittests/mocks/PusDistributorMock.cpp | 4 +-- unittests/mocks/PusDistributorMock.h | 6 ++-- .../PollingSequenceFactory.cpp | 3 +- unittests/tmtcservices/testPsb.cpp | 2 +- 15 files changed, 53 insertions(+), 26 deletions(-) diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h index b7a6198e..b987e760 100644 --- a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h +++ b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h @@ -3,10 +3,10 @@ #include -#include "../datapool/PoolEntryIF.h" -#include "../housekeeping/HousekeepingMessage.h" -#include "../ipc/MessageQueueSenderIF.h" -#include "../serviceinterface/ServiceInterface.h" +#include "fsfw/datapool/PoolEntryIF.h" +#include "fsfw/housekeeping/HousekeepingMessage.h" +#include "fsfw/ipc/MessageQueueSenderIF.h" +#include "fsfw/serviceinterface.h" #include "LocalDataPoolManager.h" #include "localPoolDefinitions.h" diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h index 9cda75c6..6832e809 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h @@ -1,9 +1,9 @@ #ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ -#include +#include "fsfw/FSFW.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/serviceinterface/ServiceInterfaceStream.h b/src/fsfw/serviceinterface/ServiceInterfaceStream.h index 0b3d6745..bf3424a6 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceStream.h +++ b/src/fsfw/serviceinterface/ServiceInterfaceStream.h @@ -1,7 +1,7 @@ #ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ -#include +#include "fsfw/FSFW.h" #include "ServiceInterfaceBuffer.h" diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp index 8e6f9eeb..816d3037 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -1,3 +1,4 @@ +#include "fsfw/FSFW.h" #include "fsfw/tcdistribution/CcsdsDistributor.h" #include "definitions.h" @@ -9,7 +10,9 @@ CcsdsDistributor::CcsdsDistributor(uint16_t setDefaultApid, object_id_t setObjectId, CcsdsPacketCheckIF* packetChecker) - : TcDistributorBase(setObjectId), defaultApid(setDefaultApid), packetChecker(packetChecker) {} + : TcDistributorBase(setObjectId), + defaultApid(setDefaultApid), + packetChecker(packetChecker) {} CcsdsDistributor::~CcsdsDistributor() = default; @@ -52,13 +55,16 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { sif::info << "CCSDSDistributor::selectDestination has packet with APID 0x" << std::hex << currentPacket.getApid() << std::dec << std::endl; #endif - auto position = receiverMap.find(currentPacket.getApid()); - if (position != receiverMap.end()) { - destId = position->second.destId; + auto iter = receiverMap.find(currentPacket.getApid()); + if (iter != receiverMap.end()) { + destId = iter->second.destId; + if (iter->second.removeHeader) { + handleCcsdsHeaderRemoval(); + } } else { // The APID was not found. Forward packet to main SW-APID anyway to // create acceptance failure report. - auto iter = receiverMap.find(defaultApid); + iter = receiverMap.find(defaultApid); if (iter != receiverMap.end()) { destId = iter->second.destId; } else { @@ -69,6 +75,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { } void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) { +#if FSFW_VERBOSE_LEVEL >= 1 const char* reason = "Unknown reason"; if (result == tcdistrib::INVALID_CCSDS_VERSION) { reason = "Invalid CCSDS version"; @@ -79,7 +86,6 @@ void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) { } else if (result == tcdistrib::INVALID_PACKET_TYPE) { reason = "Invalid Packet Type TM detected"; } -#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "CCSDS packet check failed: " << reason << std::endl; #else @@ -144,3 +150,16 @@ void CcsdsDistributor::print() { } const char* CcsdsDistributor::getName() const { return "CCSDS Distributor"; } + +ReturnValue_t CcsdsDistributor::handleCcsdsHeaderRemoval() { + currentMessage; + auto accessorPair = tcStore->getData(currentMessage.getStorageId()); + if(accessorPair.first != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << __func__ << ": Getting TC data failed" << std::endl; +#else + sif::printError("%s: Getting TC data failed\n", __func__); +#endif + return accessorPair.first; + } +} diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.h b/src/fsfw/tcdistribution/CcsdsDistributor.h index cd010ad5..542625eb 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.h +++ b/src/fsfw/tcdistribution/CcsdsDistributor.h @@ -37,9 +37,9 @@ class CcsdsDistributor : public TcDistributorBase, */ ~CcsdsDistributor() override; - MessageQueueId_t getRequestQueue() const override; + [[nodiscard]] MessageQueueId_t getRequestQueue() const override; ReturnValue_t registerApplication(DestInfo info) override; - uint32_t getIdentifier() const override; + [[nodiscard]] uint32_t getIdentifier() const override; ReturnValue_t initialize() override; [[nodiscard]] const char* getName() const override; @@ -63,6 +63,7 @@ class CcsdsDistributor : public TcDistributorBase, static void handlePacketCheckFailure(ReturnValue_t result); + ReturnValue_t handleCcsdsHeaderRemoval(); void print(); /** * The default APID, where packets with unknown APID are sent to. diff --git a/src/fsfw/tcdistribution/CcsdsDistributorIF.h b/src/fsfw/tcdistribution/CcsdsDistributorIF.h index aee9d46d..7e7a586d 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributorIF.h +++ b/src/fsfw/tcdistribution/CcsdsDistributorIF.h @@ -17,7 +17,7 @@ class CcsdsDistributorIF { struct DestInfo { DestInfo(const char* name, uint16_t apid, MessageQueueId_t destId, bool removeHeader) : name(name), apid(apid), destId(destId), removeHeader(removeHeader) {} - DestInfo(const char* name, AcceptsTelecommandsIF& ccsdsReceiver, bool removeHeader_) + DestInfo(const char* name, const AcceptsTelecommandsIF& ccsdsReceiver, bool removeHeader_) : name(name) { apid = ccsdsReceiver.getIdentifier(); destId = ccsdsReceiver.getRequestQueue(); diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.cpp b/src/fsfw/tcdistribution/CcsdsUnpacker.cpp index d3524c17..42a7cd28 100644 --- a/src/fsfw/tcdistribution/CcsdsUnpacker.cpp +++ b/src/fsfw/tcdistribution/CcsdsUnpacker.cpp @@ -55,6 +55,6 @@ ReturnValue_t CcsdsUnpacker::performOperation(uint8_t operationCode) { void CcsdsUnpacker::setDifferentTargetStore(StorageManagerIF& otherTargetStore) { targetStore = &otherTargetStore; } -ReturnValue_t CcsdsUnpacker::performOperation(uint8_t operationCode) { return 0; } + uint32_t CcsdsUnpacker::getIdentifier() const { return 0; } MessageQueueId_t CcsdsUnpacker::getRequestQueue() const { return 0; } diff --git a/src/fsfw/tcdistribution/TcDistributorBase.h b/src/fsfw/tcdistribution/TcDistributorBase.h index c1fd4531..08b72823 100644 --- a/src/fsfw/tcdistribution/TcDistributorBase.h +++ b/src/fsfw/tcdistribution/TcDistributorBase.h @@ -65,15 +65,16 @@ class TcDistributorBase : public SystemObject, public ExecutableObjectIF, public * The last received incoming packet information is stored in this * member. * As different child classes unpack the incoming packet differently - * (i.e. as a CCSDS Space Packet or as a PUS Telecommand Packet), it - * is not tried to unpack the packet information within this class. + * (i.e. as a CCSDS Space Packet or as a PUS Telecommand Packet), no unpacking will be + * done in this class. */ TmTcMessage currentMessage; /** * This method shall unpack the routing information from the incoming * packet and select the map entry which represents the packet's target. - * @return An iterator to the map element to forward to or queuMap.end(). + * @return + * - @c RETURN_OK if a desitnation was selected successfully */ virtual ReturnValue_t selectDestination(MessageQueueId_t& destId) = 0; /** diff --git a/unittests/CatchDefinitions.cpp b/unittests/CatchDefinitions.cpp index 85e3aad0..15ff1de9 100644 --- a/unittests/CatchDefinitions.cpp +++ b/unittests/CatchDefinitions.cpp @@ -1,3 +1,4 @@ +#include "fsfw/FSFW.h" #include "CatchDefinitions.h" #include diff --git a/unittests/CatchDefinitions.h b/unittests/CatchDefinitions.h index dbe3848b..be49e6e8 100644 --- a/unittests/CatchDefinitions.h +++ b/unittests/CatchDefinitions.h @@ -1,6 +1,7 @@ #ifndef FSFW_UNITTEST_CORE_CATCHDEFINITIONS_H_ #define FSFW_UNITTEST_CORE_CATCHDEFINITIONS_H_ +#include "fsfw/FSFW.h" #include #include #include diff --git a/unittests/CatchSetup.cpp b/unittests/CatchSetup.cpp index 9206c2e1..848af5e7 100644 --- a/unittests/CatchSetup.cpp +++ b/unittests/CatchSetup.cpp @@ -1,3 +1,4 @@ +#include "fsfw/FSFW.h" #include "CatchDefinitions.h" #include "CatchFactory.h" diff --git a/unittests/mocks/PusDistributorMock.cpp b/unittests/mocks/PusDistributorMock.cpp index cb9aed32..6dbba967 100644 --- a/unittests/mocks/PusDistributorMock.cpp +++ b/unittests/mocks/PusDistributorMock.cpp @@ -5,8 +5,8 @@ PusDistributorMock::PusDistributorMock() : SystemObject(objects::NO_OBJECT, fals PusDistributorMock::PusDistributorMock(object_id_t registeredId) : SystemObject(registeredId, true) {} -ReturnValue_t PusDistributorMock::registerService(AcceptsTelecommandsIF *service) { +ReturnValue_t PusDistributorMock::registerService(const AcceptsTelecommandsIF& service) { registerCallCount++; - lastServiceArg = service; + registeredServies.push_back(&service); return HasReturnvaluesIF::RETURN_OK; } diff --git a/unittests/mocks/PusDistributorMock.h b/unittests/mocks/PusDistributorMock.h index e19820f3..d85030c9 100644 --- a/unittests/mocks/PusDistributorMock.h +++ b/unittests/mocks/PusDistributorMock.h @@ -4,13 +4,15 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tcdistribution/PusDistributorIF.h" +#include + class PusDistributorMock : public SystemObject, public PusDistributorIF { public: PusDistributorMock(); explicit PusDistributorMock(object_id_t registeredId); unsigned int registerCallCount = 0; - AcceptsTelecommandsIF* lastServiceArg = nullptr; - ReturnValue_t registerService(AcceptsTelecommandsIF* service) override; + std::vector registeredServies; + ReturnValue_t registerService(const AcceptsTelecommandsIF& service) override; }; #endif // FSFW_TESTS_PUSDISTRIBUTORMOCK_H diff --git a/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp b/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp index 0c44f6a2..34a8cfbd 100644 --- a/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp +++ b/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp @@ -1,3 +1,4 @@ +#include "fsfw/FSFW.h" #include "PollingSequenceFactory.h" #include @@ -20,7 +21,7 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { return HasReturnvaluesIF::RETURN_OK; } else { -#if FSFW_CPP_OSTREAM_ENABLED +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" << std::endl; #else sif::printError("pst::pollingSequenceInitDefault: Sequence invalid!"); diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index 464fb3da..0240223a 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -192,7 +192,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { REQUIRE(PsbMock::getStaticPusDistributor() == distributorId); REQUIRE(psb2.initialize() == result::OK); REQUIRE(pusDistrib.registerCallCount == 1); - REQUIRE(pusDistrib.lastServiceArg == &psb2); + REQUIRE(pusDistrib.registeredServies.front() == &psb2); } SECTION("Auto Initialize Packet Destination") { From 52ee50ba8c616f736dc107c007688a5cf03b50c1 Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Mon, 1 Aug 2022 16:21:07 +0200 Subject: [PATCH 171/532] Fixed cmake variable for tests in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 847e5e9a..1b2ca52d 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ You can use the following commands inside the `fsfw` folder to set up the build ```sh mkdir build-tests && cd build-tests -cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host -DCMAKE_BUILD_TYPE=Debug .. +cmake -DFSFW_BUILD_TESTS=ON -DFSFW_OSAL=host -DCMAKE_BUILD_TYPE=Debug .. ``` You can also use `-DFSFW_OSAL=linux` on Linux systems. From 902a4bfa9ce3228c6d14d96c00cd0f410a47141d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 1 Aug 2022 17:16:37 +0200 Subject: [PATCH 172/532] unittests for TC and CCSDS distributor --- CMakeLists.txt | 4 +- src/fsfw/datapoollocal/HasLocalDataPoolIF.h | 2 +- src/fsfw/events/fwSubsystemIdRanges.h | 1 + .../serviceinterface/ServiceInterfaceBuffer.h | 1 - .../serviceinterface/ServiceInterfaceStream.h | 3 +- src/fsfw/tcdistribution/CcsdsDistributor.cpp | 69 ++++++----- src/fsfw/tcdistribution/CcsdsDistributor.h | 3 +- src/fsfw/tcdistribution/CcsdsDistributorIF.h | 4 +- src/fsfw/tcdistribution/CcsdsUnpacker.cpp | 21 ++-- src/fsfw/tcdistribution/CcsdsUnpacker.h | 3 +- src/fsfw/tcdistribution/CfdpDistributor.cpp | 2 + src/fsfw/tcdistribution/PusDistributor.cpp | 3 +- src/fsfw/tcdistribution/TcDistributorBase.cpp | 25 +++- src/fsfw/tcdistribution/TcDistributorBase.h | 8 +- .../tmtcpacket/ccsds/SpacePacketReader.cpp | 5 +- unittests/CMakeLists.txt | 1 + unittests/CatchDefinitions.cpp | 3 +- unittests/CatchDefinitions.h | 3 +- unittests/CatchSetup.cpp | 2 +- unittests/mocks/AcceptsTcMock.cpp | 8 ++ unittests/mocks/AcceptsTcMock.h | 20 ++++ unittests/mocks/CMakeLists.txt | 2 + unittests/mocks/CcsdsCheckerMock.cpp | 10 ++ unittests/mocks/CcsdsCheckerMock.h | 16 +++ unittests/mocks/PusDistributorMock.h | 4 +- unittests/tcdistributor/CMakeLists.txt | 3 + .../tcdistributor/testCcsdsDistributor.cpp | 113 ++++++++++++++++++ .../PollingSequenceFactory.cpp | 2 +- unittests/tmtcpacket/testCcsdsReader.cpp | 2 +- 29 files changed, 277 insertions(+), 66 deletions(-) create mode 100644 unittests/mocks/AcceptsTcMock.cpp create mode 100644 unittests/mocks/AcceptsTcMock.h create mode 100644 unittests/mocks/CcsdsCheckerMock.cpp create mode 100644 unittests/mocks/CcsdsCheckerMock.h create mode 100644 unittests/tcdistributor/CMakeLists.txt create mode 100644 unittests/tcdistributor/testCcsdsDistributor.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index cfae2acb..c9c267f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,8 @@ if(FSFW_GENERATE_SECTIONS) option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) endif() -option(FSFW_BUILD_TESTS "Build unittest binary in addition to static library" +option(FSFW_BUILD_TESTS + "Build unittest binary in addition to static library. Requires Catch2" OFF) option(FSFW_CICD_BUILD "Build for CI/CD. This can disable problematic test" OFF) option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF) @@ -115,7 +116,6 @@ endif() option(FSFW_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON) # Options to exclude parts of the FSFW from compilation. option(FSFW_ADD_INTERNAL_TESTS "Add internal unit tests" ON) -option(FSFW_ADD_UNITTESTS "Add regular unittests. Requires Catch2" OFF) option(FSFW_ADD_HAL "Add Hardware Abstraction Layer" ON) # Optional sources diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h index b987e760..a0f8b03a 100644 --- a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h +++ b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h @@ -3,11 +3,11 @@ #include +#include "LocalDataPoolManager.h" #include "fsfw/datapool/PoolEntryIF.h" #include "fsfw/housekeeping/HousekeepingMessage.h" #include "fsfw/ipc/MessageQueueSenderIF.h" #include "fsfw/serviceinterface.h" -#include "LocalDataPoolManager.h" #include "localPoolDefinitions.h" class AccessPoolManagerIF; diff --git a/src/fsfw/events/fwSubsystemIdRanges.h b/src/fsfw/events/fwSubsystemIdRanges.h index fa4351e9..a09c935c 100644 --- a/src/fsfw/events/fwSubsystemIdRanges.h +++ b/src/fsfw/events/fwSubsystemIdRanges.h @@ -19,6 +19,7 @@ enum : uint8_t { HK = 73, SYSTEM_MANAGER = 74, SYSTEM_MANAGER_1 = 75, + TC_DISTRIBUTION = 76, SYSTEM_1 = 79, PUS_SERVICE_1 = 80, PUS_SERVICE_2 = 82, diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h index 6832e809..9e692a05 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h @@ -2,7 +2,6 @@ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ #include "fsfw/FSFW.h" - #include "fsfw/returnvalues/HasReturnvaluesIF.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/serviceinterface/ServiceInterfaceStream.h b/src/fsfw/serviceinterface/ServiceInterfaceStream.h index bf3424a6..ca746e7d 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceStream.h +++ b/src/fsfw/serviceinterface/ServiceInterfaceStream.h @@ -1,9 +1,8 @@ #ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ -#include "fsfw/FSFW.h" - #include "ServiceInterfaceBuffer.h" +#include "fsfw/FSFW.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp index 816d3037..f168e20a 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -1,7 +1,7 @@ -#include "fsfw/FSFW.h" #include "fsfw/tcdistribution/CcsdsDistributor.h" #include "definitions.h" +#include "fsfw/FSFW.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" @@ -9,9 +9,11 @@ #define CCSDS_DISTRIBUTOR_DEBUGGING 0 CcsdsDistributor::CcsdsDistributor(uint16_t setDefaultApid, object_id_t setObjectId, + StorageManagerIF* tcStore, MessageQueueIF* queue, CcsdsPacketCheckIF* packetChecker) - : TcDistributorBase(setObjectId), + : TcDistributorBase(setObjectId, queue), defaultApid(setDefaultApid), + tcStore(tcStore), packetChecker(packetChecker) {} CcsdsDistributor::~CcsdsDistributor() = default; @@ -28,9 +30,8 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { currentMessage.getStorageId().packetIndex); #endif #endif - const uint8_t* packet = nullptr; - size_t size = 0; - ReturnValue_t result = tcStore->getData(currentMessage.getStorageId(), &packet, &size); + auto accessorPair = tcStore->getData(currentMessage.getStorageId()); + ReturnValue_t result = accessorPair.first; if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -45,8 +46,11 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { #endif return result; } - SpacePacketReader currentPacket(packet, size); - result = packetChecker->checkPacket(currentPacket, size); + if (accessorPair.second.size() < ccsds::HEADER_LEN) { + return SerializeIF::STREAM_TOO_SHORT; + } + SpacePacketReader currentPacket(accessorPair.second.data(), accessorPair.second.size()); + result = packetChecker->checkPacket(currentPacket, accessorPair.second.size()); if (result != HasReturnvaluesIF::RETURN_OK) { handlePacketCheckFailure(result); return result; @@ -59,11 +63,12 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { if (iter != receiverMap.end()) { destId = iter->second.destId; if (iter->second.removeHeader) { - handleCcsdsHeaderRemoval(); + // Do not call accessor release method here to ensure the old packet gets deleted. + return handleCcsdsHeaderRemoval(accessorPair.second); } } else { // The APID was not found. Forward packet to main SW-APID anyway to - // create acceptance failure report. + // create acceptance failure report. iter = receiverMap.find(defaultApid); if (iter != receiverMap.end()) { destId = iter->second.destId; @@ -71,6 +76,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { return DESTINATION_NOT_FOUND; } } + accessorPair.second.release(); return HasReturnvaluesIF::RETURN_OK; } @@ -111,23 +117,28 @@ ReturnValue_t CcsdsDistributor::initialize() { if (packetChecker == nullptr) { packetChecker = new CcsdsPacketChecker(ccsds::PacketType::TC); } - ReturnValue_t status = this->TcDistributorBase::initialize(); - this->tcStore = ObjectManager::instance()->get(objects::TC_STORE); - if (this->tcStore == nullptr) { + ReturnValue_t result = TcDistributorBase::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if (tcStore == nullptr) { + tcStore = ObjectManager::instance()->get(objects::TC_STORE); + if (tcStore == nullptr) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CCSDSDistributor::initialize: Could not initialize" - " TC store!" - << std::endl; + sif::error << "CCSDSDistributor::initialize: Could not initialize" + " TC store!" + << std::endl; #else - sif::printError( - "CCSDSDistributor::initialize: Could not initialize" - " TC store!\n"); + sif::printError( + "CCSDSDistributor::initialize: Could not initialize" + " TC store!\n"); #endif #endif - status = RETURN_FAILED; + return ObjectManagerIF::CHILD_INIT_FAILED; + } } - return status; + return result; } ReturnValue_t CcsdsDistributor::callbackAfterSending(ReturnValue_t queueStatus) { @@ -151,15 +162,19 @@ void CcsdsDistributor::print() { const char* CcsdsDistributor::getName() const { return "CCSDS Distributor"; } -ReturnValue_t CcsdsDistributor::handleCcsdsHeaderRemoval() { - currentMessage; - auto accessorPair = tcStore->getData(currentMessage.getStorageId()); - if(accessorPair.first != HasReturnvaluesIF::RETURN_OK) { +ReturnValue_t CcsdsDistributor::handleCcsdsHeaderRemoval(ConstStorageAccessor& accessor) { + store_address_t newStoreId; + ReturnValue_t result = tcStore->addData(&newStoreId, accessor.data() + ccsds::HEADER_LEN, + accessor.size() - ccsds::HEADER_LEN); + if (result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << __func__ << ": Getting TC data failed" << std::endl; + sif::error << __func__ << ": TC store full" << std::endl; #else - sif::printError("%s: Getting TC data failed\n", __func__); + sif::printError("%s: TC store full\n", __func__); #endif - return accessorPair.first; + return result; } + currentMessage.setStorageId(newStoreId); + // The const accessor will delete the old data automatically + return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.h b/src/fsfw/tcdistribution/CcsdsDistributor.h index 542625eb..c2ada02d 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.h +++ b/src/fsfw/tcdistribution/CcsdsDistributor.h @@ -31,6 +31,7 @@ class CcsdsDistributor : public TcDistributorBase, * destination are sent to. */ CcsdsDistributor(uint16_t unknownApid, object_id_t setObjectId, + StorageManagerIF* tcStore = nullptr, MessageQueueIF* msgQueue = nullptr, CcsdsPacketCheckIF* packetChecker = nullptr); /** * The destructor is empty. @@ -63,7 +64,7 @@ class CcsdsDistributor : public TcDistributorBase, static void handlePacketCheckFailure(ReturnValue_t result); - ReturnValue_t handleCcsdsHeaderRemoval(); + ReturnValue_t handleCcsdsHeaderRemoval(ConstStorageAccessor& accessor); void print(); /** * The default APID, where packets with unknown APID are sent to. diff --git a/src/fsfw/tcdistribution/CcsdsDistributorIF.h b/src/fsfw/tcdistribution/CcsdsDistributorIF.h index 7e7a586d..6deb1c67 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributorIF.h +++ b/src/fsfw/tcdistribution/CcsdsDistributorIF.h @@ -17,8 +17,8 @@ class CcsdsDistributorIF { struct DestInfo { DestInfo(const char* name, uint16_t apid, MessageQueueId_t destId, bool removeHeader) : name(name), apid(apid), destId(destId), removeHeader(removeHeader) {} - DestInfo(const char* name, const AcceptsTelecommandsIF& ccsdsReceiver, bool removeHeader_) - : name(name) { + DestInfo(const AcceptsTelecommandsIF& ccsdsReceiver, bool removeHeader_) + : name(ccsdsReceiver.getName()) { apid = ccsdsReceiver.getIdentifier(); destId = ccsdsReceiver.getRequestQueue(); removeHeader = removeHeader_; diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.cpp b/src/fsfw/tcdistribution/CcsdsUnpacker.cpp index 42a7cd28..9b212d2e 100644 --- a/src/fsfw/tcdistribution/CcsdsUnpacker.cpp +++ b/src/fsfw/tcdistribution/CcsdsUnpacker.cpp @@ -4,29 +4,28 @@ CcsdsUnpacker::CcsdsUnpacker(MessageQueueIF& msgQueue, AcceptsTelecommandsIF& receiver, StorageManagerIF& sourceStore) - : sourceStore(sourceStore), msgQueue(msgQueue), receiver(receiver) { + : sourceStore(sourceStore), msgQueue(msgQueue), receiver(receiver) { msgQueue.setDefaultDestination(receiver.getRequestQueue()); } ReturnValue_t CcsdsUnpacker::performOperation(uint8_t operationCode) { TmTcMessage msg; ReturnValue_t result; - for (result = msgQueue.receiveMessage(&msg); result == HasReturnvaluesIF::RETURN_OK; + for (result = msgQueue.receiveMessage(&msg); result == HasReturnvaluesIF::RETURN_OK; result = msgQueue.receiveMessage(&msg)) { auto resultPair = sourceStore.getData(msg.getStorageId()); - if(resultPair.first != HasReturnvaluesIF::RETURN_OK) { + if (resultPair.first != HasReturnvaluesIF::RETURN_OK) { continue; } - if(resultPair.second.size() < 6) { + if (resultPair.second.size() < 6) { // TODO: This is a config error. Does it make sense to forward the message? result = msgQueue.sendToDefault(&msg); - if(result != HasReturnvaluesIF::RETURN_OK) { - + if (result != HasReturnvaluesIF::RETURN_OK) { } continue; } StorageManagerIF* tgtStore; - if(targetStore != nullptr) { + if (targetStore != nullptr) { tgtStore = targetStore; } else { tgtStore = &sourceStore; @@ -34,24 +33,22 @@ ReturnValue_t CcsdsUnpacker::performOperation(uint8_t operationCode) { store_address_t newId; uint8_t* ptr; result = tgtStore->getFreeElement(&newId, resultPair.second.size(), &ptr); - if(result != HasReturnvaluesIF::RETURN_OK) { + if (result != HasReturnvaluesIF::RETURN_OK) { // TODO: Implement error handling } std::memcpy(ptr, resultPair.second.data() + 6, resultPair.second.size() - 6); result = sourceStore.deleteData(msg.getStorageId()); - if(result != HasReturnvaluesIF::RETURN_OK) { + if (result != HasReturnvaluesIF::RETURN_OK) { // TODO: Implement error handling (though this really should not happen) } TmTcMessage newMsg(newId); result = msgQueue.sendToDefault(&newMsg); - if(result != HasReturnvaluesIF::RETURN_OK) { - + if (result != HasReturnvaluesIF::RETURN_OK) { } } return result; } - void CcsdsUnpacker::setDifferentTargetStore(StorageManagerIF& otherTargetStore) { targetStore = &otherTargetStore; } diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.h b/src/fsfw/tcdistribution/CcsdsUnpacker.h index d8c5e8b5..267b8e64 100644 --- a/src/fsfw/tcdistribution/CcsdsUnpacker.h +++ b/src/fsfw/tcdistribution/CcsdsUnpacker.h @@ -7,7 +7,8 @@ class CcsdsUnpacker : public ExecutableObjectIF, public AcceptsTelecommandsIF { public: - CcsdsUnpacker(MessageQueueIF& msgQueue, AcceptsTelecommandsIF& receiver, StorageManagerIF& sourceStore); + CcsdsUnpacker(MessageQueueIF& msgQueue, AcceptsTelecommandsIF& receiver, + StorageManagerIF& sourceStore); void setDifferentTargetStore(StorageManagerIF& otherTargetStore); ReturnValue_t performOperation(uint8_t operationCode) override; diff --git a/src/fsfw/tcdistribution/CfdpDistributor.cpp b/src/fsfw/tcdistribution/CfdpDistributor.cpp index abbad748..3b1d1538 100644 --- a/src/fsfw/tcdistribution/CfdpDistributor.cpp +++ b/src/fsfw/tcdistribution/CfdpDistributor.cpp @@ -68,6 +68,7 @@ ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { // } else { // return queueMapIt; // } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t CfdpDistributor::registerHandler(AcceptsTelecommandsIF* handler) { @@ -141,4 +142,5 @@ ReturnValue_t CfdpDistributor::initialize() { // return RETURN_FAILED; // } // return ccsdsDistributor->registerApplication(this); + return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index e85a6047..7be0810d 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -139,8 +139,7 @@ ReturnValue_t PusDistributor::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } } - return ccsdsDistributor->registerApplication( - CcsdsDistributorIF::DestInfo(getName(), *this, false)); + return ccsdsDistributor->registerApplication(CcsdsDistributorIF::DestInfo(*this, false)); } void PusDistributor::checkerFailurePrinter() const { diff --git a/src/fsfw/tcdistribution/TcDistributorBase.cpp b/src/fsfw/tcdistribution/TcDistributorBase.cpp index 70388b99..33c779eb 100644 --- a/src/fsfw/tcdistribution/TcDistributorBase.cpp +++ b/src/fsfw/tcdistribution/TcDistributorBase.cpp @@ -3,22 +3,35 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/tmtcservices/TmTcMessage.h" -TcDistributorBase::TcDistributorBase(object_id_t objectId) : SystemObject(objectId) { - tcQueue = QueueFactory::instance()->createMessageQueue(DISTRIBUTER_MAX_PACKETS); +TcDistributorBase::TcDistributorBase(object_id_t objectId, MessageQueueIF* tcQueue_) + : SystemObject(objectId), tcQueue(tcQueue_) { + if (tcQueue == nullptr) { + ownedQueue = true; + tcQueue = QueueFactory::instance()->createMessageQueue(DISTRIBUTER_MAX_PACKETS); + } } -TcDistributorBase::~TcDistributorBase() { QueueFactory::instance()->deleteMessageQueue(tcQueue); } +TcDistributorBase::~TcDistributorBase() { + if (ownedQueue) { + QueueFactory::instance()->deleteMessageQueue(tcQueue); + } +} ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) { ReturnValue_t status; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; for (status = tcQueue->receiveMessage(¤tMessage); status == RETURN_OK; status = tcQueue->receiveMessage(¤tMessage)) { - status = handlePacket(); + ReturnValue_t packetResult = handlePacket(); + if (packetResult != HasReturnvaluesIF::RETURN_OK) { + result = packetResult; + triggerEvent(HANDLE_PACKET_FAILED, packetResult, __LINE__); + } } if (status == MessageQueueIF::EMPTY) { - return RETURN_OK; + return result; } - return status; + return result; } ReturnValue_t TcDistributorBase::handlePacket() { diff --git a/src/fsfw/tcdistribution/TcDistributorBase.h b/src/fsfw/tcdistribution/TcDistributorBase.h index 08b72823..c2bee0b9 100644 --- a/src/fsfw/tcdistribution/TcDistributorBase.h +++ b/src/fsfw/tcdistribution/TcDistributorBase.h @@ -3,6 +3,7 @@ #include +#include "fsfw/events/Event.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/objectmanager/ObjectManagerIF.h" #include "fsfw/objectmanager/SystemObject.h" @@ -33,6 +34,10 @@ class TcDistributorBase : public SystemObject, public ExecutableObjectIF, public static constexpr ReturnValue_t PACKET_LOST = MAKE_RETURN_CODE(1); static constexpr ReturnValue_t DESTINATION_NOT_FOUND = MAKE_RETURN_CODE(2); static constexpr ReturnValue_t SERVICE_ID_ALREADY_EXISTS = MAKE_RETURN_CODE(3); + + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TC_DISTRIBUTION; + //! P1: Returnvalue, P2: Line number + static constexpr Event HANDLE_PACKET_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); /** * Within the default constructor, the SystemObject id is set and the * message queue is initialized. @@ -40,7 +45,7 @@ class TcDistributorBase : public SystemObject, public ExecutableObjectIF, public * @param set_object_id This id is assigned to the distributor * implementation. */ - explicit TcDistributorBase(object_id_t objectId); + explicit TcDistributorBase(object_id_t objectId, MessageQueueIF* tcQueue = nullptr); /** * The destructor is empty, the message queues are not in the vicinity of * this class. @@ -56,6 +61,7 @@ class TcDistributorBase : public SystemObject, public ExecutableObjectIF, public ReturnValue_t performOperation(uint8_t opCode) override; protected: + bool ownedQueue = false; /** * This is the receiving queue for incoming Telecommands. * The child classes must make its queue id public. diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp index b6f03de9..4a140dac 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp @@ -35,8 +35,11 @@ uint16_t SpacePacketReader::getPacketDataLen() const { return ccsds::getPacketLe ReturnValue_t SpacePacketReader::setInternalFields(const uint8_t* data, size_t maxSize_) { bufSize = maxSize_; + if (maxSize_ < ccsds::HEADER_LEN) { + return SerializeIF::STREAM_TOO_SHORT; + } spHeader = reinterpret_cast(data); - if (maxSize_ > 6) { + if (maxSize_ > ccsds::HEADER_LEN) { packetDataField = data + ccsds::HEADER_LEN; } return checkSize(); diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index fc03a728..595d9553 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -13,6 +13,7 @@ target_sources(${FSFW_TEST_TGT} PRIVATE add_subdirectory(testcfg) add_subdirectory(mocks) +add_subdirectory(tcdistributor) add_subdirectory(action) add_subdirectory(power) add_subdirectory(util) diff --git a/unittests/CatchDefinitions.cpp b/unittests/CatchDefinitions.cpp index 15ff1de9..3c76fd88 100644 --- a/unittests/CatchDefinitions.cpp +++ b/unittests/CatchDefinitions.cpp @@ -1,9 +1,10 @@ -#include "fsfw/FSFW.h" #include "CatchDefinitions.h" #include #include +#include "fsfw/FSFW.h" + StorageManagerIF* tglob::getIpcStoreHandle() { if (ObjectManager::instance() != nullptr) { return ObjectManager::instance()->get(objects::IPC_STORE); diff --git a/unittests/CatchDefinitions.h b/unittests/CatchDefinitions.h index be49e6e8..7ffad55a 100644 --- a/unittests/CatchDefinitions.h +++ b/unittests/CatchDefinitions.h @@ -1,11 +1,12 @@ #ifndef FSFW_UNITTEST_CORE_CATCHDEFINITIONS_H_ #define FSFW_UNITTEST_CORE_CATCHDEFINITIONS_H_ -#include "fsfw/FSFW.h" #include #include #include +#include "fsfw/FSFW.h" + namespace tconst { static constexpr MessageQueueId_t testQueueId = 42; } diff --git a/unittests/CatchSetup.cpp b/unittests/CatchSetup.cpp index 848af5e7..4f2a4a54 100644 --- a/unittests/CatchSetup.cpp +++ b/unittests/CatchSetup.cpp @@ -1,6 +1,6 @@ -#include "fsfw/FSFW.h" #include "CatchDefinitions.h" #include "CatchFactory.h" +#include "fsfw/FSFW.h" #ifdef GCOV #include diff --git a/unittests/mocks/AcceptsTcMock.cpp b/unittests/mocks/AcceptsTcMock.cpp new file mode 100644 index 00000000..a9afafd9 --- /dev/null +++ b/unittests/mocks/AcceptsTcMock.cpp @@ -0,0 +1,8 @@ +#include "AcceptsTcMock.h" + +AcceptsTcMock::AcceptsTcMock(const char* name, uint32_t id, MessageQueueId_t queueId) + : name(name), id(id), queueId(queueId) {} + +const char* AcceptsTcMock::getName() const { return name; } +uint32_t AcceptsTcMock::getIdentifier() const { return id; } +MessageQueueId_t AcceptsTcMock::getRequestQueue() const { return queueId; } diff --git a/unittests/mocks/AcceptsTcMock.h b/unittests/mocks/AcceptsTcMock.h new file mode 100644 index 00000000..028b68cd --- /dev/null +++ b/unittests/mocks/AcceptsTcMock.h @@ -0,0 +1,20 @@ +#ifndef FSFW_TESTS_ACCEPTSTCMOCK_H +#define FSFW_TESTS_ACCEPTSTCMOCK_H + +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" + +class AcceptsTcMock : public AcceptsTelecommandsIF { + public: + AcceptsTcMock(const char* name, uint32_t id, MessageQueueId_t queueId); + [[nodiscard]] const char* getName() const override; + [[nodiscard]] uint32_t getIdentifier() const override; + [[nodiscard]] MessageQueueId_t getRequestQueue() const override; + + const char* name; + uint32_t id; + MessageQueueId_t queueId; + + private: +}; + +#endif // FSFW_TESTS_ACCEPTSTCMOCK_H diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index f3b50f62..3a8c8d18 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -11,4 +11,6 @@ target_sources(${FSFW_TEST_TGT} PRIVATE PusServiceBaseMock.cpp AcceptsTmMock.cpp PusDistributorMock.cpp + CcsdsCheckerMock.cpp + AcceptsTcMock.cpp ) diff --git a/unittests/mocks/CcsdsCheckerMock.cpp b/unittests/mocks/CcsdsCheckerMock.cpp new file mode 100644 index 00000000..18c5fb4e --- /dev/null +++ b/unittests/mocks/CcsdsCheckerMock.cpp @@ -0,0 +1,10 @@ +#include "CcsdsCheckerMock.h" + +CcsdsCheckerMock::CcsdsCheckerMock() = default; + +ReturnValue_t CcsdsCheckerMock::checkPacket(const SpacePacketReader& currentPacket, + size_t packetLen) { + checkCallCount++; + checkedPacketLen = packetLen; + return nextResult; +} diff --git a/unittests/mocks/CcsdsCheckerMock.h b/unittests/mocks/CcsdsCheckerMock.h new file mode 100644 index 00000000..a9388ae5 --- /dev/null +++ b/unittests/mocks/CcsdsCheckerMock.h @@ -0,0 +1,16 @@ +#ifndef FSFW_TESTS_CCSDSCHECKERMOCK_H +#define FSFW_TESTS_CCSDSCHECKERMOCK_H + +#include "fsfw/tcdistribution/CcsdsPacketCheckIF.h" +class CcsdsCheckerMock : public CcsdsPacketCheckIF { + public: + CcsdsCheckerMock(); + unsigned int checkCallCount = 0; + size_t checkedPacketLen = 0; + ReturnValue_t nextResult = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t checkPacket(const SpacePacketReader& currentPacket, size_t packetLen) override; + + private: +}; + +#endif // FSFW_TESTS_CCSDSCHECKERMOCK_H diff --git a/unittests/mocks/PusDistributorMock.h b/unittests/mocks/PusDistributorMock.h index d85030c9..417ae448 100644 --- a/unittests/mocks/PusDistributorMock.h +++ b/unittests/mocks/PusDistributorMock.h @@ -1,11 +1,11 @@ #ifndef FSFW_TESTS_PUSDISTRIBUTORMOCK_H #define FSFW_TESTS_PUSDISTRIBUTORMOCK_H +#include + #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tcdistribution/PusDistributorIF.h" -#include - class PusDistributorMock : public SystemObject, public PusDistributorIF { public: PusDistributorMock(); diff --git a/unittests/tcdistributor/CMakeLists.txt b/unittests/tcdistributor/CMakeLists.txt new file mode 100644 index 00000000..d4182326 --- /dev/null +++ b/unittests/tcdistributor/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE + testCcsdsDistributor.cpp +) diff --git a/unittests/tcdistributor/testCcsdsDistributor.cpp b/unittests/tcdistributor/testCcsdsDistributor.cpp new file mode 100644 index 00000000..8aa248fa --- /dev/null +++ b/unittests/tcdistributor/testCcsdsDistributor.cpp @@ -0,0 +1,113 @@ +#include +#include + +#include "fsfw/storagemanager/LocalPool.h" +#include "fsfw/tcdistribution/CcsdsDistributor.h" +#include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" +#include "mocks/AcceptsTcMock.h" +#include "mocks/CcsdsCheckerMock.h" +#include "mocks/MessageQueueMock.h" + +TEST_CASE("CCSDS Distributor", "[ccsds-distrib]") { + LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; + LocalPool pool(objects::NO_OBJECT, cfg); + auto queue = MessageQueueMock(1); + auto checkerMock = CcsdsCheckerMock(); + uint16_t unregisteredApid = 0; + uint16_t defaultApid = 4; + MessageQueueId_t defaultQueueId = 5; + auto ccsdsDistrib = CcsdsDistributor(defaultApid, 1, &pool, &queue, &checkerMock); + uint32_t tcAcceptorApid = 1; + MessageQueueId_t tcAcceptorQueueId = 3; + + auto tcAcceptorMock = AcceptsTcMock("TC Receiver Dummy", tcAcceptorApid, tcAcceptorQueueId); + auto defReceiverMock = AcceptsTcMock("Default Receiver Dummy", defaultApid, defaultQueueId); + auto packetId = PacketId(ccsds::PacketType::TC, true, 0); + auto psc = PacketSeqCtrl(ccsds::SequenceFlags::FIRST_SEGMENT, 0x34); + auto spParams = SpacePacketParams(packetId, psc, 0x16); + SpacePacketCreator spCreator(spParams); + std::array buf{}; + + auto createSpacePacket = [&](uint16_t apid, TmTcMessage& msg) { + store_address_t storeId{}; + spCreator.setApid(tcAcceptorApid); + uint8_t* dataPtr; + REQUIRE(pool.getFreeElement(&storeId, spCreator.getSerializedSize(), &dataPtr) == result::OK); + size_t serLen = 0; + REQUIRE(spCreator.SerializeIF::serializeBe(dataPtr, serLen, ccsds::HEADER_LEN) == result::OK); + REQUIRE(spCreator.SerializeIF::serializeBe(buf.data(), serLen, ccsds::HEADER_LEN) == + result::OK); + msg.setStorageId(storeId); + }; + + SECTION("State") { + CHECK(ccsdsDistrib.initialize() == result::OK); + CHECK(ccsdsDistrib.getRequestQueue() == 1); + CHECK(ccsdsDistrib.getIdentifier() == 0); + CHECK(ccsdsDistrib.getObjectId() == 1); + REQUIRE(ccsdsDistrib.getName() != nullptr); + CHECK(std::strcmp(ccsdsDistrib.getName(), "CCSDS Distributor") == 0); + } + + SECTION("Basic Forwarding") { + CcsdsDistributor::DestInfo info(tcAcceptorMock, false); + REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); + TmTcMessage message; + createSpacePacket(tcAcceptorApid, message); + store_address_t storeId = message.getStorageId(); + queue.addReceivedMessage(message); + REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); + CHECK(checkerMock.checkedPacketLen == 6); + CHECK(checkerMock.checkCallCount == 1); + CHECK(queue.wasMessageSent()); + CHECK(queue.numberOfSentMessages() == 1); + // The packet is forwarded, with no need to delete the data + CHECK(pool.hasDataAtId(storeId)); + TmTcMessage sentMsg; + CHECK(queue.getNextSentMessage(tcAcceptorQueueId, sentMsg) == result::OK); + CHECK(sentMsg.getStorageId() == storeId); + auto accessor = pool.getData(storeId); + CHECK(accessor.first == result::OK); + CHECK(accessor.second.size() == ccsds::HEADER_LEN); + for (size_t i = 0; i < ccsds::HEADER_LEN; i++) { + CHECK(accessor.second.data()[i] == buf[i]); + } + } + + SECTION("Forwarding to Default Destination, but not registered") { + TmTcMessage message; + createSpacePacket(unregisteredApid, message); + store_address_t storeId = message.getStorageId(); + message.setStorageId(storeId); + queue.addReceivedMessage(message); + REQUIRE(ccsdsDistrib.performOperation(0) == TcDistributorBase::DESTINATION_NOT_FOUND); + } + + SECTION("Forward to Default Handler") { + CcsdsDistributor::DestInfo info(defReceiverMock, false); + ccsdsDistrib.registerApplication(info); + TmTcMessage message; + createSpacePacket(defaultApid, message); + store_address_t storeId = message.getStorageId(); + message.setStorageId(storeId); + queue.addReceivedMessage(message); + REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); + CHECK(checkerMock.checkedPacketLen == 6); + CHECK(checkerMock.checkCallCount == 1); + CHECK(queue.wasMessageSent()); + CHECK(queue.numberOfSentMessages() == 1); + // The packet is forwarded, with no need to delete the data + CHECK(pool.hasDataAtId(storeId)); + TmTcMessage sentMsg; + CHECK(queue.getNextSentMessage(defaultQueueId, sentMsg) == result::OK); + CHECK(sentMsg.getStorageId() == storeId); + auto accessor = pool.getData(storeId); + CHECK(accessor.first == result::OK); + CHECK(accessor.second.size() == ccsds::HEADER_LEN); + for (size_t i = 0; i < ccsds::HEADER_LEN; i++) { + CHECK(accessor.second.data()[i] == buf[i]); + } + } + + SECTION("Remove CCSDS header") {} +} \ No newline at end of file diff --git a/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp b/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp index 34a8cfbd..cdf40d89 100644 --- a/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp +++ b/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp @@ -1,10 +1,10 @@ -#include "fsfw/FSFW.h" #include "PollingSequenceFactory.h" #include #include #include +#include "fsfw/FSFW.h" #include "tests/TestsConfig.h" ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) { diff --git a/unittests/tmtcpacket/testCcsdsReader.cpp b/unittests/tmtcpacket/testCcsdsReader.cpp index 75b4af87..61c4dd55 100644 --- a/unittests/tmtcpacket/testCcsdsReader.cpp +++ b/unittests/tmtcpacket/testCcsdsReader.cpp @@ -64,7 +64,7 @@ TEST_CASE("CCSDS Reader", "[ccsds-reader]") { SECTION("Invalid Size") { for (size_t i = 0; i < 5; i++) { REQUIRE(reader.setReadOnlyData(buf.data(), i) == SerializeIF::STREAM_TOO_SHORT); - REQUIRE(not reader.isNull()); + REQUIRE(reader.isNull()); REQUIRE(reader.getPacketData() == nullptr); } } From 1db04cf20c6250fd02a1dd19f4bd8bd796130708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=BCller?= Date: Mon, 1 Aug 2022 20:45:39 +0200 Subject: [PATCH 173/532] Update 'docs/getting_started.rst' Update for new recommended build folder and cmake define name --- docs/getting_started.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 01724b3a..9e739f8b 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -105,8 +105,8 @@ You can use the following commands inside the ``fsfw`` folder to set up the buil .. code-block:: console - mkdir build-tests && cd build-tests - cmake -DFSFW_BUILD_UNITTESTS=ON -DFSFW_OSAL=host .. + mkdir cmake-build-tests && cd cmake-build-tests + cmake -DFSFW_BUILD_TESTS=ON -DFSFW_OSAL=host .. You can also use ``-DFSFW_OSAL=linux`` on Linux systems. From 19817bd3a582a42e457526a22d52bd84cc74be58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20M=C3=BCller?= Date: Mon, 1 Aug 2022 20:47:53 +0200 Subject: [PATCH 174/532] Update 'docs/getting_started.rst' Actually, this version still uses old folder names --- docs/getting_started.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 9e739f8b..4f8ae543 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -105,7 +105,7 @@ You can use the following commands inside the ``fsfw`` folder to set up the buil .. code-block:: console - mkdir cmake-build-tests && cd cmake-build-tests + mkdir build-tests && cd build-tests cmake -DFSFW_BUILD_TESTS=ON -DFSFW_OSAL=host .. From a426aef7c73247634929b5dbb9a3919328591807 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Aug 2022 11:33:10 +0200 Subject: [PATCH 175/532] add some more tests for CCSDS distributor --- src/fsfw/tcdistribution/CcsdsDistributor.cpp | 21 ++++-- src/fsfw/tcdistribution/CcsdsDistributor.h | 4 +- src/fsfw/tcdistribution/TcDistributorBase.cpp | 3 +- .../tmtcpacket/ccsds/SpacePacketCreator.cpp | 10 ++- .../tmtcpacket/ccsds/SpacePacketCreator.h | 33 ++++++++- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 5 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 6 +- unittests/cfdp/testTlvsLvs.cpp | 10 +-- .../tcdistributor/testCcsdsDistributor.cpp | 69 +++++++++++++++++-- unittests/tmtcpacket/testCcsdsCreator.cpp | 14 +++- 10 files changed, 142 insertions(+), 33 deletions(-) diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp index f168e20a..2e09e71f 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -46,7 +46,16 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { #endif return result; } - if (accessorPair.second.size() < ccsds::HEADER_LEN) { + // Minimum length of a space packet + if (accessorPair.second.size() < ccsds::HEADER_LEN + 1) { +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << __func__ << ": SP with length" << accessorPair.second.size() << " too short" + << std::endl; +#else + sif::printError("%s: SP with length %d too short\n", __func__, accessorPair.second.size()); +#endif +#endif return SerializeIF::STREAM_TOO_SHORT; } SpacePacketReader currentPacket(accessorPair.second.data(), accessorPair.second.size()); @@ -62,11 +71,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { auto iter = receiverMap.find(currentPacket.getApid()); if (iter != receiverMap.end()) { destId = iter->second.destId; - if (iter->second.removeHeader) { - // Do not call accessor release method here to ensure the old packet gets deleted. - return handleCcsdsHeaderRemoval(accessorPair.second); - } - } else { + } else if (iter == receiverMap.end()) { // The APID was not found. Forward packet to main SW-APID anyway to // create acceptance failure report. iter = receiverMap.find(defaultApid); @@ -76,6 +81,10 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { return DESTINATION_NOT_FOUND; } } + if (iter->second.removeHeader) { + // Do not call accessor release method here to ensure the old packet gets deleted. + return handleCcsdsHeaderRemoval(accessorPair.second); + } accessorPair.second.release(); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.h b/src/fsfw/tcdistribution/CcsdsDistributor.h index c2ada02d..0444a868 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.h +++ b/src/fsfw/tcdistribution/CcsdsDistributor.h @@ -53,7 +53,9 @@ class CcsdsDistributor : public TcDistributorBase, * registered and forwards the packet to the according message queue. * If the packet is not found, it returns the queue to @c defaultApid, * where a Acceptance Failure message should be generated. - * @return Iterator to map entry of found APID or iterator to default APID. + * @return + * - @c RETURN_OK if a valid desintation was found, error code otherwise + * - @c SerializeIF::STREAM_TOO_SHORT: Packet too short to be a space packet */ ReturnValue_t selectDestination(MessageQueueId_t& destId) override; /** diff --git a/src/fsfw/tcdistribution/TcDistributorBase.cpp b/src/fsfw/tcdistribution/TcDistributorBase.cpp index 33c779eb..e673d628 100644 --- a/src/fsfw/tcdistribution/TcDistributorBase.cpp +++ b/src/fsfw/tcdistribution/TcDistributorBase.cpp @@ -40,8 +40,7 @@ ReturnValue_t TcDistributorBase::handlePacket() { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - result = tcQueue->sendMessage(destId, ¤tMessage); - return callbackAfterSending(result); + return callbackAfterSending(tcQueue->sendMessage(destId, ¤tMessage)); } ReturnValue_t TcDistributorBase::callbackAfterSending(ReturnValue_t queueStatus) { diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp index ee27cc9b..a946650b 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp @@ -40,7 +40,13 @@ ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size return SerializeAdapter::serialize(¶ms.dataLen, buffer, size, maxSize, streamEndianness); } -size_t SpacePacketCreator::getSerializedSize() const { return 6; } +void SpacePacketCreator::setCcsdsLenFromTotalDataFieldLen(size_t actualLength) { + if (actualLength == 0) { + return; + } + setDataLenField(actualLength - 1); +} +size_t SpacePacketCreator::getSerializedSize() const { return ccsds::HEADER_LEN; } ReturnValue_t SpacePacketCreator::deSerialize(const uint8_t **buffer, size_t *size, SerializeIF::Endianness streamEndianness) { @@ -64,7 +70,7 @@ void SpacePacketCreator::setSeqCount(uint16_t seqCount) { void SpacePacketCreator::setSeqFlags(ccsds::SequenceFlags flags) { params.packetSeqCtrl.seqFlags = flags; } -void SpacePacketCreator::setDataLen(uint16_t dataLen_) { params.dataLen = dataLen_; } +void SpacePacketCreator::setDataLenField(uint16_t dataLen_) { params.dataLen = dataLen_; } void SpacePacketCreator::checkFieldValidity() { valid = true; if (params.packetId.apid > ccsds::LIMIT_APID or diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h index 5869560d..59234a1b 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.h @@ -38,24 +38,51 @@ class SpacePacketCreator : public SpacePacketIF, public SerializeIF { [[nodiscard]] uint16_t getPacketDataLen() const override; SpacePacketParams &getParams(); + /** + * Sets the CCSDS data length field from the actual data field length. The field will contain + * the actual length minus one. This means that the minimum allowed size is one, as is also + * specified in 4.1.4.1.2 of the standard. Values of 0 will be ignored. + * @param dataFieldLen + */ + void setCcsdsLenFromTotalDataFieldLen(size_t dataFieldLen); void setParams(SpacePacketParams params); void setSecHeaderFlag(); void setPacketType(ccsds::PacketType type); void setApid(uint16_t apid); void setSeqCount(uint16_t seqCount); void setSeqFlags(ccsds::SequenceFlags flags); - void setDataLen(uint16_t dataLen); + void setDataLenField(uint16_t dataLen); + /** + * Please note that this method will only serialize the header part of the space packet. + * @param buffer + * @param size + * @param maxSize + * @param streamEndianness + * @return + */ ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; + /** + * This will always return 6 or ccsds::HEADER_LEN + * @return + */ [[nodiscard]] size_t getSerializedSize() const override; - ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, - Endianness streamEndianness) override; private: void checkFieldValidity(); bool valid{}; SpacePacketParams params{}; + + /** + * Forbidden to call and always return HasReturnvaluesIF::RETURN_FAILED + * @param buffer + * @param size + * @param streamEndianness + * @return + */ + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override; }; #endif // FSFW_TMTCPACKET_SPACEPACKETCREATOR_H diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 2e786e6e..b40724ba 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -58,8 +58,9 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max } void PusTcCreator::updateSpLengthField() { - spCreator.setDataLen(ecss::PusTcDataFieldHeader::MIN_SIZE + pusParams.dataWrapper.getLength() + - 1); + spCreator.setCcsdsLenFromTotalDataFieldLen(ecss::PusTcDataFieldHeader::MIN_SIZE + + pusParams.dataWrapper.getLength() + + sizeof(ecss::PusChecksumT)); } size_t PusTcCreator::getSerializedSize() const { return spCreator.getFullPacketLen(); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 64dbbfeb..eefcbec7 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -111,12 +111,12 @@ TimeStamperIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } void PusTmCreator::updateSpLengthField() { - size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + pusParams.dataWrapper.getLength() + - sizeof(ecss::PusChecksumT) - 1; + size_t headerLen = + PusTmIF::MIN_SEC_HEADER_LEN + pusParams.dataWrapper.getLength() + sizeof(ecss::PusChecksumT); if (pusParams.secHeader.timeStamper != nullptr) { headerLen += pusParams.secHeader.timeStamper->getSerializedSize(); } - spCreator.setDataLen(headerLen); + spCreator.setCcsdsLenFromTotalDataFieldLen(headerLen); } void PusTmCreator::setApid(uint16_t apid) { spCreator.setApid(apid); } diff --git a/unittests/cfdp/testTlvsLvs.cpp b/unittests/cfdp/testTlvsLvs.cpp index c251fd15..98dec980 100644 --- a/unittests/cfdp/testTlvsLvs.cpp +++ b/unittests/cfdp/testTlvsLvs.cpp @@ -16,15 +16,15 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { using namespace cfdp; - int result = HasReturnvaluesIF::RETURN_OK; - std::array rawBuf; + ReturnValue_t result; + std::array rawBuf{}; uint8_t* serPtr = rawBuf.data(); const uint8_t* deserPtr = rawBuf.data(); size_t deserSize = 0; cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::TWO_BYTES, 0x0ff0); SECTION("TLV Serialization") { - std::array tlvRawBuf; + std::array tlvRawBuf{}; serPtr = tlvRawBuf.data(); result = sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK); @@ -88,7 +88,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { SECTION("TLV Deserialization") { // Serialization was tested before, generate raw data now - std::array tlvRawBuf; + std::array tlvRawBuf{}; serPtr = tlvRawBuf.data(); result = sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK); @@ -136,7 +136,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { } SECTION("LV Serialization") { - std::array lvRawBuf; + std::array lvRawBuf{}; serPtr = lvRawBuf.data(); result = sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), SerializeIF::Endianness::NETWORK); diff --git a/unittests/tcdistributor/testCcsdsDistributor.cpp b/unittests/tcdistributor/testCcsdsDistributor.cpp index 8aa248fa..30e96945 100644 --- a/unittests/tcdistributor/testCcsdsDistributor.cpp +++ b/unittests/tcdistributor/testCcsdsDistributor.cpp @@ -28,15 +28,25 @@ TEST_CASE("CCSDS Distributor", "[ccsds-distrib]") { SpacePacketCreator spCreator(spParams); std::array buf{}; - auto createSpacePacket = [&](uint16_t apid, TmTcMessage& msg) { + auto createSpacePacket = [&](uint16_t apid, TmTcMessage& msg, uint8_t* dataField = nullptr, + size_t dataFieldLen = 1) { store_address_t storeId{}; spCreator.setApid(tcAcceptorApid); + spCreator.setCcsdsLenFromTotalDataFieldLen(dataFieldLen); uint8_t* dataPtr; - REQUIRE(pool.getFreeElement(&storeId, spCreator.getSerializedSize(), &dataPtr) == result::OK); + REQUIRE(pool.getFreeElement(&storeId, spCreator.getSerializedSize() + dataFieldLen, &dataPtr) == + result::OK); size_t serLen = 0; REQUIRE(spCreator.SerializeIF::serializeBe(dataPtr, serLen, ccsds::HEADER_LEN) == result::OK); REQUIRE(spCreator.SerializeIF::serializeBe(buf.data(), serLen, ccsds::HEADER_LEN) == result::OK); + if (dataField == nullptr) { + dataPtr[ccsds::HEADER_LEN] = 0; + buf[ccsds::HEADER_LEN] = 0; + } else { + std::memcpy(dataPtr + ccsds::HEADER_LEN, dataField, dataFieldLen); + std::memcpy(buf.data() + ccsds::HEADER_LEN, dataField, dataFieldLen); + } msg.setStorageId(storeId); }; @@ -57,7 +67,7 @@ TEST_CASE("CCSDS Distributor", "[ccsds-distrib]") { store_address_t storeId = message.getStorageId(); queue.addReceivedMessage(message); REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); - CHECK(checkerMock.checkedPacketLen == 6); + CHECK(checkerMock.checkedPacketLen == 7); CHECK(checkerMock.checkCallCount == 1); CHECK(queue.wasMessageSent()); CHECK(queue.numberOfSentMessages() == 1); @@ -68,7 +78,7 @@ TEST_CASE("CCSDS Distributor", "[ccsds-distrib]") { CHECK(sentMsg.getStorageId() == storeId); auto accessor = pool.getData(storeId); CHECK(accessor.first == result::OK); - CHECK(accessor.second.size() == ccsds::HEADER_LEN); + CHECK(accessor.second.size() == ccsds::HEADER_LEN + 1); for (size_t i = 0; i < ccsds::HEADER_LEN; i++) { CHECK(accessor.second.data()[i] == buf[i]); } @@ -92,7 +102,7 @@ TEST_CASE("CCSDS Distributor", "[ccsds-distrib]") { message.setStorageId(storeId); queue.addReceivedMessage(message); REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); - CHECK(checkerMock.checkedPacketLen == 6); + CHECK(checkerMock.checkedPacketLen == 7); CHECK(checkerMock.checkCallCount == 1); CHECK(queue.wasMessageSent()); CHECK(queue.numberOfSentMessages() == 1); @@ -103,11 +113,56 @@ TEST_CASE("CCSDS Distributor", "[ccsds-distrib]") { CHECK(sentMsg.getStorageId() == storeId); auto accessor = pool.getData(storeId); CHECK(accessor.first == result::OK); - CHECK(accessor.second.size() == ccsds::HEADER_LEN); + CHECK(accessor.second.size() == ccsds::HEADER_LEN + 1); for (size_t i = 0; i < ccsds::HEADER_LEN; i++) { CHECK(accessor.second.data()[i] == buf[i]); } } - SECTION("Remove CCSDS header") {} + SECTION("Remove CCSDS header") { + uint16_t tgtApid = 0; + MessageQueueId_t tgtQueueId = MessageQueueIF::NO_QUEUE; + SECTION("Default destination") { + CcsdsDistributor::DestInfo info(defReceiverMock, true); + tgtApid = defaultApid; + tgtQueueId = defaultQueueId; + REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); + } + SECTION("Specific destination") { + CcsdsDistributor::DestInfo info(tcAcceptorMock, true); + tgtApid = tcAcceptorApid; + tgtQueueId = tcAcceptorQueueId; + REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); + } + TmTcMessage message; + std::array dataField = {0, 1, 2, 3, 4}; + createSpacePacket(tgtApid, message, dataField.data(), 5); + store_address_t storeId = message.getStorageId(); + message.setStorageId(storeId); + queue.addReceivedMessage(message); + REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); + CHECK(checkerMock.checkedPacketLen == 11); + CHECK(checkerMock.checkCallCount == 1); + // Data was deleted from old slot to re-store without the header + CHECK(not pool.hasDataAtId(storeId)); + TmTcMessage sentMsg; + CHECK(queue.getNextSentMessage(tgtQueueId, sentMsg) == result::OK); + CHECK(sentMsg.getStorageId() != storeId); + auto accessor = pool.getData(sentMsg.getStorageId()); + CHECK(accessor.first == result::OK); + CHECK(accessor.second.size() == 5); + // Verify correctness of data field + for (size_t i = 0; i < 5; i++) { + CHECK(accessor.second.data()[i] == i); + } + } + + SECTION("Invalid Space Packet, Too Short") { + store_address_t storeId{}; + std::array data = {1, 2, 3, 4}; + pool.addData(&storeId, data.data(), data.size()); + TmTcMessage message(storeId); + queue.addReceivedMessage(message); + REQUIRE(ccsdsDistrib.performOperation(0) == SerializeIF::STREAM_TOO_SHORT); + } } \ No newline at end of file diff --git a/unittests/tmtcpacket/testCcsdsCreator.cpp b/unittests/tmtcpacket/testCcsdsCreator.cpp index 465e6475..b4a089d0 100644 --- a/unittests/tmtcpacket/testCcsdsCreator.cpp +++ b/unittests/tmtcpacket/testCcsdsCreator.cpp @@ -39,7 +39,8 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { SECTION("Deserialization Fails") { serLen = 6; const uint8_t* readOnlyPtr = buf.data(); - REQUIRE(base.deSerialize(&readOnlyPtr, &serLen, SerializeIF::Endianness::BIG) == + SerializeIF& ser = dynamic_cast(base); + REQUIRE(ser.deSerialize(&readOnlyPtr, &serLen, SerializeIF::Endianness::BIG) == HasReturnvaluesIF::RETURN_FAILED); } @@ -64,7 +65,7 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { base.setApid(static_cast(std::pow(2, 11)) - 1); base.setSeqCount(static_cast(std::pow(2, 14)) - 1); base.setSeqFlags(ccsds::SequenceFlags::UNSEGMENTED); - base.setDataLen(static_cast(std::pow(2, 16)) - 1); + base.setDataLenField(static_cast(std::pow(2, 16)) - 1); REQUIRE(base.isValid()); REQUIRE(base.serializeBe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); CHECK(buf[0] == 0x1F); @@ -75,6 +76,15 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { CHECK(buf[5] == 0xFF); } + SECTION("Setting data length 0 is ignored") { + SpacePacketCreator creator = SpacePacketCreator( + ccsds::PacketType::TC, true, 0xFFFF, ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x22); + creator.setCcsdsLenFromTotalDataFieldLen(0); + REQUIRE(creator.getPacketDataLen() == 0x22); + creator.setCcsdsLenFromTotalDataFieldLen(1); + REQUIRE(creator.getPacketDataLen() == 0x00); + } + SECTION("Invalid APID") { SpacePacketCreator creator = SpacePacketCreator( ccsds::PacketType::TC, true, 0xFFFF, ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); From b0c479cab9bffedfcf5529727b72be673d3282d5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Aug 2022 11:34:30 +0200 Subject: [PATCH 176/532] remove some shadowing warnings --- unittests/cfdp/testTlvsLvs.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/unittests/cfdp/testTlvsLvs.cpp b/unittests/cfdp/testTlvsLvs.cpp index 98dec980..90dd688c 100644 --- a/unittests/cfdp/testTlvsLvs.cpp +++ b/unittests/cfdp/testTlvsLvs.cpp @@ -153,10 +153,10 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(deserSize == 3); REQUIRE(rawBuf[0] == 2); - uint16_t sourceId = 0; - result = SerializeAdapter::deSerialize(&sourceId, rawBuf.data() + 1, &deserSize, + uint16_t sourceIdRaw = 0; + result = SerializeAdapter::deSerialize(&sourceIdRaw, rawBuf.data() + 1, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(sourceId == 0x0ff0); + REQUIRE(sourceIdRaw == 0x0ff0); auto lvEmpty = Lv(nullptr, 0); REQUIRE(lvEmpty.getSerializedSize() == 1); @@ -169,7 +169,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { } SECTION("LV Deserialization") { - std::array lvRawBuf; + std::array lvRawBuf{}; serPtr = lvRawBuf.data(); result = sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), SerializeIF::Endianness::NETWORK); @@ -186,10 +186,10 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(uninitLv.getSerializedSize() == 3); const uint8_t* storedValue = uninitLv.getValue(nullptr); - uint16_t sourceId = 0; - result = SerializeAdapter::deSerialize(&sourceId, storedValue, &deserSize, + uint16_t sourceIdRaw = 0; + result = SerializeAdapter::deSerialize(&sourceIdRaw, storedValue, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(sourceId == 0x0ff0); + REQUIRE(sourceIdRaw == 0x0ff0); auto lvEmpty = Lv(nullptr, 0); REQUIRE(lvEmpty.getSerializedSize() == 1); @@ -306,7 +306,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { FaultHandlerOverrideTlv faultOverrideTlv(cfdp::ConditionCode::FILESTORE_REJECTION, cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION); size_t sz = 0; - ReturnValue_t result = + result = faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); REQUIRE(faultOverrideTlv.getSerializedSize() == 3); REQUIRE(sz == 3); From df690b9628251b0515ef39637bb2159ae16dc9a6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Aug 2022 11:36:56 +0200 Subject: [PATCH 177/532] some re-ordering --- src/fsfw/tcdistribution/CcsdsDistributor.cpp | 13 +++++++++---- src/fsfw/tcdistribution/CcsdsDistributor.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp index 2e09e71f..0ec5ed5c 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -16,7 +16,11 @@ CcsdsDistributor::CcsdsDistributor(uint16_t setDefaultApid, object_id_t setObjec tcStore(tcStore), packetChecker(packetChecker) {} -CcsdsDistributor::~CcsdsDistributor() = default; +CcsdsDistributor::~CcsdsDistributor() { + if (ownedPacketChecker) { + delete packetChecker; + } +} ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { #if CCSDS_DISTRIBUTOR_DEBUGGING == 1 @@ -123,13 +127,14 @@ ReturnValue_t CcsdsDistributor::registerApplication(DestInfo info) { uint32_t CcsdsDistributor::getIdentifier() const { return 0; } ReturnValue_t CcsdsDistributor::initialize() { - if (packetChecker == nullptr) { - packetChecker = new CcsdsPacketChecker(ccsds::PacketType::TC); - } ReturnValue_t result = TcDistributorBase::initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } + if (packetChecker == nullptr) { + ownedPacketChecker = true; + packetChecker = new CcsdsPacketChecker(ccsds::PacketType::TC); + } if (tcStore == nullptr) { tcStore = ObjectManager::instance()->get(objects::TC_STORE); if (tcStore == nullptr) { diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.h b/src/fsfw/tcdistribution/CcsdsDistributor.h index 0444a868..83199646 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.h +++ b/src/fsfw/tcdistribution/CcsdsDistributor.h @@ -78,6 +78,7 @@ class CcsdsDistributor : public TcDistributorBase, */ StorageManagerIF* tcStore = nullptr; + bool ownedPacketChecker = false; CcsdsPacketCheckIF* packetChecker = nullptr; }; From 60ea9a9a7cee194cc3faee7d5122bae4c60c334d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Aug 2022 13:15:49 +0200 Subject: [PATCH 178/532] clean up a few tests --- scripts/auto-formatter.sh | 3 +- src/fsfw/cfdp/definitions.h | 14 ++++---- src/fsfw/cfdp/pdu/PduConfig.cpp | 12 ++++--- src/fsfw/cfdp/pdu/PduConfig.h | 4 +-- src/fsfw/cfdp/pdu/VarLenField.cpp | 7 ++++ src/fsfw/cfdp/pdu/VarLenField.h | 12 ++++--- unittests/CMakeLists.txt | 13 ++----- unittests/action/CMakeLists.txt | 4 +-- unittests/cfdp/CMakeLists.txt | 25 ++++++------- unittests/cfdp/testAckPdu.cpp | 46 ++++++++++++------------ unittests/cfdp/testCfdp.cpp | 25 ++++++------- unittests/cfdp/testCfdpHeader.cpp | 3 ++ unittests/cfdp/testEofPdu.cpp | 2 +- unittests/cfdp/testFileData.cpp | 2 +- unittests/cfdp/testFinishedPdu.cpp | 2 +- unittests/cfdp/testKeepAlivePdu.cpp | 2 +- unittests/cfdp/testMetadataPdu.cpp | 2 +- unittests/cfdp/testNakPdu.cpp | 2 +- unittests/cfdp/testPromptPdu.cpp | 4 +-- unittests/container/CMakeLists.txt | 20 +++++------ unittests/datapoollocal/CMakeLists.txt | 9 ++--- unittests/devicehandler/CMakeLists.txt | 6 ++-- unittests/globalfunctions/CMakeLists.txt | 10 ++---- unittests/hal/CMakeLists.txt | 4 +-- unittests/internalerror/CMakeLists.txt | 4 +-- unittests/mocks/CMakeLists.txt | 32 ++++++++--------- unittests/osal/CMakeLists.txt | 7 ++-- unittests/power/CMakeLists.txt | 4 +-- unittests/serialize/CMakeLists.txt | 9 ++--- unittests/storagemanager/CMakeLists.txt | 5 +-- unittests/tcdistributor/CMakeLists.txt | 4 +-- unittests/testcfg/CMakeLists.txt | 21 ++++------- unittests/timemanager/CMakeLists.txt | 5 +-- unittests/tmtcpacket/CMakeLists.txt | 20 +++++------ unittests/tmtcservices/CMakeLists.txt | 8 ++--- unittests/util/CMakeLists.txt | 6 ++-- 36 files changed, 160 insertions(+), 198 deletions(-) create mode 100644 unittests/cfdp/testCfdpHeader.cpp diff --git a/scripts/auto-formatter.sh b/scripts/auto-formatter.sh index c0ae7099..97b4bcc1 100755 --- a/scripts/auto-formatter.sh +++ b/scripts/auto-formatter.sh @@ -7,7 +7,8 @@ cmake_fmt="cmake-format" file_selectors="-iname CMakeLists.txt" if command -v ${cmake_fmt} &> /dev/null; then ${cmake_fmt} -i CMakeLists.txt - find ./src ${file_selectors} | xargs ${cmake_fmt} -i + find ./src ${file_selectors} | xargs ${cmake_fmt} -i + find ./unittests ${file_selectors} | xargs ${cmake_fmt} -i else echo "No ${cmake_fmt} tool found, not formatting CMake files" fi diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 772b3ae3..6b3b11e3 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -42,17 +42,17 @@ enum ChecksumType { NULL_CHECKSUM = 15 }; -enum PduType : bool { FILE_DIRECTIVE = 0, FILE_DATA = 1 }; +enum PduType : uint8_t { FILE_DIRECTIVE = 0, FILE_DATA = 1 }; -enum TransmissionModes : bool { ACKNOWLEDGED = 0, UNACKNOWLEDGED = 1 }; +enum TransmissionModes : uint8_t { ACKNOWLEDGED = 0, UNACKNOWLEDGED = 1 }; -enum SegmentMetadataFlag : bool { NOT_PRESENT = 0, PRESENT = 1 }; +enum SegmentMetadataFlag : bool { NOT_PRESENT = false, PRESENT = true }; -enum Direction : bool { TOWARDS_RECEIVER = 0, TOWARDS_SENDER = 1 }; +enum Direction : uint8_t { TOWARDS_RECEIVER = 0, TOWARDS_SENDER = 1 }; enum SegmentationControl : bool { - NO_RECORD_BOUNDARIES_PRESERVATION = 0, - RECORD_BOUNDARIES_PRESERVATION = 1 + NO_RECORD_BOUNDARIES_PRESERVATION = false, + RECORD_BOUNDARIES_PRESERVATION = true }; enum WidthInBytes : uint8_t { @@ -106,7 +106,7 @@ enum FinishedFileStatus { FILE_STATUS_UNREPORTED = 3 }; -enum PromptResponseRequired : bool { PROMPT_NAK = 0, PROMPT_KEEP_ALIVE = 1 }; +enum PromptResponseRequired : uint8_t { PROMPT_NAK = 0, PROMPT_KEEP_ALIVE = 1 }; enum TlvTypes : uint8_t { FILESTORE_REQUEST = 0x00, diff --git a/src/fsfw/cfdp/pdu/PduConfig.cpp b/src/fsfw/cfdp/pdu/PduConfig.cpp index d495f864..dd04e986 100644 --- a/src/fsfw/cfdp/pdu/PduConfig.cpp +++ b/src/fsfw/cfdp/pdu/PduConfig.cpp @@ -1,12 +1,14 @@ #include "PduConfig.h" -PduConfig::PduConfig(cfdp::TransmissionModes mode, cfdp::TransactionSeqNum seqNum, - cfdp::EntityId sourceId, cfdp::EntityId destId, bool crcFlag, bool largeFile, +#include + +PduConfig::PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionModes mode, + cfdp::TransactionSeqNum seqNum, bool crcFlag, bool largeFile, cfdp::Direction direction) : mode(mode), - seqNum(seqNum), - sourceId(sourceId), - destId(destId), + seqNum(std::move(seqNum)), + sourceId(std::move(sourceId)), + destId(std::move(destId)), crcFlag(crcFlag), largeFile(largeFile), direction(direction) {} diff --git a/src/fsfw/cfdp/pdu/PduConfig.h b/src/fsfw/cfdp/pdu/PduConfig.h index e5b52e52..f92b25fc 100644 --- a/src/fsfw/cfdp/pdu/PduConfig.h +++ b/src/fsfw/cfdp/pdu/PduConfig.h @@ -21,8 +21,8 @@ struct TransactionSeqNum : public VarLenField { class PduConfig { public: - PduConfig(cfdp::TransmissionModes mode, cfdp::TransactionSeqNum seqNum, cfdp::EntityId sourceId, - cfdp::EntityId destId, bool crcFlag = false, bool largeFile = false, + PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionModes mode, + cfdp::TransactionSeqNum seqNum, bool crcFlag = false, bool largeFile = false, cfdp::Direction direction = cfdp::Direction::TOWARDS_RECEIVER); cfdp::TransmissionModes mode; cfdp::TransactionSeqNum seqNum; diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/pdu/VarLenField.cpp index b11c3b09..cb72735e 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.cpp +++ b/src/fsfw/cfdp/pdu/VarLenField.cpp @@ -118,3 +118,10 @@ ReturnValue_t cfdp::VarLenField::deSerialize(const uint8_t **buffer, size_t *siz } } } + +template +cfdp::VarLenField::VarLenField(UnsignedByteField byteField) + : width(static_cast(sizeof(T))) { + static_assert((sizeof(T) % 2) == 0); + value = byteField.getValue(); +} diff --git a/src/fsfw/cfdp/pdu/VarLenField.h b/src/fsfw/cfdp/pdu/VarLenField.h index 590c2dd5..3b7ccc5a 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.h +++ b/src/fsfw/cfdp/pdu/VarLenField.h @@ -4,9 +4,9 @@ #include #include -#include "../definitions.h" +#include "fsfw/cfdp/definitions.h" #include "fsfw/serialize/SerializeIF.h" - +#include "fsfw/util/UnsignedByteField.h" namespace cfdp { class VarLenField : public SerializeIF { @@ -19,6 +19,8 @@ class VarLenField : public SerializeIF { }; VarLenField(); + template + explicit VarLenField(UnsignedByteField byteField); VarLenField(cfdp::WidthInBytes width, size_t value); ReturnValue_t setValue(cfdp::WidthInBytes, size_t value); @@ -26,13 +28,13 @@ class VarLenField : public SerializeIF { ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; - size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(cfdp::WidthInBytes width, const uint8_t **buffer, size_t *size, Endianness streamEndianness); - cfdp::WidthInBytes getWidth() const; - size_t getValue() const; + [[nodiscard]] cfdp::WidthInBytes getWidth() const; + [[nodiscard]] size_t getValue() const; private: ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 595d9553..1f52a52e 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -1,14 +1,7 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - CatchDefinitions.cpp - CatchFactory.cpp - printChar.cpp - testVersion.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE CatchDefinitions.cpp CatchFactory.cpp + printChar.cpp testVersion.cpp) -target_sources(${FSFW_TEST_TGT} PRIVATE - CatchRunner.cpp - CatchSetup.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE CatchRunner.cpp CatchSetup.cpp) add_subdirectory(testcfg) add_subdirectory(mocks) diff --git a/unittests/action/CMakeLists.txt b/unittests/action/CMakeLists.txt index 659f251a..99941357 100644 --- a/unittests/action/CMakeLists.txt +++ b/unittests/action/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - TestActionHelper.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE TestActionHelper.cpp) diff --git a/unittests/cfdp/CMakeLists.txt b/unittests/cfdp/CMakeLists.txt index 8e18cd3b..fcae5bba 100644 --- a/unittests/cfdp/CMakeLists.txt +++ b/unittests/cfdp/CMakeLists.txt @@ -1,12 +1,13 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testCfdp.cpp - testTlvsLvs.cpp - testAckPdu.cpp - testEofPdu.cpp - testNakPdu.cpp - testFinishedPdu.cpp - testPromptPdu.cpp - testKeepAlivePdu.cpp - testMetadataPdu.cpp - testFileData.cpp -) +target_sources( + ${FSFW_TEST_TGT} + PRIVATE testCfdp.cpp + testTlvsLvs.cpp + testAckPdu.cpp + testEofPdu.cpp + testNakPdu.cpp + testFinishedPdu.cpp + testPromptPdu.cpp + testKeepAlivePdu.cpp + testMetadataPdu.cpp + testFileData.cpp + testCfdpHeader.cpp) diff --git a/unittests/cfdp/testAckPdu.cpp b/unittests/cfdp/testAckPdu.cpp index e5668799..70451aa0 100644 --- a/unittests/cfdp/testAckPdu.cpp +++ b/unittests/cfdp/testAckPdu.cpp @@ -7,7 +7,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result; std::array buf = {}; uint8_t* bufptr = buf.data(); size_t maxsz = buf.size(); @@ -15,7 +15,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { auto seqNum = TransactionSeqNum(WidthInBytes::TWO_BYTES, 15); auto sourceId = EntityId(WidthInBytes::TWO_BYTES, 1); auto destId = EntityId(WidthInBytes::TWO_BYTES, 2); - auto pduConf = PduConfig(TransmissionModes::ACKNOWLEDGED, seqNum, sourceId, destId); + auto pduConf = PduConfig(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); AckInfo ackInfo(FileDirectives::EOF_DIRECTIVE, ConditionCode::NO_ERROR, AckTransactionStatus::ACTIVE); auto ackSerializer = AckPduSerializer(ackInfo, pduConf); @@ -23,10 +23,10 @@ TEST_CASE("ACK PDU", "[AckPdu]") { REQUIRE(result == HasReturnvaluesIF::RETURN_OK); SECTION("Serialize") { - REQUIRE(buf.data()[sz - 3] == cfdp::FileDirectives::ACK); - REQUIRE((buf.data()[sz - 2] >> 4) == FileDirectives::EOF_DIRECTIVE); - REQUIRE((buf.data()[sz - 2] & 0x0f) == 0); - REQUIRE(buf.data()[sz - 1] == AckTransactionStatus::ACTIVE); + REQUIRE(buf[sz - 3] == cfdp::FileDirectives::ACK); + REQUIRE((buf[sz - 2] >> 4) == FileDirectives::EOF_DIRECTIVE); + REQUIRE((buf[sz - 2] & 0x0f) == 0); + REQUIRE(buf[sz - 1] == AckTransactionStatus::ACTIVE); ackInfo.setAckedDirective(FileDirectives::FINISH); ackInfo.setAckedConditionCode(ConditionCode::FILESTORE_REJECTION); ackInfo.setTransactionStatus(AckTransactionStatus::TERMINATED); @@ -35,11 +35,11 @@ TEST_CASE("ACK PDU", "[AckPdu]") { sz = 0; result = ackSerializer2.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(buf.data()[sz - 3] == cfdp::FileDirectives::ACK); - REQUIRE((buf.data()[sz - 2] >> 4) == FileDirectives::FINISH); - REQUIRE((buf.data()[sz - 2] & 0x0f) == 0b0001); - REQUIRE((buf.data()[sz - 1] >> 4) == ConditionCode::FILESTORE_REJECTION); - REQUIRE((buf.data()[sz - 1] & 0b11) == AckTransactionStatus::TERMINATED); + REQUIRE(buf[sz - 3] == cfdp::FileDirectives::ACK); + REQUIRE((buf[sz - 2] >> 4) == FileDirectives::FINISH); + REQUIRE((buf[sz - 2] & 0x0f) == 0b0001); + REQUIRE((buf[sz - 1] >> 4) == ConditionCode::FILESTORE_REJECTION); + REQUIRE((buf[sz - 1] & 0b11) == AckTransactionStatus::TERMINATED); bufptr = buf.data(); sz = 0; @@ -56,14 +56,14 @@ TEST_CASE("ACK PDU", "[AckPdu]") { } SECTION("Deserialize") { - AckInfo ackInfo; - auto reader = AckPduDeserializer(buf.data(), sz, ackInfo); + AckInfo ackInfo2; + auto reader = AckPduDeserializer(buf.data(), sz, ackInfo2); result = reader.parseData(); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(ackInfo.getAckedDirective() == FileDirectives::EOF_DIRECTIVE); - REQUIRE(ackInfo.getAckedConditionCode() == ConditionCode::NO_ERROR); - REQUIRE(ackInfo.getDirectiveSubtypeCode() == 0); - REQUIRE(ackInfo.getTransactionStatus() == AckTransactionStatus::ACTIVE); + REQUIRE(ackInfo2.getAckedDirective() == FileDirectives::EOF_DIRECTIVE); + REQUIRE(ackInfo2.getAckedConditionCode() == ConditionCode::NO_ERROR); + REQUIRE(ackInfo2.getDirectiveSubtypeCode() == 0); + REQUIRE(ackInfo2.getTransactionStatus() == AckTransactionStatus::ACTIVE); AckInfo newInfo = AckInfo(FileDirectives::FINISH, ConditionCode::FILESTORE_REJECTION, AckTransactionStatus::TERMINATED); @@ -73,13 +73,13 @@ TEST_CASE("ACK PDU", "[AckPdu]") { result = ackSerializer2.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - auto reader2 = AckPduDeserializer(buf.data(), sz, ackInfo); + auto reader2 = AckPduDeserializer(buf.data(), sz, ackInfo2); result = reader2.parseData(); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(ackInfo.getAckedDirective() == FileDirectives::FINISH); - REQUIRE(ackInfo.getAckedConditionCode() == ConditionCode::FILESTORE_REJECTION); - REQUIRE(ackInfo.getDirectiveSubtypeCode() == 0b0001); - REQUIRE(ackInfo.getTransactionStatus() == AckTransactionStatus::TERMINATED); + REQUIRE(ackInfo2.getAckedDirective() == FileDirectives::FINISH); + REQUIRE(ackInfo2.getAckedConditionCode() == ConditionCode::FILESTORE_REJECTION); + REQUIRE(ackInfo2.getDirectiveSubtypeCode() == 0b0001); + REQUIRE(ackInfo2.getTransactionStatus() == AckTransactionStatus::TERMINATED); uint8_t prevVal = buf[sz - 2]; buf[sz - 2] = FileDirectives::INVALID_DIRECTIVE << 4; @@ -93,7 +93,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { result = reader2.parseData(); REQUIRE(result == cfdp::INVALID_DIRECTIVE_FIELDS); buf[sz - 3] = cfdp::FileDirectives::ACK; - auto maxSizeTooSmall = AckPduDeserializer(buf.data(), sz - 2, ackInfo); + auto maxSizeTooSmall = AckPduDeserializer(buf.data(), sz - 2, ackInfo2); result = maxSizeTooSmall.parseData(); REQUIRE(result == SerializeIF::STREAM_TOO_SHORT); } diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index e7acab01..9184156c 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -13,13 +13,13 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { using namespace cfdp; - std::array serBuf; + std::array serBuf{}; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; cfdp::TransactionSeqNum seqNum = TransactionSeqNum(cfdp::WidthInBytes::ONE_BYTE, 2); cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0); cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1); PduConfig pduConf = - PduConfig(cfdp::TransmissionModes::ACKNOWLEDGED, seqNum, sourceId, destId, false); + PduConfig(sourceId, destId, cfdp::TransmissionModes::ACKNOWLEDGED, seqNum, false); uint8_t* serTarget = serBuf.data(); const uint8_t* deserTarget = serTarget; size_t serSize = 0; @@ -79,8 +79,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { REQUIRE(serBuf[6] == 1); for (uint8_t idx = 0; idx < 7; idx++) { - ReturnValue_t result = - headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); + result = headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); } @@ -123,8 +122,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { SerializeIF::Endianness::BIG); for (uint8_t idx = 0; idx < 14; idx++) { - ReturnValue_t result = - headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); + result = headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); } REQUIRE(headerSerializer.getCrcFlag() == true); @@ -144,11 +142,11 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { SerializeIF::Endianness::NETWORK); REQUIRE(deSerSize == 4); REQUIRE(entityId == 0xff00ff00); - uint16_t seqNum = 0; - SerializeAdapter::deSerialize(&seqNum, serBuf.data() + 8, &deSerSize, + uint16_t seqNumRaw = 0; + SerializeAdapter::deSerialize(&seqNumRaw, serBuf.data() + 8, &deSerSize, SerializeIF::Endianness::NETWORK); REQUIRE(deSerSize == 2); - REQUIRE(seqNum == 0x0fff); + REQUIRE(seqNumRaw == 0x0fff); SerializeAdapter::deSerialize(&entityId, serBuf.data() + 10, &deSerSize, SerializeIF::Endianness::NETWORK); REQUIRE(deSerSize == 4); @@ -195,8 +193,8 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { // We unittested the serializer before, so we can use it now to generate valid raw CFDP // data auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); - ReturnValue_t result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); + result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG); REQUIRE(result == result::OK); REQUIRE(serBuf[1] == 0); REQUIRE(serBuf[2] == 0); @@ -272,7 +270,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { size_t deSerSize = headerDeser.getWholePduSize(); serTarget = serBuf.data(); - const uint8_t** serTargetConst = const_cast(&serTarget); + const auto** serTargetConst = const_cast(&serTarget); result = headerDeser.parseData(); REQUIRE(result == result::OK); @@ -356,8 +354,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { cfdp::FileSize fss; REQUIRE(fss.getSize() == 0); fss.setFileSize(0x20, false); - ReturnValue_t result = - fss.serialize(&buffer, &size, fssBuf.size(), SerializeIF::Endianness::MACHINE); + result = fss.serialize(&buffer, &size, fssBuf.size(), SerializeIF::Endianness::MACHINE); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); uint32_t fileSize = 0; result = SerializeAdapter::deSerialize(&fileSize, fssBuf.data(), nullptr, diff --git a/unittests/cfdp/testCfdpHeader.cpp b/unittests/cfdp/testCfdpHeader.cpp new file mode 100644 index 00000000..77579bd4 --- /dev/null +++ b/unittests/cfdp/testCfdpHeader.cpp @@ -0,0 +1,3 @@ +// +// Created by rmueller on 8/3/22. +// diff --git a/unittests/cfdp/testEofPdu.cpp b/unittests/cfdp/testEofPdu.cpp index d400af5a..44e21bdf 100644 --- a/unittests/cfdp/testEofPdu.cpp +++ b/unittests/cfdp/testEofPdu.cpp @@ -20,7 +20,7 @@ TEST_CASE("EOF PDU", "[EofPdu]") { TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(TransmissionModes::ACKNOWLEDGED, seqNum, sourceId, destId); + PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); auto eofSerializer = EofPduSerializer(pduConf, eofInfo); SECTION("Serialize") { diff --git a/unittests/cfdp/testFileData.cpp b/unittests/cfdp/testFileData.cpp index 1f6a09e9..fcf586eb 100644 --- a/unittests/cfdp/testFileData.cpp +++ b/unittests/cfdp/testFileData.cpp @@ -17,7 +17,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(TransmissionModes::ACKNOWLEDGED, seqNum, sourceId, destId); + PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); for (uint8_t idx = 0; idx < 10; idx++) { fileBuffer[idx] = idx; diff --git a/unittests/cfdp/testFinishedPdu.cpp b/unittests/cfdp/testFinishedPdu.cpp index 143eaf2a..f581ee0b 100644 --- a/unittests/cfdp/testFinishedPdu.cpp +++ b/unittests/cfdp/testFinishedPdu.cpp @@ -14,7 +14,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(TransmissionModes::ACKNOWLEDGED, seqNum, sourceId, destId); + PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); cfdp::Lv emptyFsMsg; FinishedInfo info(cfdp::ConditionCode::INACTIVITY_DETECTED, diff --git a/unittests/cfdp/testKeepAlivePdu.cpp b/unittests/cfdp/testKeepAlivePdu.cpp index 8ec8c66c..e6eb919e 100644 --- a/unittests/cfdp/testKeepAlivePdu.cpp +++ b/unittests/cfdp/testKeepAlivePdu.cpp @@ -14,7 +14,7 @@ TEST_CASE("Keep Alive PDU", "[KeepAlivePdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(TransmissionModes::ACKNOWLEDGED, seqNum, sourceId, destId); + PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); FileSize progress(0x50); diff --git a/unittests/cfdp/testMetadataPdu.cpp b/unittests/cfdp/testMetadataPdu.cpp index 331d64a9..71749af3 100644 --- a/unittests/cfdp/testMetadataPdu.cpp +++ b/unittests/cfdp/testMetadataPdu.cpp @@ -17,7 +17,7 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(TransmissionModes::ACKNOWLEDGED, seqNum, sourceId, destId); + PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); std::string firstFileName = "hello.txt"; cfdp::Lv sourceFileName(reinterpret_cast(firstFileName.data()), diff --git a/unittests/cfdp/testNakPdu.cpp b/unittests/cfdp/testNakPdu.cpp index 38b45300..eb112402 100644 --- a/unittests/cfdp/testNakPdu.cpp +++ b/unittests/cfdp/testNakPdu.cpp @@ -15,7 +15,7 @@ TEST_CASE("NAK PDU", "[NakPdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(TransmissionModes::ACKNOWLEDGED, seqNum, sourceId, destId); + PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); FileSize startOfScope(50); FileSize endOfScope(1050); diff --git a/unittests/cfdp/testPromptPdu.cpp b/unittests/cfdp/testPromptPdu.cpp index 9f406aec..d8e33441 100644 --- a/unittests/cfdp/testPromptPdu.cpp +++ b/unittests/cfdp/testPromptPdu.cpp @@ -14,7 +14,7 @@ TEST_CASE("Prompt PDU", "[PromptPdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(TransmissionModes::ACKNOWLEDGED, seqNum, sourceId, destId); + PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); SECTION("Serialize") { PromptPduSerializer serializer(pduConf, cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); @@ -24,7 +24,7 @@ TEST_CASE("Prompt PDU", "[PromptPdu]") { REQUIRE(sz == 12); REQUIRE(serializer.getPduDataFieldLen() == 2); REQUIRE(rawBuf[10] == FileDirectives::PROMPT); - REQUIRE((rawBuf[sz - 1] >> 7) & 0x01 == cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); + REQUIRE(((rawBuf[sz - 1] >> 7) & 0x01) == cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { uint8_t* buffer = rawBuf.data(); diff --git a/unittests/container/CMakeLists.txt b/unittests/container/CMakeLists.txt index 5dae974c..d65e5993 100644 --- a/unittests/container/CMakeLists.txt +++ b/unittests/container/CMakeLists.txt @@ -1,10 +1,10 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - RingBufferTest.cpp - TestArrayList.cpp - TestDynamicFifo.cpp - TestFifo.cpp - TestFixedArrayList.cpp - TestFixedMap.cpp - TestFixedOrderedMultimap.cpp - TestPlacementFactory.cpp -) +target_sources( + ${FSFW_TEST_TGT} + PRIVATE RingBufferTest.cpp + TestArrayList.cpp + TestDynamicFifo.cpp + TestFifo.cpp + TestFixedArrayList.cpp + TestFixedMap.cpp + TestFixedOrderedMultimap.cpp + TestPlacementFactory.cpp) diff --git a/unittests/datapoollocal/CMakeLists.txt b/unittests/datapoollocal/CMakeLists.txt index 016645fd..2c7a573f 100644 --- a/unittests/datapoollocal/CMakeLists.txt +++ b/unittests/datapoollocal/CMakeLists.txt @@ -1,6 +1,3 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testLocalPoolVariable.cpp - testLocalPoolVector.cpp - testDataSet.cpp - testLocalPoolManager.cpp -) +target_sources( + ${FSFW_TEST_TGT} PRIVATE testLocalPoolVariable.cpp testLocalPoolVector.cpp + testDataSet.cpp testLocalPoolManager.cpp) diff --git a/unittests/devicehandler/CMakeLists.txt b/unittests/devicehandler/CMakeLists.txt index 5d4d9b06..068e0dd4 100644 --- a/unittests/devicehandler/CMakeLists.txt +++ b/unittests/devicehandler/CMakeLists.txt @@ -1,4 +1,2 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - DeviceHandlerCommander.cpp - TestDeviceHandlerBase.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE DeviceHandlerCommander.cpp + TestDeviceHandlerBase.cpp) diff --git a/unittests/globalfunctions/CMakeLists.txt b/unittests/globalfunctions/CMakeLists.txt index 348b99fc..ee94ca77 100644 --- a/unittests/globalfunctions/CMakeLists.txt +++ b/unittests/globalfunctions/CMakeLists.txt @@ -1,7 +1,3 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testDleEncoder.cpp - testOpDivider.cpp - testBitutil.cpp - testCRC.cpp - testTimevalOperations.cpp -) +target_sources( + ${FSFW_TEST_TGT} PRIVATE testDleEncoder.cpp testOpDivider.cpp testBitutil.cpp + testCRC.cpp testTimevalOperations.cpp) diff --git a/unittests/hal/CMakeLists.txt b/unittests/hal/CMakeLists.txt index ee14a3aa..152bb39f 100644 --- a/unittests/hal/CMakeLists.txt +++ b/unittests/hal/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testCommandExecutor.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE testCommandExecutor.cpp) diff --git a/unittests/internalerror/CMakeLists.txt b/unittests/internalerror/CMakeLists.txt index d49ce006..c02cbafc 100644 --- a/unittests/internalerror/CMakeLists.txt +++ b/unittests/internalerror/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - TestInternalErrorReporter.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE TestInternalErrorReporter.cpp) diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 3a8c8d18..0294af31 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -1,16 +1,16 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - PowerSwitcherMock.cpp - DeviceHandlerMock.cpp - DeviceFdirMock.cpp - CookieIFMock.cpp - ComIFMock.cpp - MessageQueueMock.cpp - InternalErrorReporterMock.cpp - LocalPoolOwnerBase.cpp - PusVerificationReporterMock.cpp - PusServiceBaseMock.cpp - AcceptsTmMock.cpp - PusDistributorMock.cpp - CcsdsCheckerMock.cpp - AcceptsTcMock.cpp -) +target_sources( + ${FSFW_TEST_TGT} + PRIVATE PowerSwitcherMock.cpp + DeviceHandlerMock.cpp + DeviceFdirMock.cpp + CookieIFMock.cpp + ComIFMock.cpp + MessageQueueMock.cpp + InternalErrorReporterMock.cpp + LocalPoolOwnerBase.cpp + PusVerificationReporterMock.cpp + PusServiceBaseMock.cpp + AcceptsTmMock.cpp + PusDistributorMock.cpp + CcsdsCheckerMock.cpp + AcceptsTcMock.cpp) diff --git a/unittests/osal/CMakeLists.txt b/unittests/osal/CMakeLists.txt index 0c93eba1..90eea2c7 100644 --- a/unittests/osal/CMakeLists.txt +++ b/unittests/osal/CMakeLists.txt @@ -1,5 +1,2 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testMq.cpp - TestSemaphore.cpp - TestClock.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE testMq.cpp TestSemaphore.cpp + TestClock.cpp) diff --git a/unittests/power/CMakeLists.txt b/unittests/power/CMakeLists.txt index 667e6f51..78c33b42 100644 --- a/unittests/power/CMakeLists.txt +++ b/unittests/power/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testPowerSwitcher.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE testPowerSwitcher.cpp) diff --git a/unittests/serialize/CMakeLists.txt b/unittests/serialize/CMakeLists.txt index be4301db..b42be1d5 100644 --- a/unittests/serialize/CMakeLists.txt +++ b/unittests/serialize/CMakeLists.txt @@ -1,6 +1,3 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testSerialBufferAdapter.cpp - testSerializeAdapter.cpp - testSerialLinkedPacket.cpp - testSerializeIF.cpp -) +target_sources( + ${FSFW_TEST_TGT} PRIVATE testSerialBufferAdapter.cpp testSerializeAdapter.cpp + testSerialLinkedPacket.cpp testSerializeIF.cpp) diff --git a/unittests/storagemanager/CMakeLists.txt b/unittests/storagemanager/CMakeLists.txt index d2bb4dbc..19e84233 100644 --- a/unittests/storagemanager/CMakeLists.txt +++ b/unittests/storagemanager/CMakeLists.txt @@ -1,4 +1 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testAccessor.cpp - testPool.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE testAccessor.cpp testPool.cpp) diff --git a/unittests/tcdistributor/CMakeLists.txt b/unittests/tcdistributor/CMakeLists.txt index d4182326..1743440a 100644 --- a/unittests/tcdistributor/CMakeLists.txt +++ b/unittests/tcdistributor/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testCcsdsDistributor.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE testCcsdsDistributor.cpp) diff --git a/unittests/testcfg/CMakeLists.txt b/unittests/testcfg/CMakeLists.txt index f840e38b..3edb59f6 100644 --- a/unittests/testcfg/CMakeLists.txt +++ b/unittests/testcfg/CMakeLists.txt @@ -1,23 +1,16 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - ipc/MissionMessageTypes.cpp - pollingsequence/PollingSequenceFactory.cpp -) +target_sources( + ${FSFW_TEST_TGT} PRIVATE ipc/MissionMessageTypes.cpp + pollingsequence/PollingSequenceFactory.cpp) # Add include paths for the executable -target_include_directories(${FSFW_TEST_TGT} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} -) +target_include_directories(${FSFW_TEST_TGT} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) # If a special translation file for object IDs exists, compile it. if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp") - target_sources(${FSFW_TEST_TGT} PRIVATE - objects/translateObjects.cpp - ) + target_sources(${FSFW_TEST_TGT} PRIVATE objects/translateObjects.cpp) endif() # If a special translation file for events exists, compile it. if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp") - target_sources(${FSFW_TEST_TGT} PRIVATE - events/translateEvents.cpp - ) -endif() \ No newline at end of file + target_sources(${FSFW_TEST_TGT} PRIVATE events/translateEvents.cpp) +endif() diff --git a/unittests/timemanager/CMakeLists.txt b/unittests/timemanager/CMakeLists.txt index 4b1693a9..ad9cae23 100644 --- a/unittests/timemanager/CMakeLists.txt +++ b/unittests/timemanager/CMakeLists.txt @@ -1,4 +1 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - TestCountdown.cpp - TestCCSDSTime.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE TestCountdown.cpp TestCCSDSTime.cpp) diff --git a/unittests/tmtcpacket/CMakeLists.txt b/unittests/tmtcpacket/CMakeLists.txt index 5b53328f..4415685e 100644 --- a/unittests/tmtcpacket/CMakeLists.txt +++ b/unittests/tmtcpacket/CMakeLists.txt @@ -1,10 +1,10 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testCcsdsCreator.cpp - testCcsdsReader.cpp - testPusTcCreator.cpp - testPusTcReader.cpp - testPusTmCreator.cpp - testPusTmReader.cpp - testCcsds.cpp - testZcTmWriter.cpp -) +target_sources( + ${FSFW_TEST_TGT} + PRIVATE testCcsdsCreator.cpp + testCcsdsReader.cpp + testPusTcCreator.cpp + testPusTcReader.cpp + testPusTmCreator.cpp + testPusTmReader.cpp + testCcsds.cpp + testZcTmWriter.cpp) diff --git a/unittests/tmtcservices/CMakeLists.txt b/unittests/tmtcservices/CMakeLists.txt index 9e60ced1..1004a5f9 100644 --- a/unittests/tmtcservices/CMakeLists.txt +++ b/unittests/tmtcservices/CMakeLists.txt @@ -1,6 +1,2 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testStoreHelper.cpp - testSendHelper.cpp - testStoreAndSendHelper.cpp - testPsb.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE testStoreHelper.cpp testSendHelper.cpp + testStoreAndSendHelper.cpp testPsb.cpp) diff --git a/unittests/util/CMakeLists.txt b/unittests/util/CMakeLists.txt index b79b77db..672670b8 100644 --- a/unittests/util/CMakeLists.txt +++ b/unittests/util/CMakeLists.txt @@ -1,4 +1,2 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testUnsignedByteField.cpp - testObjectId.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE testUnsignedByteField.cpp + testObjectId.cpp) From cc98512caf7b431401679ce77549f0ff02cce726 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Aug 2022 13:23:49 +0200 Subject: [PATCH 179/532] use tags properly --- unittests/cfdp/CMakeLists.txt | 3 +- unittests/cfdp/testCfdp.cpp | 276 +---------------- unittests/cfdp/testCfdpHeader.cpp | 292 +++++++++++++++++- unittests/cfdp/testEofPdu.cpp | 2 +- unittests/cfdp/testFileData.cpp | 2 +- unittests/cfdp/testFileDirective.cpp | 73 +++++ unittests/cfdp/testFinishedPdu.cpp | 2 +- unittests/cfdp/testKeepAlivePdu.cpp | 2 +- unittests/cfdp/testMetadataPdu.cpp | 2 +- unittests/cfdp/testNakPdu.cpp | 2 +- unittests/cfdp/testPromptPdu.cpp | 2 +- unittests/cfdp/testTlvsLvs.cpp | 2 +- .../tcdistributor/testCcsdsDistributor.cpp | 2 +- 13 files changed, 375 insertions(+), 287 deletions(-) create mode 100644 unittests/cfdp/testFileDirective.cpp diff --git a/unittests/cfdp/CMakeLists.txt b/unittests/cfdp/CMakeLists.txt index fcae5bba..9cc2726e 100644 --- a/unittests/cfdp/CMakeLists.txt +++ b/unittests/cfdp/CMakeLists.txt @@ -10,4 +10,5 @@ target_sources( testKeepAlivePdu.cpp testMetadataPdu.cpp testFileData.cpp - testCfdpHeader.cpp) + testCfdpHeader.cpp + testFileDirective.cpp) diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 9184156c..8cfdbca4 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -2,19 +2,16 @@ #include #include -#include "CatchDefinitions.h" #include "fsfw/cfdp/FileSize.h" #include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" #include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" -#include "fsfw/cfdp/pdu/HeaderDeserializer.h" -#include "fsfw/cfdp/pdu/HeaderSerializer.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serialize/SerializeAdapter.h" -TEST_CASE("CFDP Base", "[CfdpBase]") { +TEST_CASE("CFDP Base", "[cfdp]") { using namespace cfdp; std::array serBuf{}; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result; cfdp::TransactionSeqNum seqNum = TransactionSeqNum(cfdp::WidthInBytes::ONE_BYTE, 2); cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0); cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1); @@ -24,275 +21,6 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { const uint8_t* deserTarget = serTarget; size_t serSize = 0; - SECTION("Header Serialization") { - auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); - const uint8_t** dummyPtr = nullptr; - ReturnValue_t deserResult = - headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK); - REQUIRE(deserResult == result::FAILED); - deserResult = headerSerializer.serialize(nullptr, &serSize, serBuf.size(), - SerializeIF::Endianness::NETWORK); - REQUIRE(deserResult == result::FAILED); - REQUIRE(seqNum.getSerializedSize() == 1); - - REQUIRE(headerSerializer.getPduDataFieldLen() == 0); - REQUIRE(headerSerializer.getSerializedSize() == 7); - REQUIRE(headerSerializer.getWholePduSize() == 7); - REQUIRE(headerSerializer.getCrcFlag() == false); - REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_RECEIVER); - REQUIRE(headerSerializer.getLargeFileFlag() == false); - REQUIRE(headerSerializer.getLenEntityIds() == 1); - REQUIRE(headerSerializer.getLenSeqNum() == 1); - REQUIRE(headerSerializer.getPduType() == cfdp::PduType::FILE_DIRECTIVE); - REQUIRE(headerSerializer.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); - REQUIRE(headerSerializer.getSegmentationControl() == false); - REQUIRE(headerSerializer.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); - - cfdp::TransactionSeqNum seqNumLocal; - headerSerializer.getTransactionSeqNum(seqNumLocal); - REQUIRE(seqNumLocal.getWidth() == cfdp::WidthInBytes::ONE_BYTE); - REQUIRE(seqNumLocal.getValue() == 2); - cfdp::EntityId sourceDestId; - headerSerializer.getSourceId(sourceDestId); - REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::ONE_BYTE); - REQUIRE(sourceDestId.getValue() == 0); - headerSerializer.getDestId(sourceDestId); - REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::ONE_BYTE); - REQUIRE(sourceDestId.getValue() == 1); - - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); - REQUIRE(serSize == 7); - // Only version bits are set - REQUIRE(serBuf[0] == 0b00100000); - // PDU data field length is 0 - REQUIRE(serBuf[1] == 0); - REQUIRE(serBuf[2] == 0); - // Entity and Transaction Sequence number are 1 byte large - REQUIRE(serBuf[3] == 0b00010001); - // Source ID - REQUIRE(serBuf[4] == 0); - // Transaction Seq Number - REQUIRE(serBuf[5] == 2); - // Dest ID - REQUIRE(serBuf[6] == 1); - - for (uint8_t idx = 0; idx < 7; idx++) { - result = headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); - REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); - } - - // Set PDU data field len - headerSerializer.setPduDataFieldLen(0x0ff0); - REQUIRE(headerSerializer.getPduDataFieldLen() == 0x0ff0); - REQUIRE(headerSerializer.getSerializedSize() == 7); - REQUIRE(headerSerializer.getWholePduSize() == 7 + 0x0ff0); - serTarget = serBuf.data(); - serSize = 0; - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - REQUIRE(serBuf[1] == 0x0f); - REQUIRE(serBuf[2] == 0xf0); - - pduConf.crcFlag = true; - pduConf.largeFile = true; - pduConf.direction = cfdp::Direction::TOWARDS_SENDER; - pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; - headerSerializer.setSegmentationControl( - cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); - headerSerializer.setPduType(cfdp::PduType::FILE_DATA); - headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); - serTarget = serBuf.data(); - serSize = 0; - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - - // Everything except version bit flipped to one now - REQUIRE(serBuf[0] == 0x3f); - REQUIRE(serBuf[3] == 0x99); - pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); - pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); - pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); - REQUIRE(pduConf.sourceId.getSerializedSize() == 4); - REQUIRE(headerSerializer.getSerializedSize() == 14); - serTarget = serBuf.data(); - serSize = 0; - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - - for (uint8_t idx = 0; idx < 14; idx++) { - result = headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); - REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); - } - REQUIRE(headerSerializer.getCrcFlag() == true); - REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER); - REQUIRE(headerSerializer.getLargeFileFlag() == true); - REQUIRE(headerSerializer.getLenEntityIds() == 4); - REQUIRE(headerSerializer.getLenSeqNum() == 2); - REQUIRE(headerSerializer.getPduType() == cfdp::PduType::FILE_DATA); - REQUIRE(headerSerializer.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); - REQUIRE(headerSerializer.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); - REQUIRE(headerSerializer.getSegmentationControl() == true); - // Last three bits are 2 now (length of seq number) and bit 1 to bit 3 is 4 (len entity IDs) - REQUIRE(serBuf[3] == 0b11001010); - uint32_t entityId = 0; - size_t deSerSize = 0; - SerializeAdapter::deSerialize(&entityId, serBuf.data() + 4, &deSerSize, - SerializeIF::Endianness::NETWORK); - REQUIRE(deSerSize == 4); - REQUIRE(entityId == 0xff00ff00); - uint16_t seqNumRaw = 0; - SerializeAdapter::deSerialize(&seqNumRaw, serBuf.data() + 8, &deSerSize, - SerializeIF::Endianness::NETWORK); - REQUIRE(deSerSize == 2); - REQUIRE(seqNumRaw == 0x0fff); - SerializeAdapter::deSerialize(&entityId, serBuf.data() + 10, &deSerSize, - SerializeIF::Endianness::NETWORK); - REQUIRE(deSerSize == 4); - REQUIRE(entityId == 0x00ff00ff); - - result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff); - REQUIRE(result == result::FAILED); - result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff); - REQUIRE(result == result::FAILED); - result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff); - REQUIRE(result == result::FAILED); - uint8_t oneByteSourceId = 32; - serTarget = &oneByteSourceId; - size_t deserLen = 1; - pduConf.sourceId.deSerialize(cfdp::WidthInBytes::ONE_BYTE, - const_cast(&serTarget), &deserLen, - SerializeIF::Endianness::MACHINE); - REQUIRE(pduConf.sourceId.getValue() == 32); - - uint16_t twoByteSourceId = 0xf0f0; - serTarget = reinterpret_cast(&twoByteSourceId); - deserLen = 2; - pduConf.sourceId.deSerialize(cfdp::WidthInBytes::TWO_BYTES, - const_cast(&serTarget), &deserLen, - SerializeIF::Endianness::MACHINE); - REQUIRE(pduConf.sourceId.getValue() == 0xf0f0); - - uint32_t fourByteSourceId = 0xf0f0f0f0; - serTarget = reinterpret_cast(&fourByteSourceId); - deserLen = 4; - pduConf.sourceId.deSerialize(cfdp::WidthInBytes::FOUR_BYTES, - const_cast(&serTarget), &deserLen, - SerializeIF::Endianness::MACHINE); - REQUIRE(pduConf.sourceId.getValue() == 0xf0f0f0f0); - - pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 1); - serTarget = serBuf.data(); - serSize = 1; - result = pduConf.sourceId.serialize(&serTarget, &serSize, 1, SerializeIF::Endianness::MACHINE); - REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); - } - - SECTION("Header Deserialization") { - // We unittested the serializer before, so we can use it now to generate valid raw CFDP - // data - auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); - REQUIRE(serBuf[1] == 0); - REQUIRE(serBuf[2] == 0); - // Entity and Transaction Sequence number are 1 byte large - REQUIRE(serBuf[3] == 0b00010001); - REQUIRE(serSize == 7); - // Deser call not strictly necessary - auto headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); - - ReturnValue_t serResult = headerDeser.parseData(); - REQUIRE(serResult == result::OK); - REQUIRE(headerDeser.getPduDataFieldLen() == 0); - REQUIRE(headerDeser.getHeaderSize() == 7); - REQUIRE(headerDeser.getWholePduSize() == 7); - REQUIRE(headerDeser.getCrcFlag() == false); - REQUIRE(headerDeser.getDirection() == cfdp::Direction::TOWARDS_RECEIVER); - REQUIRE(headerDeser.getLargeFileFlag() == false); - REQUIRE(headerDeser.getLenEntityIds() == 1); - REQUIRE(headerDeser.getLenSeqNum() == 1); - REQUIRE(headerDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE); - REQUIRE(headerDeser.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); - REQUIRE(headerDeser.getSegmentationControl() == false); - REQUIRE(headerDeser.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); - - pduConf.crcFlag = true; - pduConf.largeFile = true; - pduConf.direction = cfdp::Direction::TOWARDS_SENDER; - pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; - headerSerializer.setSegmentationControl( - cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); - headerSerializer.setPduType(cfdp::PduType::FILE_DATA); - headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); - result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); - REQUIRE(result == result::OK); - result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); - REQUIRE(result == result::OK); - result = pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); - REQUIRE(result == result::OK); - serTarget = serBuf.data(); - serSize = 0; - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); - - result = headerDeser.parseData(); - REQUIRE(result == result::OK); - // Everything except version bit flipped to one now - REQUIRE(serBuf[0] == 0x3f); - REQUIRE(serBuf[3] == 0b11001010); - REQUIRE(headerDeser.getWholePduSize() == 14); - - REQUIRE(headerDeser.getCrcFlag() == true); - REQUIRE(headerDeser.getDirection() == cfdp::Direction::TOWARDS_SENDER); - REQUIRE(headerDeser.getLargeFileFlag() == true); - REQUIRE(headerDeser.getLenEntityIds() == 4); - REQUIRE(headerDeser.getLenSeqNum() == 2); - REQUIRE(headerDeser.getPduType() == cfdp::PduType::FILE_DATA); - REQUIRE(headerDeser.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); - REQUIRE(headerDeser.getSegmentationControl() == true); - REQUIRE(headerDeser.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); - - cfdp::TransactionSeqNum seqNumLocal; - headerDeser.getTransactionSeqNum(seqNumLocal); - REQUIRE(seqNumLocal.getWidth() == cfdp::WidthInBytes::TWO_BYTES); - REQUIRE(seqNumLocal.getValue() == 0x0fff); - cfdp::EntityId sourceDestId; - headerDeser.getSourceId(sourceDestId); - REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::FOUR_BYTES); - REQUIRE(sourceDestId.getValue() == 0xff00ff00); - headerDeser.getDestId(sourceDestId); - REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::FOUR_BYTES); - REQUIRE(sourceDestId.getValue() == 0x00ff00ff); - - size_t deSerSize = headerDeser.getWholePduSize(); - serTarget = serBuf.data(); - const auto** serTargetConst = const_cast(&serTarget); - result = headerDeser.parseData(); - REQUIRE(result == result::OK); - - headerDeser.setData(nullptr, -1); - REQUIRE(headerDeser.getHeaderSize() == 0); - headerDeser.setData(serBuf.data(), serBuf.size()); - - serTarget = serBuf.data(); - serSize = 0; - pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 22); - pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48); - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); - REQUIRE(headerDeser.getWholePduSize() == 8); - headerDeser.setData(serBuf.data(), serBuf.size()); - - headerDeser.getSourceId(sourceDestId); - REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::ONE_BYTE); - REQUIRE(sourceDestId.getValue() == 22); - } - SECTION("File Directive") { auto fdSer = FileDirectiveSerializer(pduConf, FileDirectives::ACK, 4); REQUIRE(fdSer.getSerializedSize() == 8); diff --git a/unittests/cfdp/testCfdpHeader.cpp b/unittests/cfdp/testCfdpHeader.cpp index 77579bd4..3e9cfccd 100644 --- a/unittests/cfdp/testCfdpHeader.cpp +++ b/unittests/cfdp/testCfdpHeader.cpp @@ -1,3 +1,289 @@ -// -// Created by rmueller on 8/3/22. -// +#include +#include + +#include "fsfw/cfdp/pdu/HeaderDeserializer.h" +#include "fsfw/cfdp/pdu/HeaderSerializer.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +TEST_CASE("CFDP Header", "[cfdp]") { + using namespace cfdp; + std::array serBuf{}; + ReturnValue_t result; + cfdp::TransactionSeqNum seqNum = TransactionSeqNum(cfdp::WidthInBytes::ONE_BYTE, 2); + cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0); + cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1); + PduConfig pduConf = + PduConfig(sourceId, destId, cfdp::TransmissionModes::ACKNOWLEDGED, seqNum, false); + uint8_t* serTarget = serBuf.data(); + const uint8_t* deserTarget = serTarget; + size_t serSize = 0; + + SECTION("Header Serialization") { + auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); + const uint8_t** dummyPtr = nullptr; + ReturnValue_t deserResult = + headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK); + REQUIRE(deserResult == result::FAILED); + deserResult = headerSerializer.serialize(nullptr, &serSize, serBuf.size(), + SerializeIF::Endianness::NETWORK); + REQUIRE(deserResult == result::FAILED); + REQUIRE(seqNum.getSerializedSize() == 1); + + REQUIRE(headerSerializer.getPduDataFieldLen() == 0); + REQUIRE(headerSerializer.getSerializedSize() == 7); + REQUIRE(headerSerializer.getWholePduSize() == 7); + REQUIRE(headerSerializer.getCrcFlag() == false); + REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_RECEIVER); + REQUIRE(headerSerializer.getLargeFileFlag() == false); + REQUIRE(headerSerializer.getLenEntityIds() == 1); + REQUIRE(headerSerializer.getLenSeqNum() == 1); + REQUIRE(headerSerializer.getPduType() == cfdp::PduType::FILE_DIRECTIVE); + REQUIRE(headerSerializer.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); + REQUIRE(headerSerializer.getSegmentationControl() == false); + REQUIRE(headerSerializer.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); + + cfdp::TransactionSeqNum seqNumLocal; + headerSerializer.getTransactionSeqNum(seqNumLocal); + REQUIRE(seqNumLocal.getWidth() == cfdp::WidthInBytes::ONE_BYTE); + REQUIRE(seqNumLocal.getValue() == 2); + cfdp::EntityId sourceDestId; + headerSerializer.getSourceId(sourceDestId); + REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::ONE_BYTE); + REQUIRE(sourceDestId.getValue() == 0); + headerSerializer.getDestId(sourceDestId); + REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::ONE_BYTE); + REQUIRE(sourceDestId.getValue() == 1); + + result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG); + REQUIRE(result == result::OK); + REQUIRE(serSize == 7); + // Only version bits are set + REQUIRE(serBuf[0] == 0b00100000); + // PDU data field length is 0 + REQUIRE(serBuf[1] == 0); + REQUIRE(serBuf[2] == 0); + // Entity and Transaction Sequence number are 1 byte large + REQUIRE(serBuf[3] == 0b00010001); + // Source ID + REQUIRE(serBuf[4] == 0); + // Transaction Seq Number + REQUIRE(serBuf[5] == 2); + // Dest ID + REQUIRE(serBuf[6] == 1); + + for (uint8_t idx = 0; idx < 7; idx++) { + result = headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); + REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); + } + + // Set PDU data field len + headerSerializer.setPduDataFieldLen(0x0ff0); + REQUIRE(headerSerializer.getPduDataFieldLen() == 0x0ff0); + REQUIRE(headerSerializer.getSerializedSize() == 7); + REQUIRE(headerSerializer.getWholePduSize() == 7 + 0x0ff0); + serTarget = serBuf.data(); + serSize = 0; + result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG); + REQUIRE(serBuf[1] == 0x0f); + REQUIRE(serBuf[2] == 0xf0); + + pduConf.crcFlag = true; + pduConf.largeFile = true; + pduConf.direction = cfdp::Direction::TOWARDS_SENDER; + pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; + headerSerializer.setSegmentationControl( + cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); + headerSerializer.setPduType(cfdp::PduType::FILE_DATA); + headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); + serTarget = serBuf.data(); + serSize = 0; + result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG); + + // Everything except version bit flipped to one now + REQUIRE(serBuf[0] == 0x3f); + REQUIRE(serBuf[3] == 0x99); + pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); + pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); + pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); + REQUIRE(pduConf.sourceId.getSerializedSize() == 4); + REQUIRE(headerSerializer.getSerializedSize() == 14); + serTarget = serBuf.data(); + serSize = 0; + result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG); + + for (uint8_t idx = 0; idx < 14; idx++) { + result = headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); + REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); + } + REQUIRE(headerSerializer.getCrcFlag() == true); + REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER); + REQUIRE(headerSerializer.getLargeFileFlag() == true); + REQUIRE(headerSerializer.getLenEntityIds() == 4); + REQUIRE(headerSerializer.getLenSeqNum() == 2); + REQUIRE(headerSerializer.getPduType() == cfdp::PduType::FILE_DATA); + REQUIRE(headerSerializer.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); + REQUIRE(headerSerializer.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); + REQUIRE(headerSerializer.getSegmentationControl() == true); + // Last three bits are 2 now (length of seq number) and bit 1 to bit 3 is 4 (len entity IDs) + REQUIRE(serBuf[3] == 0b11001010); + uint32_t entityId = 0; + size_t deSerSize = 0; + SerializeAdapter::deSerialize(&entityId, serBuf.data() + 4, &deSerSize, + SerializeIF::Endianness::NETWORK); + REQUIRE(deSerSize == 4); + REQUIRE(entityId == 0xff00ff00); + uint16_t seqNumRaw = 0; + SerializeAdapter::deSerialize(&seqNumRaw, serBuf.data() + 8, &deSerSize, + SerializeIF::Endianness::NETWORK); + REQUIRE(deSerSize == 2); + REQUIRE(seqNumRaw == 0x0fff); + SerializeAdapter::deSerialize(&entityId, serBuf.data() + 10, &deSerSize, + SerializeIF::Endianness::NETWORK); + REQUIRE(deSerSize == 4); + REQUIRE(entityId == 0x00ff00ff); + + result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff); + REQUIRE(result == result::FAILED); + result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff); + REQUIRE(result == result::FAILED); + result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff); + REQUIRE(result == result::FAILED); + uint8_t oneByteSourceId = 32; + serTarget = &oneByteSourceId; + size_t deserLen = 1; + pduConf.sourceId.deSerialize(cfdp::WidthInBytes::ONE_BYTE, + const_cast(&serTarget), &deserLen, + SerializeIF::Endianness::MACHINE); + REQUIRE(pduConf.sourceId.getValue() == 32); + + uint16_t twoByteSourceId = 0xf0f0; + serTarget = reinterpret_cast(&twoByteSourceId); + deserLen = 2; + pduConf.sourceId.deSerialize(cfdp::WidthInBytes::TWO_BYTES, + const_cast(&serTarget), &deserLen, + SerializeIF::Endianness::MACHINE); + REQUIRE(pduConf.sourceId.getValue() == 0xf0f0); + + uint32_t fourByteSourceId = 0xf0f0f0f0; + serTarget = reinterpret_cast(&fourByteSourceId); + deserLen = 4; + pduConf.sourceId.deSerialize(cfdp::WidthInBytes::FOUR_BYTES, + const_cast(&serTarget), &deserLen, + SerializeIF::Endianness::MACHINE); + REQUIRE(pduConf.sourceId.getValue() == 0xf0f0f0f0); + + pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 1); + serTarget = serBuf.data(); + serSize = 1; + result = pduConf.sourceId.serialize(&serTarget, &serSize, 1, SerializeIF::Endianness::MACHINE); + REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); + } + + SECTION("Header Deserialization") { + // We unittested the serializer before, so we can use it now to generate valid raw CFDP + // data + auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); + result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG); + REQUIRE(result == result::OK); + REQUIRE(serBuf[1] == 0); + REQUIRE(serBuf[2] == 0); + // Entity and Transaction Sequence number are 1 byte large + REQUIRE(serBuf[3] == 0b00010001); + REQUIRE(serSize == 7); + // Deser call not strictly necessary + auto headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); + + ReturnValue_t serResult = headerDeser.parseData(); + REQUIRE(serResult == result::OK); + REQUIRE(headerDeser.getPduDataFieldLen() == 0); + REQUIRE(headerDeser.getHeaderSize() == 7); + REQUIRE(headerDeser.getWholePduSize() == 7); + REQUIRE(headerDeser.getCrcFlag() == false); + REQUIRE(headerDeser.getDirection() == cfdp::Direction::TOWARDS_RECEIVER); + REQUIRE(headerDeser.getLargeFileFlag() == false); + REQUIRE(headerDeser.getLenEntityIds() == 1); + REQUIRE(headerDeser.getLenSeqNum() == 1); + REQUIRE(headerDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE); + REQUIRE(headerDeser.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); + REQUIRE(headerDeser.getSegmentationControl() == false); + REQUIRE(headerDeser.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); + + pduConf.crcFlag = true; + pduConf.largeFile = true; + pduConf.direction = cfdp::Direction::TOWARDS_SENDER; + pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; + headerSerializer.setSegmentationControl( + cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); + headerSerializer.setPduType(cfdp::PduType::FILE_DATA); + headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); + result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); + REQUIRE(result == result::OK); + result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); + REQUIRE(result == result::OK); + result = pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); + REQUIRE(result == result::OK); + serTarget = serBuf.data(); + serSize = 0; + result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG); + headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); + + result = headerDeser.parseData(); + REQUIRE(result == result::OK); + // Everything except version bit flipped to one now + REQUIRE(serBuf[0] == 0x3f); + REQUIRE(serBuf[3] == 0b11001010); + REQUIRE(headerDeser.getWholePduSize() == 14); + + REQUIRE(headerDeser.getCrcFlag() == true); + REQUIRE(headerDeser.getDirection() == cfdp::Direction::TOWARDS_SENDER); + REQUIRE(headerDeser.getLargeFileFlag() == true); + REQUIRE(headerDeser.getLenEntityIds() == 4); + REQUIRE(headerDeser.getLenSeqNum() == 2); + REQUIRE(headerDeser.getPduType() == cfdp::PduType::FILE_DATA); + REQUIRE(headerDeser.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); + REQUIRE(headerDeser.getSegmentationControl() == true); + REQUIRE(headerDeser.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); + + cfdp::TransactionSeqNum seqNumLocal; + headerDeser.getTransactionSeqNum(seqNumLocal); + REQUIRE(seqNumLocal.getWidth() == cfdp::WidthInBytes::TWO_BYTES); + REQUIRE(seqNumLocal.getValue() == 0x0fff); + cfdp::EntityId sourceDestId; + headerDeser.getSourceId(sourceDestId); + REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::FOUR_BYTES); + REQUIRE(sourceDestId.getValue() == 0xff00ff00); + headerDeser.getDestId(sourceDestId); + REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::FOUR_BYTES); + REQUIRE(sourceDestId.getValue() == 0x00ff00ff); + + size_t deSerSize = headerDeser.getWholePduSize(); + serTarget = serBuf.data(); + const auto** serTargetConst = const_cast(&serTarget); + result = headerDeser.parseData(); + REQUIRE(result == result::OK); + + headerDeser.setData(nullptr, -1); + REQUIRE(headerDeser.getHeaderSize() == 0); + headerDeser.setData(serBuf.data(), serBuf.size()); + + serTarget = serBuf.data(); + serSize = 0; + pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 22); + pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48); + result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG); + REQUIRE(result == result::OK); + REQUIRE(headerDeser.getWholePduSize() == 8); + headerDeser.setData(serBuf.data(), serBuf.size()); + + headerDeser.getSourceId(sourceDestId); + REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::ONE_BYTE); + REQUIRE(sourceDestId.getValue() == 22); + } +} diff --git a/unittests/cfdp/testEofPdu.cpp b/unittests/cfdp/testEofPdu.cpp index 44e21bdf..b6eb88d7 100644 --- a/unittests/cfdp/testEofPdu.cpp +++ b/unittests/cfdp/testEofPdu.cpp @@ -5,7 +5,7 @@ #include "fsfw/cfdp/pdu/EofPduSerializer.h" #include "fsfw/globalfunctions/arrayprinter.h" -TEST_CASE("EOF PDU", "[EofPdu]") { +TEST_CASE("EOF PDU", "[cfdp][pdu]") { using namespace cfdp; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; diff --git a/unittests/cfdp/testFileData.cpp b/unittests/cfdp/testFileData.cpp index fcf586eb..272cea47 100644 --- a/unittests/cfdp/testFileData.cpp +++ b/unittests/cfdp/testFileData.cpp @@ -6,7 +6,7 @@ #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serviceinterface.h" -TEST_CASE("File Data PDU", "[FileDataPdu]") { +TEST_CASE("File Data PDU", "[cfdp][pdu]") { using namespace cfdp; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; diff --git a/unittests/cfdp/testFileDirective.cpp b/unittests/cfdp/testFileDirective.cpp new file mode 100644 index 00000000..31053d01 --- /dev/null +++ b/unittests/cfdp/testFileDirective.cpp @@ -0,0 +1,73 @@ +#include +#include + +#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" + +TEST_CASE("CFDP File Directive", "[cfdp]") { + using namespace cfdp; + std::array serBuf{}; + ReturnValue_t result; + cfdp::TransactionSeqNum seqNum = TransactionSeqNum(cfdp::WidthInBytes::ONE_BYTE, 2); + cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0); + cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1); + PduConfig pduConf = + PduConfig(sourceId, destId, cfdp::TransmissionModes::ACKNOWLEDGED, seqNum, false); + uint8_t* serTarget = serBuf.data(); + const uint8_t* deserTarget = serTarget; + size_t serSize = 0; + + SECTION("File Directive") { + auto fdSer = FileDirectiveSerializer(pduConf, FileDirectives::ACK, 4); + REQUIRE(fdSer.getSerializedSize() == 8); + serTarget = serBuf.data(); + serSize = 0; + result = fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + // Only version bits are set + REQUIRE(serBuf[0] == 0b00100000); + // PDU data field length is 5 (4 + Directive code octet) + REQUIRE(serBuf[1] == 0); + REQUIRE(serBuf[2] == 5); + // Entity and Transaction Sequence number are 1 byte large + REQUIRE(serBuf[3] == 0b00010001); + // Source ID + REQUIRE(serBuf[4] == 0); + // Transaction Seq Number + REQUIRE(serBuf[5] == 2); + // Dest ID + REQUIRE(serBuf[6] == 1); + REQUIRE(serBuf[7] == FileDirectives::ACK); + + serTarget = serBuf.data(); + size_t deserSize = 20; + serSize = 0; + REQUIRE(fdSer.deSerialize(&deserTarget, &deserSize, SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(fdSer.serialize(nullptr, nullptr, 85, SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_FAILED); + for (uint8_t idx = 0; idx < 8; idx++) { + serTarget = serBuf.data(); + serSize = 0; + REQUIRE(fdSer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::NETWORK) == + SerializeIF::BUFFER_TOO_SHORT); + } + + deserTarget = serBuf.data(); + deserSize = 0; + auto fdDeser = FileDirectiveDeserializer(deserTarget, serBuf.size()); + REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::NETWORK); + fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); + REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); + fdDeser.setEndianness(SerializeIF::Endianness::NETWORK); + REQUIRE(fdDeser.parseData() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK); + REQUIRE(fdDeser.getPduDataFieldLen() == 5); + REQUIRE(fdDeser.getHeaderSize() == 8); + REQUIRE(fdDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE); + + serBuf[7] = 0xff; + // Invalid file directive + REQUIRE(fdDeser.parseData() == cfdp::INVALID_DIRECTIVE_FIELDS); + } +} \ No newline at end of file diff --git a/unittests/cfdp/testFinishedPdu.cpp b/unittests/cfdp/testFinishedPdu.cpp index f581ee0b..c2aa3bb1 100644 --- a/unittests/cfdp/testFinishedPdu.cpp +++ b/unittests/cfdp/testFinishedPdu.cpp @@ -5,7 +5,7 @@ #include "fsfw/cfdp/pdu/FinishedPduSerializer.h" #include "fsfw/globalfunctions/arrayprinter.h" -TEST_CASE("Finished PDU", "[FinishedPdu]") { +TEST_CASE("Finished PDU", "[cfdp][pdu]") { using namespace cfdp; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; std::array fnBuffer = {}; diff --git a/unittests/cfdp/testKeepAlivePdu.cpp b/unittests/cfdp/testKeepAlivePdu.cpp index e6eb919e..876b71f6 100644 --- a/unittests/cfdp/testKeepAlivePdu.cpp +++ b/unittests/cfdp/testKeepAlivePdu.cpp @@ -5,7 +5,7 @@ #include "fsfw/cfdp/pdu/KeepAlivePduSerializer.h" #include "fsfw/globalfunctions/arrayprinter.h" -TEST_CASE("Keep Alive PDU", "[KeepAlivePdu]") { +TEST_CASE("Keep Alive PDU", "[cfdp][pdu]") { using namespace cfdp; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; std::array kaBuffer = {}; diff --git a/unittests/cfdp/testMetadataPdu.cpp b/unittests/cfdp/testMetadataPdu.cpp index 71749af3..b54d8f79 100644 --- a/unittests/cfdp/testMetadataPdu.cpp +++ b/unittests/cfdp/testMetadataPdu.cpp @@ -8,7 +8,7 @@ #include "fsfw/cfdp/tlv/FilestoreResponseTlv.h" #include "fsfw/globalfunctions/arrayprinter.h" -TEST_CASE("Metadata PDU", "[MetadataPdu]") { +TEST_CASE("Metadata PDU", "[cfdp][pdu]") { using namespace cfdp; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; std::array mdBuffer = {}; diff --git a/unittests/cfdp/testNakPdu.cpp b/unittests/cfdp/testNakPdu.cpp index eb112402..5eee60a4 100644 --- a/unittests/cfdp/testNakPdu.cpp +++ b/unittests/cfdp/testNakPdu.cpp @@ -6,7 +6,7 @@ #include "fsfw/cfdp/pdu/PduConfig.h" #include "fsfw/globalfunctions/arrayprinter.h" -TEST_CASE("NAK PDU", "[NakPdu]") { +TEST_CASE("NAK PDU", "[cfdp][pdu]") { using namespace cfdp; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; std::array nakBuffer = {}; diff --git a/unittests/cfdp/testPromptPdu.cpp b/unittests/cfdp/testPromptPdu.cpp index d8e33441..88dc8ac9 100644 --- a/unittests/cfdp/testPromptPdu.cpp +++ b/unittests/cfdp/testPromptPdu.cpp @@ -5,7 +5,7 @@ #include "fsfw/cfdp/pdu/PromptPduSerializer.h" #include "fsfw/globalfunctions/arrayprinter.h" -TEST_CASE("Prompt PDU", "[PromptPdu]") { +TEST_CASE("Prompt PDU", "[cfdp][pdu]") { using namespace cfdp; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; std::array rawBuf = {}; diff --git a/unittests/cfdp/testTlvsLvs.cpp b/unittests/cfdp/testTlvsLvs.cpp index 90dd688c..e311b5d6 100644 --- a/unittests/cfdp/testTlvsLvs.cpp +++ b/unittests/cfdp/testTlvsLvs.cpp @@ -14,7 +14,7 @@ #include "fsfw/cfdp/tlv/Tlv.h" #include "fsfw/globalfunctions/arrayprinter.h" -TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { +TEST_CASE("CFDP TLV LV", "[cfdp]") { using namespace cfdp; ReturnValue_t result; std::array rawBuf{}; diff --git a/unittests/tcdistributor/testCcsdsDistributor.cpp b/unittests/tcdistributor/testCcsdsDistributor.cpp index 30e96945..b283b3bd 100644 --- a/unittests/tcdistributor/testCcsdsDistributor.cpp +++ b/unittests/tcdistributor/testCcsdsDistributor.cpp @@ -8,7 +8,7 @@ #include "mocks/CcsdsCheckerMock.h" #include "mocks/MessageQueueMock.h" -TEST_CASE("CCSDS Distributor", "[ccsds-distrib]") { +TEST_CASE("CCSDS Distributor", "[ccsds][tcdistrib]") { LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; LocalPool pool(objects::NO_OBJECT, cfg); auto queue = MessageQueueMock(1); From 29bcaee19653a4e99b763e7877dffabc8ffd44f1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Aug 2022 13:34:49 +0200 Subject: [PATCH 180/532] some tests for new var len field --- src/fsfw/cfdp/pdu/VarLenField.cpp | 25 +++++++++---------------- src/fsfw/cfdp/pdu/VarLenField.h | 9 ++++++++- unittests/cfdp/testCfdp.cpp | 14 +++++++++++++- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/pdu/VarLenField.cpp index cb72735e..7713ed11 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.cpp +++ b/src/fsfw/cfdp/pdu/VarLenField.cpp @@ -21,27 +21,27 @@ cfdp::VarLenField::VarLenField() : width(cfdp::WidthInBytes::ONE_BYTE) { value.o cfdp::WidthInBytes cfdp::VarLenField::getWidth() const { return width; } -ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, size_t value) { +ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, size_t value_) { switch (widthInBytes) { case (cfdp::WidthInBytes::ONE_BYTE): { - if (value > UINT8_MAX) { + if (value_ > UINT8_MAX) { return HasReturnvaluesIF::RETURN_FAILED; } - this->value.oneByte = value; + this->value.oneByte = value_; break; } case (cfdp::WidthInBytes::TWO_BYTES): { - if (value > UINT16_MAX) { + if (value_ > UINT16_MAX) { return HasReturnvaluesIF::RETURN_FAILED; } - this->value.twoBytes = value; + this->value.twoBytes = value_; break; } case (cfdp::WidthInBytes::FOUR_BYTES): { - if (value > UINT32_MAX) { + if (value_ > UINT32_MAX) { return HasReturnvaluesIF::RETURN_FAILED; } - this->value.fourBytes = value; + this->value.fourBytes = value_; break; } default: { @@ -93,9 +93,9 @@ ReturnValue_t cfdp::VarLenField::serialize(uint8_t **buffer, size_t *size, size_ size_t cfdp::VarLenField::getSerializedSize() const { return width; } -ReturnValue_t cfdp::VarLenField::deSerialize(cfdp::WidthInBytes width, const uint8_t **buffer, +ReturnValue_t cfdp::VarLenField::deSerialize(cfdp::WidthInBytes width_, const uint8_t **buffer, size_t *size, Endianness streamEndianness) { - this->width = width; + this->width = width_; return deSerialize(buffer, size, streamEndianness); } @@ -118,10 +118,3 @@ ReturnValue_t cfdp::VarLenField::deSerialize(const uint8_t **buffer, size_t *siz } } } - -template -cfdp::VarLenField::VarLenField(UnsignedByteField byteField) - : width(static_cast(sizeof(T))) { - static_assert((sizeof(T) % 2) == 0); - value = byteField.getValue(); -} diff --git a/src/fsfw/cfdp/pdu/VarLenField.h b/src/fsfw/cfdp/pdu/VarLenField.h index 3b7ccc5a..dfc6b195 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.h +++ b/src/fsfw/cfdp/pdu/VarLenField.h @@ -41,9 +41,16 @@ class VarLenField : public SerializeIF { Endianness streamEndianness) override; cfdp::WidthInBytes width; - LengthFieldLen value; + LengthFieldLen value{}; }; +template +cfdp::VarLenField::VarLenField(UnsignedByteField byteField) + : width(static_cast(sizeof(T))) { + static_assert((sizeof(T) % 2) == 0); + setValue(width, byteField.getValue()); +} + } // namespace cfdp #endif /* FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_ */ diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 8cfdbca4..475322a2 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -75,7 +75,7 @@ TEST_CASE("CFDP Base", "[cfdp]") { REQUIRE(fdDeser.parseData() == cfdp::INVALID_DIRECTIVE_FIELDS); } - SECTION("FileSize") { + SECTION("File Size") { std::array fssBuf = {}; uint8_t* buffer = fssBuf.data(); size_t size = 0; @@ -90,4 +90,16 @@ TEST_CASE("CFDP Base", "[cfdp]") { REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(fileSize == 0x20); } + + SECTION("Var Length Field") { + VarLenField defaultField; + CHECK(defaultField.getValue() == 0); + CHECK(defaultField.getWidth() == WidthInBytes::ONE_BYTE); + VarLenField explicitField(WidthInBytes::FOUR_BYTES, 12); + CHECK(explicitField.getWidth() == WidthInBytes::FOUR_BYTES); + CHECK(explicitField.getValue() == 12); + VarLenField fromUnsignedByteField(UnsignedByteField(12)); + CHECK(fromUnsignedByteField.getWidth() == WidthInBytes::TWO_BYTES); + CHECK(fromUnsignedByteField.getValue() == 12); + } } From b20e8a9679b7b46dfec43d3716bdd36c4313e68e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Aug 2022 15:12:29 +0200 Subject: [PATCH 181/532] continue new cfdp router --- src/fsfw/cfdp/CMakeLists.txt | 3 +- src/fsfw/cfdp/CfdpDistributor.cpp | 144 +++++++++++++++++ src/fsfw/cfdp/CfdpHandler.cpp | 111 +++++++------ src/fsfw/cfdp/CfdpHandler.h | 126 +++++++-------- src/fsfw/cfdp/CfdpRouter.cpp | 65 ++++++++ src/fsfw/cfdp/CfdpRouter.h | 74 +++++++++ .../CfdpRouterIF.h} | 16 +- src/fsfw/cfdp/pdu/VarLenField.cpp | 8 + src/fsfw/cfdp/pdu/VarLenField.h | 3 + src/fsfw/events/fwSubsystemIdRanges.h | 2 +- src/fsfw/tcdistribution/CMakeLists.txt | 10 +- src/fsfw/tcdistribution/CcsdsDistributor.cpp | 6 +- src/fsfw/tcdistribution/CcsdsDistributorIF.h | 12 +- .../tcdistribution/CcsdsPacketChecker.cpp | 8 +- src/fsfw/tcdistribution/CcsdsUnpacker.cpp | 57 ------- src/fsfw/tcdistribution/CcsdsUnpacker.h | 24 --- src/fsfw/tcdistribution/CfdpDistributor.cpp | 146 ------------------ src/fsfw/tcdistribution/CfdpDistributor.h | 71 --------- src/fsfw/tcdistribution/PusDistributor.cpp | 8 +- src/fsfw/tcdistribution/PusPacketChecker.cpp | 8 +- src/fsfw/tcdistribution/TcDistributorBase.cpp | 3 +- src/fsfw/tcdistribution/TcDistributorBase.h | 4 - src/fsfw/tcdistribution/definitions.h | 10 +- src/fsfw/tmtcservices/AcceptsTelemetryIF.h | 2 + unittests/mocks/AcceptsTmMock.cpp | 2 + unittests/mocks/AcceptsTmMock.h | 1 + .../tcdistributor/testCcsdsDistributor.cpp | 2 +- 27 files changed, 464 insertions(+), 462 deletions(-) create mode 100644 src/fsfw/cfdp/CfdpDistributor.cpp create mode 100644 src/fsfw/cfdp/CfdpRouter.cpp create mode 100644 src/fsfw/cfdp/CfdpRouter.h rename src/fsfw/{tcdistribution/CfdpDistributorIF.h => cfdp/CfdpRouterIF.h} (51%) delete mode 100644 src/fsfw/tcdistribution/CcsdsUnpacker.cpp delete mode 100644 src/fsfw/tcdistribution/CcsdsUnpacker.h delete mode 100644 src/fsfw/tcdistribution/CfdpDistributor.cpp delete mode 100644 src/fsfw/tcdistribution/CfdpDistributor.h diff --git a/src/fsfw/cfdp/CMakeLists.txt b/src/fsfw/cfdp/CMakeLists.txt index f2affbb4..2d58e190 100644 --- a/src/fsfw/cfdp/CMakeLists.txt +++ b/src/fsfw/cfdp/CMakeLists.txt @@ -1,4 +1,5 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE CfdpHandler.cpp CfdpMessage.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpRouter.cpp) +# CfdpDistributor.cpp CfdpHandler.cpp add_subdirectory(pdu) add_subdirectory(tlv) diff --git a/src/fsfw/cfdp/CfdpDistributor.cpp b/src/fsfw/cfdp/CfdpDistributor.cpp new file mode 100644 index 00000000..fa221822 --- /dev/null +++ b/src/fsfw/cfdp/CfdpDistributor.cpp @@ -0,0 +1,144 @@ +//#include "CfdpRouter.h" +//#include "fsfw/tcdistribution/CcsdsDistributorIF.h" +//#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h" +// +//#ifndef FSFW_CFDP_DISTRIBUTOR_DEBUGGING +//#define FSFW_CFDP_DISTRIBUTOR_DEBUGGING 1 +//#endif +// +// CfdpHandler::CfdpHandler(uint16_t setApid, object_id_t setObjectId, +// object_id_t setPacketSource) +// : TcDistributorBase(setObjectId), +// apid(setApid), +// checker(setApid), +// tcStatus(RETURN_FAILED), +// packetSource(setPacketSource) {} +// +// CfdpHandler::~CfdpHandler() = default; +// +// ReturnValue_t CfdpHandler::selectDestination(MessageQueueId_t& destId) { +// //#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 +// // store_address_t storeId = this->currentMessage.getStorageId(); +// //#if FSFW_CPP_OSTREAM_ENABLED == 1 +// // sif::debug << "CFDPDistributor::handlePacket received: " << storeId.poolIndex << ", " +// // << storeId.packetIndex << std::endl; +// //#else +// // sif::printDebug("CFDPDistributor::handlePacket received: %d, %d\n", storeId.poolIndex, +// // storeId.packetIndex); +// //#endif +// //#endif +// // auto queueMapIt = this->queueMap.end(); +// // if (this->currentPacket == nullptr) { +// // return queueMapIt; +// // } +// // this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); +// // if (currentPacket->getFullData() != nullptr) { +// // tcStatus = checker.checkPacket(*currentPacket, currentPacket->getFullPacketLen()); +// // if (tcStatus != HasReturnvaluesIF::RETURN_OK) { +// //#if FSFW_VERBOSE_LEVEL >= 1 +// //#if FSFW_CPP_OSTREAM_ENABLED == 1 +// // sif::debug << "CFDPDistributor::handlePacket: Packet format invalid, code " +// // << static_cast(tcStatus) << std::endl; +// //#else +// // sif::printDebug("CFDPDistributor::handlePacket: Packet format invalid, code %d\n", +// // static_cast(tcStatus)); +// //#endif +// //#endif +// // } +// // queueMapIt = this->queueMap.find(0); +// // } else { +// // tcStatus = PACKET_LOST; +// // } +// // +// // if (queueMapIt == this->queueMap.end()) { +// // tcStatus = DESTINATION_NOT_FOUND; +// //#if FSFW_VERBOSE_LEVEL >= 1 +// //#if FSFW_CPP_OSTREAM_ENABLED == 1 +// // sif::debug << "CFDPDistributor::handlePacket: Destination not found" << std::endl; +// //#else +// // sif::printDebug("CFDPDistributor::handlePacket: Destination not found\n"); +// //#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ +// //#endif +// // } +// // +// // if (tcStatus != RETURN_OK) { +// // return this->queueMap.end(); +// // } else { +// // return queueMapIt; +// // } +// return HasReturnvaluesIF::RETURN_OK; +//} +// +// ReturnValue_t CfdpHandler::registerHandler(AcceptsTelecommandsIF* handler) { +// // uint16_t handlerId = +// // handler->getIdentifier(); // should be 0, because CfdpHandler does not set a set a +// // service-ID +// //#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 +// //#if FSFW_CPP_OSTREAM_ENABLED == 1 +// // sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast(handlerId) +// // << std::endl; +// //#else +// // sif::printInfo("CFDPDistributor::registerHandler: Handler ID: %d\n", +// // static_cast(handlerId)); +// //#endif +// //#endif +// // MessageQueueId_t queue = handler->getRequestQueue(); +// // auto returnPair = queueMap.emplace(handlerId, queue); +// // if (not returnPair.second) { +// //#if FSFW_VERBOSE_LEVEL >= 1 +// //#if FSFW_CPP_OSTREAM_ENABLED == 1 +// // sif::error << "CFDPDistributor::registerHandler: Service ID already" +// // " exists in map" +// // << std::endl; +// //#else +// // sif::printError("CFDPDistributor::registerHandler: Service ID already exists in map\n"); +// //#endif +// //#endif +// // return SERVICE_ID_ALREADY_EXISTS; +// // } +// return HasReturnvaluesIF::RETURN_OK; +//} +// +// MessageQueueId_t CfdpHandler::getRequestQueue() const { return tcQueue->getId(); } +// +//// ReturnValue_t CFDPDistributor::callbackAfterSending(ReturnValue_t queueStatus) { +//// if (queueStatus != RETURN_OK) { +//// tcStatus = queueStatus; +//// } +//// if (tcStatus != RETURN_OK) { +//// this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, +//// currentPacket, tcStatus); +//// // A failed packet is deleted immediately after reporting, +//// // otherwise it will block memory. +//// currentPacket->deletePacket(); +//// return RETURN_FAILED; +//// } else { +//// this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, +//// currentPacket); +//// return RETURN_OK; +//// } +//// } +// +// uint32_t CfdpHandler::getIdentifier() const { return this->apid; } +// +// ReturnValue_t CfdpHandler::initialize() { +// // currentPacket = new CfdpPacketStored(); +// // if (currentPacket == nullptr) { +// // // Should not happen, memory allocation failed! +// // return ObjectManagerIF::CHILD_INIT_FAILED; +// // } +// // +// // auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); +// // if (ccsdsDistributor == nullptr) { +// //#if FSFW_CPP_OSTREAM_ENABLED == 1 +// // sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl; +// // sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; +// //#else +// // sif::printError("CFDPDistributor::initialize: Packet source invalid\n"); +// // sif::printError("Make sure it exists and implements CcsdsDistributorIF\n"); +// //#endif +// // return RETURN_FAILED; +// // } +// // return ccsdsDistributor->registerApplication(this); +// return HasReturnvaluesIF::RETURN_OK; +//} diff --git a/src/fsfw/cfdp/CfdpHandler.cpp b/src/fsfw/cfdp/CfdpHandler.cpp index 35e5b2bc..1bf03e10 100644 --- a/src/fsfw/cfdp/CfdpHandler.cpp +++ b/src/fsfw/cfdp/CfdpHandler.cpp @@ -1,57 +1,54 @@ -#include "fsfw/cfdp/CfdpHandler.h" - -#include "fsfw/cfdp/CfdpMessage.h" -#include "fsfw/ipc/CommandMessage.h" -#include "fsfw/ipc/QueueFactory.h" -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/storagemanager/storeAddress.h" -#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" - -object_id_t CfdpHandler::packetSource = 0; -object_id_t CfdpHandler::packetDestination = 0; - -CfdpHandler::CfdpHandler(object_id_t setObjectId, CfdpDistributor* dist) - : SystemObject(setObjectId) { - requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION); - distributor = dist; -} - -CfdpHandler::~CfdpHandler() = default; - -ReturnValue_t CfdpHandler::initialize() { - ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { - return result; - } - this->distributor->registerHandler(this); - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CfdpHandler::handleRequest(store_address_t storeId) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "CFDPHandler::handleRequest" << std::endl; -#else - sif::printDebug("CFDPHandler::handleRequest\n"); -#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif - - // TODO read out packet from store using storeId - - return RETURN_OK; -} - -ReturnValue_t CfdpHandler::performOperation(uint8_t opCode) { - ReturnValue_t status = RETURN_OK; - CommandMessage currentMessage; - for (status = this->requestQueue->receiveMessage(¤tMessage); status == RETURN_OK; - status = this->requestQueue->receiveMessage(¤tMessage)) { - store_address_t storeId = CfdpMessage::getStoreId(¤tMessage); - this->handleRequest(storeId); - } - return RETURN_OK; -} - -uint32_t CfdpHandler::getIdentifier() const { return 0; } - -MessageQueueId_t CfdpHandler::getRequestQueue() const { return this->requestQueue->getId(); } +//#include "fsfw/cfdp/CfdpHandler.h" +// +//#include "fsfw/cfdp/CfdpMessage.h" +//#include "fsfw/ipc/CommandMessage.h" +//#include "fsfw/ipc/QueueFactory.h" +//#include "fsfw/objectmanager/ObjectManager.h" +//#include "fsfw/storagemanager/storeAddress.h" +//#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" +// +// CfdpHandler::CfdpHandler(object_id_t setObjectId, CfdpHandler* dist) +// : SystemObject(setObjectId) { +// requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION); +// distributor = dist; +//} +// +// CfdpHandler::~CfdpHandler() = default; +// +// ReturnValue_t CfdpHandler::initialize() { +// ReturnValue_t result = SystemObject::initialize(); +// if (result != RETURN_OK) { +// return result; +// } +// this->distributor->registerHandler(this); +// return HasReturnvaluesIF::RETURN_OK; +//} +// +// ReturnValue_t CfdpHandler::handleRequest(store_address_t storeId) { +//#if FSFW_VERBOSE_LEVEL >= 1 +//#if FSFW_CPP_OSTREAM_ENABLED == 1 +// sif::debug << "CFDPHandler::handleRequest" << std::endl; +//#else +// sif::printDebug("CFDPHandler::handleRequest\n"); +//#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ +//#endif +// +// // TODO read out packet from store using storeId +// +// return RETURN_OK; +//} +// +// ReturnValue_t CfdpHandler::performOperation(uint8_t opCode) { +// ReturnValue_t status = RETURN_OK; +// CommandMessage currentMessage; +// for (status = this->requestQueue->receiveMessage(¤tMessage); status == RETURN_OK; +// status = this->requestQueue->receiveMessage(¤tMessage)) { +// store_address_t storeId = CfdpMessage::getStoreId(¤tMessage); +// this->handleRequest(storeId); +// } +// return RETURN_OK; +//} +// +// uint32_t CfdpHandler::getIdentifier() const { return 0; } +// +// MessageQueueId_t CfdpHandler::getRequestQueue() const { return this->requestQueue->getId(); } diff --git a/src/fsfw/cfdp/CfdpHandler.h b/src/fsfw/cfdp/CfdpHandler.h index 8730f3eb..8c2827ec 100644 --- a/src/fsfw/cfdp/CfdpHandler.h +++ b/src/fsfw/cfdp/CfdpHandler.h @@ -1,63 +1,63 @@ -#ifndef FSFW_CFDP_CFDPHANDLER_H_ -#define FSFW_CFDP_CFDPHANDLER_H_ - -#include "fsfw/ipc/MessageQueueIF.h" -#include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/tcdistribution/CfdpDistributor.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" - -namespace Factory { -void setStaticFrameworkObjectIds(); -} - -class CfdpHandler : public ExecutableObjectIF, - public AcceptsTelecommandsIF, - public SystemObject, - public HasReturnvaluesIF { - friend void(Factory::setStaticFrameworkObjectIds)(); - - public: - CfdpHandler(object_id_t setObjectId, CfdpDistributor* distributor); - /** - * The destructor is empty. - */ - virtual ~CfdpHandler(); - - virtual ReturnValue_t handleRequest(store_address_t storeId); - - virtual ReturnValue_t initialize() override; - virtual uint32_t getIdentifier() const override; - MessageQueueId_t getRequestQueue() const override; - ReturnValue_t performOperation(uint8_t opCode) override; - - protected: - /** - * This is a complete instance of the telecommand reception queue - * of the class. It is initialized on construction of the class. - */ - MessageQueueIF* requestQueue = nullptr; - - CfdpDistributor* distributor = nullptr; - - /** - * The current CFDP packet to be processed. - * It is deleted after handleRequest was executed. - */ - CfdpPacketStored currentPacket; - - static object_id_t packetSource; - - static object_id_t packetDestination; - - private: - /** - * This constant sets the maximum number of packets accepted per call. - * Remember that one packet must be completely handled in one - * #handleRequest call. - */ - static const uint8_t CFDP_HANDLER_MAX_RECEPTION = 100; -}; - -#endif /* FSFW_CFDP_CFDPHANDLER_H_ */ +//#ifndef FSFW_CFDP_CFDPHANDLER_H_ +//#define FSFW_CFDP_CFDPHANDLER_H_ +// +//#include "fsfw/ipc/MessageQueueIF.h" +//#include "fsfw/objectmanager/SystemObject.h" +//#include "fsfw/returnvalues/HasReturnvaluesIF.h" +//#include "fsfw/storagemanager/storeAddress.h" +//#include "fsfw/tasks/ExecutableObjectIF.h" +//#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +// +// namespace Factory { +// void setStaticFrameworkObjectIds(); +//} +// +// class CfdpHandler : public ExecutableObjectIF, +// public AcceptsTelecommandsIF, +// public SystemObject, +// public HasReturnvaluesIF { +// friend void(Factory::setStaticFrameworkObjectIds)(); +// +// public: +// CfdpHandler(object_id_t setObjectId, CfdpHandler* distributor); +// /** +// * The destructor is empty. +// */ +// virtual ~CfdpHandler(); +// +// virtual ReturnValue_t handleRequest(store_address_t storeId); +// +// virtual ReturnValue_t initialize() override; +// virtual uint32_t getIdentifier() const override; +// MessageQueueId_t getRequestQueue() const override; +// ReturnValue_t performOperation(uint8_t opCode) override; +// +// protected: +// /** +// * This is a complete instance of the telecommand reception queue +// * of the class. It is initialized on construction of the class. +// */ +// MessageQueueIF* requestQueue = nullptr; +// +// CfdpHandler* distributor = nullptr; +// +// /** +// * The current CFDP packet to be processed. +// * It is deleted after handleRequest was executed. +// */ +// CfdpPacketStored currentPacket; +// +// static object_id_t packetSource; +// +// static object_id_t packetDestination; +// +// private: +// /** +// * This constant sets the maximum number of packets accepted per call. +// * Remember that one packet must be completely handled in one +// * #handleRequest call. +// */ +// static const uint8_t CFDP_HANDLER_MAX_RECEPTION = 100; +//}; +// +//#endif /* FSFW_CFDP_CFDPHANDLER_H_ */ diff --git a/src/fsfw/cfdp/CfdpRouter.cpp b/src/fsfw/cfdp/CfdpRouter.cpp new file mode 100644 index 00000000..9e4f623e --- /dev/null +++ b/src/fsfw/cfdp/CfdpRouter.cpp @@ -0,0 +1,65 @@ +#include "CfdpRouter.h" + +#include + +#include "fsfw/tcdistribution/definitions.h" + +CfdpRouter::CfdpRouter(CfdpRouterCfg cfg) : TcDistributorBase(cfg.objectId), tmQueue(cfg.tmQueue) {} + +ReturnValue_t CfdpRouter::registerTmSink(cfdp::EntityId address, AcceptsTelemetryIF& tmDest) { + for (const auto& dest : tmDestinations) { + if (dest.id == address) { + return HasReturnvaluesIF::RETURN_FAILED; + } + } + tmDestinations.emplace_back(address, tmDest.getName(), tmDest.getReportReceptionQueue()); + return HasReturnvaluesIF::RETURN_OK; +} +ReturnValue_t CfdpRouter::registerTcDestination(cfdp::EntityId address, + AcceptsTelecommandsIF& tcDest) { + for (const auto& dest : tcDestinations) { + if (dest.id == address) { + return HasReturnvaluesIF::RETURN_FAILED; + } + } + tcDestinations.emplace_back(address, tcDest.getName(), tcDest.getRequestQueue()); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CfdpRouter::selectDestination(MessageQueueId_t& destId) { return 0; } + +const char* CfdpRouter::getName() const { return "CFDP Router"; } + +uint32_t CfdpRouter::getIdentifier() const { return 0; } + +MessageQueueId_t CfdpRouter::getRequestQueue() const { return tcQueue->getId(); } + +MessageQueueId_t CfdpRouter::getReportReceptionQueue(uint8_t virtualChannel) { + return tmQueue.getId(); +} + +ReturnValue_t CfdpRouter::performOperation(uint8_t opCode) { + lastTcError = TcDistributorBase::performOperation(opCode); + lastTmError = performTmHandling(); + if (lastTcError != HasReturnvaluesIF::RETURN_OK or lastTmError != HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CfdpRouter::performTmHandling() { + ReturnValue_t status; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + for (status = tmQueue.receiveMessage(¤tMessage); status == RETURN_OK; + status = tmQueue.receiveMessage(¤tMessage)) { + ReturnValue_t packetResult = handlePacket(); + if (packetResult != HasReturnvaluesIF::RETURN_OK) { + result = packetResult; + triggerEvent(tmtcdistrib::HANDLE_PACKET_FAILED, packetResult, ccsds::PacketType::TM); + } + } + if (status == MessageQueueIF::EMPTY) { + return result; + } + return result; +} diff --git a/src/fsfw/cfdp/CfdpRouter.h b/src/fsfw/cfdp/CfdpRouter.h new file mode 100644 index 00000000..178f0177 --- /dev/null +++ b/src/fsfw/cfdp/CfdpRouter.h @@ -0,0 +1,74 @@ +#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ +#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ + +#include +#include + +#include "CfdpRouterIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tcdistribution/CfdpPacketChecker.h" +#include "fsfw/tcdistribution/TcDistributorBase.h" +#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/tmtcservices/VerificationReporter.h" + +struct CfdpRouterCfg { + CfdpRouterCfg(object_id_t objectId, MessageQueueIF& tmQueue) + : objectId(objectId), tmQueue(tmQueue) {} + + object_id_t objectId; + MessageQueueIF& tmQueue; +}; +/** + * This will be the primary component to perform PDU forwading procedures. This includes forwarding + * CFDP TC packets to registered source or destination handlers, and forwarding all telemetry + * generated by them to registered TM sinks. + * @ingroup tc_distribution + */ +class CfdpRouter : public TcDistributorBase, + public CfdpRouterIF, + public AcceptsTelecommandsIF, + public AcceptsTelemetryIF { + public: + /** + * The ctor passes @c set_apid to the checker class and calls the + * TcDistribution ctor with a certain object id. + * @param setApid The APID of this receiving Application. + * @param setObjectId Object ID of the distributor itself + * @param setPacketSource Object ID of the source of TC packets. + * Must implement CcsdsDistributorIF. + */ + explicit CfdpRouter(CfdpRouterCfg cfg); + + ReturnValue_t performOperation(uint8_t opCode) override; + ReturnValue_t performTmHandling(); + [[nodiscard]] const char* getName() const override; + [[nodiscard]] uint32_t getIdentifier() const override; + [[nodiscard]] MessageQueueId_t getRequestQueue() const override; + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override; + ReturnValue_t registerTmSink(cfdp::EntityId address, AcceptsTelemetryIF& tmDest) override; + ReturnValue_t registerTcDestination(cfdp::EntityId address, + AcceptsTelecommandsIF& tcDest) override; + + protected: + struct EntityInfo { + EntityInfo(cfdp::EntityId id, const char* name, MessageQueueId_t queueId) + : id(std::move(id)), name(name), queueId(queueId) {} + cfdp::EntityId id; + const char* name; + MessageQueueId_t queueId; + }; + ReturnValue_t lastTcError = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t lastTmError = HasReturnvaluesIF::RETURN_OK; + // I don't think a regular OBSW will have more than 1 or 2 of these destinations, so I think + // it is okay to accept the overhead here + std::vector tmDestinations; + std::vector tcDestinations; + MessageQueueIF& tmQueue; + + ReturnValue_t selectDestination(MessageQueueId_t& destId) override; + + private: +}; + +#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ */ diff --git a/src/fsfw/tcdistribution/CfdpDistributorIF.h b/src/fsfw/cfdp/CfdpRouterIF.h similarity index 51% rename from src/fsfw/tcdistribution/CfdpDistributorIF.h rename to src/fsfw/cfdp/CfdpRouterIF.h index 660a9709..0c630407 100644 --- a/src/fsfw/tcdistribution/CfdpDistributorIF.h +++ b/src/fsfw/cfdp/CfdpRouterIF.h @@ -1,26 +1,32 @@ #ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_ #define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_ -#include "../ipc/MessageQueueSenderIF.h" -#include "../tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/cfdp/definitions.h" +#include "fsfw/cfdp/pdu/PduHeaderIF.h" +#include "fsfw/ipc/MessageQueueSenderIF.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" /** * This interface allows CFDP Services to register themselves at a CFDP Distributor. * @ingroup tc_distribution */ -class CfdpDistributorIF { +class CfdpRouterIF { public: /** * The empty virtual destructor. */ - virtual ~CfdpDistributorIF() = default; + virtual ~CfdpRouterIF() = default; + + virtual ReturnValue_t registerTmSink(cfdp::EntityId address, AcceptsTelemetryIF& tmDest) = 0; /** * With this method, Handlers can register themselves at the CFDP Distributor. * @param handler A pointer to the registering Handler. * @return - @c RETURN_OK on success, * - @c RETURN_FAILED on failure. */ - virtual ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) = 0; + virtual ReturnValue_t registerTcDestination(cfdp::EntityId address, + AcceptsTelecommandsIF& tcDest) = 0; }; #endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_ */ diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/pdu/VarLenField.cpp index 7713ed11..a403534b 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.cpp +++ b/src/fsfw/cfdp/pdu/VarLenField.cpp @@ -118,3 +118,11 @@ ReturnValue_t cfdp::VarLenField::deSerialize(const uint8_t **buffer, size_t *siz } } } + +bool cfdp::VarLenField::operator<(const cfdp::VarLenField &other) const { + return getValue() < other.getValue(); +} + +bool cfdp::VarLenField::operator==(const cfdp::VarLenField &other) const { + return getValue() == other.getValue(); +} diff --git a/src/fsfw/cfdp/pdu/VarLenField.h b/src/fsfw/cfdp/pdu/VarLenField.h index dfc6b195..7f8a1acb 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.h +++ b/src/fsfw/cfdp/pdu/VarLenField.h @@ -23,6 +23,9 @@ class VarLenField : public SerializeIF { explicit VarLenField(UnsignedByteField byteField); VarLenField(cfdp::WidthInBytes width, size_t value); + bool operator==(const VarLenField &other) const; + bool operator<(const VarLenField &other) const; + ReturnValue_t setValue(cfdp::WidthInBytes, size_t value); ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, diff --git a/src/fsfw/events/fwSubsystemIdRanges.h b/src/fsfw/events/fwSubsystemIdRanges.h index a09c935c..d8e4ade6 100644 --- a/src/fsfw/events/fwSubsystemIdRanges.h +++ b/src/fsfw/events/fwSubsystemIdRanges.h @@ -19,7 +19,7 @@ enum : uint8_t { HK = 73, SYSTEM_MANAGER = 74, SYSTEM_MANAGER_1 = 75, - TC_DISTRIBUTION = 76, + TMTC_DISTRIBUTION = 76, SYSTEM_1 = 79, PUS_SERVICE_1 = 80, PUS_SERVICE_2 = 82, diff --git a/src/fsfw/tcdistribution/CMakeLists.txt b/src/fsfw/tcdistribution/CMakeLists.txt index 5501f4af..bcad563a 100644 --- a/src/fsfw/tcdistribution/CMakeLists.txt +++ b/src/fsfw/tcdistribution/CMakeLists.txt @@ -1,10 +1,4 @@ target_sources( ${LIB_FSFW_NAME} - PRIVATE CcsdsDistributor.cpp - PusDistributor.cpp - TcDistributorBase.cpp - PusPacketChecker.cpp - TcPacketCheckCFDP.cpp - CfdpDistributor.cpp - CcsdsPacketChecker.cpp - CcsdsUnpacker.cpp) + PRIVATE CcsdsDistributor.cpp PusDistributor.cpp TcDistributorBase.cpp + PusPacketChecker.cpp TcPacketCheckCFDP.cpp CcsdsPacketChecker.cpp) diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp index 0ec5ed5c..6932d2d3 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -96,13 +96,13 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) { #if FSFW_VERBOSE_LEVEL >= 1 const char* reason = "Unknown reason"; - if (result == tcdistrib::INVALID_CCSDS_VERSION) { + if (result == tmtcdistrib::INVALID_CCSDS_VERSION) { reason = "Invalid CCSDS version"; } else if (result == tcdistrib::INCOMPLETE_PACKET) { reason = "Size missmatch between CCSDS data length and packet length"; - } else if (result == tcdistrib::INVALID_APID) { + } else if (result == tmtcdistrib::INVALID_APID) { reason = "No valid handler APID found"; - } else if (result == tcdistrib::INVALID_PACKET_TYPE) { + } else if (result == tmtcdistrib::INVALID_PACKET_TYPE) { reason = "Invalid Packet Type TM detected"; } #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/tcdistribution/CcsdsDistributorIF.h b/src/fsfw/tcdistribution/CcsdsDistributorIF.h index 6deb1c67..f70a2ef9 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributorIF.h +++ b/src/fsfw/tcdistribution/CcsdsDistributorIF.h @@ -35,12 +35,12 @@ class CcsdsDistributorIF { * @param info Contains all necessary info to register an application. * @return * - @c RETURN_OK on success, - * - @c RETURN_FAILED or tcdistrib error code on failure. - * - @c tcdistrib::INVALID_CCSDS_VERSION - * - @c tcdistrib::INVALID_APID No APID available to handle this packet - * - @c tcdistrib::INVALID_PACKET_TYPE Packet type TM detected - * - @c tcdistrib::INCORRECT_PRIMARY_HEADER Something other wrong with primary header - * - @c tcdistrib::INCOMPLETE_PACKET Size missmatch between data length field and actual + * - @c RETURN_FAILED or tmtcdistrib error code on failure. + * - @c tmtcdistrib::INVALID_CCSDS_VERSION + * - @c tmtcdistrib::INVALID_APID No APID available to handle this packet + * - @c tmtcdistrib::INVALID_PACKET_TYPE Packet type TM detected + * - @c tmtcdistrib::INCORRECT_PRIMARY_HEADER Something other wrong with primary header + * - @c tmtcdistrib::INCOMPLETE_PACKET Size missmatch between data length field and actual * length */ virtual ReturnValue_t registerApplication(DestInfo info) = 0; diff --git a/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp b/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp index 394f5a57..ea2bd9d1 100644 --- a/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp +++ b/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp @@ -10,19 +10,19 @@ ReturnValue_t CcsdsPacketChecker::checkPacket(const SpacePacketReader& currentPa size_t packetLen) { if (checkApid) { if (currentPacket.getApid() != apid) { - return tcdistrib::INVALID_APID; + return tmtcdistrib::INVALID_APID; } } if (currentPacket.getVersion() != ccsdsVersion) { - return tcdistrib::INVALID_CCSDS_VERSION; + return tmtcdistrib::INVALID_CCSDS_VERSION; } if (currentPacket.getPacketType() != packetType) { - return tcdistrib::INVALID_PACKET_TYPE; + return tmtcdistrib::INVALID_PACKET_TYPE; } // This assumes that the getFullPacketLen version uses the space packet data length field if (currentPacket.getFullPacketLen() != packetLen) { - return tcdistrib::INCOMPLETE_PACKET; + return tmtcdistrib::INCOMPLETE_PACKET; } return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.cpp b/src/fsfw/tcdistribution/CcsdsUnpacker.cpp deleted file mode 100644 index 9b212d2e..00000000 --- a/src/fsfw/tcdistribution/CcsdsUnpacker.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "CcsdsUnpacker.h" - -#include "fsfw/tmtcservices/TmTcMessage.h" - -CcsdsUnpacker::CcsdsUnpacker(MessageQueueIF& msgQueue, AcceptsTelecommandsIF& receiver, - StorageManagerIF& sourceStore) - : sourceStore(sourceStore), msgQueue(msgQueue), receiver(receiver) { - msgQueue.setDefaultDestination(receiver.getRequestQueue()); -} - -ReturnValue_t CcsdsUnpacker::performOperation(uint8_t operationCode) { - TmTcMessage msg; - ReturnValue_t result; - for (result = msgQueue.receiveMessage(&msg); result == HasReturnvaluesIF::RETURN_OK; - result = msgQueue.receiveMessage(&msg)) { - auto resultPair = sourceStore.getData(msg.getStorageId()); - if (resultPair.first != HasReturnvaluesIF::RETURN_OK) { - continue; - } - if (resultPair.second.size() < 6) { - // TODO: This is a config error. Does it make sense to forward the message? - result = msgQueue.sendToDefault(&msg); - if (result != HasReturnvaluesIF::RETURN_OK) { - } - continue; - } - StorageManagerIF* tgtStore; - if (targetStore != nullptr) { - tgtStore = targetStore; - } else { - tgtStore = &sourceStore; - } - store_address_t newId; - uint8_t* ptr; - result = tgtStore->getFreeElement(&newId, resultPair.second.size(), &ptr); - if (result != HasReturnvaluesIF::RETURN_OK) { - // TODO: Implement error handling - } - std::memcpy(ptr, resultPair.second.data() + 6, resultPair.second.size() - 6); - result = sourceStore.deleteData(msg.getStorageId()); - if (result != HasReturnvaluesIF::RETURN_OK) { - // TODO: Implement error handling (though this really should not happen) - } - TmTcMessage newMsg(newId); - result = msgQueue.sendToDefault(&newMsg); - if (result != HasReturnvaluesIF::RETURN_OK) { - } - } - return result; -} - -void CcsdsUnpacker::setDifferentTargetStore(StorageManagerIF& otherTargetStore) { - targetStore = &otherTargetStore; -} - -uint32_t CcsdsUnpacker::getIdentifier() const { return 0; } -MessageQueueId_t CcsdsUnpacker::getRequestQueue() const { return 0; } diff --git a/src/fsfw/tcdistribution/CcsdsUnpacker.h b/src/fsfw/tcdistribution/CcsdsUnpacker.h deleted file mode 100644 index 267b8e64..00000000 --- a/src/fsfw/tcdistribution/CcsdsUnpacker.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef FSFW_TCDISTRIBUTION_CCSDSUNPACKER_H -#define FSFW_TCDISTRIBUTION_CCSDSUNPACKER_H - -#include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/tasks/ExecutableObjectIF.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" - -class CcsdsUnpacker : public ExecutableObjectIF, public AcceptsTelecommandsIF { - public: - CcsdsUnpacker(MessageQueueIF& msgQueue, AcceptsTelecommandsIF& receiver, - StorageManagerIF& sourceStore); - - void setDifferentTargetStore(StorageManagerIF& otherTargetStore); - ReturnValue_t performOperation(uint8_t operationCode) override; - uint32_t getIdentifier() const override; - MessageQueueId_t getRequestQueue() const override; - - private: - StorageManagerIF& sourceStore; - StorageManagerIF* targetStore = nullptr; - MessageQueueIF& msgQueue; - AcceptsTelecommandsIF& receiver; -}; -#endif // FSFW_TCDISTRIBUTION_CCSDSUNPACKER_H diff --git a/src/fsfw/tcdistribution/CfdpDistributor.cpp b/src/fsfw/tcdistribution/CfdpDistributor.cpp deleted file mode 100644 index 3b1d1538..00000000 --- a/src/fsfw/tcdistribution/CfdpDistributor.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "fsfw/tcdistribution/CfdpDistributor.h" - -#include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/tcdistribution/CcsdsDistributorIF.h" -#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h" - -#ifndef FSFW_CFDP_DISTRIBUTOR_DEBUGGING -#define FSFW_CFDP_DISTRIBUTOR_DEBUGGING 1 -#endif - -CfdpDistributor::CfdpDistributor(uint16_t setApid, object_id_t setObjectId, - object_id_t setPacketSource) - : TcDistributorBase(setObjectId), - apid(setApid), - checker(setApid), - tcStatus(RETURN_FAILED), - packetSource(setPacketSource) {} - -CfdpDistributor::~CfdpDistributor() = default; - -ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { - //#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 - // store_address_t storeId = this->currentMessage.getStorageId(); - //#if FSFW_CPP_OSTREAM_ENABLED == 1 - // sif::debug << "CFDPDistributor::handlePacket received: " << storeId.poolIndex << ", " - // << storeId.packetIndex << std::endl; - //#else - // sif::printDebug("CFDPDistributor::handlePacket received: %d, %d\n", storeId.poolIndex, - // storeId.packetIndex); - //#endif - //#endif - // auto queueMapIt = this->queueMap.end(); - // if (this->currentPacket == nullptr) { - // return queueMapIt; - // } - // this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); - // if (currentPacket->getFullData() != nullptr) { - // tcStatus = checker.checkPacket(*currentPacket, currentPacket->getFullPacketLen()); - // if (tcStatus != HasReturnvaluesIF::RETURN_OK) { - //#if FSFW_VERBOSE_LEVEL >= 1 - //#if FSFW_CPP_OSTREAM_ENABLED == 1 - // sif::debug << "CFDPDistributor::handlePacket: Packet format invalid, code " - // << static_cast(tcStatus) << std::endl; - //#else - // sif::printDebug("CFDPDistributor::handlePacket: Packet format invalid, code %d\n", - // static_cast(tcStatus)); - //#endif - //#endif - // } - // queueMapIt = this->queueMap.find(0); - // } else { - // tcStatus = PACKET_LOST; - // } - // - // if (queueMapIt == this->queueMap.end()) { - // tcStatus = DESTINATION_NOT_FOUND; - //#if FSFW_VERBOSE_LEVEL >= 1 - //#if FSFW_CPP_OSTREAM_ENABLED == 1 - // sif::debug << "CFDPDistributor::handlePacket: Destination not found" << std::endl; - //#else - // sif::printDebug("CFDPDistributor::handlePacket: Destination not found\n"); - //#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ - //#endif - // } - // - // if (tcStatus != RETURN_OK) { - // return this->queueMap.end(); - // } else { - // return queueMapIt; - // } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CfdpDistributor::registerHandler(AcceptsTelecommandsIF* handler) { - // uint16_t handlerId = - // handler->getIdentifier(); // should be 0, because CfdpHandler does not set a set a - // service-ID - //#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 - //#if FSFW_CPP_OSTREAM_ENABLED == 1 - // sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast(handlerId) - // << std::endl; - //#else - // sif::printInfo("CFDPDistributor::registerHandler: Handler ID: %d\n", - // static_cast(handlerId)); - //#endif - //#endif - // MessageQueueId_t queue = handler->getRequestQueue(); - // auto returnPair = queueMap.emplace(handlerId, queue); - // if (not returnPair.second) { - //#if FSFW_VERBOSE_LEVEL >= 1 - //#if FSFW_CPP_OSTREAM_ENABLED == 1 - // sif::error << "CFDPDistributor::registerHandler: Service ID already" - // " exists in map" - // << std::endl; - //#else - // sif::printError("CFDPDistributor::registerHandler: Service ID already exists in map\n"); - //#endif - //#endif - // return SERVICE_ID_ALREADY_EXISTS; - // } - return HasReturnvaluesIF::RETURN_OK; -} - -MessageQueueId_t CfdpDistributor::getRequestQueue() const { return tcQueue->getId(); } - -// ReturnValue_t CFDPDistributor::callbackAfterSending(ReturnValue_t queueStatus) { -// if (queueStatus != RETURN_OK) { -// tcStatus = queueStatus; -// } -// if (tcStatus != RETURN_OK) { -// this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, -// currentPacket, tcStatus); -// // A failed packet is deleted immediately after reporting, -// // otherwise it will block memory. -// currentPacket->deletePacket(); -// return RETURN_FAILED; -// } else { -// this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, -// currentPacket); -// return RETURN_OK; -// } -// } - -uint32_t CfdpDistributor::getIdentifier() const { return this->apid; } - -ReturnValue_t CfdpDistributor::initialize() { - // currentPacket = new CfdpPacketStored(); - // if (currentPacket == nullptr) { - // // Should not happen, memory allocation failed! - // return ObjectManagerIF::CHILD_INIT_FAILED; - // } - // - // auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); - // if (ccsdsDistributor == nullptr) { - //#if FSFW_CPP_OSTREAM_ENABLED == 1 - // sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl; - // sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; - //#else - // sif::printError("CFDPDistributor::initialize: Packet source invalid\n"); - // sif::printError("Make sure it exists and implements CcsdsDistributorIF\n"); - //#endif - // return RETURN_FAILED; - // } - // return ccsdsDistributor->registerApplication(this); - return HasReturnvaluesIF::RETURN_OK; -} diff --git a/src/fsfw/tcdistribution/CfdpDistributor.h b/src/fsfw/tcdistribution/CfdpDistributor.h deleted file mode 100644 index 7bfaee7b..00000000 --- a/src/fsfw/tcdistribution/CfdpDistributor.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ -#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ - -#include - -#include "../returnvalues/HasReturnvaluesIF.h" -#include "../tmtcpacket/cfdp/CfdpPacketStored.h" -#include "../tmtcservices/AcceptsTelecommandsIF.h" -#include "../tmtcservices/VerificationReporter.h" -#include "CfdpDistributorIF.h" -#include "TcDistributorBase.h" - -/** - * This class accepts CFDP Telecommands and forwards them to Application - * services. - * @ingroup tc_distribution - */ -class CfdpDistributor : public TcDistributorBase, - public CfdpDistributorIF, - public AcceptsTelecommandsIF { - public: - /** - * The ctor passes @c set_apid to the checker class and calls the - * TcDistribution ctor with a certain object id. - * @param setApid The APID of this receiving Application. - * @param setObjectId Object ID of the distributor itself - * @param setPacketSource Object ID of the source of TC packets. - * Must implement CcsdsDistributorIF. - */ - CfdpDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource); - /** - * The destructor is empty. - */ - ~CfdpDistributor() override; - ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) override; - MessageQueueId_t getRequestQueue() const override; - ReturnValue_t initialize() override; - uint32_t getIdentifier() const override; - - protected: - uint16_t apid; - /** - * The currently handled packet is stored here. - */ - CfdpPacketStored* currentPacket = nullptr; - CfdpPacketChecker checker; - /** - * With this variable, the current check status is stored to generate - * acceptance messages later. - */ - ReturnValue_t tcStatus; - - const object_id_t packetSource; - - /** - * This method reads the packet service, checks if such a service is - * registered and forwards the packet to the destination. - * It also initiates the formal packet check and sending of verification - * messages. - * @return Iterator to map entry of found service id - * or iterator to @c map.end(). - */ - ReturnValue_t selectDestination(MessageQueueId_t& destId) override; - /** - * The callback here handles the generation of acceptance - * success/failure messages. - */ - // ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override; -}; - -#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ */ diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 7be0810d..f719b50f 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -147,13 +147,13 @@ void PusDistributor::checkerFailurePrinter() const { const char* reason = "Unknown reason"; if (tcStatus == tcdistrib::INCORRECT_CHECKSUM) { reason = "Checksum Error"; - } else if (tcStatus == tcdistrib::INCORRECT_PRIMARY_HEADER) { + } else if (tcStatus == tmtcdistrib::INCORRECT_PRIMARY_HEADER) { reason = "Incorrect Primary Header"; - } else if (tcStatus == tcdistrib::INVALID_APID) { + } else if (tcStatus == tmtcdistrib::INVALID_APID) { reason = "Illegal APID"; - } else if (tcStatus == tcdistrib::INCORRECT_SECONDARY_HEADER) { + } else if (tcStatus == tmtcdistrib::INCORRECT_SECONDARY_HEADER) { reason = "Incorrect Secondary Header"; - } else if (tcStatus == tcdistrib::INCOMPLETE_PACKET) { + } else if (tcStatus == tmtcdistrib::INCOMPLETE_PACKET) { reason = "Incomplete packet"; } #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/tcdistribution/PusPacketChecker.cpp b/src/fsfw/tcdistribution/PusPacketChecker.cpp index 8ea8b6a8..52f7f77e 100644 --- a/src/fsfw/tcdistribution/PusPacketChecker.cpp +++ b/src/fsfw/tcdistribution/PusPacketChecker.cpp @@ -12,17 +12,17 @@ PusPacketChecker::PusPacketChecker(uint16_t apid, ccsds::PacketType packetType_, ReturnValue_t PusPacketChecker::checkPacket(const PusTcReader& pusPacket, size_t packetLen) { // Other primary header fields are checked by base class if (not pusPacket.hasSecHeader()) { - return tcdistrib::INVALID_SEC_HEADER_FIELD; + return tmtcdistrib::INVALID_SEC_HEADER_FIELD; } uint16_t calculated_crc = CRC::crc16ccitt(pusPacket.getFullData(), pusPacket.getFullPacketLen()); if (calculated_crc != 0) { - return tcdistrib::INCORRECT_CHECKSUM; + return tmtcdistrib::INCORRECT_CHECKSUM; } if (pusPacket.getApid() != apid) { - return tcdistrib::INVALID_APID; + return tmtcdistrib::INVALID_APID; } if (pusPacket.getPusVersion() != pusVersion) { - return tcdistrib::INVALID_PUS_VERSION; + return tmtcdistrib::INVALID_PUS_VERSION; } return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/tcdistribution/TcDistributorBase.cpp b/src/fsfw/tcdistribution/TcDistributorBase.cpp index e673d628..230c97fb 100644 --- a/src/fsfw/tcdistribution/TcDistributorBase.cpp +++ b/src/fsfw/tcdistribution/TcDistributorBase.cpp @@ -1,5 +1,6 @@ #include "fsfw/tcdistribution/TcDistributorBase.h" +#include "definitions.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/tmtcservices/TmTcMessage.h" @@ -25,7 +26,7 @@ ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) { ReturnValue_t packetResult = handlePacket(); if (packetResult != HasReturnvaluesIF::RETURN_OK) { result = packetResult; - triggerEvent(HANDLE_PACKET_FAILED, packetResult, __LINE__); + triggerEvent(tmtcdistrib::HANDLE_PACKET_FAILED, packetResult, 1); } } if (status == MessageQueueIF::EMPTY) { diff --git a/src/fsfw/tcdistribution/TcDistributorBase.h b/src/fsfw/tcdistribution/TcDistributorBase.h index c2bee0b9..81132fbd 100644 --- a/src/fsfw/tcdistribution/TcDistributorBase.h +++ b/src/fsfw/tcdistribution/TcDistributorBase.h @@ -34,10 +34,6 @@ class TcDistributorBase : public SystemObject, public ExecutableObjectIF, public static constexpr ReturnValue_t PACKET_LOST = MAKE_RETURN_CODE(1); static constexpr ReturnValue_t DESTINATION_NOT_FOUND = MAKE_RETURN_CODE(2); static constexpr ReturnValue_t SERVICE_ID_ALREADY_EXISTS = MAKE_RETURN_CODE(3); - - static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TC_DISTRIBUTION; - //! P1: Returnvalue, P2: Line number - static constexpr Event HANDLE_PACKET_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); /** * Within the default constructor, the SystemObject id is set and the * message queue is initialized. diff --git a/src/fsfw/tcdistribution/definitions.h b/src/fsfw/tcdistribution/definitions.h index ce640308..8cae639e 100644 --- a/src/fsfw/tcdistribution/definitions.h +++ b/src/fsfw/tcdistribution/definitions.h @@ -3,10 +3,12 @@ #include +#include "fsfw/events/Event.h" +#include "fsfw/events/fwSubsystemIdRanges.h" #include "fsfw/returnvalues/FwClassIds.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" -namespace tcdistrib { +namespace tmtcdistrib { static const uint8_t INTERFACE_ID = CLASS_ID::PACKET_CHECK; static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(0); static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(1); @@ -20,5 +22,9 @@ static constexpr ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE(7); static constexpr ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE(8); static constexpr ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE(9); -}; // namespace tcdistrib +static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TMTC_DISTRIBUTION; +//! P1: Returnvalue, P2: 0 for TM issues, 1 for TC issues +static constexpr Event HANDLE_PACKET_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); + +}; // namespace tmtcdistrib #endif // FSFW_TMTCPACKET_DEFINITIONS_H diff --git a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h index 6f8a6226..c3e3eff3 100644 --- a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h +++ b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h @@ -14,6 +14,8 @@ class AcceptsTelemetryIF { * @brief The virtual destructor as it is mandatory for C++ interfaces. */ virtual ~AcceptsTelemetryIF() = default; + + [[nodiscard]] virtual const char* getName() const = 0; /** * @brief This method returns the message queue id of the telemetry * receiving message queue. diff --git a/unittests/mocks/AcceptsTmMock.cpp b/unittests/mocks/AcceptsTmMock.cpp index 5b1e0d05..7b997047 100644 --- a/unittests/mocks/AcceptsTmMock.cpp +++ b/unittests/mocks/AcceptsTmMock.cpp @@ -9,3 +9,5 @@ AcceptsTmMock::AcceptsTmMock(MessageQueueId_t queueToReturn) MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) { return returnedQueue; } + +const char* AcceptsTmMock::getName() const { return "TM Acceptor Mock"; } diff --git a/unittests/mocks/AcceptsTmMock.h b/unittests/mocks/AcceptsTmMock.h index a9422eb4..d6cc7f85 100644 --- a/unittests/mocks/AcceptsTmMock.h +++ b/unittests/mocks/AcceptsTmMock.h @@ -10,6 +10,7 @@ class AcceptsTmMock : public SystemObject, public AcceptsTelemetryIF { explicit AcceptsTmMock(MessageQueueId_t queueToReturn); MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override; + const char* getName() const override; MessageQueueId_t returnedQueue; }; diff --git a/unittests/tcdistributor/testCcsdsDistributor.cpp b/unittests/tcdistributor/testCcsdsDistributor.cpp index b283b3bd..ce96a425 100644 --- a/unittests/tcdistributor/testCcsdsDistributor.cpp +++ b/unittests/tcdistributor/testCcsdsDistributor.cpp @@ -8,7 +8,7 @@ #include "mocks/CcsdsCheckerMock.h" #include "mocks/MessageQueueMock.h" -TEST_CASE("CCSDS Distributor", "[ccsds][tcdistrib]") { +TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; LocalPool pool(objects::NO_OBJECT, cfg); auto queue = MessageQueueMock(1); From 7fb9e14555ee14910b11d5087aa1c1e503eb2e36 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Aug 2022 15:22:39 +0200 Subject: [PATCH 182/532] better names for CFDP components --- src/fsfw/cfdp/CfdpRouter.cpp | 2 - src/fsfw/cfdp/pdu/CMakeLists.txt | 4 +- src/fsfw/cfdp/pdu/FileDataDeserializer.cpp | 8 +- src/fsfw/cfdp/pdu/FileDataDeserializer.h | 4 +- src/fsfw/cfdp/pdu/FileDataSerializer.cpp | 7 +- src/fsfw/cfdp/pdu/FileDataSerializer.h | 4 +- .../cfdp/pdu/FileDirectiveDeserializer.cpp | 8 +- src/fsfw/cfdp/pdu/FileDirectiveDeserializer.h | 4 +- src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp | 8 +- src/fsfw/cfdp/pdu/FileDirectiveSerializer.h | 4 +- src/fsfw/cfdp/pdu/HeaderCreator.cpp | 114 +++++++++++++++++ .../{HeaderSerializer.h => HeaderCreator.h} | 4 +- ...eaderDeserializer.cpp => HeaderReader.cpp} | 56 +++++---- .../{HeaderDeserializer.h => HeaderReader.h} | 45 ++++--- src/fsfw/cfdp/pdu/HeaderSerializer.cpp | 117 ------------------ src/fsfw/cfdp/pdu/PduHeaderIF.h | 26 ++-- src/fsfw/cfdp/pdu/PromptPduDeserializer.h | 2 +- unittests/cfdp/testCfdpHeader.cpp | 12 +- 18 files changed, 217 insertions(+), 212 deletions(-) create mode 100644 src/fsfw/cfdp/pdu/HeaderCreator.cpp rename src/fsfw/cfdp/pdu/{HeaderSerializer.h => HeaderCreator.h} (96%) rename src/fsfw/cfdp/pdu/{HeaderDeserializer.cpp => HeaderReader.cpp} (63%) rename src/fsfw/cfdp/pdu/{HeaderDeserializer.h => HeaderReader.h} (61%) delete mode 100644 src/fsfw/cfdp/pdu/HeaderSerializer.cpp diff --git a/src/fsfw/cfdp/CfdpRouter.cpp b/src/fsfw/cfdp/CfdpRouter.cpp index 9e4f623e..dfe910e6 100644 --- a/src/fsfw/cfdp/CfdpRouter.cpp +++ b/src/fsfw/cfdp/CfdpRouter.cpp @@ -1,7 +1,5 @@ #include "CfdpRouter.h" -#include - #include "fsfw/tcdistribution/definitions.h" CfdpRouter::CfdpRouter(CfdpRouterCfg cfg) : TcDistributorBase(cfg.objectId), tmQueue(cfg.tmQueue) {} diff --git a/src/fsfw/cfdp/pdu/CMakeLists.txt b/src/fsfw/cfdp/pdu/CMakeLists.txt index 4f345bdc..0d49217b 100644 --- a/src/fsfw/cfdp/pdu/CMakeLists.txt +++ b/src/fsfw/cfdp/pdu/CMakeLists.txt @@ -2,8 +2,8 @@ target_sources( ${LIB_FSFW_NAME} PRIVATE PduConfig.cpp VarLenField.cpp - HeaderSerializer.cpp - HeaderDeserializer.cpp + HeaderCreator.cpp + HeaderReader.cpp FileDirectiveDeserializer.cpp FileDirectiveSerializer.cpp AckInfo.cpp diff --git a/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp b/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp index 240c4188..2b3171a8 100644 --- a/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp @@ -2,16 +2,16 @@ FileDataDeserializer::FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info) - : HeaderDeserializer(pduBuf, maxSize), info(info) {} + : HeaderReader(pduBuf, maxSize), info(info) {} ReturnValue_t FileDataDeserializer::parseData() { - ReturnValue_t result = HeaderDeserializer::parseData(); + ReturnValue_t result = HeaderReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - size_t currentIdx = HeaderDeserializer::getHeaderSize(); + size_t currentIdx = HeaderReader::getHeaderSize(); const uint8_t* buf = rawPtr + currentIdx; - size_t remSize = HeaderDeserializer::getWholePduSize() - currentIdx; + size_t remSize = HeaderReader::getWholePduSize() - currentIdx; if (remSize < 1) { return SerializeIF::STREAM_TOO_SHORT; } diff --git a/src/fsfw/cfdp/pdu/FileDataDeserializer.h b/src/fsfw/cfdp/pdu/FileDataDeserializer.h index 833c0561..f6723fec 100644 --- a/src/fsfw/cfdp/pdu/FileDataDeserializer.h +++ b/src/fsfw/cfdp/pdu/FileDataDeserializer.h @@ -3,9 +3,9 @@ #include "../definitions.h" #include "FileDataInfo.h" -#include "HeaderDeserializer.h" +#include "HeaderReader.h" -class FileDataDeserializer : public HeaderDeserializer { +class FileDataDeserializer : public HeaderReader { public: FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info); diff --git a/src/fsfw/cfdp/pdu/FileDataSerializer.cpp b/src/fsfw/cfdp/pdu/FileDataSerializer.cpp index 837b418b..2e86a255 100644 --- a/src/fsfw/cfdp/pdu/FileDataSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDataSerializer.cpp @@ -3,8 +3,7 @@ #include FileDataSerializer::FileDataSerializer(PduConfig& conf, FileDataInfo& info) - : HeaderSerializer(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()), - info(info) { + : HeaderCreator(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) { update(); } @@ -16,7 +15,7 @@ void FileDataSerializer::update() { ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { - ReturnValue_t result = HeaderSerializer::serialize(buffer, size, maxSize, streamEndianness); + ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -51,5 +50,5 @@ ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size } size_t FileDataSerializer::getSerializedSize() const { - return HeaderSerializer::getSerializedSize() + info.getSerializedSize(this->getLargeFileFlag()); + return HeaderCreator::getSerializedSize() + info.getSerializedSize(this->getLargeFileFlag()); } diff --git a/src/fsfw/cfdp/pdu/FileDataSerializer.h b/src/fsfw/cfdp/pdu/FileDataSerializer.h index 662b9b4d..17d72e2e 100644 --- a/src/fsfw/cfdp/pdu/FileDataSerializer.h +++ b/src/fsfw/cfdp/pdu/FileDataSerializer.h @@ -3,9 +3,9 @@ #include "../definitions.h" #include "FileDataInfo.h" -#include "HeaderSerializer.h" +#include "HeaderCreator.h" -class FileDataSerializer : public HeaderSerializer { +class FileDataSerializer : public HeaderCreator { public: FileDataSerializer(PduConfig& conf, FileDataInfo& info); diff --git a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp b/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp index 3c0552f7..162312d3 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp @@ -1,12 +1,12 @@ #include "FileDirectiveDeserializer.h" FileDirectiveDeserializer::FileDirectiveDeserializer(const uint8_t *pduBuf, size_t maxSize) - : HeaderDeserializer(pduBuf, maxSize) {} + : HeaderReader(pduBuf, maxSize) {} cfdp::FileDirectives FileDirectiveDeserializer::getFileDirective() const { return fileDirective; } ReturnValue_t FileDirectiveDeserializer::parseData() { - ReturnValue_t result = HeaderDeserializer::parseData(); + ReturnValue_t result = HeaderReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -16,7 +16,7 @@ ReturnValue_t FileDirectiveDeserializer::parseData() { if (FileDirectiveDeserializer::getWholePduSize() > maxSize) { return SerializeIF::STREAM_TOO_SHORT; } - size_t currentIdx = HeaderDeserializer::getHeaderSize(); + size_t currentIdx = HeaderReader::getHeaderSize(); if (not checkFileDirective(rawPtr[currentIdx])) { return cfdp::INVALID_DIRECTIVE_FIELDS; } @@ -26,7 +26,7 @@ ReturnValue_t FileDirectiveDeserializer::parseData() { size_t FileDirectiveDeserializer::getHeaderSize() const { // return size of header plus the directive byte - return HeaderDeserializer::getHeaderSize() + 1; + return HeaderReader::getHeaderSize() + 1; } bool FileDirectiveDeserializer::checkFileDirective(uint8_t rawByte) { diff --git a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.h b/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.h index 064cb64a..193a71f3 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.h +++ b/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.h @@ -2,7 +2,7 @@ #define FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVEDESERIALIZER_H_ #include "../definitions.h" -#include "fsfw/cfdp/pdu/HeaderDeserializer.h" +#include "fsfw/cfdp/pdu/HeaderReader.h" /** * @brief This class is used to deserialize a PDU file directive header from raw memory. @@ -11,7 +11,7 @@ * This is a zero-copy implementation and #parseData needs to be called to ensure the data is * valid. */ -class FileDirectiveDeserializer : public HeaderDeserializer { +class FileDirectiveDeserializer : public HeaderReader { public: FileDirectiveDeserializer(const uint8_t* pduBuf, size_t maxSize); diff --git a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp b/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp index 98b2d0a2..e70b8b83 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp @@ -3,11 +3,11 @@ FileDirectiveSerializer::FileDirectiveSerializer(PduConfig &pduConf, cfdp::FileDirectives directiveCode, size_t directiveParamFieldLen) - : HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1), + : HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1), directiveCode(directiveCode) {} size_t FileDirectiveSerializer::getSerializedSize() const { - return HeaderSerializer::getSerializedSize() + 1; + return HeaderCreator::getSerializedSize() + 1; } ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, @@ -18,7 +18,7 @@ ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, if (FileDirectiveSerializer::getWholePduSize() > maxSize) { return BUFFER_TOO_SHORT; } - ReturnValue_t result = HeaderSerializer::serialize(buffer, size, maxSize, streamEndianness); + ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -34,5 +34,5 @@ ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, void FileDirectiveSerializer::setDirectiveDataFieldLen(size_t len) { // Set length of data field plus 1 byte for the directive octet - HeaderSerializer::setPduDataFieldLen(len + 1); + HeaderCreator::setPduDataFieldLen(len + 1); } diff --git a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.h b/src/fsfw/cfdp/pdu/FileDirectiveSerializer.h index 8f86a5e1..ffe34412 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.h +++ b/src/fsfw/cfdp/pdu/FileDirectiveSerializer.h @@ -1,9 +1,9 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_ -#include "fsfw/cfdp/pdu/HeaderSerializer.h" +#include "fsfw/cfdp/pdu/HeaderCreator.h" -class FileDirectiveSerializer : public HeaderSerializer { +class FileDirectiveSerializer : public HeaderCreator { public: FileDirectiveSerializer(PduConfig& pduConf, cfdp::FileDirectives directiveCode, size_t directiveParamFieldLen); diff --git a/src/fsfw/cfdp/pdu/HeaderCreator.cpp b/src/fsfw/cfdp/pdu/HeaderCreator.cpp new file mode 100644 index 00000000..debeedeb --- /dev/null +++ b/src/fsfw/cfdp/pdu/HeaderCreator.cpp @@ -0,0 +1,114 @@ +#include "HeaderCreator.h" + +#include "HeaderReader.h" + +HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen, + cfdp::SegmentMetadataFlag segmentMetadataFlag, + cfdp::SegmentationControl segCtrl) + : pduType(pduType), + segmentMetadataFlag(segmentMetadataFlag), + segmentationCtrl(segCtrl), + pduDataFieldLen(initPduDataFieldLen), + pduConf(pduConf) {} + +ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const { + if (buffer == nullptr or size == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + if (maxSize < this->getSerializedSize()) { + return BUFFER_TOO_SHORT; + } + **buffer = cfdp::VERSION_BITS | this->pduType << 4 | pduConf.direction << 3 | pduConf.mode << 2 | + pduConf.crcFlag << 1 | pduConf.largeFile; + *buffer += 1; + **buffer = (pduDataFieldLen & 0xff00) >> 8; + *buffer += 1; + **buffer = pduDataFieldLen & 0x00ff; + *buffer += 1; + **buffer = segmentationCtrl << 7 | pduConf.sourceId.getWidth() << 4 | segmentMetadataFlag << 3 | + pduConf.seqNum.getWidth(); + *buffer += 1; + *size += 4; + ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + + return HasReturnvaluesIF::RETURN_OK; +} + +size_t HeaderCreator::getSerializedSize() const { + size_t shit = pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4; + return shit; +} + +ReturnValue_t HeaderCreator::deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) { + // We could implement this, but I prefer dedicated classes + return HasReturnvaluesIF::RETURN_FAILED; +} + +size_t HeaderCreator::getWholePduSize() const { + // Return size of header plus the PDU data field length + return pduDataFieldLen + HeaderCreator::getSerializedSize(); +} + +size_t HeaderCreator::getPduDataFieldLen() const { return pduDataFieldLen; } + +void HeaderCreator::setPduDataFieldLen(size_t pduDataFieldLen_) { + pduDataFieldLen = pduDataFieldLen_; +} + +void HeaderCreator::setPduType(cfdp::PduType pduType_) { pduType = pduType_; } + +void HeaderCreator::setSegmentMetadataFlag(cfdp::SegmentMetadataFlag segmentMetadataFlag_) { + segmentMetadataFlag = segmentMetadataFlag_; +} + +cfdp::PduType HeaderCreator::getPduType() const { return pduType; } + +cfdp::Direction HeaderCreator::getDirection() const { return pduConf.direction; } + +cfdp::TransmissionModes HeaderCreator::getTransmissionMode() const { return pduConf.mode; } + +bool HeaderCreator::getCrcFlag() const { return pduConf.crcFlag; } + +bool HeaderCreator::getLargeFileFlag() const { return pduConf.largeFile; } + +cfdp::SegmentationControl HeaderCreator::getSegmentationControl() const { return segmentationCtrl; } + +cfdp::WidthInBytes HeaderCreator::getLenEntityIds() const { return pduConf.sourceId.getWidth(); } + +cfdp::WidthInBytes HeaderCreator::getLenSeqNum() const { return pduConf.seqNum.getWidth(); } + +cfdp::SegmentMetadataFlag HeaderCreator::getSegmentMetadataFlag() const { + return segmentMetadataFlag; +} + +void HeaderCreator::getSourceId(cfdp::EntityId &sourceId) const { sourceId = pduConf.sourceId; } + +void HeaderCreator::getDestId(cfdp::EntityId &destId) const { destId = pduConf.destId; } + +void HeaderCreator::setSegmentationControl(cfdp::SegmentationControl segmentationControl) { + this->segmentationCtrl = segmentationControl; +} + +void HeaderCreator::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const { + seqNum = pduConf.seqNum; +} + +bool HeaderCreator::hasSegmentMetadataFlag() const { + if (this->segmentMetadataFlag == cfdp::SegmentMetadataFlag::PRESENT) { + return true; + } + return false; +} diff --git a/src/fsfw/cfdp/pdu/HeaderSerializer.h b/src/fsfw/cfdp/pdu/HeaderCreator.h similarity index 96% rename from src/fsfw/cfdp/pdu/HeaderSerializer.h rename to src/fsfw/cfdp/pdu/HeaderCreator.h index 1de97d63..a9f9b581 100644 --- a/src/fsfw/cfdp/pdu/HeaderSerializer.h +++ b/src/fsfw/cfdp/pdu/HeaderCreator.h @@ -6,9 +6,9 @@ #include "PduHeaderIF.h" #include "fsfw/serialize/SerializeIF.h" -class HeaderSerializer : public SerializeIF, public PduHeaderIF { +class HeaderCreator : public SerializeIF, public PduHeaderIF { public: - HeaderSerializer( + HeaderCreator( PduConfig& pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen, cfdp::SegmentMetadataFlag segmentMetadataFlag = cfdp::SegmentMetadataFlag::NOT_PRESENT, cfdp::SegmentationControl segCtrl = diff --git a/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp similarity index 63% rename from src/fsfw/cfdp/pdu/HeaderDeserializer.cpp rename to src/fsfw/cfdp/pdu/HeaderReader.cpp index 70f397f8..7aec3f49 100644 --- a/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp @@ -1,20 +1,20 @@ -#include "HeaderDeserializer.h" +#include "HeaderReader.h" #include #include -HeaderDeserializer::HeaderDeserializer(const uint8_t *pduBuf, size_t maxSize) +HeaderReader::HeaderReader(const uint8_t *pduBuf, size_t maxSize) : rawPtr(pduBuf), maxSize(maxSize) {} -ReturnValue_t HeaderDeserializer::parseData() { +ReturnValue_t HeaderReader::parseData() { if (maxSize < 7) { return SerializeIF::STREAM_TOO_SHORT; } return setData(const_cast(rawPtr), maxSize); } -ReturnValue_t HeaderDeserializer::setData(uint8_t *dataPtr, size_t maxSize, void *args) { +ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) { if (dataPtr == nullptr) { // Allowed for now this->fixedHeader = nullptr; @@ -26,76 +26,74 @@ ReturnValue_t HeaderDeserializer::setData(uint8_t *dataPtr, size_t maxSize, void cfdp::WidthInBytes widthSeqNum = getLenSeqNum(); seqNumRaw = static_cast(sourceIdRaw) + static_cast(widthEntityIds); destIdRaw = static_cast(seqNumRaw) + static_cast(widthSeqNum); - this->maxSize = maxSize; + maxSize = maxSize_; return HasReturnvaluesIF::RETURN_OK; } -size_t HeaderDeserializer::getHeaderSize() const { +size_t HeaderReader::getHeaderSize() const { if (fixedHeader != nullptr) { return getLenEntityIds() * 2 + getLenSeqNum() + 4; } return 0; } -size_t HeaderDeserializer::getPduDataFieldLen() const { +size_t HeaderReader::getPduDataFieldLen() const { uint16_t pduFiedlLen = (fixedHeader->pduDataFieldLenH << 8) | fixedHeader->pduDataFieldLenL; return pduFiedlLen; } -size_t HeaderDeserializer::getWholePduSize() const { - return getPduDataFieldLen() + getHeaderSize(); -} +size_t HeaderReader::getWholePduSize() const { return getPduDataFieldLen() + getHeaderSize(); } -cfdp::PduType HeaderDeserializer::getPduType() const { +cfdp::PduType HeaderReader::getPduType() const { return static_cast((fixedHeader->firstByte >> 4) & 0x01); } -cfdp::Direction HeaderDeserializer::getDirection() const { +cfdp::Direction HeaderReader::getDirection() const { return static_cast((fixedHeader->firstByte >> 3) & 0x01); } -cfdp::TransmissionModes HeaderDeserializer::getTransmissionMode() const { +cfdp::TransmissionModes HeaderReader::getTransmissionMode() const { return static_cast((fixedHeader->firstByte >> 2) & 0x01); } -bool HeaderDeserializer::getCrcFlag() const { return (fixedHeader->firstByte >> 1) & 0x01; } +bool HeaderReader::getCrcFlag() const { return (fixedHeader->firstByte >> 1) & 0x01; } -bool HeaderDeserializer::getLargeFileFlag() const { return fixedHeader->firstByte & 0x01; } +bool HeaderReader::getLargeFileFlag() const { return fixedHeader->firstByte & 0x01; } -cfdp::SegmentationControl HeaderDeserializer::getSegmentationControl() const { +cfdp::SegmentationControl HeaderReader::getSegmentationControl() const { return static_cast((fixedHeader->fourthByte >> 7) & 0x01); } -cfdp::WidthInBytes HeaderDeserializer::getLenEntityIds() const { +cfdp::WidthInBytes HeaderReader::getLenEntityIds() const { return static_cast((fixedHeader->fourthByte >> 4) & 0x07); } -cfdp::WidthInBytes HeaderDeserializer::getLenSeqNum() const { +cfdp::WidthInBytes HeaderReader::getLenSeqNum() const { return static_cast(fixedHeader->fourthByte & 0x07); } -cfdp::SegmentMetadataFlag HeaderDeserializer::getSegmentMetadataFlag() const { +cfdp::SegmentMetadataFlag HeaderReader::getSegmentMetadataFlag() const { return static_cast((fixedHeader->fourthByte >> 3) & 0x01); } -void HeaderDeserializer::getSourceId(cfdp::EntityId &sourceId) const { +void HeaderReader::getSourceId(cfdp::EntityId &sourceId) const { assignVarLenField(dynamic_cast(&sourceId), getLenEntityIds(), this->sourceIdRaw); } -void HeaderDeserializer::getDestId(cfdp::EntityId &destId) const { +void HeaderReader::getDestId(cfdp::EntityId &destId) const { assignVarLenField(dynamic_cast(&destId), getLenEntityIds(), this->destIdRaw); } -void HeaderDeserializer::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const { +void HeaderReader::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const { assignVarLenField(dynamic_cast(&seqNum), getLenSeqNum(), this->seqNumRaw); } -void HeaderDeserializer::assignVarLenField(cfdp::VarLenField *field, cfdp::WidthInBytes width, - void *sourcePtr) const { +void HeaderReader::assignVarLenField(cfdp::VarLenField *field, cfdp::WidthInBytes width, + void *sourcePtr) const { switch (width) { case (cfdp::WidthInBytes::ONE_BYTE): { - uint8_t *fieldTyped = static_cast(sourcePtr); + auto *fieldTyped = static_cast(sourcePtr); field->setValue(width, *fieldTyped); break; } @@ -118,11 +116,15 @@ void HeaderDeserializer::assignVarLenField(cfdp::VarLenField *field, cfdp::Width } } -size_t HeaderDeserializer::getMaxSize() const { return maxSize; } +size_t HeaderReader::getMaxSize() const { return maxSize; } -bool HeaderDeserializer::hasSegmentMetadataFlag() const { +bool HeaderReader::hasSegmentMetadataFlag() const { if (this->getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT) { return true; } return false; } + +ReturnValue_t HeaderReader::setData(const uint8_t *dataPtr, size_t maxSize_) { + return setData(const_cast(dataPtr), maxSize_, nullptr); +} diff --git a/src/fsfw/cfdp/pdu/HeaderDeserializer.h b/src/fsfw/cfdp/pdu/HeaderReader.h similarity index 61% rename from src/fsfw/cfdp/pdu/HeaderDeserializer.h rename to src/fsfw/cfdp/pdu/HeaderReader.h index ed033697..997828b6 100644 --- a/src/fsfw/cfdp/pdu/HeaderDeserializer.h +++ b/src/fsfw/cfdp/pdu/HeaderReader.h @@ -23,7 +23,7 @@ struct PduHeaderFixedStruct { * This is a zero-copy implementation and #parseData needs to be called to ensure the data is * valid. */ -class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF { +class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { public: /** * Initialize a PDU header from raw data. This is a zero-copy implementation and #parseData @@ -31,7 +31,7 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF * @param pduBuf * @param maxSize */ - HeaderDeserializer(const uint8_t* pduBuf, size_t maxSize); + HeaderReader(const uint8_t* pduBuf, size_t maxSize); /** * This needs to be called before accessing the PDU fields to avoid segmentation faults. @@ -41,21 +41,21 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF * - SerializeIF::BUFFER_TOO_SHORT if buffer is shorter than expected */ virtual ReturnValue_t parseData(); - size_t getHeaderSize() const; + [[nodiscard]] size_t getHeaderSize() const; - size_t getPduDataFieldLen() const override; - size_t getWholePduSize() const override; + [[nodiscard]] size_t getPduDataFieldLen() const override; + [[nodiscard]] size_t getWholePduSize() const override; - cfdp::PduType getPduType() const override; - cfdp::Direction getDirection() const override; - cfdp::TransmissionModes getTransmissionMode() const override; - bool getCrcFlag() const override; - bool getLargeFileFlag() const override; - cfdp::SegmentationControl getSegmentationControl() const override; - cfdp::WidthInBytes getLenEntityIds() const override; - cfdp::WidthInBytes getLenSeqNum() const override; - cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override; - bool hasSegmentMetadataFlag() const override; + [[nodiscard]] cfdp::PduType getPduType() const override; + [[nodiscard]] cfdp::Direction getDirection() const override; + [[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override; + [[nodiscard]] bool getCrcFlag() const override; + [[nodiscard]] bool getLargeFileFlag() const override; + [[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const override; + [[nodiscard]] cfdp::WidthInBytes getLenEntityIds() const override; + [[nodiscard]] cfdp::WidthInBytes getLenSeqNum() const override; + [[nodiscard]] cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override; + [[nodiscard]] bool hasSegmentMetadataFlag() const override; void getSourceId(cfdp::EntityId& sourceId) const override; void getDestId(cfdp::EntityId& destId) const override; @@ -63,6 +63,8 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF ReturnValue_t deserResult = HasReturnvaluesIF::RETURN_OK; + [[nodiscard]] size_t getMaxSize() const; + /** * Can also be used to reset the pointer to a nullptr, but the getter functions will not * perform nullptr checks! @@ -71,9 +73,7 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF * @param args * @return */ - ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) override; - - size_t getMaxSize() const; + ReturnValue_t setData(const uint8_t* dataPtr, size_t maxSize); protected: PduHeaderFixedStruct* fixedHeader = nullptr; @@ -81,6 +81,15 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF size_t maxSize = 0; private: + /** + * Can also be used to reset the pointer to a nullptr, but the getter functions will not + * perform nullptr checks! + * @param dataPtr + * @param maxSize + * @param args + * @return + */ + ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) override; void assignVarLenField(cfdp::VarLenField* field, cfdp::WidthInBytes width, void* sourcePtr) const; void* sourceIdRaw = nullptr; void* seqNumRaw = nullptr; diff --git a/src/fsfw/cfdp/pdu/HeaderSerializer.cpp b/src/fsfw/cfdp/pdu/HeaderSerializer.cpp deleted file mode 100644 index 041fb714..00000000 --- a/src/fsfw/cfdp/pdu/HeaderSerializer.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include "HeaderSerializer.h" - -#include "HeaderDeserializer.h" - -HeaderSerializer::HeaderSerializer(PduConfig &pduConf, cfdp::PduType pduType, - size_t initPduDataFieldLen, - cfdp::SegmentMetadataFlag segmentMetadataFlag, - cfdp::SegmentationControl segCtrl) - : pduType(pduType), - segmentMetadataFlag(segmentMetadataFlag), - segmentationCtrl(segCtrl), - pduDataFieldLen(initPduDataFieldLen), - pduConf(pduConf) {} - -ReturnValue_t HeaderSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const { - if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - if (maxSize < this->getSerializedSize()) { - return BUFFER_TOO_SHORT; - } - **buffer = cfdp::VERSION_BITS | this->pduType << 4 | pduConf.direction << 3 | pduConf.mode << 2 | - pduConf.crcFlag << 1 | pduConf.largeFile; - *buffer += 1; - **buffer = (pduDataFieldLen & 0xff00) >> 8; - *buffer += 1; - **buffer = pduDataFieldLen & 0x00ff; - *buffer += 1; - **buffer = segmentationCtrl << 7 | pduConf.sourceId.getWidth() << 4 | segmentMetadataFlag << 3 | - pduConf.seqNum.getWidth(); - *buffer += 1; - *size += 4; - ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - - return HasReturnvaluesIF::RETURN_OK; -} - -size_t HeaderSerializer::getSerializedSize() const { - size_t shit = pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4; - return shit; -} - -ReturnValue_t HeaderSerializer::deSerialize(const uint8_t **buffer, size_t *size, - Endianness streamEndianness) { - // We could implement this, but I prefer dedicated classes - return HasReturnvaluesIF::RETURN_FAILED; -} - -size_t HeaderSerializer::getWholePduSize() const { - // Return size of header plus the PDU data field length - return pduDataFieldLen + HeaderSerializer::getSerializedSize(); -} - -size_t HeaderSerializer::getPduDataFieldLen() const { return pduDataFieldLen; } - -void HeaderSerializer::setPduDataFieldLen(size_t pduDataFieldLen) { - this->pduDataFieldLen = pduDataFieldLen; -} - -void HeaderSerializer::setPduType(cfdp::PduType pduType) { this->pduType = pduType; } - -void HeaderSerializer::setSegmentMetadataFlag(cfdp::SegmentMetadataFlag segmentMetadataFlag) { - this->segmentMetadataFlag = segmentMetadataFlag; -} - -cfdp::PduType HeaderSerializer::getPduType() const { return pduType; } - -cfdp::Direction HeaderSerializer::getDirection() const { return pduConf.direction; } - -cfdp::TransmissionModes HeaderSerializer::getTransmissionMode() const { return pduConf.mode; } - -bool HeaderSerializer::getCrcFlag() const { return pduConf.crcFlag; } - -bool HeaderSerializer::getLargeFileFlag() const { return pduConf.largeFile; } - -cfdp::SegmentationControl HeaderSerializer::getSegmentationControl() const { - return segmentationCtrl; -} - -cfdp::WidthInBytes HeaderSerializer::getLenEntityIds() const { return pduConf.sourceId.getWidth(); } - -cfdp::WidthInBytes HeaderSerializer::getLenSeqNum() const { return pduConf.seqNum.getWidth(); } - -cfdp::SegmentMetadataFlag HeaderSerializer::getSegmentMetadataFlag() const { - return segmentMetadataFlag; -} - -void HeaderSerializer::getSourceId(cfdp::EntityId &sourceId) const { sourceId = pduConf.sourceId; } - -void HeaderSerializer::getDestId(cfdp::EntityId &destId) const { destId = pduConf.destId; } - -void HeaderSerializer::setSegmentationControl(cfdp::SegmentationControl segmentationControl) { - this->segmentationCtrl = segmentationControl; -} - -void HeaderSerializer::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const { - seqNum = pduConf.seqNum; -} - -bool HeaderSerializer::hasSegmentMetadataFlag() const { - if (this->segmentMetadataFlag == cfdp::SegmentMetadataFlag::PRESENT) { - return true; - } - return false; -} diff --git a/src/fsfw/cfdp/pdu/PduHeaderIF.h b/src/fsfw/cfdp/pdu/PduHeaderIF.h index f05d95a4..86956ff0 100644 --- a/src/fsfw/cfdp/pdu/PduHeaderIF.h +++ b/src/fsfw/cfdp/pdu/PduHeaderIF.h @@ -13,20 +13,20 @@ */ class PduHeaderIF { public: - virtual ~PduHeaderIF(){}; + virtual ~PduHeaderIF() = default; - virtual size_t getWholePduSize() const = 0; - virtual size_t getPduDataFieldLen() const = 0; - virtual cfdp::PduType getPduType() const = 0; - virtual cfdp::Direction getDirection() const = 0; - virtual cfdp::TransmissionModes getTransmissionMode() const = 0; - virtual bool getCrcFlag() const = 0; - virtual bool getLargeFileFlag() const = 0; - virtual cfdp::SegmentationControl getSegmentationControl() const = 0; - virtual cfdp::WidthInBytes getLenEntityIds() const = 0; - virtual cfdp::WidthInBytes getLenSeqNum() const = 0; - virtual cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const = 0; - virtual bool hasSegmentMetadataFlag() const = 0; + [[nodiscard]] virtual size_t getWholePduSize() const = 0; + [[nodiscard]] virtual size_t getPduDataFieldLen() const = 0; + [[nodiscard]] virtual cfdp::PduType getPduType() const = 0; + [[nodiscard]] virtual cfdp::Direction getDirection() const = 0; + [[nodiscard]] virtual cfdp::TransmissionModes getTransmissionMode() const = 0; + [[nodiscard]] virtual bool getCrcFlag() const = 0; + [[nodiscard]] virtual bool getLargeFileFlag() const = 0; + [[nodiscard]] virtual cfdp::SegmentationControl getSegmentationControl() const = 0; + [[nodiscard]] virtual cfdp::WidthInBytes getLenEntityIds() const = 0; + [[nodiscard]] virtual cfdp::WidthInBytes getLenSeqNum() const = 0; + [[nodiscard]] virtual cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const = 0; + [[nodiscard]] virtual bool hasSegmentMetadataFlag() const = 0; virtual void getSourceId(cfdp::EntityId& sourceId) const = 0; virtual void getDestId(cfdp::EntityId& destId) const = 0; virtual void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const = 0; diff --git a/src/fsfw/cfdp/pdu/PromptPduDeserializer.h b/src/fsfw/cfdp/pdu/PromptPduDeserializer.h index 9441f364..2f75033b 100644 --- a/src/fsfw/cfdp/pdu/PromptPduDeserializer.h +++ b/src/fsfw/cfdp/pdu/PromptPduDeserializer.h @@ -7,7 +7,7 @@ class PromptPduDeserializer : public FileDirectiveDeserializer { public: PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize); - cfdp::PromptResponseRequired getPromptResponseRequired() const; + [[nodiscard]] cfdp::PromptResponseRequired getPromptResponseRequired() const; ReturnValue_t parseData() override; private: diff --git a/unittests/cfdp/testCfdpHeader.cpp b/unittests/cfdp/testCfdpHeader.cpp index 3e9cfccd..6453b809 100644 --- a/unittests/cfdp/testCfdpHeader.cpp +++ b/unittests/cfdp/testCfdpHeader.cpp @@ -1,8 +1,8 @@ #include #include -#include "fsfw/cfdp/pdu/HeaderDeserializer.h" -#include "fsfw/cfdp/pdu/HeaderSerializer.h" +#include "fsfw/cfdp/pdu/HeaderCreator.h" +#include "fsfw/cfdp/pdu/HeaderReader.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" TEST_CASE("CFDP Header", "[cfdp]") { @@ -19,7 +19,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { size_t serSize = 0; SECTION("Header Serialization") { - auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); + auto headerSerializer = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); const uint8_t** dummyPtr = nullptr; ReturnValue_t deserResult = headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK); @@ -186,7 +186,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { SECTION("Header Deserialization") { // We unittested the serializer before, so we can use it now to generate valid raw CFDP // data - auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); + auto headerSerializer = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); REQUIRE(result == result::OK); @@ -196,7 +196,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(serBuf[3] == 0b00010001); REQUIRE(serSize == 7); // Deser call not strictly necessary - auto headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); + auto headerDeser = HeaderReader(serBuf.data(), serBuf.size()); ReturnValue_t serResult = headerDeser.parseData(); REQUIRE(serResult == result::OK); @@ -231,7 +231,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { serSize = 0; result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); + headerDeser = HeaderReader(serBuf.data(), serBuf.size()); result = headerDeser.parseData(); REQUIRE(result == result::OK); From acf5c2a56de9f0754ee974267351b3104ea6904b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Aug 2022 16:00:48 +0200 Subject: [PATCH 183/532] better names --- src/fsfw/cfdp/pdu/AckPduDeserializer.cpp | 6 ++--- src/fsfw/cfdp/pdu/AckPduDeserializer.h | 4 ++-- src/fsfw/cfdp/pdu/AckPduSerializer.cpp | 7 +++--- src/fsfw/cfdp/pdu/AckPduSerializer.h | 6 ++--- src/fsfw/cfdp/pdu/CMakeLists.txt | 8 +++---- src/fsfw/cfdp/pdu/EofPduDeserializer.cpp | 6 ++--- src/fsfw/cfdp/pdu/EofPduDeserializer.h | 4 ++-- src/fsfw/cfdp/pdu/EofPduSerializer.cpp | 7 +++--- src/fsfw/cfdp/pdu/EofPduSerializer.h | 4 ++-- ...DataSerializer.cpp => FileDataCreator.cpp} | 12 +++++----- src/fsfw/cfdp/pdu/FileDataCreator.h | 23 ++++++++++++++++++ ...ataDeserializer.cpp => FileDataReader.cpp} | 13 +++++----- ...ileDataDeserializer.h => FileDataReader.h} | 8 +++---- src/fsfw/cfdp/pdu/FileDataSerializer.h | 23 ------------------ ...erializer.cpp => FileDirectiveCreator.cpp} | 17 +++++++------ ...iveSerializer.h => FileDirectiveCreator.h} | 10 ++++---- ...serializer.cpp => FileDirectiveReader.cpp} | 24 +++++++++---------- ...veDeserializer.h => FileDirectiveReader.h} | 14 +++++------ src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp | 10 ++++---- src/fsfw/cfdp/pdu/FinishedPduDeserializer.h | 4 ++-- src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp | 5 ++-- src/fsfw/cfdp/pdu/FinishedPduSerializer.h | 6 ++--- src/fsfw/cfdp/pdu/HeaderCreator.cpp | 3 +-- src/fsfw/cfdp/pdu/HeaderReader.cpp | 7 +++--- src/fsfw/cfdp/pdu/HeaderReader.h | 2 +- .../cfdp/pdu/KeepAlivePduDeserializer.cpp | 8 +++---- src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h | 4 ++-- src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp | 7 +++--- src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h | 4 ++-- src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp | 8 +++---- src/fsfw/cfdp/pdu/MetadataPduDeserializer.h | 4 ++-- src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp | 7 +++--- src/fsfw/cfdp/pdu/MetadataPduSerializer.h | 4 ++-- src/fsfw/cfdp/pdu/NakInfo.cpp | 2 +- src/fsfw/cfdp/pdu/NakPduDeserializer.cpp | 8 +++---- src/fsfw/cfdp/pdu/NakPduDeserializer.h | 4 ++-- src/fsfw/cfdp/pdu/NakPduSerializer.cpp | 7 +++--- src/fsfw/cfdp/pdu/NakPduSerializer.h | 4 ++-- src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp | 10 ++++---- src/fsfw/cfdp/pdu/PromptPduDeserializer.h | 4 ++-- src/fsfw/cfdp/pdu/PromptPduSerializer.cpp | 9 ++++--- src/fsfw/cfdp/pdu/PromptPduSerializer.h | 6 ++--- unittests/cfdp/testCfdp.cpp | 8 +++---- unittests/cfdp/testFileData.cpp | 10 ++++---- unittests/cfdp/testFileDirective.cpp | 8 +++---- unittests/cfdp/testNakPdu.cpp | 2 +- unittests/cfdp/testPromptPdu.cpp | 2 ++ 47 files changed, 178 insertions(+), 185 deletions(-) rename src/fsfw/cfdp/pdu/{FileDataSerializer.cpp => FileDataCreator.cpp} (81%) create mode 100644 src/fsfw/cfdp/pdu/FileDataCreator.h rename src/fsfw/cfdp/pdu/{FileDataDeserializer.cpp => FileDataReader.cpp} (73%) rename src/fsfw/cfdp/pdu/{FileDataDeserializer.h => FileDataReader.h} (67%) delete mode 100644 src/fsfw/cfdp/pdu/FileDataSerializer.h rename src/fsfw/cfdp/pdu/{FileDirectiveSerializer.cpp => FileDirectiveCreator.cpp} (53%) rename src/fsfw/cfdp/pdu/{FileDirectiveSerializer.h => FileDirectiveCreator.h} (66%) rename src/fsfw/cfdp/pdu/{FileDirectiveDeserializer.cpp => FileDirectiveReader.cpp} (53%) rename src/fsfw/cfdp/pdu/{FileDirectiveDeserializer.h => FileDirectiveReader.h} (71%) diff --git a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp index f5babf4b..1217344e 100644 --- a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp @@ -1,14 +1,14 @@ #include "AckPduDeserializer.h" AckPduDeserializer::AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, AckInfo& info) - : FileDirectiveDeserializer(pduBuf, maxSize), info(info) {} + : FileDirectiveReader(pduBuf, maxSize), info(info) {} ReturnValue_t AckPduDeserializer::parseData() { - ReturnValue_t result = FileDirectiveDeserializer::parseData(); + ReturnValue_t result = FileDirectiveReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); + size_t currentIdx = FileDirectiveReader::getHeaderSize(); if (currentIdx + 2 > this->maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } diff --git a/src/fsfw/cfdp/pdu/AckPduDeserializer.h b/src/fsfw/cfdp/pdu/AckPduDeserializer.h index 0bb95071..4da50261 100644 --- a/src/fsfw/cfdp/pdu/AckPduDeserializer.h +++ b/src/fsfw/cfdp/pdu/AckPduDeserializer.h @@ -2,9 +2,9 @@ #define FSFW_SRC_FSFW_CFDP_PDU_ACKPDUDESERIALIZER_H_ #include "AckInfo.h" -#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" -class AckPduDeserializer : public FileDirectiveDeserializer { +class AckPduDeserializer : public FileDirectiveReader { public: AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, AckInfo& info); diff --git a/src/fsfw/cfdp/pdu/AckPduSerializer.cpp b/src/fsfw/cfdp/pdu/AckPduSerializer.cpp index d19418f1..5405f96c 100644 --- a/src/fsfw/cfdp/pdu/AckPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/AckPduSerializer.cpp @@ -1,16 +1,15 @@ #include "AckPduSerializer.h" AckPduSerializer::AckPduSerializer(AckInfo &ackInfo, PduConfig &pduConf) - : FileDirectiveSerializer(pduConf, cfdp::FileDirectives::ACK, 2), ackInfo(ackInfo) {} + : FileDirectiveCreator(pduConf, cfdp::FileDirectives::ACK, 2), ackInfo(ackInfo) {} size_t AckPduSerializer::getSerializedSize() const { - return FileDirectiveSerializer::getWholePduSize(); + return FileDirectiveCreator::getWholePduSize(); } ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { - ReturnValue_t result = - FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); + ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/cfdp/pdu/AckPduSerializer.h b/src/fsfw/cfdp/pdu/AckPduSerializer.h index 68a049e2..92014e4e 100644 --- a/src/fsfw/cfdp/pdu/AckPduSerializer.h +++ b/src/fsfw/cfdp/pdu/AckPduSerializer.h @@ -2,10 +2,10 @@ #define FSFW_SRC_FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_ #include "AckInfo.h" -#include "FileDirectiveDeserializer.h" -#include "FileDirectiveSerializer.h" +#include "FileDirectiveCreator.h" +#include "FileDirectiveReader.h" -class AckPduSerializer : public FileDirectiveSerializer { +class AckPduSerializer : public FileDirectiveCreator { public: /** * @brief Serializer to pack ACK PDUs diff --git a/src/fsfw/cfdp/pdu/CMakeLists.txt b/src/fsfw/cfdp/pdu/CMakeLists.txt index 0d49217b..21fe0820 100644 --- a/src/fsfw/cfdp/pdu/CMakeLists.txt +++ b/src/fsfw/cfdp/pdu/CMakeLists.txt @@ -4,8 +4,8 @@ target_sources( VarLenField.cpp HeaderCreator.cpp HeaderReader.cpp - FileDirectiveDeserializer.cpp - FileDirectiveSerializer.cpp + FileDirectiveReader.cpp + FileDirectiveCreator.cpp AckInfo.cpp AckPduSerializer.cpp AckPduDeserializer.cpp @@ -25,6 +25,6 @@ target_sources( KeepAlivePduDeserializer.cpp PromptPduSerializer.cpp PromptPduDeserializer.cpp - FileDataSerializer.cpp - FileDataDeserializer.cpp + FileDataCreator.cpp + FileDataReader.cpp FileDataInfo.cpp) diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp index e1ab8dc9..e532419f 100644 --- a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp @@ -4,10 +4,10 @@ #include "fsfw/serviceinterface.h" EofPduDeserializer::EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo) - : FileDirectiveDeserializer(pduBuf, maxSize), info(eofInfo) {} + : FileDirectiveReader(pduBuf, maxSize), info(eofInfo) {} ReturnValue_t EofPduDeserializer::parseData() { - ReturnValue_t result = FileDirectiveDeserializer::parseData(); + ReturnValue_t result = FileDirectiveReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -17,7 +17,7 @@ ReturnValue_t EofPduDeserializer::parseData() { if (this->getLargeFileFlag()) { expectedFileFieldLen = 8; } - size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); + size_t currentIdx = FileDirectiveReader::getHeaderSize(); size_t deserLen = maxSize; if (maxSize < currentIdx + 5 + expectedFileFieldLen) { return SerializeIF::STREAM_TOO_SHORT; diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.h b/src/fsfw/cfdp/pdu/EofPduDeserializer.h index 8f62b25a..ce918475 100644 --- a/src/fsfw/cfdp/pdu/EofPduDeserializer.h +++ b/src/fsfw/cfdp/pdu/EofPduDeserializer.h @@ -2,9 +2,9 @@ #define FSFW_SRC_FSFW_CFDP_PDU_EOFPDUDESERIALIZER_H_ #include "EofInfo.h" -#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" -class EofPduDeserializer : public FileDirectiveDeserializer { +class EofPduDeserializer : public FileDirectiveReader { public: EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo); diff --git a/src/fsfw/cfdp/pdu/EofPduSerializer.cpp b/src/fsfw/cfdp/pdu/EofPduSerializer.cpp index e9fe0ca0..f6dc343c 100644 --- a/src/fsfw/cfdp/pdu/EofPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduSerializer.cpp @@ -4,18 +4,17 @@ #include "fsfw/serviceinterface.h" EofPduSerializer::EofPduSerializer(PduConfig &conf, EofInfo &info) - : FileDirectiveSerializer(conf, cfdp::FileDirectives::EOF_DIRECTIVE, 9), info(info) { + : FileDirectiveCreator(conf, cfdp::FileDirectives::EOF_DIRECTIVE, 9), info(info) { setDirectiveDataFieldLen(info.getSerializedSize(getLargeFileFlag())); } size_t EofPduSerializer::getSerializedSize() const { - return FileDirectiveSerializer::getWholePduSize(); + return FileDirectiveCreator::getWholePduSize(); } ReturnValue_t EofPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { - ReturnValue_t result = - FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); + ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/cfdp/pdu/EofPduSerializer.h b/src/fsfw/cfdp/pdu/EofPduSerializer.h index fbdcfe67..737e8dee 100644 --- a/src/fsfw/cfdp/pdu/EofPduSerializer.h +++ b/src/fsfw/cfdp/pdu/EofPduSerializer.h @@ -2,10 +2,10 @@ #define FSFW_SRC_FSFW_CFDP_PDU_EOFPDUSERIALIZER_H_ #include "EofInfo.h" -#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" #include "fsfw/cfdp/tlv/EntityIdTlv.h" -class EofPduSerializer : public FileDirectiveSerializer { +class EofPduSerializer : public FileDirectiveCreator { public: EofPduSerializer(PduConfig& conf, EofInfo& info); diff --git a/src/fsfw/cfdp/pdu/FileDataSerializer.cpp b/src/fsfw/cfdp/pdu/FileDataCreator.cpp similarity index 81% rename from src/fsfw/cfdp/pdu/FileDataSerializer.cpp rename to src/fsfw/cfdp/pdu/FileDataCreator.cpp index 2e86a255..39d3838a 100644 --- a/src/fsfw/cfdp/pdu/FileDataSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDataCreator.cpp @@ -1,20 +1,20 @@ -#include "FileDataSerializer.h" +#include "FileDataCreator.h" #include -FileDataSerializer::FileDataSerializer(PduConfig& conf, FileDataInfo& info) +FileDataCreator::FileDataCreator(PduConfig& conf, FileDataInfo& info) : HeaderCreator(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) { update(); } -void FileDataSerializer::update() { +void FileDataCreator::update() { this->setSegmentMetadataFlag(info.getSegmentMetadataFlag()); this->setSegmentationControl(info.getSegmentationControl()); setPduDataFieldLen(info.getSerializedSize(this->getLargeFileFlag())); } -ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const { +ReturnValue_t FileDataCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const { ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -49,6 +49,6 @@ ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size return HasReturnvaluesIF::RETURN_OK; } -size_t FileDataSerializer::getSerializedSize() const { +size_t FileDataCreator::getSerializedSize() const { return HeaderCreator::getSerializedSize() + info.getSerializedSize(this->getLargeFileFlag()); } diff --git a/src/fsfw/cfdp/pdu/FileDataCreator.h b/src/fsfw/cfdp/pdu/FileDataCreator.h new file mode 100644 index 00000000..774baf00 --- /dev/null +++ b/src/fsfw/cfdp/pdu/FileDataCreator.h @@ -0,0 +1,23 @@ +#ifndef FSFW_CFDP_PDU_FILEDATASERIALIZER_H_ +#define FSFW_CFDP_PDU_FILEDATASERIALIZER_H_ + +#include "../definitions.h" +#include "FileDataInfo.h" +#include "HeaderCreator.h" + +class FileDataCreator : public HeaderCreator { + public: + FileDataCreator(PduConfig& conf, FileDataInfo& info); + + void update(); + + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const override; + + [[nodiscard]] size_t getSerializedSize() const override; + + private: + FileDataInfo& info; +}; + +#endif /* FSFW_CFDP_PDU_FILEDATASERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp b/src/fsfw/cfdp/pdu/FileDataReader.cpp similarity index 73% rename from src/fsfw/cfdp/pdu/FileDataDeserializer.cpp rename to src/fsfw/cfdp/pdu/FileDataReader.cpp index 2b3171a8..30581da4 100644 --- a/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDataReader.cpp @@ -1,10 +1,9 @@ -#include "FileDataDeserializer.h" +#include "FileDataReader.h" -FileDataDeserializer::FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize, - FileDataInfo& info) +FileDataReader::FileDataReader(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info) : HeaderReader(pduBuf, maxSize), info(info) {} -ReturnValue_t FileDataDeserializer::parseData() { +ReturnValue_t FileDataReader::parseData() { ReturnValue_t result = HeaderReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -41,8 +40,8 @@ ReturnValue_t FileDataDeserializer::parseData() { return HasReturnvaluesIF::RETURN_OK; } -SerializeIF::Endianness FileDataDeserializer::getEndianness() const { return endianness; } +SerializeIF::Endianness FileDataReader::getEndianness() const { return endianness; } -void FileDataDeserializer::setEndianness(SerializeIF::Endianness endianness) { - this->endianness = endianness; +void FileDataReader::setEndianness(SerializeIF::Endianness endianness_) { + endianness = endianness_; } diff --git a/src/fsfw/cfdp/pdu/FileDataDeserializer.h b/src/fsfw/cfdp/pdu/FileDataReader.h similarity index 67% rename from src/fsfw/cfdp/pdu/FileDataDeserializer.h rename to src/fsfw/cfdp/pdu/FileDataReader.h index f6723fec..62e0f89b 100644 --- a/src/fsfw/cfdp/pdu/FileDataDeserializer.h +++ b/src/fsfw/cfdp/pdu/FileDataReader.h @@ -5,12 +5,12 @@ #include "FileDataInfo.h" #include "HeaderReader.h" -class FileDataDeserializer : public HeaderReader { +class FileDataReader : public HeaderReader { public: - FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info); + FileDataReader(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info); - ReturnValue_t parseData(); - SerializeIF::Endianness getEndianness() const; + ReturnValue_t parseData() override; + [[nodiscard]] SerializeIF::Endianness getEndianness() const; void setEndianness(SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK); private: diff --git a/src/fsfw/cfdp/pdu/FileDataSerializer.h b/src/fsfw/cfdp/pdu/FileDataSerializer.h deleted file mode 100644 index 17d72e2e..00000000 --- a/src/fsfw/cfdp/pdu/FileDataSerializer.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef FSFW_SRC_FSFW_CFDP_PDU_FILEDATASERIALIZER_H_ -#define FSFW_SRC_FSFW_CFDP_PDU_FILEDATASERIALIZER_H_ - -#include "../definitions.h" -#include "FileDataInfo.h" -#include "HeaderCreator.h" - -class FileDataSerializer : public HeaderCreator { - public: - FileDataSerializer(PduConfig& conf, FileDataInfo& info); - - void update(); - - ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const override; - - size_t getSerializedSize() const override; - - private: - FileDataInfo& info; -}; - -#endif /* FSFW_SRC_FSFW_CFDP_PDU_FILEDATADESERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp similarity index 53% rename from src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp rename to src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp index e70b8b83..169c2d5f 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp @@ -1,21 +1,20 @@ -#include "FileDirectiveSerializer.h" +#include "FileDirectiveCreator.h" -FileDirectiveSerializer::FileDirectiveSerializer(PduConfig &pduConf, - cfdp::FileDirectives directiveCode, - size_t directiveParamFieldLen) +FileDirectiveCreator::FileDirectiveCreator(PduConfig &pduConf, cfdp::FileDirectives directiveCode, + size_t directiveParamFieldLen) : HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1), directiveCode(directiveCode) {} -size_t FileDirectiveSerializer::getSerializedSize() const { +size_t FileDirectiveCreator::getSerializedSize() const { return HeaderCreator::getSerializedSize() + 1; } -ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const { +ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const { if (buffer == nullptr or size == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } - if (FileDirectiveSerializer::getWholePduSize() > maxSize) { + if (FileDirectiveCreator::getWholePduSize() > maxSize) { return BUFFER_TOO_SHORT; } ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness); @@ -32,7 +31,7 @@ ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, return HasReturnvaluesIF::RETURN_OK; } -void FileDirectiveSerializer::setDirectiveDataFieldLen(size_t len) { +void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) { // Set length of data field plus 1 byte for the directive octet HeaderCreator::setPduDataFieldLen(len + 1); } diff --git a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.h b/src/fsfw/cfdp/pdu/FileDirectiveCreator.h similarity index 66% rename from src/fsfw/cfdp/pdu/FileDirectiveSerializer.h rename to src/fsfw/cfdp/pdu/FileDirectiveCreator.h index ffe34412..566ae3cc 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.h +++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.h @@ -3,18 +3,18 @@ #include "fsfw/cfdp/pdu/HeaderCreator.h" -class FileDirectiveSerializer : public HeaderCreator { +class FileDirectiveCreator : public HeaderCreator { public: - FileDirectiveSerializer(PduConfig& pduConf, cfdp::FileDirectives directiveCode, - size_t directiveParamFieldLen); + FileDirectiveCreator(PduConfig& pduConf, cfdp::FileDirectives directiveCode, + size_t directiveParamFieldLen); /** * This only returns the size of the PDU header + 1 for the directive code octet. - * Use FileDirectiveSerializer::getWholePduSize to get the full packet length, assuming + * Use FileDirectiveCreator::getWholePduSize to get the full packet length, assuming * the length fields was set correctly * @return */ - size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; diff --git a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp similarity index 53% rename from src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp rename to src/fsfw/cfdp/pdu/FileDirectiveReader.cpp index 162312d3..d51846b8 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp @@ -1,11 +1,11 @@ -#include "FileDirectiveDeserializer.h" +#include "FileDirectiveReader.h" -FileDirectiveDeserializer::FileDirectiveDeserializer(const uint8_t *pduBuf, size_t maxSize) +FileDirectiveReader::FileDirectiveReader(const uint8_t *pduBuf, size_t maxSize) : HeaderReader(pduBuf, maxSize) {} -cfdp::FileDirectives FileDirectiveDeserializer::getFileDirective() const { return fileDirective; } +cfdp::FileDirectives FileDirectiveReader::getFileDirective() const { return fileDirective; } -ReturnValue_t FileDirectiveDeserializer::parseData() { +ReturnValue_t FileDirectiveReader::parseData() { ReturnValue_t result = HeaderReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -13,7 +13,7 @@ ReturnValue_t FileDirectiveDeserializer::parseData() { if (this->getPduDataFieldLen() < 1) { return cfdp::INVALID_PDU_DATAFIELD_LEN; } - if (FileDirectiveDeserializer::getWholePduSize() > maxSize) { + if (FileDirectiveReader::getWholePduSize() > maxSize) { return SerializeIF::STREAM_TOO_SHORT; } size_t currentIdx = HeaderReader::getHeaderSize(); @@ -24,12 +24,12 @@ ReturnValue_t FileDirectiveDeserializer::parseData() { return HasReturnvaluesIF::RETURN_OK; } -size_t FileDirectiveDeserializer::getHeaderSize() const { +size_t FileDirectiveReader::getHeaderSize() const { // return size of header plus the directive byte return HeaderReader::getHeaderSize() + 1; } -bool FileDirectiveDeserializer::checkFileDirective(uint8_t rawByte) { +bool FileDirectiveReader::checkFileDirective(uint8_t rawByte) { if (rawByte < cfdp::FileDirectives::EOF_DIRECTIVE or (rawByte > cfdp::FileDirectives::PROMPT and rawByte != cfdp::FileDirectives::KEEP_ALIVE)) { // Invalid directive field. TODO: Custom returnvalue @@ -38,12 +38,12 @@ bool FileDirectiveDeserializer::checkFileDirective(uint8_t rawByte) { return true; } -void FileDirectiveDeserializer::setFileDirective(cfdp::FileDirectives fileDirective) { - this->fileDirective = fileDirective; +void FileDirectiveReader::setFileDirective(cfdp::FileDirectives fileDirective_) { + fileDirective = fileDirective_; } -void FileDirectiveDeserializer::setEndianness(SerializeIF::Endianness endianness) { - this->endianness = endianness; +void FileDirectiveReader::setEndianness(SerializeIF::Endianness endianness_) { + endianness = endianness_; } -SerializeIF::Endianness FileDirectiveDeserializer::getEndianness() const { return endianness; } +SerializeIF::Endianness FileDirectiveReader::getEndianness() const { return endianness; } diff --git a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.h b/src/fsfw/cfdp/pdu/FileDirectiveReader.h similarity index 71% rename from src/fsfw/cfdp/pdu/FileDirectiveDeserializer.h rename to src/fsfw/cfdp/pdu/FileDirectiveReader.h index 193a71f3..69dd44cd 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.h +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.h @@ -11,24 +11,24 @@ * This is a zero-copy implementation and #parseData needs to be called to ensure the data is * valid. */ -class FileDirectiveDeserializer : public HeaderReader { +class FileDirectiveReader : public HeaderReader { public: - FileDirectiveDeserializer(const uint8_t* pduBuf, size_t maxSize); + FileDirectiveReader(const uint8_t* pduBuf, size_t maxSize); /** * This needs to be called before accessing the PDU fields to avoid segmentation faults. * @return */ - virtual ReturnValue_t parseData(); - size_t getHeaderSize() const; + ReturnValue_t parseData() override; + [[nodiscard]] size_t getHeaderSize() const override; - cfdp::FileDirectives getFileDirective() const; + [[nodiscard]] cfdp::FileDirectives getFileDirective() const; void setEndianness(SerializeIF::Endianness endianness); - SerializeIF::Endianness getEndianness() const; + [[nodiscard]] SerializeIF::Endianness getEndianness() const; protected: - bool checkFileDirective(uint8_t rawByte); + static bool checkFileDirective(uint8_t rawByte); private: void setFileDirective(cfdp::FileDirectives fileDirective); diff --git a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp index feeca617..4209af65 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp @@ -2,21 +2,21 @@ FinishPduDeserializer::FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize, FinishedInfo& info) - : FileDirectiveDeserializer(pduBuf, maxSize), finishedInfo(info) {} + : FileDirectiveReader(pduBuf, maxSize), finishedInfo(info) {} ReturnValue_t FinishPduDeserializer::parseData() { - ReturnValue_t result = FileDirectiveDeserializer::parseData(); + ReturnValue_t result = FileDirectiveReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); + size_t currentIdx = FileDirectiveReader::getHeaderSize(); const uint8_t* buf = rawPtr + currentIdx; - size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx; + size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx; if (remSize < 1) { return SerializeIF::STREAM_TOO_SHORT; } uint8_t firstByte = *buf; - cfdp::ConditionCode condCode = static_cast((firstByte >> 4) & 0x0f); + auto condCode = static_cast((firstByte >> 4) & 0x0f); finishedInfo.setConditionCode(condCode); finishedInfo.setDeliveryCode(static_cast(firstByte >> 2 & 0b1)); finishedInfo.setFileStatus(static_cast(firstByte & 0b11)); diff --git a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.h b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.h index a34fc4cb..1a13cad5 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.h +++ b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.h @@ -1,10 +1,10 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ -#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" #include "fsfw/cfdp/pdu/FinishedInfo.h" -class FinishPduDeserializer : public FileDirectiveDeserializer { +class FinishPduDeserializer : public FileDirectiveReader { public: FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize, FinishedInfo& info); diff --git a/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp index 115a2c9c..de71d9d2 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp @@ -1,7 +1,7 @@ #include "FinishedPduSerializer.h" FinishPduSerializer::FinishPduSerializer(PduConfig &conf, FinishedInfo &finishInfo) - : FileDirectiveSerializer(conf, cfdp::FileDirectives::FINISH, 0), finishInfo(finishInfo) { + : FileDirectiveCreator(conf, cfdp::FileDirectives::FINISH, 0), finishInfo(finishInfo) { updateDirectiveFieldLen(); } @@ -15,8 +15,7 @@ void FinishPduSerializer::updateDirectiveFieldLen() { ReturnValue_t FinishPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { - ReturnValue_t result = - FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); + ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/cfdp/pdu/FinishedPduSerializer.h b/src/fsfw/cfdp/pdu/FinishedPduSerializer.h index d66b25f2..eb162c94 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduSerializer.h +++ b/src/fsfw/cfdp/pdu/FinishedPduSerializer.h @@ -2,10 +2,10 @@ #define FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_ #include "FinishedInfo.h" -#include "fsfw/cfdp/pdu/FileDataSerializer.h" -#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" +#include "fsfw/cfdp/pdu/FileDataCreator.h" +#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" -class FinishPduSerializer : public FileDirectiveSerializer { +class FinishPduSerializer : public FileDirectiveCreator { public: FinishPduSerializer(PduConfig& pduConf, FinishedInfo& finishInfo); diff --git a/src/fsfw/cfdp/pdu/HeaderCreator.cpp b/src/fsfw/cfdp/pdu/HeaderCreator.cpp index debeedeb..d70e8270 100644 --- a/src/fsfw/cfdp/pdu/HeaderCreator.cpp +++ b/src/fsfw/cfdp/pdu/HeaderCreator.cpp @@ -47,8 +47,7 @@ ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t ma } size_t HeaderCreator::getSerializedSize() const { - size_t shit = pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4; - return shit; + return pduConf.seqNum.getWidth() + pduConf.sourceId.getWidth() * 2 + 4; } ReturnValue_t HeaderCreator::deSerialize(const uint8_t **buffer, size_t *size, diff --git a/src/fsfw/cfdp/pdu/HeaderReader.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp index 7aec3f49..cd8667b2 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.cpp +++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp @@ -38,11 +38,12 @@ size_t HeaderReader::getHeaderSize() const { } size_t HeaderReader::getPduDataFieldLen() const { - uint16_t pduFiedlLen = (fixedHeader->pduDataFieldLenH << 8) | fixedHeader->pduDataFieldLenL; - return pduFiedlLen; + return (fixedHeader->pduDataFieldLenH << 8) | fixedHeader->pduDataFieldLenL; } -size_t HeaderReader::getWholePduSize() const { return getPduDataFieldLen() + getHeaderSize(); } +size_t HeaderReader::getWholePduSize() const { + return getPduDataFieldLen() + HeaderReader::getHeaderSize(); +} cfdp::PduType HeaderReader::getPduType() const { return static_cast((fixedHeader->firstByte >> 4) & 0x01); diff --git a/src/fsfw/cfdp/pdu/HeaderReader.h b/src/fsfw/cfdp/pdu/HeaderReader.h index 997828b6..1543a71b 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.h +++ b/src/fsfw/cfdp/pdu/HeaderReader.h @@ -41,7 +41,7 @@ class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { * - SerializeIF::BUFFER_TOO_SHORT if buffer is shorter than expected */ virtual ReturnValue_t parseData(); - [[nodiscard]] size_t getHeaderSize() const; + [[nodiscard]] virtual size_t getHeaderSize() const; [[nodiscard]] size_t getPduDataFieldLen() const override; [[nodiscard]] size_t getWholePduSize() const override; diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp index 15f80549..3acf26a1 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp @@ -2,15 +2,15 @@ KeepAlivePduDeserializer::KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize, cfdp::FileSize& progress) - : FileDirectiveDeserializer(pduBuf, maxSize), progress(progress) {} + : FileDirectiveReader(pduBuf, maxSize), progress(progress) {} ReturnValue_t KeepAlivePduDeserializer::parseData() { - ReturnValue_t result = FileDirectiveDeserializer::parseData(); + ReturnValue_t result = FileDirectiveReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); - size_t remLen = FileDirectiveDeserializer::getWholePduSize() - currentIdx; + size_t currentIdx = FileDirectiveReader::getHeaderSize(); + size_t remLen = FileDirectiveReader::getWholePduSize() - currentIdx; const uint8_t* buffer = rawPtr + currentIdx; return progress.deSerialize(&buffer, &remLen, getEndianness()); } diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h index e8b83ad6..1a8ca14d 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h +++ b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h @@ -2,9 +2,9 @@ #define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUDESERIALIZER_H_ #include "fsfw/cfdp/FileSize.h" -#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" -class KeepAlivePduDeserializer : public FileDirectiveDeserializer { +class KeepAlivePduDeserializer : public FileDirectiveReader { public: KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize, cfdp::FileSize& progress); diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp index e635ce06..d257eb3d 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp @@ -1,12 +1,12 @@ #include "KeepAlivePduSerializer.h" KeepAlivePduSerializer::KeepAlivePduSerializer(PduConfig &conf, cfdp::FileSize &progress) - : FileDirectiveSerializer(conf, cfdp::FileDirectives::KEEP_ALIVE, 4), progress(progress) { + : FileDirectiveCreator(conf, cfdp::FileDirectives::KEEP_ALIVE, 4), progress(progress) { updateDirectiveFieldLen(); } size_t KeepAlivePduSerializer::getSerializedSize() const { - return FileDirectiveSerializer::getWholePduSize(); + return FileDirectiveCreator::getWholePduSize(); } void KeepAlivePduSerializer::updateDirectiveFieldLen() { @@ -17,8 +17,7 @@ void KeepAlivePduSerializer::updateDirectiveFieldLen() { ReturnValue_t KeepAlivePduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { - ReturnValue_t result = - FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); + ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h b/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h index d2499a79..0fabeb0a 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h +++ b/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h @@ -2,9 +2,9 @@ #define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_ #include "fsfw/cfdp/FileSize.h" -#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" -class KeepAlivePduSerializer : public FileDirectiveSerializer { +class KeepAlivePduSerializer : public FileDirectiveCreator { public: KeepAlivePduSerializer(PduConfig& conf, cfdp::FileSize& progress); diff --git a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp b/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp index 161eb63a..00111303 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp @@ -2,16 +2,16 @@ MetadataPduDeserializer::MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info) - : FileDirectiveDeserializer(pduBuf, maxSize), info(info) {} + : FileDirectiveReader(pduBuf, maxSize), info(info) {} ReturnValue_t MetadataPduDeserializer::parseData() { - ReturnValue_t result = FileDirectiveDeserializer::parseData(); + ReturnValue_t result = FileDirectiveReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); + size_t currentIdx = FileDirectiveReader::getHeaderSize(); const uint8_t* buf = rawPtr + currentIdx; - size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx; + size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx; if (remSize < 1) { return SerializeIF::STREAM_TOO_SHORT; } diff --git a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.h b/src/fsfw/cfdp/pdu/MetadataPduDeserializer.h index 1a8f9315..dcbb2c55 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.h +++ b/src/fsfw/cfdp/pdu/MetadataPduDeserializer.h @@ -1,10 +1,10 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_ -#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" #include "fsfw/cfdp/pdu/MetadataInfo.h" -class MetadataPduDeserializer : public FileDirectiveDeserializer { +class MetadataPduDeserializer : public FileDirectiveReader { public: MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info); diff --git a/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp b/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp index f5c4de0a..a08b3214 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp @@ -1,7 +1,7 @@ #include "MetadataPduSerializer.h" MetadataPduSerializer::MetadataPduSerializer(PduConfig &conf, MetadataInfo &info) - : FileDirectiveSerializer(conf, cfdp::FileDirectives::METADATA, 5), info(info) { + : FileDirectiveCreator(conf, cfdp::FileDirectives::METADATA, 5), info(info) { updateDirectiveFieldLen(); } @@ -10,13 +10,12 @@ void MetadataPduSerializer::updateDirectiveFieldLen() { } size_t MetadataPduSerializer::getSerializedSize() const { - return FileDirectiveSerializer::getWholePduSize(); + return FileDirectiveCreator::getWholePduSize(); } ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { - ReturnValue_t result = - FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); + ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/cfdp/pdu/MetadataPduSerializer.h b/src/fsfw/cfdp/pdu/MetadataPduSerializer.h index cacf8a52..a6514783 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduSerializer.h +++ b/src/fsfw/cfdp/pdu/MetadataPduSerializer.h @@ -1,10 +1,10 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_ -#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" #include "fsfw/cfdp/pdu/MetadataInfo.h" -class MetadataPduSerializer : public FileDirectiveSerializer { +class MetadataPduSerializer : public FileDirectiveCreator { public: MetadataPduSerializer(PduConfig& conf, MetadataInfo& info); diff --git a/src/fsfw/cfdp/pdu/NakInfo.cpp b/src/fsfw/cfdp/pdu/NakInfo.cpp index 795004a9..14d06cb0 100644 --- a/src/fsfw/cfdp/pdu/NakInfo.cpp +++ b/src/fsfw/cfdp/pdu/NakInfo.cpp @@ -26,7 +26,7 @@ bool NakInfo::hasSegmentRequests() const { } bool NakInfo::canHoldSegmentRequests() const { - if (this->segmentRequests != nullptr and maxSegmentRequestsLen > 0) { + if (segmentRequests != nullptr and maxSegmentRequestsLen > 0) { return true; } return false; diff --git a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp b/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp index 9d5f074c..a7f23996 100644 --- a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp @@ -1,16 +1,16 @@ #include "NakPduDeserializer.h" NakPduDeserializer::NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, NakInfo& info) - : FileDirectiveDeserializer(pduBuf, maxSize), nakInfo(info) {} + : FileDirectiveReader(pduBuf, maxSize), nakInfo(info) {} ReturnValue_t NakPduDeserializer::parseData() { - ReturnValue_t result = FileDirectiveDeserializer::parseData(); + ReturnValue_t result = FileDirectiveReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); + size_t currentIdx = FileDirectiveReader::getHeaderSize(); const uint8_t* buffer = rawPtr + currentIdx; - size_t remSize = FileDirectiveDeserializer::getWholePduSize() - currentIdx; + size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx; if (remSize < 1) { return SerializeIF::STREAM_TOO_SHORT; } diff --git a/src/fsfw/cfdp/pdu/NakPduDeserializer.h b/src/fsfw/cfdp/pdu/NakPduDeserializer.h index f0f43158..c119564d 100644 --- a/src/fsfw/cfdp/pdu/NakPduDeserializer.h +++ b/src/fsfw/cfdp/pdu/NakPduDeserializer.h @@ -1,10 +1,10 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ -#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" #include "fsfw/cfdp/pdu/NakInfo.h" -class NakPduDeserializer : public FileDirectiveDeserializer { +class NakPduDeserializer : public FileDirectiveReader { public: NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, NakInfo& info); diff --git a/src/fsfw/cfdp/pdu/NakPduSerializer.cpp b/src/fsfw/cfdp/pdu/NakPduSerializer.cpp index 95f1bc98..767b2310 100644 --- a/src/fsfw/cfdp/pdu/NakPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/NakPduSerializer.cpp @@ -1,7 +1,7 @@ #include "NakPduSerializer.h" NakPduSerializer::NakPduSerializer(PduConfig &pduConf, NakInfo &nakInfo) - : FileDirectiveSerializer(pduConf, cfdp::FileDirectives::NAK, 0), nakInfo(nakInfo) { + : FileDirectiveCreator(pduConf, cfdp::FileDirectives::NAK, 0), nakInfo(nakInfo) { updateDirectiveFieldLen(); } @@ -10,13 +10,12 @@ void NakPduSerializer::updateDirectiveFieldLen() { } size_t NakPduSerializer::getSerializedSize() const { - return FileDirectiveSerializer::getWholePduSize(); + return FileDirectiveCreator::getWholePduSize(); } ReturnValue_t NakPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { - ReturnValue_t result = - FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); + ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/cfdp/pdu/NakPduSerializer.h b/src/fsfw/cfdp/pdu/NakPduSerializer.h index 4009884b..12e1bae2 100644 --- a/src/fsfw/cfdp/pdu/NakPduSerializer.h +++ b/src/fsfw/cfdp/pdu/NakPduSerializer.h @@ -6,9 +6,9 @@ #include "NakInfo.h" #include "fsfw/cfdp/FileSize.h" #include "fsfw/cfdp/definitions.h" -#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" -class NakPduSerializer : public FileDirectiveSerializer { +class NakPduSerializer : public FileDirectiveCreator { public: /** * diff --git a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp b/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp index 6a6f5505..833c9232 100644 --- a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp @@ -1,21 +1,21 @@ #include "PromptPduDeserializer.h" PromptPduDeserializer::PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize) - : FileDirectiveDeserializer(pduBuf, maxSize) {} + : FileDirectiveReader(pduBuf, maxSize) {} cfdp::PromptResponseRequired PromptPduDeserializer::getPromptResponseRequired() const { return responseRequired; } ReturnValue_t PromptPduDeserializer::parseData() { - ReturnValue_t result = FileDirectiveDeserializer::parseData(); + ReturnValue_t result = FileDirectiveReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); - if (FileDirectiveDeserializer::getWholePduSize() - currentIdx < 1) { + if (FileDirectiveReader::getWholePduSize() <= FileDirectiveReader::getHeaderSize()) { return SerializeIF::STREAM_TOO_SHORT; } - responseRequired = static_cast((rawPtr[currentIdx] >> 7) & 0x01); + responseRequired = static_cast( + (rawPtr[FileDirectiveReader::getHeaderSize()] >> 7) & 0x01); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/cfdp/pdu/PromptPduDeserializer.h b/src/fsfw/cfdp/pdu/PromptPduDeserializer.h index 2f75033b..91ed5a9a 100644 --- a/src/fsfw/cfdp/pdu/PromptPduDeserializer.h +++ b/src/fsfw/cfdp/pdu/PromptPduDeserializer.h @@ -1,9 +1,9 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUDESERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUDESERIALIZER_H_ -#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" -class PromptPduDeserializer : public FileDirectiveDeserializer { +class PromptPduDeserializer : public FileDirectiveReader { public: PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize); diff --git a/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp b/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp index a7287563..cb0f1fec 100644 --- a/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp @@ -2,24 +2,23 @@ PromptPduSerializer::PromptPduSerializer(PduConfig &conf, cfdp::PromptResponseRequired responseRequired) - : FileDirectiveSerializer(conf, cfdp::FileDirectives::PROMPT, 1), + : FileDirectiveCreator(conf, cfdp::FileDirectives::PROMPT, 1), responseRequired(responseRequired) {} size_t PromptPduSerializer::getSerializedSize() const { - return FileDirectiveSerializer::getWholePduSize(); + return FileDirectiveCreator::getWholePduSize(); } ReturnValue_t PromptPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { - ReturnValue_t result = - FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); + ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } if (*size + 1 > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } - **buffer = this->responseRequired << 7; + **buffer = responseRequired << 7; *buffer += 1; *size += 1; return result; diff --git a/src/fsfw/cfdp/pdu/PromptPduSerializer.h b/src/fsfw/cfdp/pdu/PromptPduSerializer.h index 51500224..1abe362e 100644 --- a/src/fsfw/cfdp/pdu/PromptPduSerializer.h +++ b/src/fsfw/cfdp/pdu/PromptPduSerializer.h @@ -1,13 +1,13 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUSERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_PROMPTPDUSERIALIZER_H_ -#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" -class PromptPduSerializer : public FileDirectiveSerializer { +class PromptPduSerializer : public FileDirectiveCreator { public: PromptPduSerializer(PduConfig& conf, cfdp::PromptResponseRequired responseRequired); - size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 475322a2..f3d36cdd 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -3,8 +3,8 @@ #include #include "fsfw/cfdp/FileSize.h" -#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" -#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serialize/SerializeAdapter.h" @@ -22,7 +22,7 @@ TEST_CASE("CFDP Base", "[cfdp]") { size_t serSize = 0; SECTION("File Directive") { - auto fdSer = FileDirectiveSerializer(pduConf, FileDirectives::ACK, 4); + auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4); REQUIRE(fdSer.getSerializedSize() == 8); serTarget = serBuf.data(); serSize = 0; @@ -59,7 +59,7 @@ TEST_CASE("CFDP Base", "[cfdp]") { deserTarget = serBuf.data(); deserSize = 0; - auto fdDeser = FileDirectiveDeserializer(deserTarget, serBuf.size()); + auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size()); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::NETWORK); fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); diff --git a/unittests/cfdp/testFileData.cpp b/unittests/cfdp/testFileData.cpp index 272cea47..943b6ddc 100644 --- a/unittests/cfdp/testFileData.cpp +++ b/unittests/cfdp/testFileData.cpp @@ -1,8 +1,8 @@ #include #include -#include "fsfw/cfdp/pdu/FileDataDeserializer.h" -#include "fsfw/cfdp/pdu/FileDataSerializer.h" +#include "fsfw/cfdp/pdu/FileDataCreator.h" +#include "fsfw/cfdp/pdu/FileDataReader.h" #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serviceinterface.h" @@ -26,7 +26,7 @@ TEST_CASE("File Data PDU", "[cfdp][pdu]") { FileDataInfo info(offset, fileBuffer.data(), 10); SECTION("Serialization") { - FileDataSerializer serializer(pduConf, info); + FileDataCreator serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); @@ -102,14 +102,14 @@ TEST_CASE("File Data PDU", "[cfdp][pdu]") { } SECTION("Deserialization") { - FileDataSerializer serializer(pduConf, info); + FileDataCreator serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); FileSize emptyOffset; FileDataInfo emptyInfo(emptyOffset); - FileDataDeserializer deserializer(fileDataBuffer.data(), fileDataBuffer.size(), emptyInfo); + FileDataReader deserializer(fileDataBuffer.data(), fileDataBuffer.size(), emptyInfo); result = deserializer.parseData(); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(deserializer.getWholePduSize() == 24); diff --git a/unittests/cfdp/testFileDirective.cpp b/unittests/cfdp/testFileDirective.cpp index 31053d01..3a4818ec 100644 --- a/unittests/cfdp/testFileDirective.cpp +++ b/unittests/cfdp/testFileDirective.cpp @@ -1,8 +1,8 @@ #include #include -#include "fsfw/cfdp/pdu/FileDirectiveDeserializer.h" -#include "fsfw/cfdp/pdu/FileDirectiveSerializer.h" +#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" TEST_CASE("CFDP File Directive", "[cfdp]") { using namespace cfdp; @@ -18,7 +18,7 @@ TEST_CASE("CFDP File Directive", "[cfdp]") { size_t serSize = 0; SECTION("File Directive") { - auto fdSer = FileDirectiveSerializer(pduConf, FileDirectives::ACK, 4); + auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4); REQUIRE(fdSer.getSerializedSize() == 8); serTarget = serBuf.data(); serSize = 0; @@ -55,7 +55,7 @@ TEST_CASE("CFDP File Directive", "[cfdp]") { deserTarget = serBuf.data(); deserSize = 0; - auto fdDeser = FileDirectiveDeserializer(deserTarget, serBuf.size()); + auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size()); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::NETWORK); fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); diff --git a/unittests/cfdp/testNakPdu.cpp b/unittests/cfdp/testNakPdu.cpp index 5eee60a4..0ef329ff 100644 --- a/unittests/cfdp/testNakPdu.cpp +++ b/unittests/cfdp/testNakPdu.cpp @@ -25,7 +25,7 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") { result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(serializer.getSerializedSize() == 19); - REQUIRE(serializer.FileDirectiveSerializer::getSerializedSize() == 11); + REQUIRE(serializer.FileDirectiveCreator::getSerializedSize() == 11); REQUIRE(sz == 19); REQUIRE(serializer.getPduDataFieldLen() == 9); REQUIRE(((nakBuffer[1] << 8) | nakBuffer[2]) == 0x09); diff --git a/unittests/cfdp/testPromptPdu.cpp b/unittests/cfdp/testPromptPdu.cpp index 88dc8ac9..868f7140 100644 --- a/unittests/cfdp/testPromptPdu.cpp +++ b/unittests/cfdp/testPromptPdu.cpp @@ -51,8 +51,10 @@ TEST_CASE("Prompt PDU", "[cfdp][pdu]") { REQUIRE(deserializer.getPromptResponseRequired() == cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); sz = deserializer.getWholePduSize(); + // Set invalid size rawBuf[2] = 1; result = deserializer.parseData(); + size_t sz2 = deserializer.getWholePduSize(); REQUIRE(result == SerializeIF::STREAM_TOO_SHORT); rawBuf[2] = 2; From c6a7a0fec8340efcdb905e9cad504a2592c1de9d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Aug 2022 18:14:49 +0200 Subject: [PATCH 184/532] use distributor instead of router --- src/fsfw/cfdp/CMakeLists.txt | 2 +- src/fsfw/cfdp/CfdpDistributor.cpp | 197 +++++------------- .../cfdp/{CfdpRouter.h => CfdpDistributor.h} | 28 ++- src/fsfw/cfdp/CfdpRouter.cpp | 63 ------ src/fsfw/cfdp/CfdpRouterIF.h | 32 --- src/fsfw/cfdp/pdu/HeaderReader.h | 1 + 6 files changed, 67 insertions(+), 256 deletions(-) rename src/fsfw/cfdp/{CfdpRouter.h => CfdpDistributor.h} (70%) delete mode 100644 src/fsfw/cfdp/CfdpRouter.cpp delete mode 100644 src/fsfw/cfdp/CfdpRouterIF.h diff --git a/src/fsfw/cfdp/CMakeLists.txt b/src/fsfw/cfdp/CMakeLists.txt index 2d58e190..9bd54fc8 100644 --- a/src/fsfw/cfdp/CMakeLists.txt +++ b/src/fsfw/cfdp/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpRouter.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp) # CfdpDistributor.cpp CfdpHandler.cpp add_subdirectory(pdu) diff --git a/src/fsfw/cfdp/CfdpDistributor.cpp b/src/fsfw/cfdp/CfdpDistributor.cpp index fa221822..14e0180c 100644 --- a/src/fsfw/cfdp/CfdpDistributor.cpp +++ b/src/fsfw/cfdp/CfdpDistributor.cpp @@ -1,144 +1,53 @@ -//#include "CfdpRouter.h" -//#include "fsfw/tcdistribution/CcsdsDistributorIF.h" -//#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h" -// -//#ifndef FSFW_CFDP_DISTRIBUTOR_DEBUGGING -//#define FSFW_CFDP_DISTRIBUTOR_DEBUGGING 1 -//#endif -// -// CfdpHandler::CfdpHandler(uint16_t setApid, object_id_t setObjectId, -// object_id_t setPacketSource) -// : TcDistributorBase(setObjectId), -// apid(setApid), -// checker(setApid), -// tcStatus(RETURN_FAILED), -// packetSource(setPacketSource) {} -// -// CfdpHandler::~CfdpHandler() = default; -// -// ReturnValue_t CfdpHandler::selectDestination(MessageQueueId_t& destId) { -// //#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 -// // store_address_t storeId = this->currentMessage.getStorageId(); -// //#if FSFW_CPP_OSTREAM_ENABLED == 1 -// // sif::debug << "CFDPDistributor::handlePacket received: " << storeId.poolIndex << ", " -// // << storeId.packetIndex << std::endl; -// //#else -// // sif::printDebug("CFDPDistributor::handlePacket received: %d, %d\n", storeId.poolIndex, -// // storeId.packetIndex); -// //#endif -// //#endif -// // auto queueMapIt = this->queueMap.end(); -// // if (this->currentPacket == nullptr) { -// // return queueMapIt; -// // } -// // this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); -// // if (currentPacket->getFullData() != nullptr) { -// // tcStatus = checker.checkPacket(*currentPacket, currentPacket->getFullPacketLen()); -// // if (tcStatus != HasReturnvaluesIF::RETURN_OK) { -// //#if FSFW_VERBOSE_LEVEL >= 1 -// //#if FSFW_CPP_OSTREAM_ENABLED == 1 -// // sif::debug << "CFDPDistributor::handlePacket: Packet format invalid, code " -// // << static_cast(tcStatus) << std::endl; -// //#else -// // sif::printDebug("CFDPDistributor::handlePacket: Packet format invalid, code %d\n", -// // static_cast(tcStatus)); -// //#endif -// //#endif -// // } -// // queueMapIt = this->queueMap.find(0); -// // } else { -// // tcStatus = PACKET_LOST; -// // } -// // -// // if (queueMapIt == this->queueMap.end()) { -// // tcStatus = DESTINATION_NOT_FOUND; -// //#if FSFW_VERBOSE_LEVEL >= 1 -// //#if FSFW_CPP_OSTREAM_ENABLED == 1 -// // sif::debug << "CFDPDistributor::handlePacket: Destination not found" << std::endl; -// //#else -// // sif::printDebug("CFDPDistributor::handlePacket: Destination not found\n"); -// //#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ -// //#endif -// // } -// // -// // if (tcStatus != RETURN_OK) { -// // return this->queueMap.end(); -// // } else { -// // return queueMapIt; -// // } -// return HasReturnvaluesIF::RETURN_OK; -//} -// -// ReturnValue_t CfdpHandler::registerHandler(AcceptsTelecommandsIF* handler) { -// // uint16_t handlerId = -// // handler->getIdentifier(); // should be 0, because CfdpHandler does not set a set a -// // service-ID -// //#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1 -// //#if FSFW_CPP_OSTREAM_ENABLED == 1 -// // sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast(handlerId) -// // << std::endl; -// //#else -// // sif::printInfo("CFDPDistributor::registerHandler: Handler ID: %d\n", -// // static_cast(handlerId)); -// //#endif -// //#endif -// // MessageQueueId_t queue = handler->getRequestQueue(); -// // auto returnPair = queueMap.emplace(handlerId, queue); -// // if (not returnPair.second) { -// //#if FSFW_VERBOSE_LEVEL >= 1 -// //#if FSFW_CPP_OSTREAM_ENABLED == 1 -// // sif::error << "CFDPDistributor::registerHandler: Service ID already" -// // " exists in map" -// // << std::endl; -// //#else -// // sif::printError("CFDPDistributor::registerHandler: Service ID already exists in map\n"); -// //#endif -// //#endif -// // return SERVICE_ID_ALREADY_EXISTS; -// // } -// return HasReturnvaluesIF::RETURN_OK; -//} -// -// MessageQueueId_t CfdpHandler::getRequestQueue() const { return tcQueue->getId(); } -// -//// ReturnValue_t CFDPDistributor::callbackAfterSending(ReturnValue_t queueStatus) { -//// if (queueStatus != RETURN_OK) { -//// tcStatus = queueStatus; -//// } -//// if (tcStatus != RETURN_OK) { -//// this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, -//// currentPacket, tcStatus); -//// // A failed packet is deleted immediately after reporting, -//// // otherwise it will block memory. -//// currentPacket->deletePacket(); -//// return RETURN_FAILED; -//// } else { -//// this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, -//// currentPacket); -//// return RETURN_OK; -//// } -//// } -// -// uint32_t CfdpHandler::getIdentifier() const { return this->apid; } -// -// ReturnValue_t CfdpHandler::initialize() { -// // currentPacket = new CfdpPacketStored(); -// // if (currentPacket == nullptr) { -// // // Should not happen, memory allocation failed! -// // return ObjectManagerIF::CHILD_INIT_FAILED; -// // } -// // -// // auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); -// // if (ccsdsDistributor == nullptr) { -// //#if FSFW_CPP_OSTREAM_ENABLED == 1 -// // sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl; -// // sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; -// //#else -// // sif::printError("CFDPDistributor::initialize: Packet source invalid\n"); -// // sif::printError("Make sure it exists and implements CcsdsDistributorIF\n"); -// //#endif -// // return RETURN_FAILED; -// // } -// // return ccsdsDistributor->registerApplication(this); -// return HasReturnvaluesIF::RETURN_OK; -//} +#include "CfdpDistributor.h" + +#include "fsfw/tcdistribution/definitions.h" + +CfdpDistributor::CfdpDistributor(CfdpRouterCfg cfg) : TcDistributorBase(cfg.objectId), cfg(cfg) {} + +ReturnValue_t CfdpDistributor::registerTcDestination(const cfdp::EntityId& address, + AcceptsTelecommandsIF& tcDest) { + for (const auto& dest : tcDestinations) { + if (dest.id == address) { + return HasReturnvaluesIF::RETURN_FAILED; + } + } + tcDestinations.emplace_back(address, tcDest.getName(), tcDest.getRequestQueue()); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { + auto accessorPair = cfg.tcStore.getData(currentMessage.getStorageId()); + if (accessorPair.first != HasReturnvaluesIF::RETURN_OK) { + return accessorPair.first; + } + ReturnValue_t result = pduReader.setData(accessorPair.second.data(), accessorPair.second.size()); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = pduReader.parseData(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + cfdp::EntityId foundId; + pduReader.getDestId(foundId); + bool destFound = false; + for (const auto& dest : tcDestinations) { + if (dest.id == foundId) { + destId = dest.queueId; + destFound = true; + } + } + if (not destFound) { + // TODO: Warning and event? + return HasReturnvaluesIF::RETURN_FAILED; + } + // Packet was forwarded successfully, so do not delete it. + accessorPair.second.release(); + return HasReturnvaluesIF::RETURN_OK; +} + +const char* CfdpDistributor::getName() const { return "CFDP Router"; } + +uint32_t CfdpDistributor::getIdentifier() const { return 0; } + +MessageQueueId_t CfdpDistributor::getRequestQueue() const { return tcQueue->getId(); } diff --git a/src/fsfw/cfdp/CfdpRouter.h b/src/fsfw/cfdp/CfdpDistributor.h similarity index 70% rename from src/fsfw/cfdp/CfdpRouter.h rename to src/fsfw/cfdp/CfdpDistributor.h index 178f0177..cfb31f2b 100644 --- a/src/fsfw/cfdp/CfdpRouter.h +++ b/src/fsfw/cfdp/CfdpDistributor.h @@ -4,7 +4,7 @@ #include #include -#include "CfdpRouterIF.h" +#include "fsfw/cfdp/pdu/HeaderReader.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/tcdistribution/CfdpPacketChecker.h" #include "fsfw/tcdistribution/TcDistributorBase.h" @@ -13,22 +13,23 @@ #include "fsfw/tmtcservices/VerificationReporter.h" struct CfdpRouterCfg { - CfdpRouterCfg(object_id_t objectId, MessageQueueIF& tmQueue) - : objectId(objectId), tmQueue(tmQueue) {} + CfdpRouterCfg(object_id_t objectId, MessageQueueIF& tmQueue, StorageManagerIF& tcStore, + StorageManagerIF& tmStore) + : objectId(objectId), tmQueue(tmQueue), tcStore(tcStore), tmStore(tmStore) {} object_id_t objectId; MessageQueueIF& tmQueue; + StorageManagerIF& tcStore; + StorageManagerIF& tmStore; }; + /** * This will be the primary component to perform PDU forwading procedures. This includes forwarding * CFDP TC packets to registered source or destination handlers, and forwarding all telemetry * generated by them to registered TM sinks. * @ingroup tc_distribution */ -class CfdpRouter : public TcDistributorBase, - public CfdpRouterIF, - public AcceptsTelecommandsIF, - public AcceptsTelemetryIF { +class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF { public: /** * The ctor passes @c set_apid to the checker class and calls the @@ -38,17 +39,12 @@ class CfdpRouter : public TcDistributorBase, * @param setPacketSource Object ID of the source of TC packets. * Must implement CcsdsDistributorIF. */ - explicit CfdpRouter(CfdpRouterCfg cfg); + explicit CfdpDistributor(CfdpRouterCfg cfg); - ReturnValue_t performOperation(uint8_t opCode) override; - ReturnValue_t performTmHandling(); [[nodiscard]] const char* getName() const override; [[nodiscard]] uint32_t getIdentifier() const override; [[nodiscard]] MessageQueueId_t getRequestQueue() const override; - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override; - ReturnValue_t registerTmSink(cfdp::EntityId address, AcceptsTelemetryIF& tmDest) override; - ReturnValue_t registerTcDestination(cfdp::EntityId address, - AcceptsTelecommandsIF& tcDest) override; + ReturnValue_t registerTcDestination(const cfdp::EntityId& address, AcceptsTelecommandsIF& tcDest); protected: struct EntityInfo { @@ -58,13 +54,13 @@ class CfdpRouter : public TcDistributorBase, const char* name; MessageQueueId_t queueId; }; + HeaderReader pduReader; ReturnValue_t lastTcError = HasReturnvaluesIF::RETURN_OK; ReturnValue_t lastTmError = HasReturnvaluesIF::RETURN_OK; // I don't think a regular OBSW will have more than 1 or 2 of these destinations, so I think // it is okay to accept the overhead here - std::vector tmDestinations; std::vector tcDestinations; - MessageQueueIF& tmQueue; + CfdpRouterCfg cfg; ReturnValue_t selectDestination(MessageQueueId_t& destId) override; diff --git a/src/fsfw/cfdp/CfdpRouter.cpp b/src/fsfw/cfdp/CfdpRouter.cpp deleted file mode 100644 index dfe910e6..00000000 --- a/src/fsfw/cfdp/CfdpRouter.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "CfdpRouter.h" - -#include "fsfw/tcdistribution/definitions.h" - -CfdpRouter::CfdpRouter(CfdpRouterCfg cfg) : TcDistributorBase(cfg.objectId), tmQueue(cfg.tmQueue) {} - -ReturnValue_t CfdpRouter::registerTmSink(cfdp::EntityId address, AcceptsTelemetryIF& tmDest) { - for (const auto& dest : tmDestinations) { - if (dest.id == address) { - return HasReturnvaluesIF::RETURN_FAILED; - } - } - tmDestinations.emplace_back(address, tmDest.getName(), tmDest.getReportReceptionQueue()); - return HasReturnvaluesIF::RETURN_OK; -} -ReturnValue_t CfdpRouter::registerTcDestination(cfdp::EntityId address, - AcceptsTelecommandsIF& tcDest) { - for (const auto& dest : tcDestinations) { - if (dest.id == address) { - return HasReturnvaluesIF::RETURN_FAILED; - } - } - tcDestinations.emplace_back(address, tcDest.getName(), tcDest.getRequestQueue()); - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CfdpRouter::selectDestination(MessageQueueId_t& destId) { return 0; } - -const char* CfdpRouter::getName() const { return "CFDP Router"; } - -uint32_t CfdpRouter::getIdentifier() const { return 0; } - -MessageQueueId_t CfdpRouter::getRequestQueue() const { return tcQueue->getId(); } - -MessageQueueId_t CfdpRouter::getReportReceptionQueue(uint8_t virtualChannel) { - return tmQueue.getId(); -} - -ReturnValue_t CfdpRouter::performOperation(uint8_t opCode) { - lastTcError = TcDistributorBase::performOperation(opCode); - lastTmError = performTmHandling(); - if (lastTcError != HasReturnvaluesIF::RETURN_OK or lastTmError != HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t CfdpRouter::performTmHandling() { - ReturnValue_t status; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - for (status = tmQueue.receiveMessage(¤tMessage); status == RETURN_OK; - status = tmQueue.receiveMessage(¤tMessage)) { - ReturnValue_t packetResult = handlePacket(); - if (packetResult != HasReturnvaluesIF::RETURN_OK) { - result = packetResult; - triggerEvent(tmtcdistrib::HANDLE_PACKET_FAILED, packetResult, ccsds::PacketType::TM); - } - } - if (status == MessageQueueIF::EMPTY) { - return result; - } - return result; -} diff --git a/src/fsfw/cfdp/CfdpRouterIF.h b/src/fsfw/cfdp/CfdpRouterIF.h deleted file mode 100644 index 0c630407..00000000 --- a/src/fsfw/cfdp/CfdpRouterIF.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_ -#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_ - -#include "fsfw/cfdp/definitions.h" -#include "fsfw/cfdp/pdu/PduHeaderIF.h" -#include "fsfw/ipc/MessageQueueSenderIF.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" - -/** - * This interface allows CFDP Services to register themselves at a CFDP Distributor. - * @ingroup tc_distribution - */ -class CfdpRouterIF { - public: - /** - * The empty virtual destructor. - */ - virtual ~CfdpRouterIF() = default; - - virtual ReturnValue_t registerTmSink(cfdp::EntityId address, AcceptsTelemetryIF& tmDest) = 0; - /** - * With this method, Handlers can register themselves at the CFDP Distributor. - * @param handler A pointer to the registering Handler. - * @return - @c RETURN_OK on success, - * - @c RETURN_FAILED on failure. - */ - virtual ReturnValue_t registerTcDestination(cfdp::EntityId address, - AcceptsTelecommandsIF& tcDest) = 0; -}; - -#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_ */ diff --git a/src/fsfw/cfdp/pdu/HeaderReader.h b/src/fsfw/cfdp/pdu/HeaderReader.h index 1543a71b..67a0470a 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.h +++ b/src/fsfw/cfdp/pdu/HeaderReader.h @@ -25,6 +25,7 @@ struct PduHeaderFixedStruct { */ class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { public: + HeaderReader() = default; /** * Initialize a PDU header from raw data. This is a zero-copy implementation and #parseData * needs to be called to ensure the data is valid From 269a3052ca769a2931af62180b87823fe558b159 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Aug 2022 18:18:01 +0200 Subject: [PATCH 185/532] added stubs for source and dest handler --- src/fsfw/cfdp/CMakeLists.txt | 4 +++- src/fsfw/cfdp/CfdpDestHandler.cpp | 1 + src/fsfw/cfdp/CfdpDestHandler.h | 6 ++++++ src/fsfw/cfdp/CfdpSourceHandler.cpp | 1 + src/fsfw/cfdp/CfdpSourceHandler.h | 6 ++++++ 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/fsfw/cfdp/CfdpDestHandler.cpp create mode 100644 src/fsfw/cfdp/CfdpDestHandler.h create mode 100644 src/fsfw/cfdp/CfdpSourceHandler.cpp create mode 100644 src/fsfw/cfdp/CfdpSourceHandler.h diff --git a/src/fsfw/cfdp/CMakeLists.txt b/src/fsfw/cfdp/CMakeLists.txt index 9bd54fc8..3d35ea69 100644 --- a/src/fsfw/cfdp/CMakeLists.txt +++ b/src/fsfw/cfdp/CMakeLists.txt @@ -1,4 +1,6 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp) +target_sources( + ${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp + CfdpSourceHandler.cpp CfdpDestHandler.cpp) # CfdpDistributor.cpp CfdpHandler.cpp add_subdirectory(pdu) diff --git a/src/fsfw/cfdp/CfdpDestHandler.cpp b/src/fsfw/cfdp/CfdpDestHandler.cpp new file mode 100644 index 00000000..f3eb657a --- /dev/null +++ b/src/fsfw/cfdp/CfdpDestHandler.cpp @@ -0,0 +1 @@ +#include "CfdpDestHandler.h" diff --git a/src/fsfw/cfdp/CfdpDestHandler.h b/src/fsfw/cfdp/CfdpDestHandler.h new file mode 100644 index 00000000..69d40ed3 --- /dev/null +++ b/src/fsfw/cfdp/CfdpDestHandler.h @@ -0,0 +1,6 @@ +#ifndef FSFW_CFDP_CFDPDESTHANDLER_H +#define FSFW_CFDP_CFDPDESTHANDLER_H + +class CfdpDestHandler {}; + +#endif // FSFW_CFDP_CFDPDESTHANDLER_H diff --git a/src/fsfw/cfdp/CfdpSourceHandler.cpp b/src/fsfw/cfdp/CfdpSourceHandler.cpp new file mode 100644 index 00000000..c4b42d55 --- /dev/null +++ b/src/fsfw/cfdp/CfdpSourceHandler.cpp @@ -0,0 +1 @@ +#include "CfdpSourceHandler.h" diff --git a/src/fsfw/cfdp/CfdpSourceHandler.h b/src/fsfw/cfdp/CfdpSourceHandler.h new file mode 100644 index 00000000..b343a6ed --- /dev/null +++ b/src/fsfw/cfdp/CfdpSourceHandler.h @@ -0,0 +1,6 @@ +#ifndef FSFW_CFDP_CFDPSOURCEHANDLER_H +#define FSFW_CFDP_CFDPSOURCEHANDLER_H + +class CfdpSourceHandler {}; + +#endif // FSFW_CFDP_CFDPSOURCEHANDLER_H From fdb0cc0e4495ab458ba66816376cf55ccb29ccd8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Aug 2022 12:31:19 +0200 Subject: [PATCH 186/532] tweaks for CFDP distributor --- src/fsfw/cfdp/CfdpDistributor.cpp | 3 ++- src/fsfw/cfdp/CfdpDistributor.h | 8 +++----- src/fsfw/tcdistribution/CcsdsDistributor.cpp | 2 +- src/fsfw/tcdistribution/PusDistributor.cpp | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/fsfw/cfdp/CfdpDistributor.cpp b/src/fsfw/cfdp/CfdpDistributor.cpp index 14e0180c..0b522d2d 100644 --- a/src/fsfw/cfdp/CfdpDistributor.cpp +++ b/src/fsfw/cfdp/CfdpDistributor.cpp @@ -2,7 +2,8 @@ #include "fsfw/tcdistribution/definitions.h" -CfdpDistributor::CfdpDistributor(CfdpRouterCfg cfg) : TcDistributorBase(cfg.objectId), cfg(cfg) {} +CfdpDistributor::CfdpDistributor(CfdpRouterCfg cfg) + : TcDistributorBase(cfg.objectId, cfg.tcQueue), cfg(cfg) {} ReturnValue_t CfdpDistributor::registerTcDestination(const cfdp::EntityId& address, AcceptsTelecommandsIF& tcDest) { diff --git a/src/fsfw/cfdp/CfdpDistributor.h b/src/fsfw/cfdp/CfdpDistributor.h index cfb31f2b..bf66df5e 100644 --- a/src/fsfw/cfdp/CfdpDistributor.h +++ b/src/fsfw/cfdp/CfdpDistributor.h @@ -13,14 +13,12 @@ #include "fsfw/tmtcservices/VerificationReporter.h" struct CfdpRouterCfg { - CfdpRouterCfg(object_id_t objectId, MessageQueueIF& tmQueue, StorageManagerIF& tcStore, - StorageManagerIF& tmStore) - : objectId(objectId), tmQueue(tmQueue), tcStore(tcStore), tmStore(tmStore) {} + CfdpRouterCfg(object_id_t objectId, StorageManagerIF& tcStore, MessageQueueIF* tcQueue) + : objectId(objectId), tcStore(tcStore), tcQueue(tcQueue) {} object_id_t objectId; - MessageQueueIF& tmQueue; StorageManagerIF& tcStore; - StorageManagerIF& tmStore; + MessageQueueIF* tcQueue; }; /** diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp index 6932d2d3..a2080ea8 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -98,7 +98,7 @@ void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) { const char* reason = "Unknown reason"; if (result == tmtcdistrib::INVALID_CCSDS_VERSION) { reason = "Invalid CCSDS version"; - } else if (result == tcdistrib::INCOMPLETE_PACKET) { + } else if (result == tmtcdistrib::INCOMPLETE_PACKET) { reason = "Size missmatch between CCSDS data length and packet length"; } else if (result == tmtcdistrib::INVALID_APID) { reason = "No valid handler APID found"; diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index f719b50f..5384b34c 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -145,7 +145,7 @@ ReturnValue_t PusDistributor::initialize() { void PusDistributor::checkerFailurePrinter() const { #if FSFW_VERBOSE_LEVEL >= 1 const char* reason = "Unknown reason"; - if (tcStatus == tcdistrib::INCORRECT_CHECKSUM) { + if (tcStatus == tmtcdistrib::INCORRECT_CHECKSUM) { reason = "Checksum Error"; } else if (tcStatus == tmtcdistrib::INCORRECT_PRIMARY_HEADER) { reason = "Incorrect Primary Header"; From 65a47c7c5749fc4c6f1460feb58cca037763aef1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Aug 2022 12:34:54 +0200 Subject: [PATCH 187/532] add distributor test stub --- unittests/cfdp/CMakeLists.txt | 3 ++- unittests/cfdp/testAckPdu.cpp | 2 +- unittests/cfdp/testDistributor.cpp | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 unittests/cfdp/testDistributor.cpp diff --git a/unittests/cfdp/CMakeLists.txt b/unittests/cfdp/CMakeLists.txt index 9cc2726e..31acb186 100644 --- a/unittests/cfdp/CMakeLists.txt +++ b/unittests/cfdp/CMakeLists.txt @@ -11,4 +11,5 @@ target_sources( testMetadataPdu.cpp testFileData.cpp testCfdpHeader.cpp - testFileDirective.cpp) + testFileDirective.cpp + testDistributor.cpp) diff --git a/unittests/cfdp/testAckPdu.cpp b/unittests/cfdp/testAckPdu.cpp index 70451aa0..49c81803 100644 --- a/unittests/cfdp/testAckPdu.cpp +++ b/unittests/cfdp/testAckPdu.cpp @@ -5,7 +5,7 @@ #include "fsfw/cfdp/pdu/AckPduSerializer.h" #include "fsfw/globalfunctions/arrayprinter.h" -TEST_CASE("ACK PDU", "[AckPdu]") { +TEST_CASE("ACK PDU", "[cfdp][pdu]") { using namespace cfdp; ReturnValue_t result; std::array buf = {}; diff --git a/unittests/cfdp/testDistributor.cpp b/unittests/cfdp/testDistributor.cpp new file mode 100644 index 00000000..ba66f99a --- /dev/null +++ b/unittests/cfdp/testDistributor.cpp @@ -0,0 +1,5 @@ +#include + +TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { + +} \ No newline at end of file From 43fb6ef5cb96b153feae3f409eb4fbaf513f6fcd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Aug 2022 12:35:58 +0200 Subject: [PATCH 188/532] some tag replacements --- unittests/action/TestActionHelper.cpp | 2 +- unittests/container/RingBufferTest.cpp | 2 +- unittests/container/TestArrayList.cpp | 2 +- unittests/container/TestDynamicFifo.cpp | 2 +- unittests/container/TestFifo.cpp | 2 +- unittests/container/TestFixedArrayList.cpp | 2 +- unittests/container/TestFixedMap.cpp | 2 +- unittests/container/TestFixedOrderedMultimap.cpp | 2 +- unittests/container/TestPlacementFactory.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index a6eea048..30edf397 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -8,7 +8,7 @@ #include "mocks/MessageQueueMock.h" -TEST_CASE("Action Helper", "[ActionHelper]") { +TEST_CASE("Action Helper", "[action]") { ActionHelperOwnerMockBase testDhMock; // TODO: Setting another number here breaks the test. Find out why MessageQueueMock testMqMock(MessageQueueIF::NO_QUEUE); diff --git a/unittests/container/RingBufferTest.cpp b/unittests/container/RingBufferTest.cpp index edabfd55..e621731c 100644 --- a/unittests/container/RingBufferTest.cpp +++ b/unittests/container/RingBufferTest.cpp @@ -5,7 +5,7 @@ #include "CatchDefinitions.h" -TEST_CASE("Ring Buffer Test", "[RingBufferTest]") { +TEST_CASE("Ring Buffer Test", "[containers]") { uint8_t testData[13] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; uint8_t readBuffer[10] = {13, 13, 13, 13, 13, 13, 13, 13, 13, 13}; SimpleRingBuffer ringBuffer(10, false, 5); diff --git a/unittests/container/TestArrayList.cpp b/unittests/container/TestArrayList.cpp index 4daf59d4..2c0eefdf 100644 --- a/unittests/container/TestArrayList.cpp +++ b/unittests/container/TestArrayList.cpp @@ -8,7 +8,7 @@ /** * @brief Array List test */ -TEST_CASE("Array List", "[ArrayListTest]") { +TEST_CASE("Array List", "[containers]") { // perform set-up here ArrayList list(20); struct TestClass { diff --git a/unittests/container/TestDynamicFifo.cpp b/unittests/container/TestDynamicFifo.cpp index 6769c247..cd800677 100644 --- a/unittests/container/TestDynamicFifo.cpp +++ b/unittests/container/TestDynamicFifo.cpp @@ -6,7 +6,7 @@ #include "CatchDefinitions.h" -TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { +TEST_CASE("Dynamic Fifo Tests", "[containers]") { INFO("Dynamic Fifo Tests"); struct Test { uint64_t number1; diff --git a/unittests/container/TestFifo.cpp b/unittests/container/TestFifo.cpp index 0b4b41af..b173ac46 100644 --- a/unittests/container/TestFifo.cpp +++ b/unittests/container/TestFifo.cpp @@ -6,7 +6,7 @@ #include "CatchDefinitions.h" -TEST_CASE("Static Fifo Tests", "[TestFifo]") { +TEST_CASE("Static Fifo Tests", "[containers]") { INFO("Fifo Tests"); struct Test { uint64_t number1; diff --git a/unittests/container/TestFixedArrayList.cpp b/unittests/container/TestFixedArrayList.cpp index 6beb8d5d..06f52cc7 100644 --- a/unittests/container/TestFixedArrayList.cpp +++ b/unittests/container/TestFixedArrayList.cpp @@ -5,7 +5,7 @@ #include "CatchDefinitions.h" -TEST_CASE("FixedArrayList Tests", "[TestFixedArrayList]") { +TEST_CASE("FixedArrayList Tests", "[containers]") { INFO("FixedArrayList Tests"); using testList = FixedArrayList; testList list; diff --git a/unittests/container/TestFixedMap.cpp b/unittests/container/TestFixedMap.cpp index d3c65760..49cc0c35 100644 --- a/unittests/container/TestFixedMap.cpp +++ b/unittests/container/TestFixedMap.cpp @@ -7,7 +7,7 @@ template class FixedMap; -TEST_CASE("FixedMap Tests", "[TestFixedMap]") { +TEST_CASE("FixedMap Tests", "[containers]") { INFO("FixedMap Tests"); FixedMap map(30); diff --git a/unittests/container/TestFixedOrderedMultimap.cpp b/unittests/container/TestFixedOrderedMultimap.cpp index 88b32694..361f19dc 100644 --- a/unittests/container/TestFixedOrderedMultimap.cpp +++ b/unittests/container/TestFixedOrderedMultimap.cpp @@ -5,7 +5,7 @@ #include "CatchDefinitions.h" -TEST_CASE("FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { +TEST_CASE("FixedOrderedMultimap Tests", "[containers]") { INFO("FixedOrderedMultimap Tests"); FixedOrderedMultimap map(30); diff --git a/unittests/container/TestPlacementFactory.cpp b/unittests/container/TestPlacementFactory.cpp index 1333567e..d599c708 100644 --- a/unittests/container/TestPlacementFactory.cpp +++ b/unittests/container/TestPlacementFactory.cpp @@ -7,7 +7,7 @@ #include "CatchDefinitions.h" -TEST_CASE("PlacementFactory Tests", "[TestPlacementFactory]") { +TEST_CASE("PlacementFactory Tests", "[containers]") { INFO("PlacementFactory Tests"); LocalPool::LocalPoolConfig poolCfg = { From 37c60d1dd095647257238eeffd65ef53545c5902 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Aug 2022 12:41:05 +0200 Subject: [PATCH 189/532] add source and dest test stubs --- unittests/cfdp/CMakeLists.txt | 4 +++- unittests/cfdp/testDestHandler.cpp | 5 +++++ unittests/cfdp/testSourceHandler.cpp | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 unittests/cfdp/testDestHandler.cpp create mode 100644 unittests/cfdp/testSourceHandler.cpp diff --git a/unittests/cfdp/CMakeLists.txt b/unittests/cfdp/CMakeLists.txt index 31acb186..ac4672fa 100644 --- a/unittests/cfdp/CMakeLists.txt +++ b/unittests/cfdp/CMakeLists.txt @@ -12,4 +12,6 @@ target_sources( testFileData.cpp testCfdpHeader.cpp testFileDirective.cpp - testDistributor.cpp) + testDistributor.cpp + testDestHandler.cpp + testSourceHandler.cpp) diff --git a/unittests/cfdp/testDestHandler.cpp b/unittests/cfdp/testDestHandler.cpp new file mode 100644 index 00000000..fb09d595 --- /dev/null +++ b/unittests/cfdp/testDestHandler.cpp @@ -0,0 +1,5 @@ +#include + +TEST_CASE("CFDP Dest Handler", "[cfdp]") { + +} \ No newline at end of file diff --git a/unittests/cfdp/testSourceHandler.cpp b/unittests/cfdp/testSourceHandler.cpp new file mode 100644 index 00000000..5738fbba --- /dev/null +++ b/unittests/cfdp/testSourceHandler.cpp @@ -0,0 +1,5 @@ +#include + +TEST_CASE("CFDP Source Handler", "[cfdp]") { + +} \ No newline at end of file From 202d9341d8d7686259e7143e2c219a2e23736db0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Aug 2022 17:53:42 +0200 Subject: [PATCH 190/532] add CFDP unit tests --- src/fsfw/cfdp/CfdpDistributor.cpp | 4 +- src/fsfw/cfdp/CfdpDistributor.h | 8 ++-- src/fsfw/cfdp/pdu/CMakeLists.txt | 4 +- src/fsfw/cfdp/pdu/MetadataInfo.cpp | 42 +++++++++---------- src/fsfw/cfdp/pdu/MetadataInfo.h | 15 +++---- ...uSerializer.cpp => MetadataPduCreator.cpp} | 12 +++--- src/fsfw/cfdp/pdu/MetadataPduCreator.h | 22 ++++++++++ src/fsfw/cfdp/pdu/MetadataPduDeserializer.h | 17 -------- ...Deserializer.cpp => MetadataPduReader.cpp} | 7 ++-- src/fsfw/cfdp/pdu/MetadataPduReader.h | 17 ++++++++ src/fsfw/cfdp/pdu/MetadataPduSerializer.h | 22 ---------- src/fsfw/cfdp/pdu/PduConfig.h | 4 ++ unittests/cfdp/testDestHandler.cpp | 4 +- unittests/cfdp/testDistributor.cpp | 27 +++++++++++- unittests/cfdp/testMetadataPdu.cpp | 22 +++++----- unittests/cfdp/testSourceHandler.cpp | 4 +- 16 files changed, 128 insertions(+), 103 deletions(-) rename src/fsfw/cfdp/pdu/{MetadataPduSerializer.cpp => MetadataPduCreator.cpp} (77%) create mode 100644 src/fsfw/cfdp/pdu/MetadataPduCreator.h delete mode 100644 src/fsfw/cfdp/pdu/MetadataPduDeserializer.h rename src/fsfw/cfdp/pdu/{MetadataPduDeserializer.cpp => MetadataPduReader.cpp} (87%) create mode 100644 src/fsfw/cfdp/pdu/MetadataPduReader.h delete mode 100644 src/fsfw/cfdp/pdu/MetadataPduSerializer.h diff --git a/src/fsfw/cfdp/CfdpDistributor.cpp b/src/fsfw/cfdp/CfdpDistributor.cpp index 0b522d2d..4aa9c797 100644 --- a/src/fsfw/cfdp/CfdpDistributor.cpp +++ b/src/fsfw/cfdp/CfdpDistributor.cpp @@ -2,7 +2,7 @@ #include "fsfw/tcdistribution/definitions.h" -CfdpDistributor::CfdpDistributor(CfdpRouterCfg cfg) +CfdpDistributor::CfdpDistributor(CfdpDistribCfg cfg) : TcDistributorBase(cfg.objectId, cfg.tcQueue), cfg(cfg) {} ReturnValue_t CfdpDistributor::registerTcDestination(const cfdp::EntityId& address, @@ -47,7 +47,7 @@ ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { return HasReturnvaluesIF::RETURN_OK; } -const char* CfdpDistributor::getName() const { return "CFDP Router"; } +const char* CfdpDistributor::getName() const { return "CFDP Distributor"; } uint32_t CfdpDistributor::getIdentifier() const { return 0; } diff --git a/src/fsfw/cfdp/CfdpDistributor.h b/src/fsfw/cfdp/CfdpDistributor.h index bf66df5e..8fece981 100644 --- a/src/fsfw/cfdp/CfdpDistributor.h +++ b/src/fsfw/cfdp/CfdpDistributor.h @@ -12,8 +12,8 @@ #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/VerificationReporter.h" -struct CfdpRouterCfg { - CfdpRouterCfg(object_id_t objectId, StorageManagerIF& tcStore, MessageQueueIF* tcQueue) +struct CfdpDistribCfg { + CfdpDistribCfg(object_id_t objectId, StorageManagerIF& tcStore, MessageQueueIF* tcQueue) : objectId(objectId), tcStore(tcStore), tcQueue(tcQueue) {} object_id_t objectId; @@ -37,7 +37,7 @@ class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF { * @param setPacketSource Object ID of the source of TC packets. * Must implement CcsdsDistributorIF. */ - explicit CfdpDistributor(CfdpRouterCfg cfg); + explicit CfdpDistributor(CfdpDistribCfg cfg); [[nodiscard]] const char* getName() const override; [[nodiscard]] uint32_t getIdentifier() const override; @@ -58,7 +58,7 @@ class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF { // I don't think a regular OBSW will have more than 1 or 2 of these destinations, so I think // it is okay to accept the overhead here std::vector tcDestinations; - CfdpRouterCfg cfg; + CfdpDistribCfg cfg; ReturnValue_t selectDestination(MessageQueueId_t& destId) override; diff --git a/src/fsfw/cfdp/pdu/CMakeLists.txt b/src/fsfw/cfdp/pdu/CMakeLists.txt index 21fe0820..33b05eec 100644 --- a/src/fsfw/cfdp/pdu/CMakeLists.txt +++ b/src/fsfw/cfdp/pdu/CMakeLists.txt @@ -19,8 +19,8 @@ target_sources( FinishedPduSerializer.cpp FinishedPduDeserializer.cpp MetadataInfo.cpp - MetadataPduSerializer.cpp - MetadataPduDeserializer.cpp + MetadataPduCreator.cpp + MetadataPduReader.cpp KeepAlivePduSerializer.cpp KeepAlivePduDeserializer.cpp PromptPduSerializer.cpp diff --git a/src/fsfw/cfdp/pdu/MetadataInfo.cpp b/src/fsfw/cfdp/pdu/MetadataInfo.cpp index a2ca6972..5f66b776 100644 --- a/src/fsfw/cfdp/pdu/MetadataInfo.cpp +++ b/src/fsfw/cfdp/pdu/MetadataInfo.cpp @@ -9,41 +9,41 @@ MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumTyp sourceFileName(sourceFileName), destFileName(destFileName) {} -void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray, size_t* optionsLen, - size_t* maxOptionsLen) { - this->optionsArray = optionsArray; - if (maxOptionsLen != nullptr) { - this->maxOptionsLen = *maxOptionsLen; +void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray_, const size_t* optionsLen_, + const size_t* maxOptionsLen_) { + this->optionsArray = optionsArray_; + if (maxOptionsLen_ != nullptr) { + this->maxOptionsLen = *maxOptionsLen_; } - if (optionsLen != nullptr) { - this->optionsLen = *optionsLen; + if (optionsLen_ != nullptr) { + this->optionsLen = *optionsLen_; } } cfdp::ChecksumType MetadataInfo::getChecksumType() const { return checksumType; } -void MetadataInfo::setChecksumType(cfdp::ChecksumType checksumType) { - this->checksumType = checksumType; +void MetadataInfo::setChecksumType(cfdp::ChecksumType checksumType_) { + checksumType = checksumType_; } bool MetadataInfo::isClosureRequested() const { return closureRequested; } -void MetadataInfo::setClosureRequested(bool closureRequested) { - this->closureRequested = closureRequested; +void MetadataInfo::setClosureRequested(bool closureRequested_) { + closureRequested = closureRequested_; } cfdp::Lv& MetadataInfo::getDestFileName() { return destFileName; } cfdp::FileSize& MetadataInfo::getFileSize() { return fileSize; } -ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray, size_t* optionsLen, +ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray_, size_t* optionsLen_, size_t* maxOptsLen) { - if (optionsArray == nullptr or this->optionsArray == nullptr) { + if (optionsArray_ == nullptr or optionsArray == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } - *optionsArray = this->optionsArray; - if (optionsLen != nullptr) { - *optionsLen = this->optionsLen; + *optionsArray_ = optionsArray; + if (optionsLen_ != nullptr) { + *optionsLen_ = this->optionsLen; } if (maxOptsLen != nullptr) { *maxOptsLen = this->maxOptionsLen; @@ -81,18 +81,18 @@ size_t MetadataInfo::getSerializedSize(bool fssLarge) { return size; } -void MetadataInfo::setDestFileName(cfdp::Lv& destFileName) { this->destFileName = destFileName; } +void MetadataInfo::setDestFileName(cfdp::Lv& destFileName_) { this->destFileName = destFileName_; } -void MetadataInfo::setSourceFileName(cfdp::Lv& sourceFileName) { - this->sourceFileName = sourceFileName; +void MetadataInfo::setSourceFileName(cfdp::Lv& sourceFileName_) { + this->sourceFileName = sourceFileName_; } size_t MetadataInfo::getMaxOptionsLen() const { return maxOptionsLen; } -void MetadataInfo::setMaxOptionsLen(size_t maxOptionsLen) { this->maxOptionsLen = maxOptionsLen; } +void MetadataInfo::setMaxOptionsLen(size_t maxOptionsLen_) { this->maxOptionsLen = maxOptionsLen_; } size_t MetadataInfo::getOptionsLen() const { return optionsLen; } -void MetadataInfo::setOptionsLen(size_t optionsLen) { this->optionsLen = optionsLen; } +void MetadataInfo::setOptionsLen(size_t optionsLen_) { this->optionsLen = optionsLen_; } cfdp::Lv& MetadataInfo::getSourceFileName() { return sourceFileName; } diff --git a/src/fsfw/cfdp/pdu/MetadataInfo.h b/src/fsfw/cfdp/pdu/MetadataInfo.h index 9b90138c..f71eb2f4 100644 --- a/src/fsfw/cfdp/pdu/MetadataInfo.h +++ b/src/fsfw/cfdp/pdu/MetadataInfo.h @@ -13,10 +13,11 @@ class MetadataInfo { size_t getSerializedSize(bool fssLarge = false); - void setOptionsArray(cfdp::Tlv** optionsArray, size_t* optionsLen, size_t* maxOptionsLen); - cfdp::ChecksumType getChecksumType() const; + void setOptionsArray(cfdp::Tlv** optionsArray, const size_t* optionsLen, + const size_t* maxOptionsLen); + [[nodiscard]] cfdp::ChecksumType getChecksumType() const; void setChecksumType(cfdp::ChecksumType checksumType); - bool isClosureRequested() const; + [[nodiscard]] bool isClosureRequested() const; void setClosureRequested(bool closureRequested = false); void setDestFileName(cfdp::Lv& destFileName); @@ -26,13 +27,13 @@ class MetadataInfo { cfdp::Lv& getSourceFileName(); cfdp::FileSize& getFileSize(); - bool hasOptions() const; - bool canHoldOptions() const; + [[nodiscard]] bool hasOptions() const; + [[nodiscard]] bool canHoldOptions() const; ReturnValue_t getOptions(cfdp::Tlv*** optionsArray, size_t* optionsLen, size_t* maxOptsLen); void setOptionsLen(size_t optionsLen); - size_t getOptionsLen() const; + [[nodiscard]] size_t getOptionsLen() const; void setMaxOptionsLen(size_t maxOptionsLen); - size_t getMaxOptionsLen() const; + [[nodiscard]] size_t getMaxOptionsLen() const; private: bool closureRequested = false; diff --git a/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp b/src/fsfw/cfdp/pdu/MetadataPduCreator.cpp similarity index 77% rename from src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp rename to src/fsfw/cfdp/pdu/MetadataPduCreator.cpp index a08b3214..5dcdabd2 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduCreator.cpp @@ -1,20 +1,20 @@ -#include "MetadataPduSerializer.h" +#include "MetadataPduCreator.h" -MetadataPduSerializer::MetadataPduSerializer(PduConfig &conf, MetadataInfo &info) +MetadataPduCreator::MetadataPduCreator(PduConfig &conf, MetadataInfo &info) : FileDirectiveCreator(conf, cfdp::FileDirectives::METADATA, 5), info(info) { updateDirectiveFieldLen(); } -void MetadataPduSerializer::updateDirectiveFieldLen() { +void MetadataPduCreator::updateDirectiveFieldLen() { setDirectiveDataFieldLen(info.getSerializedSize(getLargeFileFlag())); } -size_t MetadataPduSerializer::getSerializedSize() const { +size_t MetadataPduCreator::getSerializedSize() const { return FileDirectiveCreator::getWholePduSize(); } -ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const { +ReturnValue_t MetadataPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; diff --git a/src/fsfw/cfdp/pdu/MetadataPduCreator.h b/src/fsfw/cfdp/pdu/MetadataPduCreator.h new file mode 100644 index 00000000..2c2f35f8 --- /dev/null +++ b/src/fsfw/cfdp/pdu/MetadataPduCreator.h @@ -0,0 +1,22 @@ +#ifndef FSFW_CFDP_PDU_METADATAPDUCREATOR_H_ +#define FSFW_CFDP_PDU_METADATAPDUCREATOR_H_ + +#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" +#include "fsfw/cfdp/pdu/MetadataInfo.h" + +class MetadataPduCreator : public FileDirectiveCreator { + public: + MetadataPduCreator(PduConfig& conf, MetadataInfo& info); + + void updateDirectiveFieldLen(); + + [[nodiscard]] size_t getSerializedSize() const override; + + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const override; + + private: + MetadataInfo& info; +}; + +#endif /* FSFW_CFDP_PDU_METADATAPDUCREATOR_H_ */ diff --git a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.h b/src/fsfw/cfdp/pdu/MetadataPduDeserializer.h deleted file mode 100644 index dcbb2c55..00000000 --- a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_ -#define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_ - -#include "fsfw/cfdp/pdu/FileDirectiveReader.h" -#include "fsfw/cfdp/pdu/MetadataInfo.h" - -class MetadataPduDeserializer : public FileDirectiveReader { - public: - MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info); - - ReturnValue_t parseData() override; - - private: - MetadataInfo& info; -}; - -#endif /* FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp similarity index 87% rename from src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp rename to src/fsfw/cfdp/pdu/MetadataPduReader.cpp index 00111303..29dc2e15 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp @@ -1,10 +1,9 @@ -#include "MetadataPduDeserializer.h" +#include "MetadataPduReader.h" -MetadataPduDeserializer::MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize, - MetadataInfo& info) +MetadataPduReader::MetadataPduReader(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info) : FileDirectiveReader(pduBuf, maxSize), info(info) {} -ReturnValue_t MetadataPduDeserializer::parseData() { +ReturnValue_t MetadataPduReader::parseData() { ReturnValue_t result = FileDirectiveReader::parseData(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; diff --git a/src/fsfw/cfdp/pdu/MetadataPduReader.h b/src/fsfw/cfdp/pdu/MetadataPduReader.h new file mode 100644 index 00000000..3e8c0f30 --- /dev/null +++ b/src/fsfw/cfdp/pdu/MetadataPduReader.h @@ -0,0 +1,17 @@ +#ifndef FSFW_CFDP_PDU_METADATAPDUREADER_H_ +#define FSFW_CFDP_PDU_METADATAPDUREADER_H_ + +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" +#include "fsfw/cfdp/pdu/MetadataInfo.h" + +class MetadataPduReader : public FileDirectiveReader { + public: + MetadataPduReader(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info); + + ReturnValue_t parseData() override; + + private: + MetadataInfo& info; +}; + +#endif /* FSFW_CFDP_PDU_METADATAPDUREADER_H_ */ diff --git a/src/fsfw/cfdp/pdu/MetadataPduSerializer.h b/src/fsfw/cfdp/pdu/MetadataPduSerializer.h deleted file mode 100644 index a6514783..00000000 --- a/src/fsfw/cfdp/pdu/MetadataPduSerializer.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_ -#define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_ - -#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" -#include "fsfw/cfdp/pdu/MetadataInfo.h" - -class MetadataPduSerializer : public FileDirectiveCreator { - public: - MetadataPduSerializer(PduConfig& conf, MetadataInfo& info); - - void updateDirectiveFieldLen(); - - size_t getSerializedSize() const override; - - ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const override; - - private: - MetadataInfo& info; -}; - -#endif /* FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/PduConfig.h b/src/fsfw/cfdp/pdu/PduConfig.h index f92b25fc..858176ff 100644 --- a/src/fsfw/cfdp/pdu/PduConfig.h +++ b/src/fsfw/cfdp/pdu/PduConfig.h @@ -8,12 +8,16 @@ namespace cfdp { struct EntityId : public VarLenField { public: EntityId() : VarLenField() {} + template + explicit EntityId(UnsignedByteField byteField) : VarLenField(byteField) {} EntityId(cfdp::WidthInBytes width, size_t entityId) : VarLenField(width, entityId) {} }; struct TransactionSeqNum : public VarLenField { public: TransactionSeqNum() : VarLenField() {} + template + explicit TransactionSeqNum(UnsignedByteField byteField) : VarLenField(byteField) {} TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {} }; diff --git a/unittests/cfdp/testDestHandler.cpp b/unittests/cfdp/testDestHandler.cpp index fb09d595..bb2a5ac4 100644 --- a/unittests/cfdp/testDestHandler.cpp +++ b/unittests/cfdp/testDestHandler.cpp @@ -1,5 +1,3 @@ #include -TEST_CASE("CFDP Dest Handler", "[cfdp]") { - -} \ No newline at end of file +TEST_CASE("CFDP Dest Handler", "[cfdp]") {} \ No newline at end of file diff --git a/unittests/cfdp/testDistributor.cpp b/unittests/cfdp/testDistributor.cpp index ba66f99a..4b8be8fe 100644 --- a/unittests/cfdp/testDistributor.cpp +++ b/unittests/cfdp/testDistributor.cpp @@ -1,5 +1,30 @@ #include -TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { +#include "fsfw/cfdp/CfdpDistributor.h" +#include "fsfw/cfdp/pdu/MetadataPduCreator.h" +#include "fsfw/storagemanager/LocalPool.h" +#include "mocks/AcceptsTcMock.h" +#include "mocks/MessageQueueMock.h" +TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { + LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; + LocalPool pool(objects::NO_OBJECT, cfg); + auto queue = MessageQueueMock(1); + CfdpDistribCfg distribCfg(1, pool, &queue); + auto distributor = CfdpDistributor(distribCfg); + auto entityId = cfdp::EntityId(UnsignedByteField(2)); + MessageQueueId_t acceptorQueueId = 3; + auto tcAcceptor = AcceptsTcMock("TC Acceptor", 0, acceptorQueueId); + SECTION("State") { + CHECK(distributor.initialize() == result::OK); + CHECK(std::strcmp(distributor.getName(), "CFDP Distributor") == 0); + CHECK(distributor.getIdentifier() == 0); + CHECK(distributor.getRequestQueue() == queue.getId()); + } + + SECTION("Register Listener") { + CHECK(distributor.initialize() == result::OK); + CHECK(distributor.registerTcDestination(entityId, tcAcceptor)); + // queue.addReceivedMessage() + } } \ No newline at end of file diff --git a/unittests/cfdp/testMetadataPdu.cpp b/unittests/cfdp/testMetadataPdu.cpp index b54d8f79..0992a3c2 100644 --- a/unittests/cfdp/testMetadataPdu.cpp +++ b/unittests/cfdp/testMetadataPdu.cpp @@ -3,8 +3,8 @@ #include #include -#include "fsfw/cfdp/pdu/MetadataPduDeserializer.h" -#include "fsfw/cfdp/pdu/MetadataPduSerializer.h" +#include "fsfw/cfdp/pdu/MetadataPduCreator.h" +#include "fsfw/cfdp/pdu/MetadataPduReader.h" #include "fsfw/cfdp/tlv/FilestoreResponseTlv.h" #include "fsfw/globalfunctions/arrayprinter.h" @@ -39,7 +39,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { REQUIRE(options[1]->getSerializedSize() == 5); SECTION("Serialize") { - MetadataPduSerializer serializer(pduConf, info); + MetadataPduCreator serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(serializer.getWholePduSize() == 27); @@ -72,7 +72,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { otherFileName.size()); info.setSourceFileName(otherFileNameLv); size_t sizeOfOptions = options.size(); - info.setOptionsArray(options.data(), &sizeOfOptions, &sizeOfOptions); + info.setOptionsArray(*options.data(), &sizeOfOptions, &sizeOfOptions); REQUIRE(info.getMaxOptionsLen() == 2); info.setMaxOptionsLen(3); REQUIRE(info.getMaxOptionsLen() == 3); @@ -115,22 +115,22 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { } SECTION("Deserialize") { - MetadataPduSerializer serializer(pduConf, info); + MetadataPduCreator serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - MetadataPduDeserializer deserializer(mdBuffer.data(), mdBuffer.size(), info); + MetadataPduReader deserializer(mdBuffer.data(), mdBuffer.size(), info); result = deserializer.parseData(); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); size_t fullSize = deserializer.getWholePduSize(); for (size_t maxSz = 0; maxSz < fullSize; maxSz++) { - MetadataPduDeserializer invalidSzDeser(mdBuffer.data(), maxSz, info); + MetadataPduReader invalidSzDeser(mdBuffer.data(), maxSz, info); result = invalidSzDeser.parseData(); REQUIRE(result != HasReturnvaluesIF::RETURN_OK); } size_t sizeOfOptions = options.size(); size_t maxSize = 4; - info.setOptionsArray(options.data(), &sizeOfOptions, &maxSize); + info.setOptionsArray(reinterpret_cast(options.data()), &sizeOfOptions, &maxSize); REQUIRE(info.getOptionsLen() == 2); info.setChecksumType(cfdp::ChecksumType::CRC_32C); info.setClosureRequested(true); @@ -142,7 +142,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - MetadataPduDeserializer deserializer2(mdBuffer.data(), mdBuffer.size(), info); + MetadataPduReader deserializer2(mdBuffer.data(), mdBuffer.size(), info); result = deserializer2.parseData(); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(options[0]->getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); @@ -169,9 +169,9 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { mdBuffer[2] = 36 & 0xff; info.setOptionsArray(nullptr, nullptr, nullptr); REQUIRE(deserializer2.parseData() == cfdp::METADATA_CANT_PARSE_OPTIONS); - info.setOptionsArray(options.data(), &sizeOfOptions, nullptr); + info.setOptionsArray(reinterpret_cast(options.data()), &sizeOfOptions, nullptr); for (size_t maxSz = 0; maxSz < 46; maxSz++) { - MetadataPduDeserializer invalidSzDeser(mdBuffer.data(), maxSz, info); + MetadataPduReader invalidSzDeser(mdBuffer.data(), maxSz, info); result = invalidSzDeser.parseData(); REQUIRE(result == SerializeIF::STREAM_TOO_SHORT); } diff --git a/unittests/cfdp/testSourceHandler.cpp b/unittests/cfdp/testSourceHandler.cpp index 5738fbba..570ecb08 100644 --- a/unittests/cfdp/testSourceHandler.cpp +++ b/unittests/cfdp/testSourceHandler.cpp @@ -1,5 +1,3 @@ #include -TEST_CASE("CFDP Source Handler", "[cfdp]") { - -} \ No newline at end of file +TEST_CASE("CFDP Source Handler", "[cfdp]") {} \ No newline at end of file From 904abfba28f55d4f2985c81cf8954e92015db321 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Aug 2022 18:29:32 +0200 Subject: [PATCH 191/532] clean up CFDP stack a bit --- src/fsfw/cfdp/FileSize.h | 12 ++--- src/fsfw/cfdp/pdu/AckPduDeserializer.cpp | 2 +- src/fsfw/cfdp/pdu/EofPduDeserializer.cpp | 2 +- src/fsfw/cfdp/pdu/FileDataReader.cpp | 2 +- src/fsfw/cfdp/pdu/FileDirectiveReader.cpp | 4 +- src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp | 2 +- src/fsfw/cfdp/pdu/HeaderReader.cpp | 54 ++++++++++--------- src/fsfw/cfdp/pdu/HeaderReader.h | 11 +++- .../cfdp/pdu/KeepAlivePduDeserializer.cpp | 2 +- src/fsfw/cfdp/pdu/MetadataPduReader.cpp | 2 +- src/fsfw/cfdp/pdu/NakPduDeserializer.cpp | 2 +- src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp | 2 +- src/fsfw/cfdp/tlv/Lv.cpp | 7 +++ src/fsfw/cfdp/tlv/Lv.h | 3 +- src/fsfw/storagemanager/LocalPool.h | 2 +- unittests/cfdp/testDistributor.cpp | 28 ++++++++-- unittests/cfdp/testMetadataPdu.cpp | 8 +-- unittests/cfdp/testTlvsLvs.cpp | 4 +- 18 files changed, 96 insertions(+), 53 deletions(-) diff --git a/src/fsfw/cfdp/FileSize.h b/src/fsfw/cfdp/FileSize.h index 6dae9683..521d5a6f 100644 --- a/src/fsfw/cfdp/FileSize.h +++ b/src/fsfw/cfdp/FileSize.h @@ -1,5 +1,5 @@ -#ifndef FSFW_SRC_FSFW_CFDP_FILESIZE_H_ -#define FSFW_SRC_FSFW_CFDP_FILESIZE_H_ +#ifndef FSFW_CFDP_FILESIZE_H_ +#define FSFW_CFDP_FILESIZE_H_ #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serialize/SerializeIF.h" @@ -10,7 +10,7 @@ struct FileSize : public SerializeIF { public: FileSize() : largeFile(false){}; - FileSize(uint64_t fileSize, bool isLarge = false) { setFileSize(fileSize, isLarge); }; + explicit FileSize(uint64_t fileSize, bool isLarge = false) { setFileSize(fileSize, isLarge); }; ReturnValue_t serialize(bool isLarge, uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) { @@ -27,7 +27,7 @@ struct FileSize : public SerializeIF { return SerializeAdapter::serialize(&fileSize, buffer, size, maxSize, streamEndianness); } - size_t getSerializedSize() const override { + [[nodiscard]] size_t getSerializedSize() const override { if (largeFile) { return 8; } else { @@ -60,7 +60,7 @@ struct FileSize : public SerializeIF { return HasReturnvaluesIF::RETURN_OK; } - bool isLargeFile() const { return largeFile; } + [[nodiscard]] bool isLargeFile() const { return largeFile; } uint64_t getSize(bool *largeFile = nullptr) const { if (largeFile != nullptr) { *largeFile = this->largeFile; @@ -75,4 +75,4 @@ struct FileSize : public SerializeIF { } // namespace cfdp -#endif /* FSFW_SRC_FSFW_CFDP_FILESIZE_H_ */ +#endif /* FSFW_CFDP_FILESIZE_H_ */ diff --git a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp index 1217344e..9d7c981d 100644 --- a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp @@ -12,7 +12,7 @@ ReturnValue_t AckPduDeserializer::parseData() { if (currentIdx + 2 > this->maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } - if (not checkAndSetCodes(rawPtr[currentIdx], rawPtr[currentIdx + 1])) { + if (not checkAndSetCodes(pointers.rawPtr[currentIdx], pointers.rawPtr[currentIdx + 1])) { return cfdp::INVALID_ACK_DIRECTIVE_FIELDS; } return HasReturnvaluesIF::RETURN_OK; diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp index e532419f..4de67a0e 100644 --- a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp @@ -12,7 +12,7 @@ ReturnValue_t EofPduDeserializer::parseData() { return result; } - const uint8_t* bufPtr = rawPtr; + const uint8_t* bufPtr = pointers.rawPtr; size_t expectedFileFieldLen = 4; if (this->getLargeFileFlag()) { expectedFileFieldLen = 8; diff --git a/src/fsfw/cfdp/pdu/FileDataReader.cpp b/src/fsfw/cfdp/pdu/FileDataReader.cpp index 30581da4..e620636f 100644 --- a/src/fsfw/cfdp/pdu/FileDataReader.cpp +++ b/src/fsfw/cfdp/pdu/FileDataReader.cpp @@ -9,7 +9,7 @@ ReturnValue_t FileDataReader::parseData() { return result; } size_t currentIdx = HeaderReader::getHeaderSize(); - const uint8_t* buf = rawPtr + currentIdx; + const uint8_t* buf = pointers.rawPtr + currentIdx; size_t remSize = HeaderReader::getWholePduSize() - currentIdx; if (remSize < 1) { return SerializeIF::STREAM_TOO_SHORT; diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp index d51846b8..bc06a9d7 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp @@ -17,10 +17,10 @@ ReturnValue_t FileDirectiveReader::parseData() { return SerializeIF::STREAM_TOO_SHORT; } size_t currentIdx = HeaderReader::getHeaderSize(); - if (not checkFileDirective(rawPtr[currentIdx])) { + if (not checkFileDirective(pointers.rawPtr[currentIdx])) { return cfdp::INVALID_DIRECTIVE_FIELDS; } - setFileDirective(static_cast(rawPtr[currentIdx])); + setFileDirective(static_cast(pointers.rawPtr[currentIdx])); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp index 4209af65..7776778b 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp @@ -10,7 +10,7 @@ ReturnValue_t FinishPduDeserializer::parseData() { return result; } size_t currentIdx = FileDirectiveReader::getHeaderSize(); - const uint8_t* buf = rawPtr + currentIdx; + const uint8_t* buf = pointers.rawPtr + currentIdx; size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx; if (remSize < 1) { return SerializeIF::STREAM_TOO_SHORT; diff --git a/src/fsfw/cfdp/pdu/HeaderReader.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp index cd8667b2..c946ce27 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.cpp +++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp @@ -4,41 +4,42 @@ #include -HeaderReader::HeaderReader(const uint8_t *pduBuf, size_t maxSize) - : rawPtr(pduBuf), maxSize(maxSize) {} +HeaderReader::HeaderReader(const uint8_t *pduBuf, size_t maxSize) { setData(pduBuf, maxSize); } ReturnValue_t HeaderReader::parseData() { + if (isNull()) { + return HasReturnvaluesIF::RETURN_FAILED; + } if (maxSize < 7) { return SerializeIF::STREAM_TOO_SHORT; } - return setData(const_cast(rawPtr), maxSize); -} - -ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) { - if (dataPtr == nullptr) { - // Allowed for now - this->fixedHeader = nullptr; - return HasReturnvaluesIF::RETURN_OK; - } - this->fixedHeader = reinterpret_cast(const_cast(dataPtr)); - sourceIdRaw = static_cast(&fixedHeader->variableFieldsStart); + sourceIdRaw = static_cast(&pointers.fixedHeader->variableFieldsStart); cfdp::WidthInBytes widthEntityIds = getLenEntityIds(); cfdp::WidthInBytes widthSeqNum = getLenSeqNum(); seqNumRaw = static_cast(sourceIdRaw) + static_cast(widthEntityIds); destIdRaw = static_cast(seqNumRaw) + static_cast(widthSeqNum); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) { + if (maxSize_ < 7) { + return SerializeIF::STREAM_TOO_SHORT; + } + pointers.rawPtr = dataPtr; + pointers.fixedHeader = reinterpret_cast(const_cast(dataPtr)); maxSize = maxSize_; return HasReturnvaluesIF::RETURN_OK; } size_t HeaderReader::getHeaderSize() const { - if (fixedHeader != nullptr) { + if (pointers.fixedHeader != nullptr) { return getLenEntityIds() * 2 + getLenSeqNum() + 4; } return 0; } size_t HeaderReader::getPduDataFieldLen() const { - return (fixedHeader->pduDataFieldLenH << 8) | fixedHeader->pduDataFieldLenL; + return (pointers.fixedHeader->pduDataFieldLenH << 8) | pointers.fixedHeader->pduDataFieldLenL; } size_t HeaderReader::getWholePduSize() const { @@ -46,35 +47,35 @@ size_t HeaderReader::getWholePduSize() const { } cfdp::PduType HeaderReader::getPduType() const { - return static_cast((fixedHeader->firstByte >> 4) & 0x01); + return static_cast((pointers.fixedHeader->firstByte >> 4) & 0x01); } cfdp::Direction HeaderReader::getDirection() const { - return static_cast((fixedHeader->firstByte >> 3) & 0x01); + return static_cast((pointers.fixedHeader->firstByte >> 3) & 0x01); } cfdp::TransmissionModes HeaderReader::getTransmissionMode() const { - return static_cast((fixedHeader->firstByte >> 2) & 0x01); + return static_cast((pointers.fixedHeader->firstByte >> 2) & 0x01); } -bool HeaderReader::getCrcFlag() const { return (fixedHeader->firstByte >> 1) & 0x01; } +bool HeaderReader::getCrcFlag() const { return (pointers.fixedHeader->firstByte >> 1) & 0x01; } -bool HeaderReader::getLargeFileFlag() const { return fixedHeader->firstByte & 0x01; } +bool HeaderReader::getLargeFileFlag() const { return pointers.fixedHeader->firstByte & 0x01; } cfdp::SegmentationControl HeaderReader::getSegmentationControl() const { - return static_cast((fixedHeader->fourthByte >> 7) & 0x01); + return static_cast((pointers.fixedHeader->fourthByte >> 7) & 0x01); } cfdp::WidthInBytes HeaderReader::getLenEntityIds() const { - return static_cast((fixedHeader->fourthByte >> 4) & 0x07); + return static_cast((pointers.fixedHeader->fourthByte >> 4) & 0x07); } cfdp::WidthInBytes HeaderReader::getLenSeqNum() const { - return static_cast(fixedHeader->fourthByte & 0x07); + return static_cast(pointers.fixedHeader->fourthByte & 0x07); } cfdp::SegmentMetadataFlag HeaderReader::getSegmentMetadataFlag() const { - return static_cast((fixedHeader->fourthByte >> 3) & 0x01); + return static_cast((pointers.fixedHeader->fourthByte >> 3) & 0x01); } void HeaderReader::getSourceId(cfdp::EntityId &sourceId) const { @@ -129,3 +130,8 @@ bool HeaderReader::hasSegmentMetadataFlag() const { ReturnValue_t HeaderReader::setData(const uint8_t *dataPtr, size_t maxSize_) { return setData(const_cast(dataPtr), maxSize_, nullptr); } +bool HeaderReader::isNull() const { + return pointers.rawPtr == nullptr or pointers.fixedHeader == nullptr; +} + +HeaderReader::operator bool() const { return isNull(); } diff --git a/src/fsfw/cfdp/pdu/HeaderReader.h b/src/fsfw/cfdp/pdu/HeaderReader.h index 67a0470a..a973a12e 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.h +++ b/src/fsfw/cfdp/pdu/HeaderReader.h @@ -42,6 +42,9 @@ class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { * - SerializeIF::BUFFER_TOO_SHORT if buffer is shorter than expected */ virtual ReturnValue_t parseData(); + explicit operator bool() const; + [[nodiscard]] bool isNull() const; + [[nodiscard]] virtual size_t getHeaderSize() const; [[nodiscard]] size_t getPduDataFieldLen() const override; @@ -77,8 +80,12 @@ class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { ReturnValue_t setData(const uint8_t* dataPtr, size_t maxSize); protected: - PduHeaderFixedStruct* fixedHeader = nullptr; - const uint8_t* rawPtr = nullptr; + struct Pointers { + PduHeaderFixedStruct* fixedHeader = nullptr; + const uint8_t* rawPtr = nullptr; + }; + + Pointers pointers; size_t maxSize = 0; private: diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp index 3acf26a1..0b712fe1 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp @@ -11,7 +11,7 @@ ReturnValue_t KeepAlivePduDeserializer::parseData() { } size_t currentIdx = FileDirectiveReader::getHeaderSize(); size_t remLen = FileDirectiveReader::getWholePduSize() - currentIdx; - const uint8_t* buffer = rawPtr + currentIdx; + const uint8_t* buffer = pointers.rawPtr + currentIdx; return progress.deSerialize(&buffer, &remLen, getEndianness()); } diff --git a/src/fsfw/cfdp/pdu/MetadataPduReader.cpp b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp index 29dc2e15..a7fc6d78 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduReader.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp @@ -9,7 +9,7 @@ ReturnValue_t MetadataPduReader::parseData() { return result; } size_t currentIdx = FileDirectiveReader::getHeaderSize(); - const uint8_t* buf = rawPtr + currentIdx; + const uint8_t* buf = pointers.rawPtr + currentIdx; size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx; if (remSize < 1) { return SerializeIF::STREAM_TOO_SHORT; diff --git a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp b/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp index a7f23996..089dc612 100644 --- a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp @@ -9,7 +9,7 @@ ReturnValue_t NakPduDeserializer::parseData() { return result; } size_t currentIdx = FileDirectiveReader::getHeaderSize(); - const uint8_t* buffer = rawPtr + currentIdx; + const uint8_t* buffer = pointers.rawPtr + currentIdx; size_t remSize = FileDirectiveReader::getWholePduSize() - currentIdx; if (remSize < 1) { return SerializeIF::STREAM_TOO_SHORT; diff --git a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp b/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp index 833c9232..db57664d 100644 --- a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp @@ -16,6 +16,6 @@ ReturnValue_t PromptPduDeserializer::parseData() { return SerializeIF::STREAM_TOO_SHORT; } responseRequired = static_cast( - (rawPtr[FileDirectiveReader::getHeaderSize()] >> 7) & 0x01); + (pointers.rawPtr[FileDirectiveReader::getHeaderSize()] >> 7) & 0x01); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw/cfdp/tlv/Lv.cpp b/src/fsfw/cfdp/tlv/Lv.cpp index 1bb16301..09075094 100644 --- a/src/fsfw/cfdp/tlv/Lv.cpp +++ b/src/fsfw/cfdp/tlv/Lv.cpp @@ -6,6 +6,13 @@ cfdp::Lv::Lv(const uint8_t* value, size_t size) : value(value, size, true) { } } +cfdp::Lv::Lv(const char* value, size_t size) + : value(reinterpret_cast(value), size, true) { + if (size > 0) { + zeroLen = false; + } +} + cfdp::Lv::Lv() : value(static_cast(nullptr), 0, true) {} cfdp::Lv::Lv(const Lv& other) diff --git a/src/fsfw/cfdp/tlv/Lv.h b/src/fsfw/cfdp/tlv/Lv.h index 29764433..4a110f90 100644 --- a/src/fsfw/cfdp/tlv/Lv.h +++ b/src/fsfw/cfdp/tlv/Lv.h @@ -13,6 +13,7 @@ namespace cfdp { class Lv : public SerializeIF { public: Lv(const uint8_t* value, size_t size); + Lv(const char* value, size_t size); Lv(); // Delete copy ctor and assingment ctor for now because this class contains a reference to @@ -23,7 +24,7 @@ class Lv : public SerializeIF { ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; - size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; /** * @brief Deserialize a LV field from a raw buffer diff --git a/src/fsfw/storagemanager/LocalPool.h b/src/fsfw/storagemanager/LocalPool.h index 1c1d4006..bf7ef92e 100644 --- a/src/fsfw/storagemanager/LocalPool.h +++ b/src/fsfw/storagemanager/LocalPool.h @@ -88,7 +88,7 @@ class LocalPool : public SystemObject, public StorageManagerIF { */ ReturnValue_t addData(store_address_t* storeId, const uint8_t* data, size_t size, bool ignoreFault = false) override; - ReturnValue_t getFreeElement(store_address_t* storeId, const size_t size, uint8_t** pData, + ReturnValue_t getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData, bool ignoreFault = false) override; ConstAccessorPair getData(store_address_t storeId) override; diff --git a/unittests/cfdp/testDistributor.cpp b/unittests/cfdp/testDistributor.cpp index 4b8be8fe..9848bb73 100644 --- a/unittests/cfdp/testDistributor.cpp +++ b/unittests/cfdp/testDistributor.cpp @@ -12,9 +12,24 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { auto queue = MessageQueueMock(1); CfdpDistribCfg distribCfg(1, pool, &queue); auto distributor = CfdpDistributor(distribCfg); - auto entityId = cfdp::EntityId(UnsignedByteField(2)); + auto obswEntityId = cfdp::EntityId(UnsignedByteField(2)); + auto groundEntityId = cfdp::EntityId(UnsignedByteField(1)); MessageQueueId_t acceptorQueueId = 3; auto tcAcceptor = AcceptsTcMock("TC Acceptor", 0, acceptorQueueId); + cfdp::FileSize fileSize(12); + const cfdp::EntityId& sourceId(groundEntityId); + const cfdp::EntityId& destId(obswEntityId); + cfdp::TransactionSeqNum seqNum(UnsignedByteField(12)); + auto pduConf = PduConfig(sourceId, destId, cfdp::TransmissionModes::UNACKNOWLEDGED, seqNum); + std::string sourceFileString = "hello.txt"; + cfdp::Lv sourceFileName(sourceFileString.c_str(), sourceFileString.size()); + std::string destFileString = "hello2.txt"; + cfdp::Lv destFileName(destFileString.c_str(), sourceFileString.size()); + MetadataInfo metadataInfo(false, cfdp::ChecksumType::CRC_32, fileSize, sourceFileName, + destFileName); + MetadataPduCreator creator(pduConf, metadataInfo); + uint8_t* dataPtr = nullptr; + SECTION("State") { CHECK(distributor.initialize() == result::OK); CHECK(std::strcmp(distributor.getName(), "CFDP Distributor") == 0); @@ -24,7 +39,14 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { SECTION("Register Listener") { CHECK(distributor.initialize() == result::OK); - CHECK(distributor.registerTcDestination(entityId, tcAcceptor)); - // queue.addReceivedMessage() + CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); + size_t serLen = 0; + store_address_t storeId; + CHECK(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == result::OK); + REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == + result::OK); + TmTcMessage msg(storeId); + queue.addReceivedMessage(msg); + CHECK(distributor.performOperation(0) == result::OK); } } \ No newline at end of file diff --git a/unittests/cfdp/testMetadataPdu.cpp b/unittests/cfdp/testMetadataPdu.cpp index 0992a3c2..19586604 100644 --- a/unittests/cfdp/testMetadataPdu.cpp +++ b/unittests/cfdp/testMetadataPdu.cpp @@ -22,7 +22,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { std::string firstFileName = "hello.txt"; cfdp::Lv sourceFileName(reinterpret_cast(firstFileName.data()), firstFileName.size()); - cfdp::Lv destFileName(nullptr, 0); + cfdp::Lv destFileName; FileSize fileSize(35); MetadataInfo info(false, ChecksumType::MODULAR, fileSize, sourceFileName, destFileName); @@ -72,7 +72,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { otherFileName.size()); info.setSourceFileName(otherFileNameLv); size_t sizeOfOptions = options.size(); - info.setOptionsArray(*options.data(), &sizeOfOptions, &sizeOfOptions); + info.setOptionsArray(options.data(), &sizeOfOptions, &sizeOfOptions); REQUIRE(info.getMaxOptionsLen() == 2); info.setMaxOptionsLen(3); REQUIRE(info.getMaxOptionsLen() == 3); @@ -130,7 +130,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { } size_t sizeOfOptions = options.size(); size_t maxSize = 4; - info.setOptionsArray(reinterpret_cast(options.data()), &sizeOfOptions, &maxSize); + info.setOptionsArray(options.data(), &sizeOfOptions, &maxSize); REQUIRE(info.getOptionsLen() == 2); info.setChecksumType(cfdp::ChecksumType::CRC_32C); info.setClosureRequested(true); @@ -169,7 +169,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { mdBuffer[2] = 36 & 0xff; info.setOptionsArray(nullptr, nullptr, nullptr); REQUIRE(deserializer2.parseData() == cfdp::METADATA_CANT_PARSE_OPTIONS); - info.setOptionsArray(reinterpret_cast(options.data()), &sizeOfOptions, nullptr); + info.setOptionsArray(options.data(), &sizeOfOptions, nullptr); for (size_t maxSz = 0; maxSz < 46; maxSz++) { MetadataPduReader invalidSzDeser(mdBuffer.data(), maxSz, info); result = invalidSzDeser.parseData(); diff --git a/unittests/cfdp/testTlvsLvs.cpp b/unittests/cfdp/testTlvsLvs.cpp index e311b5d6..acee9cce 100644 --- a/unittests/cfdp/testTlvsLvs.cpp +++ b/unittests/cfdp/testTlvsLvs.cpp @@ -158,7 +158,7 @@ TEST_CASE("CFDP TLV LV", "[cfdp]") { SerializeIF::Endianness::BIG); REQUIRE(sourceIdRaw == 0x0ff0); - auto lvEmpty = Lv(nullptr, 0); + auto lvEmpty = Lv(); REQUIRE(lvEmpty.getSerializedSize() == 1); serPtr = rawBuf.data(); deserSize = 0; @@ -191,7 +191,7 @@ TEST_CASE("CFDP TLV LV", "[cfdp]") { SerializeIF::Endianness::BIG); REQUIRE(sourceIdRaw == 0x0ff0); - auto lvEmpty = Lv(nullptr, 0); + auto lvEmpty = Lv(); REQUIRE(lvEmpty.getSerializedSize() == 1); serPtr = rawBuf.data(); deserSize = 0; From 4f1fe39182b34d48b964926989843da6dff35dda Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Aug 2022 18:36:10 +0200 Subject: [PATCH 192/532] fix unittests --- unittests/cfdp/testKeepAlivePdu.cpp | 8 +++++--- unittests/cfdp/testMetadataPdu.cpp | 7 +++++-- unittests/cfdp/testPromptPdu.cpp | 8 +++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/unittests/cfdp/testKeepAlivePdu.cpp b/unittests/cfdp/testKeepAlivePdu.cpp index 876b71f6..127d8a8c 100644 --- a/unittests/cfdp/testKeepAlivePdu.cpp +++ b/unittests/cfdp/testKeepAlivePdu.cpp @@ -71,9 +71,11 @@ TEST_CASE("Keep Alive PDU", "[cfdp][pdu]") { // invalid max size for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { - deserializer.setData(kaBuffer.data(), invalidMaxSz); - result = deserializer.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + ReturnValue_t setResult = deserializer.setData(kaBuffer.data(), invalidMaxSz); + if (setResult == HasReturnvaluesIF::RETURN_OK) { + result = deserializer.parseData(); + REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + } } } } diff --git a/unittests/cfdp/testMetadataPdu.cpp b/unittests/cfdp/testMetadataPdu.cpp index 19586604..4ea15451 100644 --- a/unittests/cfdp/testMetadataPdu.cpp +++ b/unittests/cfdp/testMetadataPdu.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "fsfw/cfdp/pdu/MetadataPduCreator.h" #include "fsfw/cfdp/pdu/MetadataPduReader.h" @@ -172,8 +173,10 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { info.setOptionsArray(options.data(), &sizeOfOptions, nullptr); for (size_t maxSz = 0; maxSz < 46; maxSz++) { MetadataPduReader invalidSzDeser(mdBuffer.data(), maxSz, info); - result = invalidSzDeser.parseData(); - REQUIRE(result == SerializeIF::STREAM_TOO_SHORT); + if (not invalidSzDeser.isNull()) { + result = invalidSzDeser.parseData(); + REQUIRE(result == SerializeIF::STREAM_TOO_SHORT); + } } } } diff --git a/unittests/cfdp/testPromptPdu.cpp b/unittests/cfdp/testPromptPdu.cpp index 868f7140..93cb9a5d 100644 --- a/unittests/cfdp/testPromptPdu.cpp +++ b/unittests/cfdp/testPromptPdu.cpp @@ -59,9 +59,11 @@ TEST_CASE("Prompt PDU", "[cfdp][pdu]") { rawBuf[2] = 2; for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { - deserializer.setData(rawBuf.data(), invalidMaxSz); - result = deserializer.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + ReturnValue_t setResult = deserializer.setData(rawBuf.data(), invalidMaxSz); + if (setResult == result::OK) { + result = deserializer.parseData(); + REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + } } } } From 06bea2f621def14c75bfcda436d496cd6701360a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 10:59:24 +0200 Subject: [PATCH 193/532] test inNull and bool operator --- src/fsfw/cfdp/pdu/HeaderReader.cpp | 2 +- unittests/cfdp/testFileDirective.cpp | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/fsfw/cfdp/pdu/HeaderReader.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp index c946ce27..06a40347 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.cpp +++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp @@ -134,4 +134,4 @@ bool HeaderReader::isNull() const { return pointers.rawPtr == nullptr or pointers.fixedHeader == nullptr; } -HeaderReader::operator bool() const { return isNull(); } +HeaderReader::operator bool() const { return not isNull(); } diff --git a/unittests/cfdp/testFileDirective.cpp b/unittests/cfdp/testFileDirective.cpp index 3a4818ec..d7c35456 100644 --- a/unittests/cfdp/testFileDirective.cpp +++ b/unittests/cfdp/testFileDirective.cpp @@ -16,9 +16,9 @@ TEST_CASE("CFDP File Directive", "[cfdp]") { uint8_t* serTarget = serBuf.data(); const uint8_t* deserTarget = serTarget; size_t serSize = 0; + auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4); - SECTION("File Directive") { - auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4); + SECTION("Serialization") { REQUIRE(fdSer.getSerializedSize() == 8); serTarget = serBuf.data(); serSize = 0; @@ -38,24 +38,34 @@ TEST_CASE("CFDP File Directive", "[cfdp]") { // Dest ID REQUIRE(serBuf[6] == 1); REQUIRE(serBuf[7] == FileDirectives::ACK); + } - serTarget = serBuf.data(); - size_t deserSize = 20; - serSize = 0; - REQUIRE(fdSer.deSerialize(&deserTarget, &deserSize, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_FAILED); + SECTION("Serialization fails") { REQUIRE(fdSer.serialize(nullptr, nullptr, 85, SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_FAILED); + } + + SECTION("Buffer Too Short") { for (uint8_t idx = 0; idx < 8; idx++) { serTarget = serBuf.data(); serSize = 0; REQUIRE(fdSer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::NETWORK) == SerializeIF::BUFFER_TOO_SHORT); } + } + SECTION("Deserialize") { + CHECK(fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK) == + result::OK); + serTarget = serBuf.data(); + + REQUIRE(fdSer.deSerialize(&deserTarget, &serSize, SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_FAILED); deserTarget = serBuf.data(); - deserSize = 0; + CHECK(serSize == 8); auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size()); + REQUIRE(not fdDeser.isNull()); + REQUIRE(fdDeser); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::NETWORK); fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); From 2f8020baacf8c146271b549bae48e275eb45507b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 11:03:22 +0200 Subject: [PATCH 194/532] move parsing steps into parse function --- src/fsfw/cfdp/pdu/HeaderReader.cpp | 8 ++++++-- unittests/cfdp/testCfdpHeader.cpp | 4 ++-- unittests/cfdp/testFileDirective.cpp | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/fsfw/cfdp/pdu/HeaderReader.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp index 06a40347..1fd40b78 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.cpp +++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp @@ -7,12 +7,14 @@ HeaderReader::HeaderReader(const uint8_t *pduBuf, size_t maxSize) { setData(pduBuf, maxSize); } ReturnValue_t HeaderReader::parseData() { - if (isNull()) { + if (pointers.rawPtr == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } if (maxSize < 7) { return SerializeIF::STREAM_TOO_SHORT; } + pointers.fixedHeader = + reinterpret_cast(const_cast(pointers.rawPtr)); sourceIdRaw = static_cast(&pointers.fixedHeader->variableFieldsStart); cfdp::WidthInBytes widthEntityIds = getLenEntityIds(); cfdp::WidthInBytes widthSeqNum = getLenSeqNum(); @@ -22,11 +24,13 @@ ReturnValue_t HeaderReader::parseData() { } ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) { + if (dataPtr == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } if (maxSize_ < 7) { return SerializeIF::STREAM_TOO_SHORT; } pointers.rawPtr = dataPtr; - pointers.fixedHeader = reinterpret_cast(const_cast(dataPtr)); maxSize = maxSize_; return HasReturnvaluesIF::RETURN_OK; } diff --git a/unittests/cfdp/testCfdpHeader.cpp b/unittests/cfdp/testCfdpHeader.cpp index 6453b809..0b131669 100644 --- a/unittests/cfdp/testCfdpHeader.cpp +++ b/unittests/cfdp/testCfdpHeader.cpp @@ -268,8 +268,8 @@ TEST_CASE("CFDP Header", "[cfdp]") { result = headerDeser.parseData(); REQUIRE(result == result::OK); - headerDeser.setData(nullptr, -1); - REQUIRE(headerDeser.getHeaderSize() == 0); + CHECK(headerDeser.setData(nullptr, -1) != result::OK); + REQUIRE(headerDeser.getHeaderSize() == 14); headerDeser.setData(serBuf.data(), serBuf.size()); serTarget = serBuf.data(); diff --git a/unittests/cfdp/testFileDirective.cpp b/unittests/cfdp/testFileDirective.cpp index d7c35456..b694cd68 100644 --- a/unittests/cfdp/testFileDirective.cpp +++ b/unittests/cfdp/testFileDirective.cpp @@ -64,13 +64,15 @@ TEST_CASE("CFDP File Directive", "[cfdp]") { deserTarget = serBuf.data(); CHECK(serSize == 8); auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size()); - REQUIRE(not fdDeser.isNull()); - REQUIRE(fdDeser); + REQUIRE(fdDeser.isNull()); + REQUIRE(not fdDeser); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::NETWORK); fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); fdDeser.setEndianness(SerializeIF::Endianness::NETWORK); REQUIRE(fdDeser.parseData() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(not fdDeser.isNull()); + REQUIRE(fdDeser); REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK); REQUIRE(fdDeser.getPduDataFieldLen() == 5); REQUIRE(fdDeser.getHeaderSize() == 8); From c832bffdb0d6e69638c57671f1558b640a63ea95 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 11:17:57 +0200 Subject: [PATCH 195/532] clean up header test --- unittests/cfdp/testCfdpHeader.cpp | 221 +++++++++++++++++------------- 1 file changed, 124 insertions(+), 97 deletions(-) diff --git a/unittests/cfdp/testCfdpHeader.cpp b/unittests/cfdp/testCfdpHeader.cpp index 0b131669..a01325fa 100644 --- a/unittests/cfdp/testCfdpHeader.cpp +++ b/unittests/cfdp/testCfdpHeader.cpp @@ -17,18 +17,10 @@ TEST_CASE("CFDP Header", "[cfdp]") { uint8_t* serTarget = serBuf.data(); const uint8_t* deserTarget = serTarget; size_t serSize = 0; + auto headerSerializer = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); - SECTION("Header Serialization") { - auto headerSerializer = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); - const uint8_t** dummyPtr = nullptr; - ReturnValue_t deserResult = - headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK); - REQUIRE(deserResult == result::FAILED); - deserResult = headerSerializer.serialize(nullptr, &serSize, serBuf.size(), - SerializeIF::Endianness::NETWORK); - REQUIRE(deserResult == result::FAILED); + SECTION("Header State") { REQUIRE(seqNum.getSerializedSize() == 1); - REQUIRE(headerSerializer.getPduDataFieldLen() == 0); REQUIRE(headerSerializer.getSerializedSize() == 7); REQUIRE(headerSerializer.getWholePduSize() == 7); @@ -41,7 +33,6 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(headerSerializer.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); REQUIRE(headerSerializer.getSegmentationControl() == false); REQUIRE(headerSerializer.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); - cfdp::TransactionSeqNum seqNumLocal; headerSerializer.getTransactionSeqNum(seqNumLocal); REQUIRE(seqNumLocal.getWidth() == cfdp::WidthInBytes::ONE_BYTE); @@ -53,7 +44,127 @@ TEST_CASE("CFDP Header", "[cfdp]") { headerSerializer.getDestId(sourceDestId); REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::ONE_BYTE); REQUIRE(sourceDestId.getValue() == 1); + } + SECTION("Deserialization fails") { + const uint8_t** dummyPtr = nullptr; + REQUIRE(headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK) == + result::FAILED); + } + + SECTION("Serialization fails") { + REQUIRE(headerSerializer.serialize(nullptr, &serSize, serBuf.size(), + SerializeIF::Endianness::NETWORK) == result::FAILED); + } + + SECTION("Buffer Too Short") { + for (uint8_t idx = 0; idx < 7; idx++) { + result = headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); + REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); + } + } + + SECTION("Set Data Field Len") { + // Set PDU data field len + headerSerializer.setPduDataFieldLen(0x0ff0); + REQUIRE(headerSerializer.getPduDataFieldLen() == 0x0ff0); + REQUIRE(headerSerializer.getSerializedSize() == 7); + REQUIRE(headerSerializer.getWholePduSize() == 7 + 0x0ff0); + serTarget = serBuf.data(); + serSize = 0; + result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG); + REQUIRE(serBuf[1] == 0x0f); + REQUIRE(serBuf[2] == 0xf0); + } + + SECTION("Serialize with Fields Flipped") { + pduConf.crcFlag = true; + pduConf.largeFile = true; + pduConf.direction = cfdp::Direction::TOWARDS_SENDER; + pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; + headerSerializer.setSegmentationControl( + cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); + headerSerializer.setPduType(cfdp::PduType::FILE_DATA); + headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); + serTarget = serBuf.data(); + serSize = 0; + + SECTION("Regular") { + // Everything except version bit flipped to one now + REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG) == result::OK); + CHECK(serBuf[0] == 0x3f); + CHECK(serBuf[3] == 0x99); + REQUIRE(headerSerializer.getCrcFlag() == true); + REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER); + REQUIRE(headerSerializer.getLargeFileFlag() == true); + REQUIRE(headerSerializer.getLenEntityIds() == 1); + REQUIRE(headerSerializer.getLenSeqNum() == 1); + REQUIRE(headerSerializer.getPduType() == cfdp::PduType::FILE_DATA); + REQUIRE(headerSerializer.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); + REQUIRE(headerSerializer.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); + REQUIRE(headerSerializer.getSegmentationControl() == true); + } + + SECTION("Other variable sized fields") { + pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); + pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); + pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); + REQUIRE(pduConf.sourceId.getSerializedSize() == 4); + REQUIRE(headerSerializer.getSerializedSize() == 14); + REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG) == result::OK); + REQUIRE(headerSerializer.getCrcFlag() == true); + REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER); + REQUIRE(headerSerializer.getLargeFileFlag() == true); + REQUIRE(headerSerializer.getLenEntityIds() == 4); + REQUIRE(headerSerializer.getLenSeqNum() == 2); + REQUIRE(headerSerializer.getPduType() == cfdp::PduType::FILE_DATA); + REQUIRE(headerSerializer.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); + REQUIRE(headerSerializer.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); + REQUIRE(headerSerializer.getSegmentationControl() == true); + // Last three bits are 2 now (length of seq number) and bit 1 to bit 3 is 4 (len entity IDs) + REQUIRE(serBuf[3] == 0b11001010); + uint32_t entityId = 0; + size_t deSerSize = 0; + SerializeAdapter::deSerialize(&entityId, serBuf.data() + 4, &deSerSize, + SerializeIF::Endianness::NETWORK); + CHECK(deSerSize == 4); + CHECK(entityId == 0xff00ff00); + uint16_t seqNumRaw = 0; + SerializeAdapter::deSerialize(&seqNumRaw, serBuf.data() + 8, &deSerSize, + SerializeIF::Endianness::NETWORK); + CHECK(deSerSize == 2); + CHECK(seqNumRaw == 0x0fff); + SerializeAdapter::deSerialize(&entityId, serBuf.data() + 10, &deSerSize, + SerializeIF::Endianness::NETWORK); + CHECK(deSerSize == 4); + CHECK(entityId == 0x00ff00ff); + } + + SECTION("Buffer Too Short") { + pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); + pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); + pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); + for (uint8_t idx = 0; idx < 14; idx++) { + REQUIRE( + headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG) == + SerializeIF::BUFFER_TOO_SHORT); + } + } + } + + SECTION("Invalid Variable Sized Fields") { + result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff); + REQUIRE(result == result::FAILED); + result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff); + REQUIRE(result == result::FAILED); + result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff); + REQUIRE(result == result::FAILED); + } + + SECTION("Header Serialization") { result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); REQUIRE(result == result::OK); @@ -72,86 +183,6 @@ TEST_CASE("CFDP Header", "[cfdp]") { // Dest ID REQUIRE(serBuf[6] == 1); - for (uint8_t idx = 0; idx < 7; idx++) { - result = headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); - REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); - } - - // Set PDU data field len - headerSerializer.setPduDataFieldLen(0x0ff0); - REQUIRE(headerSerializer.getPduDataFieldLen() == 0x0ff0); - REQUIRE(headerSerializer.getSerializedSize() == 7); - REQUIRE(headerSerializer.getWholePduSize() == 7 + 0x0ff0); - serTarget = serBuf.data(); - serSize = 0; - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - REQUIRE(serBuf[1] == 0x0f); - REQUIRE(serBuf[2] == 0xf0); - - pduConf.crcFlag = true; - pduConf.largeFile = true; - pduConf.direction = cfdp::Direction::TOWARDS_SENDER; - pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; - headerSerializer.setSegmentationControl( - cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); - headerSerializer.setPduType(cfdp::PduType::FILE_DATA); - headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); - serTarget = serBuf.data(); - serSize = 0; - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - - // Everything except version bit flipped to one now - REQUIRE(serBuf[0] == 0x3f); - REQUIRE(serBuf[3] == 0x99); - pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); - pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); - pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); - REQUIRE(pduConf.sourceId.getSerializedSize() == 4); - REQUIRE(headerSerializer.getSerializedSize() == 14); - serTarget = serBuf.data(); - serSize = 0; - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - - for (uint8_t idx = 0; idx < 14; idx++) { - result = headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); - REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); - } - REQUIRE(headerSerializer.getCrcFlag() == true); - REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER); - REQUIRE(headerSerializer.getLargeFileFlag() == true); - REQUIRE(headerSerializer.getLenEntityIds() == 4); - REQUIRE(headerSerializer.getLenSeqNum() == 2); - REQUIRE(headerSerializer.getPduType() == cfdp::PduType::FILE_DATA); - REQUIRE(headerSerializer.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); - REQUIRE(headerSerializer.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); - REQUIRE(headerSerializer.getSegmentationControl() == true); - // Last three bits are 2 now (length of seq number) and bit 1 to bit 3 is 4 (len entity IDs) - REQUIRE(serBuf[3] == 0b11001010); - uint32_t entityId = 0; - size_t deSerSize = 0; - SerializeAdapter::deSerialize(&entityId, serBuf.data() + 4, &deSerSize, - SerializeIF::Endianness::NETWORK); - REQUIRE(deSerSize == 4); - REQUIRE(entityId == 0xff00ff00); - uint16_t seqNumRaw = 0; - SerializeAdapter::deSerialize(&seqNumRaw, serBuf.data() + 8, &deSerSize, - SerializeIF::Endianness::NETWORK); - REQUIRE(deSerSize == 2); - REQUIRE(seqNumRaw == 0x0fff); - SerializeAdapter::deSerialize(&entityId, serBuf.data() + 10, &deSerSize, - SerializeIF::Endianness::NETWORK); - REQUIRE(deSerSize == 4); - REQUIRE(entityId == 0x00ff00ff); - - result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff); - REQUIRE(result == result::FAILED); - result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff); - REQUIRE(result == result::FAILED); - result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff); - REQUIRE(result == result::FAILED); uint8_t oneByteSourceId = 32; serTarget = &oneByteSourceId; size_t deserLen = 1; @@ -184,12 +215,8 @@ TEST_CASE("CFDP Header", "[cfdp]") { } SECTION("Header Deserialization") { - // We unittested the serializer before, so we can use it now to generate valid raw CFDP - // data - auto headerSerializer = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG) == result::OK); REQUIRE(serBuf[1] == 0); REQUIRE(serBuf[2] == 0); // Entity and Transaction Sequence number are 1 byte large From 1c0b77884864c5c09e6dd1da19602c719a3762b4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 12:13:10 +0200 Subject: [PATCH 196/532] continue CFDP distrib unittests --- unittests/cfdp/testDistributor.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/unittests/cfdp/testDistributor.cpp b/unittests/cfdp/testDistributor.cpp index 9848bb73..9eb3838c 100644 --- a/unittests/cfdp/testDistributor.cpp +++ b/unittests/cfdp/testDistributor.cpp @@ -14,8 +14,8 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { auto distributor = CfdpDistributor(distribCfg); auto obswEntityId = cfdp::EntityId(UnsignedByteField(2)); auto groundEntityId = cfdp::EntityId(UnsignedByteField(1)); - MessageQueueId_t acceptorQueueId = 3; - auto tcAcceptor = AcceptsTcMock("TC Acceptor", 0, acceptorQueueId); + MessageQueueId_t receiverQueueId = 3; + auto tcAcceptor = AcceptsTcMock("CFDP Receiver", 0, receiverQueueId); cfdp::FileSize fileSize(12); const cfdp::EntityId& sourceId(groundEntityId); const cfdp::EntityId& destId(obswEntityId); @@ -48,5 +48,12 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { TmTcMessage msg(storeId); queue.addReceivedMessage(msg); CHECK(distributor.performOperation(0) == result::OK); + CHECK(queue.wasMessageSent()); + CHECK(queue.numberOfSentMessages() == 1); + // The packet is forwarded, with no need to delete the data + CHECK(pool.hasDataAtId(storeId)); + TmTcMessage sentMsg; + CHECK(queue.getNextSentMessage(receiverQueueId, sentMsg) == result::OK); + CHECK(sentMsg.getStorageId() == storeId); } } \ No newline at end of file From bddf5bded1f3ff400b7cfa457515948ff8e37a92 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 12:36:29 +0200 Subject: [PATCH 197/532] move some storage manager impl to IF - Add StorageManagerMock --- src/fsfw/cfdp/CfdpDistributor.cpp | 2 +- src/fsfw/returnvalues/FwClassIds.h | 2 +- .../storagemanager/ConstStorageAccessor.cpp | 8 +-- .../storagemanager/ConstStorageAccessor.h | 13 +++-- src/fsfw/storagemanager/LocalPool.cpp | 58 +++++++++---------- src/fsfw/storagemanager/LocalPool.h | 22 +++---- src/fsfw/storagemanager/StorageAccessor.cpp | 4 +- src/fsfw/storagemanager/StorageAccessor.h | 7 ++- src/fsfw/storagemanager/StorageManagerIF.h | 53 +++++++++++++---- src/fsfw/tcdistribution/definitions.h | 13 +++-- unittests/cfdp/testDistributor.cpp | 2 +- unittests/mocks/CMakeLists.txt | 3 +- unittests/mocks/StorageManagerMock.cpp | 32 ++++++++++ unittests/mocks/StorageManagerMock.h | 24 ++++++++ unittests/storagemanager/testAccessor.cpp | 48 +++++++-------- 15 files changed, 190 insertions(+), 101 deletions(-) create mode 100644 unittests/mocks/StorageManagerMock.cpp create mode 100644 unittests/mocks/StorageManagerMock.h diff --git a/src/fsfw/cfdp/CfdpDistributor.cpp b/src/fsfw/cfdp/CfdpDistributor.cpp index 4aa9c797..e2377024 100644 --- a/src/fsfw/cfdp/CfdpDistributor.cpp +++ b/src/fsfw/cfdp/CfdpDistributor.cpp @@ -40,7 +40,7 @@ ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { } if (not destFound) { // TODO: Warning and event? - return HasReturnvaluesIF::RETURN_FAILED; + return tmtcdistrib::NO_DESTINATION_FOUND; } // Packet was forwarded successfully, so do not delete it. accessorPair.second.release(); diff --git a/src/fsfw/returnvalues/FwClassIds.h b/src/fsfw/returnvalues/FwClassIds.h index 1dfe1cc8..9a5cc812 100644 --- a/src/fsfw/returnvalues/FwClassIds.h +++ b/src/fsfw/returnvalues/FwClassIds.h @@ -34,7 +34,7 @@ enum : uint8_t { FIFO_CLASS, // FF MESSAGE_PROXY, // MQP TRIPLE_REDUNDACY_CHECK, // TRC - PACKET_CHECK, // TCC + TMTC_DISTRIBUTION, // TCC PACKET_DISTRIBUTION, // TCD ACCEPTS_TELECOMMANDS_IF, // ATC PUS_IF, // PUS diff --git a/src/fsfw/storagemanager/ConstStorageAccessor.cpp b/src/fsfw/storagemanager/ConstStorageAccessor.cpp index df2fc750..5b0e98c3 100644 --- a/src/fsfw/storagemanager/ConstStorageAccessor.cpp +++ b/src/fsfw/storagemanager/ConstStorageAccessor.cpp @@ -19,7 +19,7 @@ ConstStorageAccessor::~ConstStorageAccessor() { } } -ConstStorageAccessor::ConstStorageAccessor(ConstStorageAccessor&& other) +ConstStorageAccessor::ConstStorageAccessor(ConstStorageAccessor&& other) noexcept : constDataPointer(other.constDataPointer), storeId(other.storeId), size_(other.size_), @@ -30,7 +30,7 @@ ConstStorageAccessor::ConstStorageAccessor(ConstStorageAccessor&& other) other.store = nullptr; } -ConstStorageAccessor& ConstStorageAccessor::operator=(ConstStorageAccessor&& other) { +ConstStorageAccessor& ConstStorageAccessor::operator=(ConstStorageAccessor&& other) noexcept { constDataPointer = other.constDataPointer; storeId = other.storeId; store = other.store; @@ -84,7 +84,7 @@ void ConstStorageAccessor::print() const { arrayprinter::print(constDataPointer, size_); } -void ConstStorageAccessor::assignStore(StorageManagerIF* store) { +void ConstStorageAccessor::assignStore(StorageManagerIF* store_) { internalState = AccessState::ASSIGNED; - this->store = store; + store = store_; } diff --git a/src/fsfw/storagemanager/ConstStorageAccessor.h b/src/fsfw/storagemanager/ConstStorageAccessor.h index a2ddad6c..e70d3f40 100644 --- a/src/fsfw/storagemanager/ConstStorageAccessor.h +++ b/src/fsfw/storagemanager/ConstStorageAccessor.h @@ -23,6 +23,7 @@ class ConstStorageAccessor { //! StorageManager classes have exclusive access to private variables. friend class PoolManager; friend class LocalPool; + friend class StorageManagerIF; public: /** @@ -30,7 +31,7 @@ class ConstStorageAccessor { * entry to access. * @param storeId */ - ConstStorageAccessor(store_address_t storeId); + explicit ConstStorageAccessor(store_address_t storeId); ConstStorageAccessor(store_address_t storeId, StorageManagerIF* store); /** @@ -43,7 +44,7 @@ class ConstStorageAccessor { * @brief Returns a pointer to the read-only data * @return */ - const uint8_t* data() const; + [[nodiscard]] const uint8_t* data() const; /** * @brief Copies the read-only data to the supplied pointer @@ -61,13 +62,13 @@ class ConstStorageAccessor { * Get the size of the data * @return */ - size_t size() const; + [[nodiscard]] size_t size() const; /** * Get the storage ID. * @return */ - store_address_t getId() const; + [[nodiscard]] store_address_t getId() const; void print() const; @@ -79,8 +80,8 @@ class ConstStorageAccessor { * @param * @return */ - ConstStorageAccessor& operator=(ConstStorageAccessor&&); - ConstStorageAccessor(ConstStorageAccessor&&); + ConstStorageAccessor& operator=(ConstStorageAccessor&&) noexcept ; + ConstStorageAccessor(ConstStorageAccessor&&) noexcept ; //! The copy ctor and copy assignemnt should be deleted implicitely //! according to https://foonathan.net/2019/02/special-member-functions/ diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index f8b2bdb3..e40315ed 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -29,7 +29,7 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig, } } -LocalPool::~LocalPool(void) {} +LocalPool::~LocalPool() = default; ReturnValue_t LocalPool::addData(store_address_t* storageId, const uint8_t* data, size_t size, bool ignoreFault) { @@ -48,22 +48,6 @@ ReturnValue_t LocalPool::getData(store_address_t packetId, const uint8_t** packe return status; } -ReturnValue_t LocalPool::getData(store_address_t storeId, ConstStorageAccessor& storeAccessor) { - uint8_t* tempData = nullptr; - ReturnValue_t status = modifyData(storeId, &tempData, &storeAccessor.size_); - storeAccessor.assignStore(this); - storeAccessor.constDataPointer = tempData; - return status; -} - -ConstAccessorPair LocalPool::getData(store_address_t storeId) { - uint8_t* tempData = nullptr; - ConstStorageAccessor constAccessor(storeId, this); - ReturnValue_t status = modifyData(storeId, &tempData, &constAccessor.size_); - constAccessor.constDataPointer = tempData; - return ConstAccessorPair(status, std::move(constAccessor)); -} - ReturnValue_t LocalPool::getFreeElement(store_address_t* storageId, const size_t size, uint8_t** pData, bool ignoreFault) { ReturnValue_t status = reserveSpace(size, storageId, ignoreFault); @@ -75,20 +59,6 @@ ReturnValue_t LocalPool::getFreeElement(store_address_t* storageId, const size_t return status; } -AccessorPair LocalPool::modifyData(store_address_t storeId) { - StorageAccessor accessor(storeId, this); - ReturnValue_t status = modifyData(storeId, &accessor.dataPointer, &accessor.size_); - accessor.assignConstPointer(); - return AccessorPair(status, std::move(accessor)); -} - -ReturnValue_t LocalPool::modifyData(store_address_t storeId, StorageAccessor& storeAccessor) { - storeAccessor.assignStore(this); - ReturnValue_t status = modifyData(storeId, &storeAccessor.dataPointer, &storeAccessor.size_); - storeAccessor.assignConstPointer(); - return status; -} - ReturnValue_t LocalPool::modifyData(store_address_t storeId, uint8_t** packetPtr, size_t* size) { ReturnValue_t status = RETURN_FAILED; if (storeId.poolIndex >= NUMBER_OF_SUBPOOLS) { @@ -197,7 +167,7 @@ void LocalPool::clearStore() { } } -ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeId, +ReturnValue_t LocalPool::reserveSpace(size_t size, store_address_t* storeId, bool ignoreFault) { ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); if (status != RETURN_OK) { @@ -349,3 +319,27 @@ bool LocalPool::hasDataAtId(store_address_t storeId) const { } return false; } + +ReturnValue_t LocalPool::getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData) { + return StorageManagerIF::getFreeElement(storeId, size, pData); +} + +ConstAccessorPair LocalPool::getData(store_address_t storeId) { + return StorageManagerIF::getData(storeId); +} + +ReturnValue_t LocalPool::addData(store_address_t* storeId, const uint8_t* data, size_t size) { + return StorageManagerIF::addData(storeId, data, size); +} + +ReturnValue_t LocalPool::getData(store_address_t storeId, ConstStorageAccessor& accessor) { + return StorageManagerIF::getData(storeId, accessor); +} + +ReturnValue_t LocalPool::modifyData(store_address_t storeId, StorageAccessor& accessor) { + return StorageManagerIF::modifyData(storeId, accessor); +} + +AccessorPair LocalPool::modifyData(store_address_t storeId) { + return StorageManagerIF::modifyData(storeId); +} diff --git a/src/fsfw/storagemanager/LocalPool.h b/src/fsfw/storagemanager/LocalPool.h index bf7ef92e..5ee2e66e 100644 --- a/src/fsfw/storagemanager/LocalPool.h +++ b/src/fsfw/storagemanager/LocalPool.h @@ -87,21 +87,23 @@ class LocalPool : public SystemObject, public StorageManagerIF { * Documentation: See StorageManagerIF.h */ ReturnValue_t addData(store_address_t* storeId, const uint8_t* data, size_t size, - bool ignoreFault = false) override; + bool ignoreFault) override; + ReturnValue_t addData(store_address_t* storeId, const uint8_t* data, size_t size) override; + + ReturnValue_t getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData) override; ReturnValue_t getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData, - bool ignoreFault = false) override; + bool ignoreFault) override; ConstAccessorPair getData(store_address_t storeId) override; - ReturnValue_t getData(store_address_t storeId, ConstStorageAccessor& constAccessor) override; + ReturnValue_t getData(store_address_t storeId, ConstStorageAccessor& accessor) override; ReturnValue_t getData(store_address_t storeId, const uint8_t** packet_ptr, size_t* size) override; AccessorPair modifyData(store_address_t storeId) override; - ReturnValue_t modifyData(store_address_t storeId, StorageAccessor& storeAccessor) override; ReturnValue_t modifyData(store_address_t storeId, uint8_t** packet_ptr, size_t* size) override; + ReturnValue_t modifyData(store_address_t storeId, StorageAccessor& accessor) override; - virtual ReturnValue_t deleteData(store_address_t storeId) override; - virtual ReturnValue_t deleteData(uint8_t* ptr, size_t size, - store_address_t* storeId = nullptr) override; + ReturnValue_t deleteData(store_address_t storeId) override; + ReturnValue_t deleteData(uint8_t* ptr, size_t size, store_address_t* storeId) override; /** * Get the total size of allocated memory for pool data. @@ -131,8 +133,8 @@ class LocalPool : public SystemObject, public StorageManagerIF { * Get number sub pools. Each pool has pages with a specific bucket size. * @return */ - max_subpools_t getNumberOfSubPools() const override; - bool hasDataAtId(store_address_t storeId) const override; + [[nodiscard]] max_subpools_t getNumberOfSubPools() const override; + [[nodiscard]] bool hasDataAtId(store_address_t storeId) const override; protected: /** @@ -142,7 +144,7 @@ class LocalPool : public SystemObject, public StorageManagerIF { * @return - #RETURN_OK on success, * - the return codes of #getPoolIndex or #findEmpty otherwise. */ - virtual ReturnValue_t reserveSpace(const size_t size, store_address_t* address, bool ignoreFault); + virtual ReturnValue_t reserveSpace(size_t size, store_address_t* address, bool ignoreFault); private: /** diff --git a/src/fsfw/storagemanager/StorageAccessor.cpp b/src/fsfw/storagemanager/StorageAccessor.cpp index b8096c1e..5010b64a 100644 --- a/src/fsfw/storagemanager/StorageAccessor.cpp +++ b/src/fsfw/storagemanager/StorageAccessor.cpp @@ -10,7 +10,7 @@ StorageAccessor::StorageAccessor(store_address_t storeId) : ConstStorageAccessor StorageAccessor::StorageAccessor(store_address_t storeId, StorageManagerIF* store) : ConstStorageAccessor(storeId, store) {} -StorageAccessor& StorageAccessor::operator=(StorageAccessor&& other) { +StorageAccessor& StorageAccessor::operator=(StorageAccessor&& other) noexcept { // Call the parent move assignment and also assign own member. dataPointer = other.dataPointer; ConstStorageAccessor::operator=(std::move(other)); @@ -18,7 +18,7 @@ StorageAccessor& StorageAccessor::operator=(StorageAccessor&& other) { } // Call the parent move ctor and also transfer own member. -StorageAccessor::StorageAccessor(StorageAccessor&& other) +StorageAccessor::StorageAccessor(StorageAccessor&& other) noexcept : ConstStorageAccessor(std::move(other)), dataPointer(other.dataPointer) {} ReturnValue_t StorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { diff --git a/src/fsfw/storagemanager/StorageAccessor.h b/src/fsfw/storagemanager/StorageAccessor.h index 5e8b25e4..f51ba7e6 100644 --- a/src/fsfw/storagemanager/StorageAccessor.h +++ b/src/fsfw/storagemanager/StorageAccessor.h @@ -12,9 +12,10 @@ class StorageAccessor : public ConstStorageAccessor { //! StorageManager classes have exclusive access to private variables. friend class PoolManager; friend class LocalPool; + friend class StorageManagerIF; public: - StorageAccessor(store_address_t storeId); + explicit StorageAccessor(store_address_t storeId); StorageAccessor(store_address_t storeId, StorageManagerIF* store); /** @@ -25,8 +26,8 @@ class StorageAccessor : public ConstStorageAccessor { * @param * @return */ - StorageAccessor& operator=(StorageAccessor&&); - StorageAccessor(StorageAccessor&&); + StorageAccessor& operator=(StorageAccessor&&) noexcept ; + StorageAccessor(StorageAccessor&&) noexcept ; ReturnValue_t write(uint8_t* data, size_t size, uint16_t offset = 0); uint8_t* data(); diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index 90ea4587..36ad5370 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -68,7 +68,12 @@ class StorageManagerIF : public HasReturnvaluesIF { * storageId is unchanged then. */ virtual ReturnValue_t addData(store_address_t* storageId, const uint8_t* data, size_t size, - bool ignoreFault = false) = 0; + bool ignoreFault) = 0; + + virtual ReturnValue_t addData(store_address_t* storageId, const uint8_t* data, size_t size) { + return addData(storageId, data, size, false); + } + /** * @brief With deleteData, the storageManager frees the memory region * identified by packet_id. @@ -88,8 +93,10 @@ class StorageManagerIF : public HasReturnvaluesIF { * @li failure code if deletion did not work */ virtual ReturnValue_t deleteData(uint8_t* buffer, size_t size, - store_address_t* storeId = nullptr) = 0; - + store_address_t* storeId) = 0; + virtual ReturnValue_t deleteData(uint8_t* buffer, size_t size) { + return deleteData(buffer, size, nullptr); + } /** * @brief Access the data by supplying a store ID. * @details @@ -98,7 +105,13 @@ class StorageManagerIF : public HasReturnvaluesIF { * @param storeId * @return Pair of return value and a ConstStorageAccessor instance */ - virtual ConstAccessorPair getData(store_address_t storeId) = 0; + virtual ConstAccessorPair getData(store_address_t storeId) { + uint8_t* tempData = nullptr; + ConstStorageAccessor constAccessor(storeId, this); + ReturnValue_t status = modifyData(storeId, &tempData, &constAccessor.size_); + constAccessor.constDataPointer = tempData; + return {status, std::move(constAccessor)}; + } /** * @brief Access the data by supplying a store ID and a helper @@ -107,7 +120,13 @@ class StorageManagerIF : public HasReturnvaluesIF { * @param constAccessor Wrapper function to access store data. * @return */ - virtual ReturnValue_t getData(store_address_t storeId, ConstStorageAccessor& constAccessor) = 0; + virtual ReturnValue_t getData(store_address_t storeId, ConstStorageAccessor& accessor) { + uint8_t* tempData = nullptr; + ReturnValue_t status = modifyData(storeId, &tempData, &accessor.size_); + accessor.assignStore(this); + accessor.constDataPointer = tempData; + return status; + } /** * @brief getData returns an address to data and the size of the data @@ -128,7 +147,12 @@ class StorageManagerIF : public HasReturnvaluesIF { * @param storeId * @return Pair of return value and StorageAccessor helper */ - virtual AccessorPair modifyData(store_address_t storeId) = 0; + virtual AccessorPair modifyData(store_address_t storeId) { + StorageAccessor accessor(storeId, this); + ReturnValue_t status = modifyData(storeId, &accessor.dataPointer, &accessor.size_); + accessor.assignConstPointer(); + return {status, std::move(accessor)}; + } /** * Modify data by supplying a store ID and a StorageAccessor helper instance. @@ -136,7 +160,12 @@ class StorageManagerIF : public HasReturnvaluesIF { * @param accessor Helper class to access the modifiable data. * @return */ - virtual ReturnValue_t modifyData(store_address_t storeId, StorageAccessor& accessor) = 0; + virtual ReturnValue_t modifyData(store_address_t storeId, StorageAccessor& accessor) { + accessor.assignStore(this); + ReturnValue_t status = modifyData(storeId, &accessor.dataPointer, &accessor.size_); + accessor.assignConstPointer(); + return status; + } /** * Get pointer and size of modifiable data by supplying the storeId @@ -155,13 +184,17 @@ class StorageManagerIF : public HasReturnvaluesIF { * written to p_data! * @param storageId A pointer to the storageId to retrieve. * @param size The size of the space to be reserved. - * @param p_data A pointer to the element data is returned here. + * @param dataPtr A pointer to the element data is returned here. * @return Returns @li RETURN_OK if data was added. * @li RETURN_FAILED if data could not be added. * storageId is unchanged then. */ - virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** p_data, - bool ignoreFault = false) = 0; + virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** dataPtr, + bool ignoreFault) = 0; + + virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** dataPtr) { + return getFreeElement(storageId, size, dataPtr, false); + } [[nodiscard]] virtual bool hasDataAtId(store_address_t storeId) const = 0; diff --git a/src/fsfw/tcdistribution/definitions.h b/src/fsfw/tcdistribution/definitions.h index 8cae639e..04c2569c 100644 --- a/src/fsfw/tcdistribution/definitions.h +++ b/src/fsfw/tcdistribution/definitions.h @@ -9,12 +9,13 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" namespace tmtcdistrib { -static const uint8_t INTERFACE_ID = CLASS_ID::PACKET_CHECK; -static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(0); -static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(1); -static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(2); -static constexpr ReturnValue_t INVALID_SEC_HEADER_FIELD = MAKE_RETURN_CODE(3); -static constexpr ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE(4); +static const uint8_t INTERFACE_ID = CLASS_ID::TMTC_DISTRIBUTION; +static constexpr ReturnValue_t NO_DESTINATION_FOUND = result::makeCode(INTERFACE_ID, 0); +static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(1); +static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(2); +static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(3); +static constexpr ReturnValue_t INVALID_SEC_HEADER_FIELD = MAKE_RETURN_CODE(4); +static constexpr ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE(5); static constexpr ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE(5); static constexpr ReturnValue_t INVALID_PUS_VERSION = MAKE_RETURN_CODE(6); diff --git a/unittests/cfdp/testDistributor.cpp b/unittests/cfdp/testDistributor.cpp index 9eb3838c..b65f6816 100644 --- a/unittests/cfdp/testDistributor.cpp +++ b/unittests/cfdp/testDistributor.cpp @@ -37,7 +37,7 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { CHECK(distributor.getRequestQueue() == queue.getId()); } - SECTION("Register Listener") { + SECTION("Packet Forwarding") { CHECK(distributor.initialize() == result::OK); CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); size_t serLen = 0; diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 0294af31..bc5649de 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -13,4 +13,5 @@ target_sources( AcceptsTmMock.cpp PusDistributorMock.cpp CcsdsCheckerMock.cpp - AcceptsTcMock.cpp) + AcceptsTcMock.cpp + StorageManagerMock.cpp) diff --git a/unittests/mocks/StorageManagerMock.cpp b/unittests/mocks/StorageManagerMock.cpp new file mode 100644 index 00000000..5172ecb5 --- /dev/null +++ b/unittests/mocks/StorageManagerMock.cpp @@ -0,0 +1,32 @@ +#include "StorageManagerMock.h" + +ReturnValue_t StorageManagerMock::addData(store_address_t *storageId, const uint8_t *data, + size_t size, bool ignoreFault) { + return 0; +} +ReturnValue_t StorageManagerMock::deleteData(store_address_t packet_id) { return 0; } + +ReturnValue_t StorageManagerMock::deleteData(uint8_t *buffer, size_t size, + store_address_t *storeId) { + return 0; +} + +ReturnValue_t StorageManagerMock::getData(store_address_t packet_id, const uint8_t **packet_ptr, + size_t *size) { + return 0; +} + +ReturnValue_t StorageManagerMock::modifyData(store_address_t packet_id, uint8_t **packet_ptr, + size_t *size) { + return 0; +} +ReturnValue_t StorageManagerMock::getFreeElement(store_address_t *storageId, size_t size, + uint8_t **p_data, bool ignoreFault) { + return 0; +} +bool StorageManagerMock::hasDataAtId(store_address_t storeId) const { return false; } +void StorageManagerMock::clearStore() {} +void StorageManagerMock::clearSubPool(uint8_t poolIndex) {} +void StorageManagerMock::getFillCount(uint8_t *buffer, uint8_t *bytesWritten) {} +size_t StorageManagerMock::getTotalSize(size_t *additionalSize) { return 0; } +StorageManagerIF::max_subpools_t StorageManagerMock::getNumberOfSubPools() const { return 0; } diff --git a/unittests/mocks/StorageManagerMock.h b/unittests/mocks/StorageManagerMock.h new file mode 100644 index 00000000..3f2bf92c --- /dev/null +++ b/unittests/mocks/StorageManagerMock.h @@ -0,0 +1,24 @@ +#ifndef FSFW_TESTS_STORAGEMANAGERMOCK_H +#define FSFW_TESTS_STORAGEMANAGERMOCK_H + +#include "fsfw/storagemanager/StorageManagerIF.h" + +class StorageManagerMock: public StorageManagerIF { + public: + ReturnValue_t addData(store_address_t *storageId, const uint8_t *data, size_t size, + bool ignoreFault) override; + ReturnValue_t deleteData(store_address_t packet_id) override; + ReturnValue_t deleteData(uint8_t *buffer, size_t size, store_address_t *storeId) override; + ReturnValue_t getData(store_address_t packet_id, const uint8_t **packet_ptr, + size_t *size) override; + ReturnValue_t modifyData(store_address_t packet_id, uint8_t **packet_ptr, size_t *size) override; + ReturnValue_t getFreeElement(store_address_t *storageId, size_t size, uint8_t **p_data, + bool ignoreFault) override; + [[nodiscard]] bool hasDataAtId(store_address_t storeId) const override; + void clearStore() override; + void clearSubPool(uint8_t poolIndex) override; + void getFillCount(uint8_t *buffer, uint8_t *bytesWritten) override; + size_t getTotalSize(size_t *additionalSize) override; + [[nodiscard]] max_subpools_t getNumberOfSubPools() const override; +}; +#endif // FSFW_TESTS_STORAGEMANAGERMOCK_H diff --git a/unittests/storagemanager/testAccessor.cpp b/unittests/storagemanager/testAccessor.cpp index 56ab411c..e28d979b 100644 --- a/unittests/storagemanager/testAccessor.cpp +++ b/unittests/storagemanager/testAccessor.cpp @@ -8,7 +8,7 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { LocalPool::LocalPoolConfig poolCfg = {{1, 10}}; - LocalPool SimplePool = LocalPool(0, poolCfg); + LocalPool simplePool = LocalPool(0, poolCfg); std::array testDataArray{}; std::array receptionArray{}; store_address_t testStoreId; @@ -20,9 +20,9 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { size_t size = 10; SECTION("Simple tests getter functions") { - result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + result = simplePool.addData(&testStoreId, testDataArray.data(), size); REQUIRE(result == result::OK); - auto resultPair = SimplePool.getData(testStoreId); + auto resultPair = simplePool.getData(testStoreId); REQUIRE(resultPair.first == result::OK); resultPair.second.getDataCopy(receptionArray.data(), 20); CHECK(resultPair.second.getId() == testStoreId); @@ -38,18 +38,18 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { } { - auto resultPairLoc = SimplePool.getData(testStoreId); + auto resultPairLoc = simplePool.getData(testStoreId); REQUIRE(resultPairLoc.first == result::OK); // data should be deleted when accessor goes out of scope. } - resultPair = SimplePool.getData(testStoreId); + resultPair = simplePool.getData(testStoreId); REQUIRE(resultPair.first == (int)StorageManagerIF::DATA_DOES_NOT_EXIST); - result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + result = simplePool.addData(&testStoreId, testDataArray.data(), size); REQUIRE(result == result::OK); { ConstStorageAccessor constAccessor(testStoreId); - result = SimplePool.getData(testStoreId, constAccessor); + result = simplePool.getData(testStoreId, constAccessor); REQUIRE(result == result::OK); constAccessor.getDataCopy(receptionArray.data(), 20); for (size_t i = 0; i < size; i++) { @@ -57,17 +57,17 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { } // likewise, data should be deleted when accessor gets out of scope. } - resultPair = SimplePool.getData(testStoreId); + resultPair = simplePool.getData(testStoreId); REQUIRE(resultPair.first == (int)StorageManagerIF::DATA_DOES_NOT_EXIST); - result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + result = simplePool.addData(&testStoreId, testDataArray.data(), size); { - resultPair = SimplePool.getData(testStoreId); + resultPair = simplePool.getData(testStoreId); REQUIRE(resultPair.first == result::OK); resultPair.second.release(); // now data should not be deleted anymore } - resultPair = SimplePool.getData(testStoreId); + resultPair = simplePool.getData(testStoreId); REQUIRE(resultPair.first == result::OK); resultPair.second.getDataCopy(receptionArray.data(), 20); for (size_t i = 0; i < size; i++) { @@ -76,11 +76,11 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { } SECTION("Simple tests modify functions") { - result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + result = simplePool.addData(&testStoreId, testDataArray.data(), size); REQUIRE(result == result::OK); { StorageAccessor accessor(testStoreId); - result = SimplePool.modifyData(testStoreId, accessor); + result = simplePool.modifyData(testStoreId, accessor); REQUIRE(result == result::OK); CHECK(accessor.getId() == testStoreId); CHECK(accessor.size() == 10); @@ -94,13 +94,13 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { } // data should be deleted when accessor goes out of scope } - auto resultPair = SimplePool.getData(testStoreId); + auto resultPair = simplePool.getData(testStoreId); REQUIRE(resultPair.first == (int)StorageManagerIF::DATA_DOES_NOT_EXIST); - result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + result = simplePool.addData(&testStoreId, testDataArray.data(), size); REQUIRE(result == result::OK); { - auto resultPairLoc = SimplePool.modifyData(testStoreId); + auto resultPairLoc = simplePool.modifyData(testStoreId); REQUIRE(resultPairLoc.first == result::OK); CHECK(resultPairLoc.second.getId() == testStoreId); CHECK(resultPairLoc.second.size() == 10); @@ -116,22 +116,22 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { resultPairLoc.second.release(); // data should not be deleted when accessor goes out of scope } - resultPair = SimplePool.getData(testStoreId); + resultPair = simplePool.getData(testStoreId); REQUIRE(resultPair.first == result::OK); } SECTION("Write tests") { - result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + result = simplePool.addData(&testStoreId, testDataArray.data(), size); REQUIRE(result == result::OK); { - auto resultPair = SimplePool.modifyData(testStoreId); + auto resultPair = simplePool.modifyData(testStoreId); REQUIRE(resultPair.first == result::OK); testDataArray[9] = 42; resultPair.second.write(testDataArray.data(), 10, 0); // now data should not be deleted resultPair.second.release(); } - auto resultConstPair = SimplePool.getData(testStoreId); + auto resultConstPair = simplePool.getData(testStoreId); REQUIRE(resultConstPair.first == result::OK); resultConstPair.second.getDataCopy(receptionArray.data(), 10); @@ -140,7 +140,7 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { } CHECK(receptionArray[9] == 42); - auto resultPair = SimplePool.modifyData(testStoreId); + auto resultPair = simplePool.modifyData(testStoreId); REQUIRE(resultPair.first == result::OK); result = resultPair.second.write(testDataArray.data(), 20, 0); REQUIRE(result == result::FAILED); @@ -150,7 +150,7 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { std::memset(testDataArray.data(), 42, 5); result = resultPair.second.write(testDataArray.data(), 5, 5); REQUIRE(result == result::OK); - resultConstPair = SimplePool.getData(testStoreId); + resultConstPair = simplePool.getData(testStoreId); resultPair.second.getDataCopy(receptionArray.data(), 20); for (size_t i = 5; i < 10; i++) { CHECK(receptionArray[i] == 42); @@ -158,7 +158,7 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { } SECTION("Operators") { - result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + result = simplePool.addData(&testStoreId, testDataArray.data(), size); REQUIRE(result == result::OK); { StorageAccessor accessor(testStoreId); @@ -169,7 +169,7 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { size_t size = 6; result = accessor.write(data.data(), data.size()); REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); - result = SimplePool.modifyData(testStoreId, accessor2); + result = simplePool.modifyData(testStoreId, accessor2); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); CHECK(accessor2.getId() == testStoreId); CHECK(accessor2.size() == 10); From 22e1555f5097cae82413976cee55921aba0ac3ee Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 12:45:05 +0200 Subject: [PATCH 198/532] basic storage manager mock --- unittests/mocks/StorageManagerMock.cpp | 67 +++++++++++++++++++++----- unittests/mocks/StorageManagerMock.h | 10 +++- 2 files changed, 65 insertions(+), 12 deletions(-) diff --git a/unittests/mocks/StorageManagerMock.cpp b/unittests/mocks/StorageManagerMock.cpp index 5172ecb5..fc517953 100644 --- a/unittests/mocks/StorageManagerMock.cpp +++ b/unittests/mocks/StorageManagerMock.cpp @@ -2,31 +2,76 @@ ReturnValue_t StorageManagerMock::addData(store_address_t *storageId, const uint8_t *data, size_t size, bool ignoreFault) { - return 0; + if (nextAddDataCallFails.first) { + return nextAddDataCallFails.second; + } + return LocalPool::addData(storageId, data, size, ignoreFault); +} +ReturnValue_t StorageManagerMock::deleteData(store_address_t packet_id) { + if(nextDeleteDataCallFails.first) { + return nextDeleteDataCallFails.second; + } + return LocalPool::deleteData(packet_id); } -ReturnValue_t StorageManagerMock::deleteData(store_address_t packet_id) { return 0; } ReturnValue_t StorageManagerMock::deleteData(uint8_t *buffer, size_t size, store_address_t *storeId) { - return 0; + if(nextDeleteDataCallFails.first) { + return nextDeleteDataCallFails.second; + } + return LocalPool::deleteData(buffer, size, storeId); } ReturnValue_t StorageManagerMock::getData(store_address_t packet_id, const uint8_t **packet_ptr, size_t *size) { - return 0; + if (nextGetDataCallFails.first) { + return nextGetDataCallFails.second; + } + return LocalPool::getData(packet_id, packet_ptr, size); } ReturnValue_t StorageManagerMock::modifyData(store_address_t packet_id, uint8_t **packet_ptr, size_t *size) { - return 0; + if (nextModifyDataCallFails.first) { + return nextModifyDataCallFails.second; + } + return LocalPool::modifyData(packet_id, packet_ptr, size); } ReturnValue_t StorageManagerMock::getFreeElement(store_address_t *storageId, size_t size, uint8_t **p_data, bool ignoreFault) { return 0; } -bool StorageManagerMock::hasDataAtId(store_address_t storeId) const { return false; } -void StorageManagerMock::clearStore() {} -void StorageManagerMock::clearSubPool(uint8_t poolIndex) {} -void StorageManagerMock::getFillCount(uint8_t *buffer, uint8_t *bytesWritten) {} -size_t StorageManagerMock::getTotalSize(size_t *additionalSize) { return 0; } -StorageManagerIF::max_subpools_t StorageManagerMock::getNumberOfSubPools() const { return 0; } +bool StorageManagerMock::hasDataAtId(store_address_t storeId) const { + return LocalPool::hasDataAtId(storeId); +} +void StorageManagerMock::clearStore() { + return LocalPool::clearStore(); +} + +void StorageManagerMock::clearSubPool(uint8_t poolIndex) { + return LocalPool::clearSubPool(poolIndex); +} + +void StorageManagerMock::getFillCount(uint8_t *buffer, uint8_t *bytesWritten) { + return LocalPool::getFillCount(buffer, bytesWritten); +} + +size_t StorageManagerMock::getTotalSize(size_t *additionalSize) { + return LocalPool::getTotalSize(additionalSize); +} + +StorageManagerIF::max_subpools_t StorageManagerMock::getNumberOfSubPools() const { + return LocalPool::getNumberOfSubPools(); +} + +void StorageManagerMock::reset() { + clearStore(); + nextAddDataCallFails.first = false; + nextAddDataCallFails.second = result::OK; + nextModifyDataCallFails.first = false; + nextModifyDataCallFails.second = result::OK; + nextGetDataCallFails.first = false; + nextGetDataCallFails.second = result::OK; + nextDeleteDataCallFails.first = false; + nextDeleteDataCallFails.second = result::OK; +} diff --git a/unittests/mocks/StorageManagerMock.h b/unittests/mocks/StorageManagerMock.h index 3f2bf92c..40bb88cc 100644 --- a/unittests/mocks/StorageManagerMock.h +++ b/unittests/mocks/StorageManagerMock.h @@ -1,9 +1,10 @@ #ifndef FSFW_TESTS_STORAGEMANAGERMOCK_H #define FSFW_TESTS_STORAGEMANAGERMOCK_H +#include "fsfw/storagemanager/LocalPool.h" #include "fsfw/storagemanager/StorageManagerIF.h" -class StorageManagerMock: public StorageManagerIF { +class StorageManagerMock: public LocalPool { public: ReturnValue_t addData(store_address_t *storageId, const uint8_t *data, size_t size, bool ignoreFault) override; @@ -20,5 +21,12 @@ class StorageManagerMock: public StorageManagerIF { void getFillCount(uint8_t *buffer, uint8_t *bytesWritten) override; size_t getTotalSize(size_t *additionalSize) override; [[nodiscard]] max_subpools_t getNumberOfSubPools() const override; + + std::pair nextAddDataCallFails; + std::pair nextModifyDataCallFails; + std::pair nextGetDataCallFails; + std::pair nextDeleteDataCallFails; + + void reset(); }; #endif // FSFW_TESTS_STORAGEMANAGERMOCK_H From 192956c2c78a51d4433f7052b1d45985b26ded9d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 12:50:50 +0200 Subject: [PATCH 199/532] use new storage manager mock --- unittests/cfdp/testDistributor.cpp | 5 +++-- unittests/mocks/StorageManagerMock.cpp | 14 +++++++++++++- unittests/mocks/StorageManagerMock.h | 4 +++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/unittests/cfdp/testDistributor.cpp b/unittests/cfdp/testDistributor.cpp index b65f6816..c5ed9948 100644 --- a/unittests/cfdp/testDistributor.cpp +++ b/unittests/cfdp/testDistributor.cpp @@ -5,10 +5,11 @@ #include "fsfw/storagemanager/LocalPool.h" #include "mocks/AcceptsTcMock.h" #include "mocks/MessageQueueMock.h" +#include "mocks/StorageManagerMock.h" TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}}; - LocalPool pool(objects::NO_OBJECT, cfg); + StorageManagerMock pool(objects::NO_OBJECT, cfg); auto queue = MessageQueueMock(1); CfdpDistribCfg distribCfg(1, pool, &queue); auto distributor = CfdpDistributor(distribCfg); @@ -42,7 +43,7 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); size_t serLen = 0; store_address_t storeId; - CHECK(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == result::OK); + CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == result::OK); REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == result::OK); TmTcMessage msg(storeId); diff --git a/unittests/mocks/StorageManagerMock.cpp b/unittests/mocks/StorageManagerMock.cpp index fc517953..13f513e6 100644 --- a/unittests/mocks/StorageManagerMock.cpp +++ b/unittests/mocks/StorageManagerMock.cpp @@ -37,10 +37,15 @@ ReturnValue_t StorageManagerMock::modifyData(store_address_t packet_id, uint8_t } return LocalPool::modifyData(packet_id, packet_ptr, size); } + ReturnValue_t StorageManagerMock::getFreeElement(store_address_t *storageId, size_t size, uint8_t **p_data, bool ignoreFault) { - return 0; + if (nextFreeElementCallFails.first) { + return nextFreeElementCallFails.second; + } + return LocalPool::getFreeElement(storageId, size, p_data, ignoreFault); } + bool StorageManagerMock::hasDataAtId(store_address_t storeId) const { return LocalPool::hasDataAtId(storeId); } @@ -74,4 +79,11 @@ void StorageManagerMock::reset() { nextGetDataCallFails.second = result::OK; nextDeleteDataCallFails.first = false; nextDeleteDataCallFails.second = result::OK; + nextFreeElementCallFails.first = false; + nextFreeElementCallFails.second = result::OK; +} + +StorageManagerMock::StorageManagerMock(object_id_t setObjectId, + const LocalPool::LocalPoolConfig &poolConfig) + : LocalPool(setObjectId, poolConfig) { } diff --git a/unittests/mocks/StorageManagerMock.h b/unittests/mocks/StorageManagerMock.h index 40bb88cc..be2b7982 100644 --- a/unittests/mocks/StorageManagerMock.h +++ b/unittests/mocks/StorageManagerMock.h @@ -6,6 +6,8 @@ class StorageManagerMock: public LocalPool { public: + StorageManagerMock(object_id_t setObjectId, const LocalPoolConfig& poolConfig); + ReturnValue_t addData(store_address_t *storageId, const uint8_t *data, size_t size, bool ignoreFault) override; ReturnValue_t deleteData(store_address_t packet_id) override; @@ -26,7 +28,7 @@ class StorageManagerMock: public LocalPool { std::pair nextModifyDataCallFails; std::pair nextGetDataCallFails; std::pair nextDeleteDataCallFails; - + std::pair nextFreeElementCallFails; void reset(); }; #endif // FSFW_TESTS_STORAGEMANAGERMOCK_H From 0d26a0f54bdb00eabdffa7b6964377c6d0ba1b77 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 13:04:23 +0200 Subject: [PATCH 200/532] fnish CFDP distributor unittests --- src/fsfw/cfdp/CfdpDistributor.h | 8 ++++ .../storagemanager/ConstStorageAccessor.h | 4 +- src/fsfw/storagemanager/LocalPool.cpp | 3 +- src/fsfw/storagemanager/PoolManager.h | 8 ++-- src/fsfw/storagemanager/StorageAccessor.h | 4 +- src/fsfw/storagemanager/StorageManagerIF.h | 3 +- unittests/cfdp/testDistributor.cpp | 40 ++++++++++++++++++- unittests/mocks/StorageManagerMock.cpp | 16 ++------ unittests/mocks/StorageManagerMock.h | 9 +++-- 9 files changed, 66 insertions(+), 29 deletions(-) diff --git a/src/fsfw/cfdp/CfdpDistributor.h b/src/fsfw/cfdp/CfdpDistributor.h index 8fece981..64c5ca9f 100644 --- a/src/fsfw/cfdp/CfdpDistributor.h +++ b/src/fsfw/cfdp/CfdpDistributor.h @@ -42,6 +42,14 @@ class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF { [[nodiscard]] const char* getName() const override; [[nodiscard]] uint32_t getIdentifier() const override; [[nodiscard]] MessageQueueId_t getRequestQueue() const override; + + /** + * Register a new CFDP entity which can receive PDUs. + * @param address + * @param tcDest + * @return + * - @c RETURN_FAILED: Entry already exists for the given address + */ ReturnValue_t registerTcDestination(const cfdp::EntityId& address, AcceptsTelecommandsIF& tcDest); protected: diff --git a/src/fsfw/storagemanager/ConstStorageAccessor.h b/src/fsfw/storagemanager/ConstStorageAccessor.h index e70d3f40..a935e467 100644 --- a/src/fsfw/storagemanager/ConstStorageAccessor.h +++ b/src/fsfw/storagemanager/ConstStorageAccessor.h @@ -80,8 +80,8 @@ class ConstStorageAccessor { * @param * @return */ - ConstStorageAccessor& operator=(ConstStorageAccessor&&) noexcept ; - ConstStorageAccessor(ConstStorageAccessor&&) noexcept ; + ConstStorageAccessor& operator=(ConstStorageAccessor&&) noexcept; + ConstStorageAccessor(ConstStorageAccessor&&) noexcept; //! The copy ctor and copy assignemnt should be deleted implicitely //! according to https://foonathan.net/2019/02/special-member-functions/ diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index e40315ed..bcb1bea6 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -167,8 +167,7 @@ void LocalPool::clearStore() { } } -ReturnValue_t LocalPool::reserveSpace(size_t size, store_address_t* storeId, - bool ignoreFault) { +ReturnValue_t LocalPool::reserveSpace(size_t size, store_address_t* storeId, bool ignoreFault) { ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); if (status != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/storagemanager/PoolManager.h b/src/fsfw/storagemanager/PoolManager.h index 0951a518..eaa978ef 100644 --- a/src/fsfw/storagemanager/PoolManager.h +++ b/src/fsfw/storagemanager/PoolManager.h @@ -27,7 +27,7 @@ class PoolManager : public LocalPool { * @brief In the PoolManager's destructor all allocated memory * is freed. */ - virtual ~PoolManager(); + ~PoolManager() override; /** * Set the default mutex timeout for internal calls. @@ -40,8 +40,7 @@ class PoolManager : public LocalPool { * which wraps LocalPool calls with a mutex protection. */ ReturnValue_t deleteData(store_address_t) override; - ReturnValue_t deleteData(uint8_t* buffer, size_t size, - store_address_t* storeId = nullptr) override; + ReturnValue_t deleteData(uint8_t* buffer, size_t size, store_address_t* storeId) override; /** * The developer is allowed to lock the mutex in case the lock needs @@ -58,8 +57,7 @@ class PoolManager : public LocalPool { //! Default mutex timeout value to prevent permanent blocking. uint32_t mutexTimeoutMs = 20; - ReturnValue_t reserveSpace(const size_t size, store_address_t* address, - bool ignoreFault) override; + ReturnValue_t reserveSpace(size_t size, store_address_t* address, bool ignoreFault) override; /** * @brief The mutex is created in the constructor and makes diff --git a/src/fsfw/storagemanager/StorageAccessor.h b/src/fsfw/storagemanager/StorageAccessor.h index f51ba7e6..b6c5dc14 100644 --- a/src/fsfw/storagemanager/StorageAccessor.h +++ b/src/fsfw/storagemanager/StorageAccessor.h @@ -26,8 +26,8 @@ class StorageAccessor : public ConstStorageAccessor { * @param * @return */ - StorageAccessor& operator=(StorageAccessor&&) noexcept ; - StorageAccessor(StorageAccessor&&) noexcept ; + StorageAccessor& operator=(StorageAccessor&&) noexcept; + StorageAccessor(StorageAccessor&&) noexcept; ReturnValue_t write(uint8_t* data, size_t size, uint16_t offset = 0); uint8_t* data(); diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index 36ad5370..502348de 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -92,8 +92,7 @@ class StorageManagerIF : public HasReturnvaluesIF { * @return @li RETURN_OK on success. * @li failure code if deletion did not work */ - virtual ReturnValue_t deleteData(uint8_t* buffer, size_t size, - store_address_t* storeId) = 0; + virtual ReturnValue_t deleteData(uint8_t* buffer, size_t size, store_address_t* storeId) = 0; virtual ReturnValue_t deleteData(uint8_t* buffer, size_t size) { return deleteData(buffer, size, nullptr); } diff --git a/unittests/cfdp/testDistributor.cpp b/unittests/cfdp/testDistributor.cpp index c5ed9948..2e94a55e 100644 --- a/unittests/cfdp/testDistributor.cpp +++ b/unittests/cfdp/testDistributor.cpp @@ -3,6 +3,7 @@ #include "fsfw/cfdp/CfdpDistributor.h" #include "fsfw/cfdp/pdu/MetadataPduCreator.h" #include "fsfw/storagemanager/LocalPool.h" +#include "fsfw/tcdistribution/definitions.h" #include "mocks/AcceptsTcMock.h" #include "mocks/MessageQueueMock.h" #include "mocks/StorageManagerMock.h" @@ -17,6 +18,8 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { auto groundEntityId = cfdp::EntityId(UnsignedByteField(1)); MessageQueueId_t receiverQueueId = 3; auto tcAcceptor = AcceptsTcMock("CFDP Receiver", 0, receiverQueueId); + + // Set up Metadata PDU for generate test data. cfdp::FileSize fileSize(12); const cfdp::EntityId& sourceId(groundEntityId); const cfdp::EntityId& destId(obswEntityId); @@ -43,7 +46,8 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); size_t serLen = 0; store_address_t storeId; - CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == result::OK); + CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == + result::OK); REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == result::OK); TmTcMessage msg(storeId); @@ -57,4 +61,38 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { CHECK(queue.getNextSentMessage(receiverQueueId, sentMsg) == result::OK); CHECK(sentMsg.getStorageId() == storeId); } + + SECTION("No Destination found") { + CHECK(distributor.initialize() == result::OK); + size_t serLen = 0; + store_address_t storeId; + CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == + result::OK); + REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == + result::OK); + TmTcMessage msg(storeId); + queue.addReceivedMessage(msg); + CHECK(distributor.performOperation(0) == tmtcdistrib::NO_DESTINATION_FOUND); + } + + SECTION("Getting data fails") { + pool.nextModifyDataCallFails.first = true; + pool.nextModifyDataCallFails.second = StorageManagerIF::DATA_DOES_NOT_EXIST; + size_t serLen = 0; + store_address_t storeId; + CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); + CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == + result::OK); + REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == + result::OK); + TmTcMessage msg(storeId); + queue.addReceivedMessage(msg); + CHECK(distributor.performOperation(0) == StorageManagerIF::DATA_DOES_NOT_EXIST); + } + + SECTION("Duplicate registration") { + CHECK(distributor.initialize() == result::OK); + CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); + CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::FAILED); + } } \ No newline at end of file diff --git a/unittests/mocks/StorageManagerMock.cpp b/unittests/mocks/StorageManagerMock.cpp index 13f513e6..387b5b17 100644 --- a/unittests/mocks/StorageManagerMock.cpp +++ b/unittests/mocks/StorageManagerMock.cpp @@ -8,7 +8,7 @@ ReturnValue_t StorageManagerMock::addData(store_address_t *storageId, const uint return LocalPool::addData(storageId, data, size, ignoreFault); } ReturnValue_t StorageManagerMock::deleteData(store_address_t packet_id) { - if(nextDeleteDataCallFails.first) { + if (nextDeleteDataCallFails.first) { return nextDeleteDataCallFails.second; } return LocalPool::deleteData(packet_id); @@ -16,7 +16,7 @@ ReturnValue_t StorageManagerMock::deleteData(store_address_t packet_id) { ReturnValue_t StorageManagerMock::deleteData(uint8_t *buffer, size_t size, store_address_t *storeId) { - if(nextDeleteDataCallFails.first) { + if (nextDeleteDataCallFails.first) { return nextDeleteDataCallFails.second; } return LocalPool::deleteData(buffer, size, storeId); @@ -24,9 +24,6 @@ ReturnValue_t StorageManagerMock::deleteData(uint8_t *buffer, size_t size, ReturnValue_t StorageManagerMock::getData(store_address_t packet_id, const uint8_t **packet_ptr, size_t *size) { - if (nextGetDataCallFails.first) { - return nextGetDataCallFails.second; - } return LocalPool::getData(packet_id, packet_ptr, size); } @@ -49,9 +46,7 @@ ReturnValue_t StorageManagerMock::getFreeElement(store_address_t *storageId, siz bool StorageManagerMock::hasDataAtId(store_address_t storeId) const { return LocalPool::hasDataAtId(storeId); } -void StorageManagerMock::clearStore() { - return LocalPool::clearStore(); -} +void StorageManagerMock::clearStore() { return LocalPool::clearStore(); } void StorageManagerMock::clearSubPool(uint8_t poolIndex) { return LocalPool::clearSubPool(poolIndex); @@ -75,8 +70,6 @@ void StorageManagerMock::reset() { nextAddDataCallFails.second = result::OK; nextModifyDataCallFails.first = false; nextModifyDataCallFails.second = result::OK; - nextGetDataCallFails.first = false; - nextGetDataCallFails.second = result::OK; nextDeleteDataCallFails.first = false; nextDeleteDataCallFails.second = result::OK; nextFreeElementCallFails.first = false; @@ -85,5 +78,4 @@ void StorageManagerMock::reset() { StorageManagerMock::StorageManagerMock(object_id_t setObjectId, const LocalPool::LocalPoolConfig &poolConfig) - : LocalPool(setObjectId, poolConfig) { -} + : LocalPool(setObjectId, poolConfig) {} diff --git a/unittests/mocks/StorageManagerMock.h b/unittests/mocks/StorageManagerMock.h index be2b7982..f33ba19b 100644 --- a/unittests/mocks/StorageManagerMock.h +++ b/unittests/mocks/StorageManagerMock.h @@ -4,9 +4,9 @@ #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/storagemanager/StorageManagerIF.h" -class StorageManagerMock: public LocalPool { +class StorageManagerMock : public LocalPool { public: - StorageManagerMock(object_id_t setObjectId, const LocalPoolConfig& poolConfig); + StorageManagerMock(object_id_t setObjectId, const LocalPoolConfig &poolConfig); ReturnValue_t addData(store_address_t *storageId, const uint8_t *data, size_t size, bool ignoreFault) override; @@ -25,8 +25,11 @@ class StorageManagerMock: public LocalPool { [[nodiscard]] max_subpools_t getNumberOfSubPools() const override; std::pair nextAddDataCallFails; + /** + * This can be used to make both the modify and get API call fail. This is because generally, + * the pool implementation get functions will use the modify API internally. + */ std::pair nextModifyDataCallFails; - std::pair nextGetDataCallFails; std::pair nextDeleteDataCallFails; std::pair nextFreeElementCallFails; void reset(); From 7fb906a0ac3746de8a8cf577787f2bdd5b9360a0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 14:05:43 +0200 Subject: [PATCH 201/532] add first fault handler base class --- src/fsfw/cfdp/CMakeLists.txt | 5 ++-- src/fsfw/cfdp/CfdpDestHandler.h | 11 ++++++- src/fsfw/cfdp/FaultHandlerBase.cpp | 5 ++++ src/fsfw/cfdp/FaultHandlerBase.h | 29 +++++++++++++++++++ src/fsfw/cfdp/definitions.h | 23 +++++++++++++++ src/fsfw/cfdp/pdu/FinishedInfo.h | 14 ++++----- src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp | 6 ++-- src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h | 22 ++++---------- unittests/cfdp/testTlvsLvs.cpp | 2 +- 9 files changed, 86 insertions(+), 31 deletions(-) create mode 100644 src/fsfw/cfdp/FaultHandlerBase.cpp create mode 100644 src/fsfw/cfdp/FaultHandlerBase.h diff --git a/src/fsfw/cfdp/CMakeLists.txt b/src/fsfw/cfdp/CMakeLists.txt index 3d35ea69..df83bd7f 100644 --- a/src/fsfw/cfdp/CMakeLists.txt +++ b/src/fsfw/cfdp/CMakeLists.txt @@ -1,6 +1,7 @@ target_sources( - ${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp - CfdpSourceHandler.cpp CfdpDestHandler.cpp) + ${LIB_FSFW_NAME} + PRIVATE CfdpMessage.cpp CfdpDistributor.cpp CfdpSourceHandler.cpp + CfdpDestHandler.cpp FaultHandlerBase.cpp) # CfdpDistributor.cpp CfdpHandler.cpp add_subdirectory(pdu) diff --git a/src/fsfw/cfdp/CfdpDestHandler.h b/src/fsfw/cfdp/CfdpDestHandler.h index 69d40ed3..e317cc4f 100644 --- a/src/fsfw/cfdp/CfdpDestHandler.h +++ b/src/fsfw/cfdp/CfdpDestHandler.h @@ -1,6 +1,15 @@ #ifndef FSFW_CFDP_CFDPDESTHANDLER_H #define FSFW_CFDP_CFDPDESTHANDLER_H -class CfdpDestHandler {}; +#include + +#include "fsfw/cfdp/pdu/PduConfig.h" + +class CfdpDestHandler { + public: + CfdpDestHandler(); + + private: +}; #endif // FSFW_CFDP_CFDPDESTHANDLER_H diff --git a/src/fsfw/cfdp/FaultHandlerBase.cpp b/src/fsfw/cfdp/FaultHandlerBase.cpp new file mode 100644 index 00000000..b56e52d5 --- /dev/null +++ b/src/fsfw/cfdp/FaultHandlerBase.cpp @@ -0,0 +1,5 @@ +#include "FaultHandlerBase.h" + +CfdpFaultHandlerBase::CfdpFaultHandlerBase() {} + +CfdpFaultHandlerBase::~CfdpFaultHandlerBase() = default; diff --git a/src/fsfw/cfdp/FaultHandlerBase.h b/src/fsfw/cfdp/FaultHandlerBase.h new file mode 100644 index 00000000..0db0743f --- /dev/null +++ b/src/fsfw/cfdp/FaultHandlerBase.h @@ -0,0 +1,29 @@ +#ifndef FSFW_CFDP_FAULTHANDLERBASE_H +#define FSFW_CFDP_FAULTHANDLERBASE_H + +#include + +#include "definitions.h" + +class CfdpFaultHandlerBase { + public: + virtual ~CfdpFaultHandlerBase(); + CfdpFaultHandlerBase(); + + private: + etl::flat_map handleMap = { + etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED, + cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED, + cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::INVALID_TRANSMISSION_MODE, + cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::FILE_CHECKSUM_FAILURE, cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::FILE_SIZE_ERROR, cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::NAK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::INACTIVITY_DETECTED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE, + cfdp::FaultHandlerCodes::IGNORE_ERROR}}; +}; + +#endif // FSFW_CFDP_FAULTHANDLERBASE_H diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 6b3b11e3..67e1edd4 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -6,6 +6,7 @@ #include #include +#include "fsfw/cfdp/pdu/PduHeaderIF.h" #include "fsfw/returnvalues/FwClassIds.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" @@ -90,6 +91,14 @@ enum ConditionCode : uint8_t { CANCEL_REQUEST_RECEIVED = 0b1111 }; +enum FaultHandlerCodes { + RESERVED = 0b0000, + NOTICE_OF_CANCELLATION = 0b0001, + NOTICE_OF_SUSPENSION = 0b0010, + IGNORE_ERROR = 0b0011, + ABANDON_TRANSACTION = 0b0100 +}; + enum AckTransactionStatus { UNDEFINED = 0b00, ACTIVE = 0b01, @@ -125,6 +134,20 @@ enum RecordContinuationState { CONTAINS_START_AND_END = 0b11 }; +struct IndicationCfg { + bool eofSentIndicRequired = true; + bool eofRecvIndicRequired = true; + bool fileSegmentRecvIndicRequired = true; + bool transactionFinishedIndicRequired = true; + bool suspendedIndicRequired = true; + bool resumedIndicRequired = true; +}; + +struct LocalEntityCfg { + EntityId localId; + IndicationCfg indicCfg; +}; + } // namespace cfdp #endif /* FSFW_SRC_FSFW_CFDP_PDU_DEFINITIONS_H_ */ diff --git a/src/fsfw/cfdp/pdu/FinishedInfo.h b/src/fsfw/cfdp/pdu/FinishedInfo.h index 5768a298..3f1758e8 100644 --- a/src/fsfw/cfdp/pdu/FinishedInfo.h +++ b/src/fsfw/cfdp/pdu/FinishedInfo.h @@ -11,10 +11,10 @@ class FinishedInfo { FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FinishedDeliveryCode deliveryCode, cfdp::FinishedFileStatus fileStatus); - size_t getSerializedSize() const; + [[nodiscard]] size_t getSerializedSize() const; - bool hasFsResponses() const; - bool canHoldFsResponses() const; + [[nodiscard]] bool hasFsResponses() const; + [[nodiscard]] bool canHoldFsResponses() const; ReturnValue_t setFilestoreResponsesArray(FilestoreResponseTlv** fsResponses, size_t* fsResponsesLen, const size_t* maxFsResponseLen); @@ -22,14 +22,14 @@ class FinishedInfo { ReturnValue_t getFilestoreResonses(FilestoreResponseTlv*** fsResponses, size_t* fsResponsesLen, size_t* fsResponsesMaxLen); - size_t getFsResponsesLen() const; + [[nodiscard]] size_t getFsResponsesLen() const; void setFilestoreResponsesArrayLen(size_t fsResponsesLen); ReturnValue_t getFaultLocation(EntityIdTlv** entityId); - cfdp::ConditionCode getConditionCode() const; + [[nodiscard]] cfdp::ConditionCode getConditionCode() const; void setConditionCode(cfdp::ConditionCode conditionCode); - cfdp::FinishedDeliveryCode getDeliveryCode() const; + [[nodiscard]] cfdp::FinishedDeliveryCode getDeliveryCode() const; void setDeliveryCode(cfdp::FinishedDeliveryCode deliveryCode); - cfdp::FinishedFileStatus getFileStatus() const; + [[nodiscard]] cfdp::FinishedFileStatus getFileStatus() const; void setFileStatus(cfdp::FinishedFileStatus fileStatus); private: diff --git a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp index f5f777ea..73dc389c 100644 --- a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp +++ b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp @@ -1,10 +1,10 @@ #include "FaultHandlerOverrideTlv.h" FaultHandlerOverrideTlv::FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode, - cfdp::FaultHandlerCode handlerCode) + cfdp::FaultHandlerCodes handlerCode) : conditionCode(conditionCode), handlerCode(handlerCode) {} -FaultHandlerOverrideTlv::FaultHandlerOverrideTlv() {} +FaultHandlerOverrideTlv::FaultHandlerOverrideTlv() = default; uint8_t FaultHandlerOverrideTlv::getLengthField() const { return 1; } @@ -45,7 +45,7 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_ *buffer += 1; *size += 1; this->conditionCode = static_cast((**buffer >> 4) & 0x0f); - this->handlerCode = static_cast(**buffer & 0x0f); + this->handlerCode = static_cast(**buffer & 0x0f); *buffer += 1; *size += 1; return HasReturnvaluesIF::RETURN_OK; diff --git a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h index 9f2adbb3..a9cee9e6 100644 --- a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h +++ b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h @@ -3,36 +3,24 @@ #include "TlvIF.h" -namespace cfdp { - -enum FaultHandlerCode { - RESERVED = 0b0000, - NOTICE_OF_CANCELLATION = 0b0001, - NOTICE_OF_SUSPENSION = 0b0010, - IGNORE_ERROR = 0b0011, - ABANDON_TRANSACTION = 0b0100 -}; - -} - class FaultHandlerOverrideTlv : public TlvIF { public: FaultHandlerOverrideTlv(); - FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode, cfdp::FaultHandlerCode handlerCode); + FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode, cfdp::FaultHandlerCodes handlerCode); ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; - size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; - uint8_t getLengthField() const override; - cfdp::TlvTypes getType() const override; + [[nodiscard]] uint8_t getLengthField() const override; + [[nodiscard]] cfdp::TlvTypes getType() const override; private: cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD; - cfdp::FaultHandlerCode handlerCode = cfdp::FaultHandlerCode::RESERVED; + cfdp::FaultHandlerCodes handlerCode = cfdp::FaultHandlerCodes::RESERVED; }; #endif /* FSFW_SRC_FSFW_CFDP_TLV_FAULTHANDLEROVERRIDETLV_H_ */ diff --git a/unittests/cfdp/testTlvsLvs.cpp b/unittests/cfdp/testTlvsLvs.cpp index acee9cce..7536069f 100644 --- a/unittests/cfdp/testTlvsLvs.cpp +++ b/unittests/cfdp/testTlvsLvs.cpp @@ -304,7 +304,7 @@ TEST_CASE("CFDP TLV LV", "[cfdp]") { FlowLabelTlv flowLabelTlv(&flowLabel, 1); FaultHandlerOverrideTlv faultOverrideTlv(cfdp::ConditionCode::FILESTORE_REJECTION, - cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION); + cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION); size_t sz = 0; result = faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); From eccb629ba8ff8761ec6b382481d0ce6262940dbf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 14:39:03 +0200 Subject: [PATCH 202/532] fnished fault handler base --- src/fsfw/cfdp/FaultHandlerBase.cpp | 38 ++++++++++++++++++++++++++++- src/fsfw/cfdp/FaultHandlerBase.h | 22 ++++++++++++++++- src/fsfw/cfdp/definitions.h | 15 ------------ src/fsfw/cfdp/mib.h | 19 +++++++++++++++ src/fsfw/cfdp/pdu/HeaderCreator.cpp | 2 -- src/fsfw/cfdp/pdu/HeaderCreator.h | 28 ++++++++++----------- src/fsfw/cfdp/pdu/PduConfig.h | 3 ++- src/fsfw/cfdp/pdu/PduHeaderIF.h | 2 +- src/fsfw/cfdp/pdu/VarLenField.cpp | 1 - src/fsfw/cfdp/pdu/VarLenField.h | 10 +++++--- 10 files changed, 100 insertions(+), 40 deletions(-) create mode 100644 src/fsfw/cfdp/mib.h diff --git a/src/fsfw/cfdp/FaultHandlerBase.cpp b/src/fsfw/cfdp/FaultHandlerBase.cpp index b56e52d5..06edabd6 100644 --- a/src/fsfw/cfdp/FaultHandlerBase.cpp +++ b/src/fsfw/cfdp/FaultHandlerBase.cpp @@ -1,5 +1,41 @@ #include "FaultHandlerBase.h" -CfdpFaultHandlerBase::CfdpFaultHandlerBase() {} +CfdpFaultHandlerBase::CfdpFaultHandlerBase() = default; + +bool CfdpFaultHandlerBase::getFaultHandler( + cfdp::ConditionCode code, cfdp::FaultHandlerCodes& handler) const { + auto iter = faultHandlerMap.find(code); + if(iter == faultHandlerMap.end()) { + return false; + } + handler = iter->second; + return true; +} + +bool CfdpFaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, + cfdp::FaultHandlerCodes handler) { + if (not faultHandlerMap.contains(code)) { + return false; + } + faultHandlerMap[code] = handler; + return true; +} + +bool CfdpFaultHandlerBase::faultCallback(cfdp::ConditionCode code) { + if (not faultHandlerMap.contains(code)) { + return false; + } + cfdp::FaultHandlerCodes fh = faultHandlerMap[code]; + if (fh == cfdp::FaultHandlerCodes::IGNORE_ERROR) { + ignoreCb(code); + } else if(fh == cfdp::FaultHandlerCodes::ABANDON_TRANSACTION) { + abandonCb(code); + } else if(fh == cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION) { + noticeOfCancellationCb(code); + } else { + noticeOfSuspensionCb(code); + } + return true; +} CfdpFaultHandlerBase::~CfdpFaultHandlerBase() = default; diff --git a/src/fsfw/cfdp/FaultHandlerBase.h b/src/fsfw/cfdp/FaultHandlerBase.h index 0db0743f..fc18f1c7 100644 --- a/src/fsfw/cfdp/FaultHandlerBase.h +++ b/src/fsfw/cfdp/FaultHandlerBase.h @@ -10,8 +10,28 @@ class CfdpFaultHandlerBase { virtual ~CfdpFaultHandlerBase(); CfdpFaultHandlerBase(); + /** + * Get the fault handler code for the given condition code + * @param code + * @param handler [out] Will be set to the approrpiate handler for the condition code if + * it is valid + * @return + * - true if the condition code is valid + * - false otherwise + */ + bool getFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes& handler) const; + + bool setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes handler); + + bool faultCallback(cfdp::ConditionCode code); + + virtual void noticeOfSuspensionCb(cfdp::ConditionCode code) = 0; + virtual void noticeOfCancellationCb(cfdp::ConditionCode code) = 0; + virtual void abandonCb(cfdp::ConditionCode code) = 0; + virtual void ignoreCb(cfdp::ConditionCode code) = 0; + private: - etl::flat_map handleMap = { + etl::flat_map faultHandlerMap = { etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED, diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 67e1edd4..b97b9b27 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -6,7 +6,6 @@ #include #include -#include "fsfw/cfdp/pdu/PduHeaderIF.h" #include "fsfw/returnvalues/FwClassIds.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" @@ -134,20 +133,6 @@ enum RecordContinuationState { CONTAINS_START_AND_END = 0b11 }; -struct IndicationCfg { - bool eofSentIndicRequired = true; - bool eofRecvIndicRequired = true; - bool fileSegmentRecvIndicRequired = true; - bool transactionFinishedIndicRequired = true; - bool suspendedIndicRequired = true; - bool resumedIndicRequired = true; -}; - -struct LocalEntityCfg { - EntityId localId; - IndicationCfg indicCfg; -}; - } // namespace cfdp #endif /* FSFW_SRC_FSFW_CFDP_PDU_DEFINITIONS_H_ */ diff --git a/src/fsfw/cfdp/mib.h b/src/fsfw/cfdp/mib.h new file mode 100644 index 00000000..3a8c96d5 --- /dev/null +++ b/src/fsfw/cfdp/mib.h @@ -0,0 +1,19 @@ +#ifndef FSFW_CFDP_MIB_H +#define FSFW_CFDP_MIB_H + +struct IndicationCfg { + bool eofSentIndicRequired = true; + bool eofRecvIndicRequired = true; + bool fileSegmentRecvIndicRequired = true; + bool transactionFinishedIndicRequired = true; + bool suspendedIndicRequired = true; + bool resumedIndicRequired = true; +}; + +struct LocalEntityCfg { + cfdp::EntityId localId; + IndicationCfg indicCfg; +}; + + +#endif // FSFW_CFDP_MIB_H diff --git a/src/fsfw/cfdp/pdu/HeaderCreator.cpp b/src/fsfw/cfdp/pdu/HeaderCreator.cpp index d70e8270..1a7afe0d 100644 --- a/src/fsfw/cfdp/pdu/HeaderCreator.cpp +++ b/src/fsfw/cfdp/pdu/HeaderCreator.cpp @@ -1,7 +1,5 @@ #include "HeaderCreator.h" -#include "HeaderReader.h" - HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen, cfdp::SegmentMetadataFlag segmentMetadataFlag, cfdp::SegmentationControl segCtrl) diff --git a/src/fsfw/cfdp/pdu/HeaderCreator.h b/src/fsfw/cfdp/pdu/HeaderCreator.h index a9f9b581..bbb4a518 100644 --- a/src/fsfw/cfdp/pdu/HeaderCreator.h +++ b/src/fsfw/cfdp/pdu/HeaderCreator.h @@ -1,9 +1,9 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_HEADERSERIALIZER_H_ #define FSFW_SRC_FSFW_CFDP_PDU_HEADERSERIALIZER_H_ -#include "../definitions.h" #include "PduConfig.h" #include "PduHeaderIF.h" +#include "fsfw/cfdp/definitions.h" #include "fsfw/serialize/SerializeIF.h" class HeaderCreator : public SerializeIF, public PduHeaderIF { @@ -23,7 +23,7 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF { * data field length was not properly. * @return */ - size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override; @@ -32,19 +32,19 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF { void setPduType(cfdp::PduType pduType); void setSegmentMetadataFlag(cfdp::SegmentMetadataFlag); - size_t getPduDataFieldLen() const override; - size_t getWholePduSize() const override; + [[nodiscard]] size_t getPduDataFieldLen() const override; + [[nodiscard]] size_t getWholePduSize() const override; - cfdp::PduType getPduType() const override; - cfdp::Direction getDirection() const override; - cfdp::TransmissionModes getTransmissionMode() const override; - bool getCrcFlag() const override; - bool getLargeFileFlag() const override; - cfdp::SegmentationControl getSegmentationControl() const override; - cfdp::WidthInBytes getLenEntityIds() const override; - cfdp::WidthInBytes getLenSeqNum() const override; - cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override; - bool hasSegmentMetadataFlag() const override; + [[nodiscard]] cfdp::PduType getPduType() const override; + [[nodiscard]] cfdp::Direction getDirection() const override; + [[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override; + [[nodiscard]] bool getCrcFlag() const override; + [[nodiscard]] bool getLargeFileFlag() const override; + [[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const override; + [[nodiscard]] cfdp::WidthInBytes getLenEntityIds() const override; + [[nodiscard]] cfdp::WidthInBytes getLenSeqNum() const override; + [[nodiscard]] cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override; + [[nodiscard]] bool hasSegmentMetadataFlag() const override; void setSegmentationControl(cfdp::SegmentationControl); void getSourceId(cfdp::EntityId& sourceId) const override; diff --git a/src/fsfw/cfdp/pdu/PduConfig.h b/src/fsfw/cfdp/pdu/PduConfig.h index 858176ff..a008f18d 100644 --- a/src/fsfw/cfdp/pdu/PduConfig.h +++ b/src/fsfw/cfdp/pdu/PduConfig.h @@ -1,6 +1,7 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_ #define FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_ +#include "fsfw/cfdp/definitions.h" #include "VarLenField.h" namespace cfdp { @@ -21,7 +22,7 @@ struct TransactionSeqNum : public VarLenField { TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {} }; -} // namespace cfdp +} class PduConfig { public: diff --git a/src/fsfw/cfdp/pdu/PduHeaderIF.h b/src/fsfw/cfdp/pdu/PduHeaderIF.h index 86956ff0..a8d007b6 100644 --- a/src/fsfw/cfdp/pdu/PduHeaderIF.h +++ b/src/fsfw/cfdp/pdu/PduHeaderIF.h @@ -3,8 +3,8 @@ #include -#include "../definitions.h" #include "PduConfig.h" +#include "fsfw/cfdp/definitions.h" /** * @brief Generic interface to access all fields of a PDU header diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/pdu/VarLenField.cpp index a403534b..1f4d2429 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.cpp +++ b/src/fsfw/cfdp/pdu/VarLenField.cpp @@ -1,6 +1,5 @@ #include "VarLenField.h" -#include "fsfw/FSFW.h" #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface.h" diff --git a/src/fsfw/cfdp/pdu/VarLenField.h b/src/fsfw/cfdp/pdu/VarLenField.h index 7f8a1acb..819e8ccd 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.h +++ b/src/fsfw/cfdp/pdu/VarLenField.h @@ -1,5 +1,5 @@ -#ifndef FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_ -#define FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_ +#ifndef FSFW_CFDP_PDU_VARLENFIELD_H_ +#define FSFW_CFDP_PDU_VARLENFIELD_H_ #include #include @@ -7,6 +7,7 @@ #include "fsfw/cfdp/definitions.h" #include "fsfw/serialize/SerializeIF.h" #include "fsfw/util/UnsignedByteField.h" + namespace cfdp { class VarLenField : public SerializeIF { @@ -21,6 +22,7 @@ class VarLenField : public SerializeIF { VarLenField(); template explicit VarLenField(UnsignedByteField byteField); + VarLenField(cfdp::WidthInBytes width, size_t value); bool operator==(const VarLenField &other) const; @@ -49,11 +51,11 @@ class VarLenField : public SerializeIF { template cfdp::VarLenField::VarLenField(UnsignedByteField byteField) - : width(static_cast(sizeof(T))) { + : width(static_cast(sizeof(T))) { static_assert((sizeof(T) % 2) == 0); setValue(width, byteField.getValue()); } } // namespace cfdp -#endif /* FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_ */ +#endif /* FSFW_CFDP_PDU_VARLENFIELD_H_ */ From dba3f9960ef56db30011f9ff73bf6a3aa5e07549 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 14:55:08 +0200 Subject: [PATCH 203/532] add CFDP fault handler mock --- src/fsfw/cfdp/FaultHandlerBase.cpp | 23 +++++------ src/fsfw/cfdp/FaultHandlerBase.h | 10 +++-- src/fsfw/cfdp/mib.h | 1 - src/fsfw/cfdp/pdu/PduConfig.h | 4 +- unittests/cfdp/CMakeLists.txt | 22 +++-------- unittests/cfdp/handler/CMakeLists.txt | 1 + .../cfdp/{ => handler}/testDestHandler.cpp | 0 .../cfdp/{ => handler}/testDistributor.cpp | 0 unittests/cfdp/pdu/CMakeLists.txt | 13 +++++++ unittests/cfdp/{ => pdu}/testAckPdu.cpp | 0 unittests/cfdp/{ => pdu}/testCfdpHeader.cpp | 0 unittests/cfdp/{ => pdu}/testEofPdu.cpp | 0 unittests/cfdp/{ => pdu}/testFileData.cpp | 0 .../cfdp/{ => pdu}/testFileDirective.cpp | 0 unittests/cfdp/{ => pdu}/testFinishedPdu.cpp | 0 unittests/cfdp/{ => pdu}/testKeepAlivePdu.cpp | 0 unittests/cfdp/{ => pdu}/testMetadataPdu.cpp | 3 +- unittests/cfdp/{ => pdu}/testNakPdu.cpp | 0 unittests/cfdp/{ => pdu}/testPromptPdu.cpp | 0 unittests/mocks/CMakeLists.txt | 3 +- unittests/mocks/CfdpFaultHandlerMock.cpp | 38 +++++++++++++++++++ unittests/mocks/CfdpFaultHandlerMock.h | 32 ++++++++++++++++ 22 files changed, 113 insertions(+), 37 deletions(-) create mode 100644 unittests/cfdp/handler/CMakeLists.txt rename unittests/cfdp/{ => handler}/testDestHandler.cpp (100%) rename unittests/cfdp/{ => handler}/testDistributor.cpp (100%) create mode 100644 unittests/cfdp/pdu/CMakeLists.txt rename unittests/cfdp/{ => pdu}/testAckPdu.cpp (100%) rename unittests/cfdp/{ => pdu}/testCfdpHeader.cpp (100%) rename unittests/cfdp/{ => pdu}/testEofPdu.cpp (100%) rename unittests/cfdp/{ => pdu}/testFileData.cpp (100%) rename unittests/cfdp/{ => pdu}/testFileDirective.cpp (100%) rename unittests/cfdp/{ => pdu}/testFinishedPdu.cpp (100%) rename unittests/cfdp/{ => pdu}/testKeepAlivePdu.cpp (100%) rename unittests/cfdp/{ => pdu}/testMetadataPdu.cpp (99%) rename unittests/cfdp/{ => pdu}/testNakPdu.cpp (100%) rename unittests/cfdp/{ => pdu}/testPromptPdu.cpp (100%) create mode 100644 unittests/mocks/CfdpFaultHandlerMock.cpp create mode 100644 unittests/mocks/CfdpFaultHandlerMock.h diff --git a/src/fsfw/cfdp/FaultHandlerBase.cpp b/src/fsfw/cfdp/FaultHandlerBase.cpp index 06edabd6..91c3afe4 100644 --- a/src/fsfw/cfdp/FaultHandlerBase.cpp +++ b/src/fsfw/cfdp/FaultHandlerBase.cpp @@ -1,19 +1,21 @@ #include "FaultHandlerBase.h" -CfdpFaultHandlerBase::CfdpFaultHandlerBase() = default; +namespace cfdp { -bool CfdpFaultHandlerBase::getFaultHandler( - cfdp::ConditionCode code, cfdp::FaultHandlerCodes& handler) const { +FaultHandlerBase::FaultHandlerBase() = default; +FaultHandlerBase::~FaultHandlerBase() = default; + +bool FaultHandlerBase::getFaultHandler(cfdp::ConditionCode code, + cfdp::FaultHandlerCodes& handler) const { auto iter = faultHandlerMap.find(code); - if(iter == faultHandlerMap.end()) { + if (iter == faultHandlerMap.end()) { return false; } handler = iter->second; return true; } -bool CfdpFaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, - cfdp::FaultHandlerCodes handler) { +bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes handler) { if (not faultHandlerMap.contains(code)) { return false; } @@ -21,21 +23,20 @@ bool CfdpFaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, return true; } -bool CfdpFaultHandlerBase::faultCallback(cfdp::ConditionCode code) { +bool FaultHandlerBase::faultCallback(cfdp::ConditionCode code) { if (not faultHandlerMap.contains(code)) { return false; } cfdp::FaultHandlerCodes fh = faultHandlerMap[code]; if (fh == cfdp::FaultHandlerCodes::IGNORE_ERROR) { ignoreCb(code); - } else if(fh == cfdp::FaultHandlerCodes::ABANDON_TRANSACTION) { + } else if (fh == cfdp::FaultHandlerCodes::ABANDON_TRANSACTION) { abandonCb(code); - } else if(fh == cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION) { + } else if (fh == cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION) { noticeOfCancellationCb(code); } else { noticeOfSuspensionCb(code); } return true; } - -CfdpFaultHandlerBase::~CfdpFaultHandlerBase() = default; +} // namespace cfdp diff --git a/src/fsfw/cfdp/FaultHandlerBase.h b/src/fsfw/cfdp/FaultHandlerBase.h index fc18f1c7..6a4abc8b 100644 --- a/src/fsfw/cfdp/FaultHandlerBase.h +++ b/src/fsfw/cfdp/FaultHandlerBase.h @@ -5,10 +5,12 @@ #include "definitions.h" -class CfdpFaultHandlerBase { +namespace cfdp { + +class FaultHandlerBase { public: - virtual ~CfdpFaultHandlerBase(); - CfdpFaultHandlerBase(); + virtual ~FaultHandlerBase(); + FaultHandlerBase(); /** * Get the fault handler code for the given condition code @@ -46,4 +48,6 @@ class CfdpFaultHandlerBase { cfdp::FaultHandlerCodes::IGNORE_ERROR}}; }; +} // namespace cfdp + #endif // FSFW_CFDP_FAULTHANDLERBASE_H diff --git a/src/fsfw/cfdp/mib.h b/src/fsfw/cfdp/mib.h index 3a8c96d5..c40034d4 100644 --- a/src/fsfw/cfdp/mib.h +++ b/src/fsfw/cfdp/mib.h @@ -15,5 +15,4 @@ struct LocalEntityCfg { IndicationCfg indicCfg; }; - #endif // FSFW_CFDP_MIB_H diff --git a/src/fsfw/cfdp/pdu/PduConfig.h b/src/fsfw/cfdp/pdu/PduConfig.h index a008f18d..48f3993b 100644 --- a/src/fsfw/cfdp/pdu/PduConfig.h +++ b/src/fsfw/cfdp/pdu/PduConfig.h @@ -1,8 +1,8 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_ #define FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_ -#include "fsfw/cfdp/definitions.h" #include "VarLenField.h" +#include "fsfw/cfdp/definitions.h" namespace cfdp { @@ -22,7 +22,7 @@ struct TransactionSeqNum : public VarLenField { TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {} }; -} +} // namespace cfdp class PduConfig { public: diff --git a/unittests/cfdp/CMakeLists.txt b/unittests/cfdp/CMakeLists.txt index ac4672fa..4a574af2 100644 --- a/unittests/cfdp/CMakeLists.txt +++ b/unittests/cfdp/CMakeLists.txt @@ -1,17 +1,5 @@ -target_sources( - ${FSFW_TEST_TGT} - PRIVATE testCfdp.cpp - testTlvsLvs.cpp - testAckPdu.cpp - testEofPdu.cpp - testNakPdu.cpp - testFinishedPdu.cpp - testPromptPdu.cpp - testKeepAlivePdu.cpp - testMetadataPdu.cpp - testFileData.cpp - testCfdpHeader.cpp - testFileDirective.cpp - testDistributor.cpp - testDestHandler.cpp - testSourceHandler.cpp) +target_sources(${FSFW_TEST_TGT} PRIVATE testCfdp.cpp testTlvsLvs.cpp + testSourceHandler.cpp) + +add_subdirectory(handler) +add_subdirectory(pdu) diff --git a/unittests/cfdp/handler/CMakeLists.txt b/unittests/cfdp/handler/CMakeLists.txt new file mode 100644 index 00000000..a209b995 --- /dev/null +++ b/unittests/cfdp/handler/CMakeLists.txt @@ -0,0 +1 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE testDistributor.cpp testDestHandler.cpp) diff --git a/unittests/cfdp/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp similarity index 100% rename from unittests/cfdp/testDestHandler.cpp rename to unittests/cfdp/handler/testDestHandler.cpp diff --git a/unittests/cfdp/testDistributor.cpp b/unittests/cfdp/handler/testDistributor.cpp similarity index 100% rename from unittests/cfdp/testDistributor.cpp rename to unittests/cfdp/handler/testDistributor.cpp diff --git a/unittests/cfdp/pdu/CMakeLists.txt b/unittests/cfdp/pdu/CMakeLists.txt new file mode 100644 index 00000000..02981217 --- /dev/null +++ b/unittests/cfdp/pdu/CMakeLists.txt @@ -0,0 +1,13 @@ +target_sources( + ${FSFW_TEST_TGT} + PRIVATE testAckPdu.cpp + testAckPdu.cpp + testEofPdu.cpp + testNakPdu.cpp + testFinishedPdu.cpp + testPromptPdu.cpp + testKeepAlivePdu.cpp + testMetadataPdu.cpp + testFileData.cpp + testCfdpHeader.cpp + testFileDirective.cpp) diff --git a/unittests/cfdp/testAckPdu.cpp b/unittests/cfdp/pdu/testAckPdu.cpp similarity index 100% rename from unittests/cfdp/testAckPdu.cpp rename to unittests/cfdp/pdu/testAckPdu.cpp diff --git a/unittests/cfdp/testCfdpHeader.cpp b/unittests/cfdp/pdu/testCfdpHeader.cpp similarity index 100% rename from unittests/cfdp/testCfdpHeader.cpp rename to unittests/cfdp/pdu/testCfdpHeader.cpp diff --git a/unittests/cfdp/testEofPdu.cpp b/unittests/cfdp/pdu/testEofPdu.cpp similarity index 100% rename from unittests/cfdp/testEofPdu.cpp rename to unittests/cfdp/pdu/testEofPdu.cpp diff --git a/unittests/cfdp/testFileData.cpp b/unittests/cfdp/pdu/testFileData.cpp similarity index 100% rename from unittests/cfdp/testFileData.cpp rename to unittests/cfdp/pdu/testFileData.cpp diff --git a/unittests/cfdp/testFileDirective.cpp b/unittests/cfdp/pdu/testFileDirective.cpp similarity index 100% rename from unittests/cfdp/testFileDirective.cpp rename to unittests/cfdp/pdu/testFileDirective.cpp diff --git a/unittests/cfdp/testFinishedPdu.cpp b/unittests/cfdp/pdu/testFinishedPdu.cpp similarity index 100% rename from unittests/cfdp/testFinishedPdu.cpp rename to unittests/cfdp/pdu/testFinishedPdu.cpp diff --git a/unittests/cfdp/testKeepAlivePdu.cpp b/unittests/cfdp/pdu/testKeepAlivePdu.cpp similarity index 100% rename from unittests/cfdp/testKeepAlivePdu.cpp rename to unittests/cfdp/pdu/testKeepAlivePdu.cpp diff --git a/unittests/cfdp/testMetadataPdu.cpp b/unittests/cfdp/pdu/testMetadataPdu.cpp similarity index 99% rename from unittests/cfdp/testMetadataPdu.cpp rename to unittests/cfdp/pdu/testMetadataPdu.cpp index 4ea15451..dec3b479 100644 --- a/unittests/cfdp/testMetadataPdu.cpp +++ b/unittests/cfdp/pdu/testMetadataPdu.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -7,6 +5,7 @@ #include "fsfw/cfdp/pdu/MetadataPduCreator.h" #include "fsfw/cfdp/pdu/MetadataPduReader.h" #include "fsfw/cfdp/tlv/FilestoreResponseTlv.h" +#include "fsfw/cfdp/tlv/MessageToUserTlv.h" #include "fsfw/globalfunctions/arrayprinter.h" TEST_CASE("Metadata PDU", "[cfdp][pdu]") { diff --git a/unittests/cfdp/testNakPdu.cpp b/unittests/cfdp/pdu/testNakPdu.cpp similarity index 100% rename from unittests/cfdp/testNakPdu.cpp rename to unittests/cfdp/pdu/testNakPdu.cpp diff --git a/unittests/cfdp/testPromptPdu.cpp b/unittests/cfdp/pdu/testPromptPdu.cpp similarity index 100% rename from unittests/cfdp/testPromptPdu.cpp rename to unittests/cfdp/pdu/testPromptPdu.cpp diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index bc5649de..0ee7bf1e 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -14,4 +14,5 @@ target_sources( PusDistributorMock.cpp CcsdsCheckerMock.cpp AcceptsTcMock.cpp - StorageManagerMock.cpp) + StorageManagerMock.cpp + CfdpFaultHandlerMock.cpp) diff --git a/unittests/mocks/CfdpFaultHandlerMock.cpp b/unittests/mocks/CfdpFaultHandlerMock.cpp new file mode 100644 index 00000000..3f7c8896 --- /dev/null +++ b/unittests/mocks/CfdpFaultHandlerMock.cpp @@ -0,0 +1,38 @@ +#include "CfdpFaultHandlerMock.h" + +void CfdpFaultHandlerMock::noticeOfSuspensionCb(cfdp::ConditionCode code) { + auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION); + info.callCount++; + info.condCodes.push(code); +} + +void CfdpFaultHandlerMock::noticeOfCancellationCb(cfdp::ConditionCode code) { + auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION); + info.callCount++; + info.condCodes.push(code); +} + +void CfdpFaultHandlerMock::abandonCb(cfdp::ConditionCode code) { + auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::ABANDON_TRANSACTION); + info.callCount++; + info.condCodes.push(code); +} + +void CfdpFaultHandlerMock::ignoreCb(cfdp::ConditionCode code) { + auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::IGNORE_ERROR); + info.callCount++; + info.condCodes.push(code); +} + +CfdpFaultHandlerMock::FaultInfo& CfdpFaultHandlerMock::getFhInfo(cfdp::FaultHandlerCodes fhCode) { + return fhInfoMap.at(fhCode); +} + +void CfdpFaultHandlerMock::reset() { fhInfoMap.clear(); } + +bool CfdpFaultHandlerMock::faultCbWasCalled() const { + return std::any_of(fhInfoMap.begin(), fhInfoMap.end(), + [](const std::pair& pair) { + return pair.second.callCount > 0; + }); +} diff --git a/unittests/mocks/CfdpFaultHandlerMock.h b/unittests/mocks/CfdpFaultHandlerMock.h new file mode 100644 index 00000000..8003798e --- /dev/null +++ b/unittests/mocks/CfdpFaultHandlerMock.h @@ -0,0 +1,32 @@ +#ifndef FSFW_TESTS_CFDPFAULTHANDLERMOCK_H +#define FSFW_TESTS_CFDPFAULTHANDLERMOCK_H + +#include +#include + +#include "fsfw/cfdp/FaultHandlerBase.h" + +class CfdpFaultHandlerMock : public cfdp::FaultHandlerBase { + public: + struct FaultInfo { + size_t callCount = 0; + std::queue condCodes; + }; + + void noticeOfSuspensionCb(cfdp::ConditionCode code) override; + void noticeOfCancellationCb(cfdp::ConditionCode code) override; + void abandonCb(cfdp::ConditionCode code) override; + void ignoreCb(cfdp::ConditionCode code) override; + + FaultInfo& getFhInfo(cfdp::FaultHandlerCodes fhCode); + bool faultCbWasCalled() const; + void reset(); + + private: + std::map fhInfoMap = { + std::pair{cfdp::FaultHandlerCodes::IGNORE_ERROR, FaultInfo()}, + std::pair{cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION, FaultInfo()}, + std::pair{cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION, FaultInfo()}, + std::pair{cfdp::FaultHandlerCodes::ABANDON_TRANSACTION, FaultInfo()}}; +}; +#endif // FSFW_TESTS_CFDPFAULTHANDLERMOCK_H From 7f9401cf63e8ff932fa78ad28eea39b82714ceed Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 15:09:43 +0200 Subject: [PATCH 204/532] some bugfixes --- src/fsfw/cfdp/FaultHandlerBase.cpp | 2 +- src/fsfw/cfdp/FaultHandlerBase.h | 8 +++-- unittests/cfdp/CMakeLists.txt | 3 +- unittests/cfdp/handler/CMakeLists.txt | 4 ++- unittests/cfdp/handler/testFaultHandler.cpp | 36 +++++++++++++++++++ .../cfdp/{ => handler}/testSourceHandler.cpp | 0 unittests/cfdp/pdu/testFileDirective.cpp | 2 +- unittests/mocks/CfdpFaultHandlerMock.h | 2 +- 8 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 unittests/cfdp/handler/testFaultHandler.cpp rename unittests/cfdp/{ => handler}/testSourceHandler.cpp (100%) diff --git a/src/fsfw/cfdp/FaultHandlerBase.cpp b/src/fsfw/cfdp/FaultHandlerBase.cpp index 91c3afe4..443a1a92 100644 --- a/src/fsfw/cfdp/FaultHandlerBase.cpp +++ b/src/fsfw/cfdp/FaultHandlerBase.cpp @@ -23,7 +23,7 @@ bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHand return true; } -bool FaultHandlerBase::faultCallback(cfdp::ConditionCode code) { +bool FaultHandlerBase::reportFault(cfdp::ConditionCode code) { if (not faultHandlerMap.contains(code)) { return false; } diff --git a/src/fsfw/cfdp/FaultHandlerBase.h b/src/fsfw/cfdp/FaultHandlerBase.h index 6a4abc8b..ba816161 100644 --- a/src/fsfw/cfdp/FaultHandlerBase.h +++ b/src/fsfw/cfdp/FaultHandlerBase.h @@ -25,7 +25,7 @@ class FaultHandlerBase { bool setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes handler); - bool faultCallback(cfdp::ConditionCode code); + bool reportFault(cfdp::ConditionCode code); virtual void noticeOfSuspensionCb(cfdp::ConditionCode code) = 0; virtual void noticeOfCancellationCb(cfdp::ConditionCode code) = 0; @@ -33,7 +33,7 @@ class FaultHandlerBase { virtual void ignoreCb(cfdp::ConditionCode code) = 0; private: - etl::flat_map faultHandlerMap = { + etl::flat_map faultHandlerMap = { etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED, @@ -45,7 +45,9 @@ class FaultHandlerBase { etl::pair{cfdp::ConditionCode::NAK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, etl::pair{cfdp::ConditionCode::INACTIVITY_DETECTED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, etl::pair{cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE, - cfdp::FaultHandlerCodes::IGNORE_ERROR}}; + cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::FILESTORE_REJECTION, cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::CHECK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}}; }; } // namespace cfdp diff --git a/unittests/cfdp/CMakeLists.txt b/unittests/cfdp/CMakeLists.txt index 4a574af2..402381f4 100644 --- a/unittests/cfdp/CMakeLists.txt +++ b/unittests/cfdp/CMakeLists.txt @@ -1,5 +1,4 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE testCfdp.cpp testTlvsLvs.cpp - testSourceHandler.cpp) +target_sources(${FSFW_TEST_TGT} PRIVATE testCfdp.cpp testTlvsLvs.cpp) add_subdirectory(handler) add_subdirectory(pdu) diff --git a/unittests/cfdp/handler/CMakeLists.txt b/unittests/cfdp/handler/CMakeLists.txt index a209b995..f70e5dfb 100644 --- a/unittests/cfdp/handler/CMakeLists.txt +++ b/unittests/cfdp/handler/CMakeLists.txt @@ -1 +1,3 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE testDistributor.cpp testDestHandler.cpp) +target_sources( + ${FSFW_TEST_TGT} PRIVATE testDistributor.cpp testDestHandler.cpp + testSourceHandler.cpp testFaultHandler.cpp) diff --git a/unittests/cfdp/handler/testFaultHandler.cpp b/unittests/cfdp/handler/testFaultHandler.cpp new file mode 100644 index 00000000..bea16889 --- /dev/null +++ b/unittests/cfdp/handler/testFaultHandler.cpp @@ -0,0 +1,36 @@ +#include + +#include "mocks/CfdpFaultHandlerMock.h" + +TEST_CASE("CFDP Fault Handler", "[cfdp]") { + using namespace cfdp; + auto fhMock = CfdpFaultHandlerMock(); + cfdp::FaultHandlerCodes fhCode; + SECTION("State") { + // Verify initial condition + CHECK(fhMock.getFaultHandler(ConditionCode::UNSUPPORTED_CHECKSUM_TYPE, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhMock.getFaultHandler(ConditionCode::POSITIVE_ACK_LIMIT_REACHED, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhMock.getFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhMock.getFaultHandler(ConditionCode::INVALID_TRANSMISSION_MODE, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhMock.getFaultHandler(ConditionCode::FILESTORE_REJECTION, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhMock.getFaultHandler(ConditionCode::FILE_CHECKSUM_FAILURE, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhMock.getFaultHandler(ConditionCode::FILE_SIZE_ERROR, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhMock.getFaultHandler(ConditionCode::NAK_LIMIT_REACHED, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhMock.getFaultHandler(ConditionCode::INACTIVITY_DETECTED, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhMock.getFaultHandler(ConditionCode::CHECK_LIMIT_REACHED, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + } + + SECTION("Call Handler") { + fhMock.reportFault(ConditionCode::CHECK_LIMIT_REACHED); + } +} \ No newline at end of file diff --git a/unittests/cfdp/testSourceHandler.cpp b/unittests/cfdp/handler/testSourceHandler.cpp similarity index 100% rename from unittests/cfdp/testSourceHandler.cpp rename to unittests/cfdp/handler/testSourceHandler.cpp diff --git a/unittests/cfdp/pdu/testFileDirective.cpp b/unittests/cfdp/pdu/testFileDirective.cpp index b694cd68..3dfaaa57 100644 --- a/unittests/cfdp/pdu/testFileDirective.cpp +++ b/unittests/cfdp/pdu/testFileDirective.cpp @@ -4,7 +4,7 @@ #include "fsfw/cfdp/pdu/FileDirectiveCreator.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h" -TEST_CASE("CFDP File Directive", "[cfdp]") { +TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { using namespace cfdp; std::array serBuf{}; ReturnValue_t result; diff --git a/unittests/mocks/CfdpFaultHandlerMock.h b/unittests/mocks/CfdpFaultHandlerMock.h index 8003798e..ae7b251e 100644 --- a/unittests/mocks/CfdpFaultHandlerMock.h +++ b/unittests/mocks/CfdpFaultHandlerMock.h @@ -19,7 +19,7 @@ class CfdpFaultHandlerMock : public cfdp::FaultHandlerBase { void ignoreCb(cfdp::ConditionCode code) override; FaultInfo& getFhInfo(cfdp::FaultHandlerCodes fhCode); - bool faultCbWasCalled() const; + [[nodiscard]] bool faultCbWasCalled() const; void reset(); private: From 4ee01e395bd4dc72f1aec1fc0dbb7880af5fef4f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 15:29:22 +0200 Subject: [PATCH 205/532] finished fault handler unit tests --- src/fsfw/cfdp/FaultHandlerBase.cpp | 11 ++++- unittests/cfdp/handler/testFaultHandler.cpp | 55 ++++++++++++++++++++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/fsfw/cfdp/FaultHandlerBase.cpp b/src/fsfw/cfdp/FaultHandlerBase.cpp index 443a1a92..1dbfce0d 100644 --- a/src/fsfw/cfdp/FaultHandlerBase.cpp +++ b/src/fsfw/cfdp/FaultHandlerBase.cpp @@ -19,6 +19,12 @@ bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHand if (not faultHandlerMap.contains(code)) { return false; } + if (handler != FaultHandlerCodes::NOTICE_OF_SUSPENSION and + handler != FaultHandlerCodes::ABANDON_TRANSACTION and + handler != FaultHandlerCodes::NOTICE_OF_CANCELLATION and + handler != FaultHandlerCodes::IGNORE_ERROR) { + return false; + } faultHandlerMap[code] = handler; return true; } @@ -34,8 +40,11 @@ bool FaultHandlerBase::reportFault(cfdp::ConditionCode code) { abandonCb(code); } else if (fh == cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION) { noticeOfCancellationCb(code); - } else { + } else if (fh == cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION) { noticeOfSuspensionCb(code); + } else { + // Should never happen, but use defensive programming + return false; } return true; } diff --git a/unittests/cfdp/handler/testFaultHandler.cpp b/unittests/cfdp/handler/testFaultHandler.cpp index bea16889..e6fb4547 100644 --- a/unittests/cfdp/handler/testFaultHandler.cpp +++ b/unittests/cfdp/handler/testFaultHandler.cpp @@ -6,6 +6,7 @@ TEST_CASE("CFDP Fault Handler", "[cfdp]") { using namespace cfdp; auto fhMock = CfdpFaultHandlerMock(); cfdp::FaultHandlerCodes fhCode; + SECTION("State") { // Verify initial condition CHECK(fhMock.getFaultHandler(ConditionCode::UNSUPPORTED_CHECKSUM_TYPE, fhCode)); @@ -30,7 +31,57 @@ TEST_CASE("CFDP Fault Handler", "[cfdp]") { CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); } - SECTION("Call Handler") { - fhMock.reportFault(ConditionCode::CHECK_LIMIT_REACHED); + SECTION("Call Handler, Ignore Fault") { + auto& info = fhMock.getFhInfo(FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhMock.reportFault(ConditionCode::CHECK_LIMIT_REACHED)); + CHECK(info.callCount == 1); + CHECK(info.condCodes.back() == ConditionCode::CHECK_LIMIT_REACHED); + fhMock.reportFault(ConditionCode::FILE_CHECKSUM_FAILURE); + CHECK(info.callCount == 2); + CHECK(info.condCodes.back() == ConditionCode::FILE_CHECKSUM_FAILURE); + } + + SECTION("Invalid Reported Code") { CHECK(not fhMock.reportFault(ConditionCode::NO_ERROR)); } + + SECTION("Invalid FH code"){ + CHECK(not fhMock.setFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, FaultHandlerCodes::RESERVED)); + CHECK(fhMock.getFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(not fhMock.setFaultHandler(ConditionCode::NO_ERROR, FaultHandlerCodes::IGNORE_ERROR)); + CHECK(not fhMock.getFaultHandler(ConditionCode::NO_ERROR, fhCode)); + } + + SECTION("Set Other Fault Handler") { + CHECK(fhMock.setFaultHandler(ConditionCode::FILE_CHECKSUM_FAILURE, + FaultHandlerCodes::NOTICE_OF_CANCELLATION)); + CHECK(fhMock.setFaultHandler(ConditionCode::INACTIVITY_DETECTED, + FaultHandlerCodes::ABANDON_TRANSACTION)); + CHECK(fhMock.setFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, + FaultHandlerCodes::NOTICE_OF_SUSPENSION)); + auto& ignoreInfo = fhMock.getFhInfo(FaultHandlerCodes::IGNORE_ERROR); + auto& cancellationInfo = fhMock.getFhInfo(FaultHandlerCodes::NOTICE_OF_CANCELLATION); + auto& suspensionInfo = fhMock.getFhInfo(FaultHandlerCodes::NOTICE_OF_SUSPENSION); + auto& abandonInfo = fhMock.getFhInfo(FaultHandlerCodes::ABANDON_TRANSACTION); + + CHECK(fhMock.reportFault(ConditionCode::FILE_CHECKSUM_FAILURE)); + CHECK(cancellationInfo.callCount == 1); + CHECK(cancellationInfo.condCodes.back() == ConditionCode::FILE_CHECKSUM_FAILURE); + CHECK(ignoreInfo.callCount == 0); + CHECK(suspensionInfo.callCount == 0); + CHECK(abandonInfo.callCount == 0); + + CHECK(fhMock.reportFault(ConditionCode::INACTIVITY_DETECTED)); + CHECK(cancellationInfo.callCount == 1); + CHECK(ignoreInfo.callCount == 0); + CHECK(suspensionInfo.callCount == 0); + CHECK(abandonInfo.callCount == 1); + CHECK(abandonInfo.condCodes.back() == ConditionCode::INACTIVITY_DETECTED); + + CHECK(fhMock.reportFault(ConditionCode::KEEP_ALIVE_LIMIT_REACHED)); + CHECK(cancellationInfo.callCount == 1); + CHECK(ignoreInfo.callCount == 0); + CHECK(suspensionInfo.callCount == 1); + CHECK(suspensionInfo.condCodes.back() == ConditionCode::KEEP_ALIVE_LIMIT_REACHED); + CHECK(abandonInfo.callCount == 1); } } \ No newline at end of file From dce1ebcf65765cf19383dbbdf29d84c687f73696 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 15:46:42 +0200 Subject: [PATCH 206/532] add CFDP user base --- src/fsfw/cfdp.h | 8 ++++++++ src/fsfw/cfdp/CMakeLists.txt | 7 ++----- src/fsfw/cfdp/CfdpDestHandler.cpp | 1 - src/fsfw/cfdp/CfdpDestHandler.h | 15 --------------- src/fsfw/cfdp/CfdpSourceHandler.cpp | 1 - src/fsfw/cfdp/handler/CMakeLists.txt | 2 ++ src/fsfw/cfdp/handler/DestHandler.cpp | 5 +++++ src/fsfw/cfdp/handler/DestHandler.h | 19 +++++++++++++++++++ .../cfdp/{ => handler}/FaultHandlerBase.cpp | 0 .../cfdp/{ => handler}/FaultHandlerBase.h | 2 +- src/fsfw/cfdp/handler/SourceHandler.cpp | 1 + .../SourceHandler.h} | 2 +- src/fsfw/cfdp/handler/UserBase.cpp | 3 +++ src/fsfw/cfdp/handler/UserBase.h | 18 ++++++++++++++++++ src/fsfw/cfdp/{ => handler}/mib.h | 14 +++++++++++++- unittests/cfdp/handler/testDestHandler.cpp | 10 +++++++++- unittests/cfdp/handler/testFaultHandler.cpp | 13 +++++++------ unittests/mocks/CfdpFaultHandlerMock.h | 2 +- 18 files changed, 90 insertions(+), 33 deletions(-) create mode 100644 src/fsfw/cfdp.h delete mode 100644 src/fsfw/cfdp/CfdpDestHandler.cpp delete mode 100644 src/fsfw/cfdp/CfdpDestHandler.h delete mode 100644 src/fsfw/cfdp/CfdpSourceHandler.cpp create mode 100644 src/fsfw/cfdp/handler/CMakeLists.txt create mode 100644 src/fsfw/cfdp/handler/DestHandler.cpp create mode 100644 src/fsfw/cfdp/handler/DestHandler.h rename src/fsfw/cfdp/{ => handler}/FaultHandlerBase.cpp (100%) rename src/fsfw/cfdp/{ => handler}/FaultHandlerBase.h (98%) create mode 100644 src/fsfw/cfdp/handler/SourceHandler.cpp rename src/fsfw/cfdp/{CfdpSourceHandler.h => handler/SourceHandler.h} (80%) create mode 100644 src/fsfw/cfdp/handler/UserBase.cpp create mode 100644 src/fsfw/cfdp/handler/UserBase.h rename src/fsfw/cfdp/{ => handler}/mib.h (56%) diff --git a/src/fsfw/cfdp.h b/src/fsfw/cfdp.h new file mode 100644 index 00000000..421a7fe1 --- /dev/null +++ b/src/fsfw/cfdp.h @@ -0,0 +1,8 @@ +#ifndef FSFW_CFDP_H +#define FSFW_CFDP_H + +#include "cfdp/definitions.h" +#include "cfdp/handler/DestHandler.h" +#include "cfdp/handler/FaultHandlerBase.h" + +#endif // FSFW_CFDP_H diff --git a/src/fsfw/cfdp/CMakeLists.txt b/src/fsfw/cfdp/CMakeLists.txt index df83bd7f..72324a53 100644 --- a/src/fsfw/cfdp/CMakeLists.txt +++ b/src/fsfw/cfdp/CMakeLists.txt @@ -1,8 +1,5 @@ -target_sources( - ${LIB_FSFW_NAME} - PRIVATE CfdpMessage.cpp CfdpDistributor.cpp CfdpSourceHandler.cpp - CfdpDestHandler.cpp FaultHandlerBase.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp) -# CfdpDistributor.cpp CfdpHandler.cpp add_subdirectory(pdu) add_subdirectory(tlv) +add_subdirectory(handler) diff --git a/src/fsfw/cfdp/CfdpDestHandler.cpp b/src/fsfw/cfdp/CfdpDestHandler.cpp deleted file mode 100644 index f3eb657a..00000000 --- a/src/fsfw/cfdp/CfdpDestHandler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "CfdpDestHandler.h" diff --git a/src/fsfw/cfdp/CfdpDestHandler.h b/src/fsfw/cfdp/CfdpDestHandler.h deleted file mode 100644 index e317cc4f..00000000 --- a/src/fsfw/cfdp/CfdpDestHandler.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef FSFW_CFDP_CFDPDESTHANDLER_H -#define FSFW_CFDP_CFDPDESTHANDLER_H - -#include - -#include "fsfw/cfdp/pdu/PduConfig.h" - -class CfdpDestHandler { - public: - CfdpDestHandler(); - - private: -}; - -#endif // FSFW_CFDP_CFDPDESTHANDLER_H diff --git a/src/fsfw/cfdp/CfdpSourceHandler.cpp b/src/fsfw/cfdp/CfdpSourceHandler.cpp deleted file mode 100644 index c4b42d55..00000000 --- a/src/fsfw/cfdp/CfdpSourceHandler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "CfdpSourceHandler.h" diff --git a/src/fsfw/cfdp/handler/CMakeLists.txt b/src/fsfw/cfdp/handler/CMakeLists.txt new file mode 100644 index 00000000..7ad995c0 --- /dev/null +++ b/src/fsfw/cfdp/handler/CMakeLists.txt @@ -0,0 +1,2 @@ +target_sources(${LIB_FSFW_NAME} PRIVATE SourceHandler.cpp DestHandler.cpp + FaultHandlerBase.cpp UserBase.cpp) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp new file mode 100644 index 00000000..72f7951e --- /dev/null +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -0,0 +1,5 @@ +#include "DestHandler.h" + +#include + +cfdp::DestHandler::DestHandler(LocalEntityCfg cfg) : cfg(std::move(cfg)) {} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h new file mode 100644 index 00000000..e934fc9c --- /dev/null +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -0,0 +1,19 @@ +#ifndef FSFW_CFDP_CFDPDESTHANDLER_H +#define FSFW_CFDP_CFDPDESTHANDLER_H + +#include "fsfw/cfdp/handler/mib.h" +#include "fsfw/cfdp/pdu/PduConfig.h" + +namespace cfdp { + +class DestHandler { + public: + DestHandler(LocalEntityCfg cfg /*, CfdpUserBase& user, RemoteConfigTableIF& remoteConfigTable*/); + + private: + LocalEntityCfg cfg; +}; + +} // namespace cfdp + +#endif // FSFW_CFDP_CFDPDESTHANDLER_H diff --git a/src/fsfw/cfdp/FaultHandlerBase.cpp b/src/fsfw/cfdp/handler/FaultHandlerBase.cpp similarity index 100% rename from src/fsfw/cfdp/FaultHandlerBase.cpp rename to src/fsfw/cfdp/handler/FaultHandlerBase.cpp diff --git a/src/fsfw/cfdp/FaultHandlerBase.h b/src/fsfw/cfdp/handler/FaultHandlerBase.h similarity index 98% rename from src/fsfw/cfdp/FaultHandlerBase.h rename to src/fsfw/cfdp/handler/FaultHandlerBase.h index ba816161..2383f849 100644 --- a/src/fsfw/cfdp/FaultHandlerBase.h +++ b/src/fsfw/cfdp/handler/FaultHandlerBase.h @@ -3,7 +3,7 @@ #include -#include "definitions.h" +#include "fsfw/cfdp/definitions.h" namespace cfdp { diff --git a/src/fsfw/cfdp/handler/SourceHandler.cpp b/src/fsfw/cfdp/handler/SourceHandler.cpp new file mode 100644 index 00000000..513b25f3 --- /dev/null +++ b/src/fsfw/cfdp/handler/SourceHandler.cpp @@ -0,0 +1 @@ +#include "SourceHandler.h" diff --git a/src/fsfw/cfdp/CfdpSourceHandler.h b/src/fsfw/cfdp/handler/SourceHandler.h similarity index 80% rename from src/fsfw/cfdp/CfdpSourceHandler.h rename to src/fsfw/cfdp/handler/SourceHandler.h index b343a6ed..319cf258 100644 --- a/src/fsfw/cfdp/CfdpSourceHandler.h +++ b/src/fsfw/cfdp/handler/SourceHandler.h @@ -1,6 +1,6 @@ #ifndef FSFW_CFDP_CFDPSOURCEHANDLER_H #define FSFW_CFDP_CFDPSOURCEHANDLER_H -class CfdpSourceHandler {}; +class SourceHandler {}; #endif // FSFW_CFDP_CFDPSOURCEHANDLER_H diff --git a/src/fsfw/cfdp/handler/UserBase.cpp b/src/fsfw/cfdp/handler/UserBase.cpp new file mode 100644 index 00000000..212396fb --- /dev/null +++ b/src/fsfw/cfdp/handler/UserBase.cpp @@ -0,0 +1,3 @@ +#include "UserBase.h" + +cfdp::UserBase::UserBase(HasFileSystemIF& vfs) : vfs(vfs) {} diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h new file mode 100644 index 00000000..c928789c --- /dev/null +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -0,0 +1,18 @@ +#ifndef FSFW_CFDP_USERBASE_H +#define FSFW_CFDP_USERBASE_H + +#include "fsfw/memory/HasFileSystemIF.h" + +namespace cfdp { + +class UserBase { + public: + explicit UserBase(HasFileSystemIF& vfs); + + private: + HasFileSystemIF& vfs; +}; + +} // namespace cfdp + +#endif // FSFW_CFDP_USERBASE_H diff --git a/src/fsfw/cfdp/mib.h b/src/fsfw/cfdp/handler/mib.h similarity index 56% rename from src/fsfw/cfdp/mib.h rename to src/fsfw/cfdp/handler/mib.h index c40034d4..e78b0f4f 100644 --- a/src/fsfw/cfdp/mib.h +++ b/src/fsfw/cfdp/handler/mib.h @@ -1,6 +1,12 @@ #ifndef FSFW_CFDP_MIB_H #define FSFW_CFDP_MIB_H +#include + +#include "FaultHandlerBase.h" + +namespace cfdp { + struct IndicationCfg { bool eofSentIndicRequired = true; bool eofRecvIndicRequired = true; @@ -11,8 +17,14 @@ struct IndicationCfg { }; struct LocalEntityCfg { - cfdp::EntityId localId; + LocalEntityCfg(EntityId localId, IndicationCfg indicationCfg, FaultHandlerBase& fhBase) + : localId(std::move(localId)), indicCfg(indicationCfg), fhBase(fhBase) {} + + EntityId localId; IndicationCfg indicCfg; + FaultHandlerBase& fhBase; }; +} // namespace cfdp + #endif // FSFW_CFDP_MIB_H diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index bb2a5ac4..e2f95388 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -1,3 +1,11 @@ #include -TEST_CASE("CFDP Dest Handler", "[cfdp]") {} \ No newline at end of file +#include "fsfw/cfdp.h" + +TEST_CASE("CFDP Dest Handler", "[cfdp]") { + using namespace cfdp; + // auto localEntityCfg = LocalEntityCfg(); + // auto destHandler = DestHandler(); + + SECTION("State") {} +} \ No newline at end of file diff --git a/unittests/cfdp/handler/testFaultHandler.cpp b/unittests/cfdp/handler/testFaultHandler.cpp index e6fb4547..945e09b8 100644 --- a/unittests/cfdp/handler/testFaultHandler.cpp +++ b/unittests/cfdp/handler/testFaultHandler.cpp @@ -43,12 +43,13 @@ TEST_CASE("CFDP Fault Handler", "[cfdp]") { SECTION("Invalid Reported Code") { CHECK(not fhMock.reportFault(ConditionCode::NO_ERROR)); } - SECTION("Invalid FH code"){ - CHECK(not fhMock.setFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, FaultHandlerCodes::RESERVED)); - CHECK(fhMock.getFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); - CHECK(not fhMock.setFaultHandler(ConditionCode::NO_ERROR, FaultHandlerCodes::IGNORE_ERROR)); - CHECK(not fhMock.getFaultHandler(ConditionCode::NO_ERROR, fhCode)); + SECTION("Invalid FH code") { + CHECK(not fhMock.setFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, + FaultHandlerCodes::RESERVED)); + CHECK(fhMock.getFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, fhCode)); + CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(not fhMock.setFaultHandler(ConditionCode::NO_ERROR, FaultHandlerCodes::IGNORE_ERROR)); + CHECK(not fhMock.getFaultHandler(ConditionCode::NO_ERROR, fhCode)); } SECTION("Set Other Fault Handler") { diff --git a/unittests/mocks/CfdpFaultHandlerMock.h b/unittests/mocks/CfdpFaultHandlerMock.h index ae7b251e..721cf7e0 100644 --- a/unittests/mocks/CfdpFaultHandlerMock.h +++ b/unittests/mocks/CfdpFaultHandlerMock.h @@ -4,7 +4,7 @@ #include #include -#include "fsfw/cfdp/FaultHandlerBase.h" +#include "fsfw/cfdp/handler/FaultHandlerBase.h" class CfdpFaultHandlerMock : public cfdp::FaultHandlerBase { public: From 7a204123053c4a80697d1c33d9ee6904bb1df1af Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 15:51:01 +0200 Subject: [PATCH 207/532] add user base documentation --- src/fsfw/cfdp/handler/UserBase.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index c928789c..6c0f372e 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -7,6 +7,12 @@ namespace cfdp { class UserBase { public: + /** + * Create a user base class which is used to provides a user interface to interact with CFDP + * handlers. It is also used to pass the Virtual Filestore (VFS) Implementation to the CFDP + * handlers so the filestore operations can be mapped to the underlying filestore. + * @param vfs Virtual Filestore Object. Will be used for all file operations + */ explicit UserBase(HasFileSystemIF& vfs); private: From bba2d883b64675adf77ea0da3928e144b1d6aa54 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 16:18:45 +0200 Subject: [PATCH 208/532] added some documentation --- src/fsfw/cfdp/handler/FaultHandlerBase.h | 21 +++++++++++++++++++++ src/fsfw/cfdp/handler/UserBase.h | 11 +++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/fsfw/cfdp/handler/FaultHandlerBase.h b/src/fsfw/cfdp/handler/FaultHandlerBase.h index 2383f849..48b9c42e 100644 --- a/src/fsfw/cfdp/handler/FaultHandlerBase.h +++ b/src/fsfw/cfdp/handler/FaultHandlerBase.h @@ -7,6 +7,27 @@ namespace cfdp { +/** + * @brief Provides a way to implement the fault handling procedures as specified + * in chapter 4.8 of the CFDP standard. + * + * @details + * It is passed into the CFDP handlers as part of the local entity configuration and provides + * a way to specify custom user error handlers. + * + * It does so by mapping each applicable CFDP condition code to a fault handler which + * is denoted by the four @cfdp::FaultHandlerCodes. This code is used to dispatch + * to a user-provided callback function: + * + * 1. @FaultHandlerCodes::IGNORE_ERROR -> @ignore_cb + * 2. @FaultHandlerCodes::NOTICE_OF_CANCELLATION` -> @notice_of_cancellation_cb + * 3. @FaultHandlerCodes::NOTICE_OF_SUSPENSION` -> @notice_of_suspension_cb + * 4. @FaultHandlerCodes::ABANDON_TRANSACTION` -> @abandon_transaction_cb + * + * For each error reported by @reportError, the appropriate fault handler callback + * will be called. The user provides the callbacks by providing a custom class which implements + * these base class and all abstract fault handler callbacks. + */ class FaultHandlerBase { public: virtual ~FaultHandlerBase(); diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index 6c0f372e..282db9e2 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -8,9 +8,16 @@ namespace cfdp { class UserBase { public: /** - * Create a user base class which is used to provides a user interface to interact with CFDP - * handlers. It is also used to pass the Virtual Filestore (VFS) Implementation to the CFDP + * @brief Base class which provides a user interface to interact with CFDP handlers. + * + * @details + * This class is also used to pass the Virtual Filestore (VFS) Implementation to the CFDP * handlers so the filestore operations can be mapped to the underlying filestore. + * + * It is used by implementing it in a child class and then passing it to the CFDP + * handler objects. The base class provides default implementation for the user indication + * primitives specified in the CFDP standard. The user can override these implementations + * to provide custom indication handlers. * @param vfs Virtual Filestore Object. Will be used for all file operations */ explicit UserBase(HasFileSystemIF& vfs); From 5bea92d2a41ab25a542de15809cb7e27cd4296e6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 16:26:37 +0200 Subject: [PATCH 209/532] some doc updates --- docs/api.rst | 1 + docs/api/cfdp.rst | 8 ++++++++ docs/highlevel.rst | 14 ++++++++------ src/fsfw/cfdp/handler/mib.h | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 docs/api/cfdp.rst diff --git a/docs/api.rst b/docs/api.rst index d2ee6c69..dc73c2c7 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -4,6 +4,7 @@ API .. toctree:: :maxdepth: 4 + api/cfdp api/objectmanager api/task api/ipc diff --git a/docs/api/cfdp.rst b/docs/api/cfdp.rst new file mode 100644 index 00000000..335a2025 --- /dev/null +++ b/docs/api/cfdp.rst @@ -0,0 +1,8 @@ +CFDP API +================= + +``UserBase`` +----------------- + +.. doxygenclass:: cfdp::UserBase + :members: \ No newline at end of file diff --git a/docs/highlevel.rst b/docs/highlevel.rst index 04eb5e7b..78ad53ff 100644 --- a/docs/highlevel.rst +++ b/docs/highlevel.rst @@ -7,12 +7,14 @@ Structure ---------- The general structure is driven by the usage of interfaces provided by objects. -The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be -widely available, even with older compilers. -The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. -This simplifies the instantiation of objects and allows the usage of some standard containers. -Dynamic Allocation after initialization is discouraged and different solutions are provided in the -FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed. +The FSFW uses C++17 as baseline. +It also uses dynamic allocation during the initialization but provides +static containers during runtime. +This simplifies the instantiation of objects and allows the usage of some +standard containers. +Dynamic Allocation after initialization is discouraged and different solutions +are provided in the FSFW to achieve that. The fsfw uses run-time type +information but will not throw exceptions. Failure Handling ----------------- diff --git a/src/fsfw/cfdp/handler/mib.h b/src/fsfw/cfdp/handler/mib.h index e78b0f4f..d5e687b4 100644 --- a/src/fsfw/cfdp/handler/mib.h +++ b/src/fsfw/cfdp/handler/mib.h @@ -3,6 +3,7 @@ #include +#include "fsfw/cfdp/pdu/PduConfig.h" #include "FaultHandlerBase.h" namespace cfdp { From 8c059f8f32e9a53cd3c43cd8192cba4432ec5fc4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 16:36:35 +0200 Subject: [PATCH 210/532] new filesystem module --- src/fsfw/CMakeLists.txt | 1 + src/fsfw/cfdp/handler/DestHandler.cpp | 3 ++- src/fsfw/cfdp/handler/DestHandler.h | 4 +++- src/fsfw/cfdp/handler/UserBase.h | 2 +- src/fsfw/cfdp/handler/mib.h | 2 +- src/fsfw/filesystem.h | 7 +++++++ src/fsfw/filesystem/CMakeLists.txt | 1 + src/fsfw/{memory => filesystem}/FileSystemArgsIF.h | 0 .../{memory => filesystem}/GenericFileSystemMessage.cpp | 2 +- src/fsfw/{memory => filesystem}/GenericFileSystemMessage.h | 0 src/fsfw/{memory => filesystem}/HasFileSystemIF.h | 0 src/fsfw/ipc/CommandMessageCleaner.cpp | 3 +-- src/fsfw/memory/CMakeLists.txt | 3 +-- unittests/cfdp/handler/testDestHandler.cpp | 5 ++++- 14 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 src/fsfw/filesystem.h create mode 100644 src/fsfw/filesystem/CMakeLists.txt rename src/fsfw/{memory => filesystem}/FileSystemArgsIF.h (100%) rename src/fsfw/{memory => filesystem}/GenericFileSystemMessage.cpp (99%) rename src/fsfw/{memory => filesystem}/GenericFileSystemMessage.h (100%) rename src/fsfw/{memory => filesystem}/HasFileSystemIF.h (100%) diff --git a/src/fsfw/CMakeLists.txt b/src/fsfw/CMakeLists.txt index 1daad714..e645d34f 100644 --- a/src/fsfw/CMakeLists.txt +++ b/src/fsfw/CMakeLists.txt @@ -31,6 +31,7 @@ add_subdirectory(thermal) add_subdirectory(timemanager) add_subdirectory(tmtcpacket) add_subdirectory(tmtcservices) +add_subdirectory(filesystem) # Optional diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 72f7951e..cd1886f3 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -2,4 +2,5 @@ #include -cfdp::DestHandler::DestHandler(LocalEntityCfg cfg) : cfg(std::move(cfg)) {} +cfdp::DestHandler::DestHandler(LocalEntityCfg cfg, UserBase& user) + : cfg(std::move(cfg)), user(user) {} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index e934fc9c..3b56e2c7 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -1,6 +1,7 @@ #ifndef FSFW_CFDP_CFDPDESTHANDLER_H #define FSFW_CFDP_CFDPDESTHANDLER_H +#include "UserBase.h" #include "fsfw/cfdp/handler/mib.h" #include "fsfw/cfdp/pdu/PduConfig.h" @@ -8,10 +9,11 @@ namespace cfdp { class DestHandler { public: - DestHandler(LocalEntityCfg cfg /*, CfdpUserBase& user, RemoteConfigTableIF& remoteConfigTable*/); + DestHandler(LocalEntityCfg cfg, UserBase& user /*, RemoteConfigTableIF& remoteConfigTable*/); private: LocalEntityCfg cfg; + UserBase& user; }; } // namespace cfdp diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index 282db9e2..07d281b0 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -1,7 +1,7 @@ #ifndef FSFW_CFDP_USERBASE_H #define FSFW_CFDP_USERBASE_H -#include "fsfw/memory/HasFileSystemIF.h" +#include "fsfw/filesystem/HasFileSystemIF.h" namespace cfdp { diff --git a/src/fsfw/cfdp/handler/mib.h b/src/fsfw/cfdp/handler/mib.h index d5e687b4..79e6d895 100644 --- a/src/fsfw/cfdp/handler/mib.h +++ b/src/fsfw/cfdp/handler/mib.h @@ -3,8 +3,8 @@ #include -#include "fsfw/cfdp/pdu/PduConfig.h" #include "FaultHandlerBase.h" +#include "fsfw/cfdp/pdu/PduConfig.h" namespace cfdp { diff --git a/src/fsfw/filesystem.h b/src/fsfw/filesystem.h new file mode 100644 index 00000000..c4a6ebc6 --- /dev/null +++ b/src/fsfw/filesystem.h @@ -0,0 +1,7 @@ +#ifndef FSFW_FILESYSTEM_H +#define FSFW_FILESYSTEM_H + +#include "filesystem/FileSystemArgsIF.h" +#include "filesystem/HasFileSystemIF.h" + +#endif // FSFW_FILESYSTEM_H diff --git a/src/fsfw/filesystem/CMakeLists.txt b/src/fsfw/filesystem/CMakeLists.txt new file mode 100644 index 00000000..a0618d97 --- /dev/null +++ b/src/fsfw/filesystem/CMakeLists.txt @@ -0,0 +1 @@ +target_sources(${LIB_FSFW_NAME} PRIVATE GenericFileSystemMessage.cpp) diff --git a/src/fsfw/memory/FileSystemArgsIF.h b/src/fsfw/filesystem/FileSystemArgsIF.h similarity index 100% rename from src/fsfw/memory/FileSystemArgsIF.h rename to src/fsfw/filesystem/FileSystemArgsIF.h diff --git a/src/fsfw/memory/GenericFileSystemMessage.cpp b/src/fsfw/filesystem/GenericFileSystemMessage.cpp similarity index 99% rename from src/fsfw/memory/GenericFileSystemMessage.cpp rename to src/fsfw/filesystem/GenericFileSystemMessage.cpp index 805c7dcc..3bcd8cf0 100644 --- a/src/fsfw/memory/GenericFileSystemMessage.cpp +++ b/src/fsfw/filesystem/GenericFileSystemMessage.cpp @@ -1,4 +1,4 @@ -#include "fsfw/memory/GenericFileSystemMessage.h" +#include "GenericFileSystemMessage.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/storagemanager/StorageManagerIF.h" diff --git a/src/fsfw/memory/GenericFileSystemMessage.h b/src/fsfw/filesystem/GenericFileSystemMessage.h similarity index 100% rename from src/fsfw/memory/GenericFileSystemMessage.h rename to src/fsfw/filesystem/GenericFileSystemMessage.h diff --git a/src/fsfw/memory/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h similarity index 100% rename from src/fsfw/memory/HasFileSystemIF.h rename to src/fsfw/filesystem/HasFileSystemIF.h diff --git a/src/fsfw/ipc/CommandMessageCleaner.cpp b/src/fsfw/ipc/CommandMessageCleaner.cpp index 328441e6..0a43774b 100644 --- a/src/fsfw/ipc/CommandMessageCleaner.cpp +++ b/src/fsfw/ipc/CommandMessageCleaner.cpp @@ -1,10 +1,9 @@ #include "fsfw/ipc/CommandMessageCleaner.h" -#include "fsfw/FSFW.h" #include "fsfw/devicehandlers/DeviceHandlerMessage.h" +#include "fsfw/filesystem/GenericFileSystemMessage.h" #include "fsfw/health/HealthMessage.h" #include "fsfw/housekeeping/HousekeepingMessage.h" -#include "fsfw/memory/GenericFileSystemMessage.h" #include "fsfw/memory/MemoryMessage.h" #include "fsfw/modes/ModeMessage.h" #include "fsfw/monitoring/MonitoringMessage.h" diff --git a/src/fsfw/memory/CMakeLists.txt b/src/fsfw/memory/CMakeLists.txt index 9e591bae..9d9c90c4 100644 --- a/src/fsfw/memory/CMakeLists.txt +++ b/src/fsfw/memory/CMakeLists.txt @@ -1,2 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE MemoryHelper.cpp MemoryMessage.cpp - GenericFileSystemMessage.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE MemoryHelper.cpp MemoryMessage.cpp) diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index e2f95388..8d971361 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -1,10 +1,13 @@ #include #include "fsfw/cfdp.h" +#include "mocks/CfdpFaultHandlerMock.h" TEST_CASE("CFDP Dest Handler", "[cfdp]") { using namespace cfdp; - // auto localEntityCfg = LocalEntityCfg(); + EntityId localId = EntityId(UnsignedByteField(2)); + auto fhMock = CfdpFaultHandlerMock(); + auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock); // auto destHandler = DestHandler(); SECTION("State") {} From d45108e3c210c1687718a1db61c486e8d3eab2a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 18:51:44 +0200 Subject: [PATCH 211/532] add remote config table provider class --- src/fsfw/cfdp/CMakeLists.txt | 3 +- .../{pdu/VarLenField.cpp => VarLenFields.cpp} | 12 ++++++-- .../{pdu/VarLenField.h => VarLenFields.h} | 29 +++++++++++++++++++ src/fsfw/cfdp/definitions.h | 6 +++- src/fsfw/cfdp/handler/DestHandler.cpp | 5 ++-- src/fsfw/cfdp/handler/DestHandler.h | 4 ++- src/fsfw/cfdp/handler/RemoteConfigTableIF.h | 15 ++++++++++ src/fsfw/cfdp/handler/UserBase.h | 15 ++++++++++ src/fsfw/cfdp/handler/mib.h | 10 +++++++ src/fsfw/cfdp/pdu/CMakeLists.txt | 1 - src/fsfw/cfdp/pdu/PduConfig.h | 22 +------------- 11 files changed, 92 insertions(+), 30 deletions(-) rename src/fsfw/cfdp/{pdu/VarLenField.cpp => VarLenFields.cpp} (93%) rename src/fsfw/cfdp/{pdu/VarLenField.h => VarLenFields.h} (64%) create mode 100644 src/fsfw/cfdp/handler/RemoteConfigTableIF.h diff --git a/src/fsfw/cfdp/CMakeLists.txt b/src/fsfw/cfdp/CMakeLists.txt index 72324a53..30a7c700 100644 --- a/src/fsfw/cfdp/CMakeLists.txt +++ b/src/fsfw/cfdp/CMakeLists.txt @@ -1,4 +1,5 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp + VarLenFields.cpp) add_subdirectory(pdu) add_subdirectory(tlv) diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/VarLenFields.cpp similarity index 93% rename from src/fsfw/cfdp/pdu/VarLenField.cpp rename to src/fsfw/cfdp/VarLenFields.cpp index 1f4d2429..c70d90ec 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.cpp +++ b/src/fsfw/cfdp/VarLenFields.cpp @@ -1,4 +1,4 @@ -#include "VarLenField.h" +#include "VarLenFields.h" #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface.h" @@ -119,9 +119,15 @@ ReturnValue_t cfdp::VarLenField::deSerialize(const uint8_t **buffer, size_t *siz } bool cfdp::VarLenField::operator<(const cfdp::VarLenField &other) const { - return getValue() < other.getValue(); + if (getWidth() < other.getWidth()) { + return true; + } else if (getWidth() == other.getWidth()) { + return getValue() < other.getValue(); + } else { + return false; + } } bool cfdp::VarLenField::operator==(const cfdp::VarLenField &other) const { - return getValue() == other.getValue(); + return getWidth() == other.getWidth() and getValue() == other.getValue(); } diff --git a/src/fsfw/cfdp/pdu/VarLenField.h b/src/fsfw/cfdp/VarLenFields.h similarity index 64% rename from src/fsfw/cfdp/pdu/VarLenField.h rename to src/fsfw/cfdp/VarLenFields.h index 819e8ccd..2b862d66 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.h +++ b/src/fsfw/cfdp/VarLenFields.h @@ -3,6 +3,7 @@ #include #include +#include #include "fsfw/cfdp/definitions.h" #include "fsfw/serialize/SerializeIF.h" @@ -56,6 +57,34 @@ cfdp::VarLenField::VarLenField(UnsignedByteField byteField) setValue(width, byteField.getValue()); } +struct EntityId : public VarLenField { + public: + EntityId() : VarLenField() {} + template + explicit EntityId(UnsignedByteField byteField) : VarLenField(byteField) {} + EntityId(cfdp::WidthInBytes width, size_t entityId) : VarLenField(width, entityId) {} +}; + +struct TransactionSeqNum : public VarLenField { + public: + TransactionSeqNum() : VarLenField() {} + template + explicit TransactionSeqNum(UnsignedByteField byteField) : VarLenField(byteField) {} + TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {} +}; + +struct TransactionId { + TransactionId(EntityId entityId, TransactionSeqNum seqNum) + : entityId(std::move(entityId)), seqNum(std::move(seqNum)) {} + + bool operator==(const TransactionId &other) { + return entityId == other.entityId and seqNum == other.seqNum; + } + + EntityId entityId; + TransactionSeqNum seqNum; +}; + } // namespace cfdp #endif /* FSFW_CFDP_PDU_VARLENFIELD_H_ */ diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index b97b9b27..4bd149e2 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -11,7 +11,11 @@ namespace cfdp { -static constexpr uint8_t VERSION_BITS = 0b00100000; +static constexpr char CFDP_VERSION_2_NAME[] = "CCSDS 727.0-B-5"; + +// Second version of the protocol, only this one is supported here +static constexpr uint8_t CFDP_VERSION_2 = 0b001; +static constexpr uint8_t VERSION_BITS = CFDP_VERSION_2 << 5; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index cd1886f3..d2b672c9 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -2,5 +2,6 @@ #include -cfdp::DestHandler::DestHandler(LocalEntityCfg cfg, UserBase& user) - : cfg(std::move(cfg)), user(user) {} +cfdp::DestHandler::DestHandler(LocalEntityCfg cfg, UserBase& user, + RemoteConfigTableIF& remoteCfgTable) + : cfg(std::move(cfg)), user(user), remoteCfgTable(remoteCfgTable) {} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 3b56e2c7..0032c7b8 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -1,6 +1,7 @@ #ifndef FSFW_CFDP_CFDPDESTHANDLER_H #define FSFW_CFDP_CFDPDESTHANDLER_H +#include "RemoteConfigTableIF.h" #include "UserBase.h" #include "fsfw/cfdp/handler/mib.h" #include "fsfw/cfdp/pdu/PduConfig.h" @@ -9,11 +10,12 @@ namespace cfdp { class DestHandler { public: - DestHandler(LocalEntityCfg cfg, UserBase& user /*, RemoteConfigTableIF& remoteConfigTable*/); + DestHandler(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable); private: LocalEntityCfg cfg; UserBase& user; + RemoteConfigTableIF& remoteCfgTable; }; } // namespace cfdp diff --git a/src/fsfw/cfdp/handler/RemoteConfigTableIF.h b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h new file mode 100644 index 00000000..c757fe7e --- /dev/null +++ b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h @@ -0,0 +1,15 @@ +#ifndef FSFW_CFDP_HANDLER_REMOTECONFIGTABLEIF_H +#define FSFW_CFDP_HANDLER_REMOTECONFIGTABLEIF_H + +#include "fsfw/cfdp/handler/mib.h" + +namespace cfdp { + +class RemoteConfigTableIF { + virtual ~RemoteConfigTableIF() = default; + virtual bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg* cfg) = 0; +}; + +} // namespace cfdp + +#endif // FSFW_CFDP_HANDLER_REMOTECONFIGTABLEIF_H diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index 07d281b0..dd3c7424 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -1,6 +1,7 @@ #ifndef FSFW_CFDP_USERBASE_H #define FSFW_CFDP_USERBASE_H +#include "fsfw/cfdp/VarLenFields.h" #include "fsfw/filesystem/HasFileSystemIF.h" namespace cfdp { @@ -22,6 +23,20 @@ class UserBase { */ explicit UserBase(HasFileSystemIF& vfs); + virtual void transactionIndication(TransactionId id) = 0; + virtual void eofSentIndication(TransactionId id) = 0; + + virtual void abandonedIndication(TransactionId id, ConditionCode code, uint64_t progress) = 0; + virtual void eofRecvIndication(TransactionId id) = 0; + + // TODO: Parameters + virtual void transactionFinishedIndication() = 0; + virtual void metadataRecvdIndication() = 0; + virtual void fileSegmentRecvdIndication() = 0; + virtual void reportIndication() = 0; + virtual void suspendedIndication() = 0; + virtual void resumedIndication() = 0; + private: HasFileSystemIF& vfs; }; diff --git a/src/fsfw/cfdp/handler/mib.h b/src/fsfw/cfdp/handler/mib.h index 79e6d895..7ba15cd3 100644 --- a/src/fsfw/cfdp/handler/mib.h +++ b/src/fsfw/cfdp/handler/mib.h @@ -26,6 +26,16 @@ struct LocalEntityCfg { FaultHandlerBase& fhBase; }; +struct RemoteEntityCfg { + EntityId remoteId; + size_t maxFileSegmentLen; + bool closureRequested; + bool crcOnTransmission; + TransmissionModes defaultTransmissionMode; + ChecksumType defaultChecksum; + const uint8_t version = CFDP_VERSION_2; +}; + } // namespace cfdp #endif // FSFW_CFDP_MIB_H diff --git a/src/fsfw/cfdp/pdu/CMakeLists.txt b/src/fsfw/cfdp/pdu/CMakeLists.txt index 33b05eec..91b5ad2e 100644 --- a/src/fsfw/cfdp/pdu/CMakeLists.txt +++ b/src/fsfw/cfdp/pdu/CMakeLists.txt @@ -1,7 +1,6 @@ target_sources( ${LIB_FSFW_NAME} PRIVATE PduConfig.cpp - VarLenField.cpp HeaderCreator.cpp HeaderReader.cpp FileDirectiveReader.cpp diff --git a/src/fsfw/cfdp/pdu/PduConfig.h b/src/fsfw/cfdp/pdu/PduConfig.h index 48f3993b..2e513159 100644 --- a/src/fsfw/cfdp/pdu/PduConfig.h +++ b/src/fsfw/cfdp/pdu/PduConfig.h @@ -1,29 +1,9 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_ #define FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_ -#include "VarLenField.h" +#include "fsfw/cfdp/VarLenFields.h" #include "fsfw/cfdp/definitions.h" -namespace cfdp { - -struct EntityId : public VarLenField { - public: - EntityId() : VarLenField() {} - template - explicit EntityId(UnsignedByteField byteField) : VarLenField(byteField) {} - EntityId(cfdp::WidthInBytes width, size_t entityId) : VarLenField(width, entityId) {} -}; - -struct TransactionSeqNum : public VarLenField { - public: - TransactionSeqNum() : VarLenField() {} - template - explicit TransactionSeqNum(UnsignedByteField byteField) : VarLenField(byteField) {} - TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {} -}; - -} // namespace cfdp - class PduConfig { public: PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionModes mode, From 0cb15e901eee6ebd1482c2cdfd8ae4f6dfa677b2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 19:00:47 +0200 Subject: [PATCH 212/532] new cfdp mock folder, added additional cfdp mocks --- src/fsfw/cfdp/handler/RemoteConfigTableIF.h | 1 + unittests/cfdp/handler/testDestHandler.cpp | 4 +-- unittests/cfdp/handler/testFaultHandler.cpp | 4 +-- unittests/mocks/CMakeLists.txt | 5 ++-- unittests/mocks/cfdp/CMakeLists.txt | 1 + .../FaultHandlerMock.cpp} | 20 +++++++++------ .../FaultHandlerMock.h} | 23 ++++++++++------- .../mocks/cfdp/RemoteConfigTableMock.cpp | 6 +++++ unittests/mocks/cfdp/RemoteConfigTableMock.h | 15 +++++++++++ unittests/mocks/cfdp/UserMock.cpp | 16 ++++++++++++ unittests/mocks/cfdp/UserMock.h | 25 +++++++++++++++++++ 11 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 unittests/mocks/cfdp/CMakeLists.txt rename unittests/mocks/{CfdpFaultHandlerMock.cpp => cfdp/FaultHandlerMock.cpp} (59%) rename unittests/mocks/{CfdpFaultHandlerMock.h => cfdp/FaultHandlerMock.h} (56%) create mode 100644 unittests/mocks/cfdp/RemoteConfigTableMock.cpp create mode 100644 unittests/mocks/cfdp/RemoteConfigTableMock.h create mode 100644 unittests/mocks/cfdp/UserMock.cpp create mode 100644 unittests/mocks/cfdp/UserMock.h diff --git a/src/fsfw/cfdp/handler/RemoteConfigTableIF.h b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h index c757fe7e..767492d5 100644 --- a/src/fsfw/cfdp/handler/RemoteConfigTableIF.h +++ b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h @@ -6,6 +6,7 @@ namespace cfdp { class RemoteConfigTableIF { + public: virtual ~RemoteConfigTableIF() = default; virtual bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg* cfg) = 0; }; diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 8d971361..d963b6c7 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -1,12 +1,12 @@ #include #include "fsfw/cfdp.h" -#include "mocks/CfdpFaultHandlerMock.h" +#include "mocks/cfdp/FaultHandlerMock.h" TEST_CASE("CFDP Dest Handler", "[cfdp]") { using namespace cfdp; EntityId localId = EntityId(UnsignedByteField(2)); - auto fhMock = CfdpFaultHandlerMock(); + auto fhMock = FaultHandlerMock(); auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock); // auto destHandler = DestHandler(); diff --git a/unittests/cfdp/handler/testFaultHandler.cpp b/unittests/cfdp/handler/testFaultHandler.cpp index 945e09b8..559744d7 100644 --- a/unittests/cfdp/handler/testFaultHandler.cpp +++ b/unittests/cfdp/handler/testFaultHandler.cpp @@ -1,10 +1,10 @@ #include -#include "mocks/CfdpFaultHandlerMock.h" +#include "mocks/cfdp/FaultHandlerMock.h" TEST_CASE("CFDP Fault Handler", "[cfdp]") { using namespace cfdp; - auto fhMock = CfdpFaultHandlerMock(); + auto fhMock = FaultHandlerMock(); cfdp::FaultHandlerCodes fhCode; SECTION("State") { diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index 0ee7bf1e..e15f3d71 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -14,5 +14,6 @@ target_sources( PusDistributorMock.cpp CcsdsCheckerMock.cpp AcceptsTcMock.cpp - StorageManagerMock.cpp - CfdpFaultHandlerMock.cpp) + StorageManagerMock.cpp) + +add_subdirectory(cfdp) diff --git a/unittests/mocks/cfdp/CMakeLists.txt b/unittests/mocks/cfdp/CMakeLists.txt new file mode 100644 index 00000000..0fa0890c --- /dev/null +++ b/unittests/mocks/cfdp/CMakeLists.txt @@ -0,0 +1 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE FaultHandlerMock.cpp UserMock.cpp RemoteConfigTableMock.cpp) diff --git a/unittests/mocks/CfdpFaultHandlerMock.cpp b/unittests/mocks/cfdp/FaultHandlerMock.cpp similarity index 59% rename from unittests/mocks/CfdpFaultHandlerMock.cpp rename to unittests/mocks/cfdp/FaultHandlerMock.cpp index 3f7c8896..26bebda5 100644 --- a/unittests/mocks/CfdpFaultHandlerMock.cpp +++ b/unittests/mocks/cfdp/FaultHandlerMock.cpp @@ -1,38 +1,42 @@ -#include "CfdpFaultHandlerMock.h" +#include "FaultHandlerMock.h" -void CfdpFaultHandlerMock::noticeOfSuspensionCb(cfdp::ConditionCode code) { +namespace cfdp { + +void FaultHandlerMock::noticeOfSuspensionCb(cfdp::ConditionCode code) { auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION); info.callCount++; info.condCodes.push(code); } -void CfdpFaultHandlerMock::noticeOfCancellationCb(cfdp::ConditionCode code) { +void FaultHandlerMock::noticeOfCancellationCb(cfdp::ConditionCode code) { auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION); info.callCount++; info.condCodes.push(code); } -void CfdpFaultHandlerMock::abandonCb(cfdp::ConditionCode code) { +void FaultHandlerMock::abandonCb(cfdp::ConditionCode code) { auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::ABANDON_TRANSACTION); info.callCount++; info.condCodes.push(code); } -void CfdpFaultHandlerMock::ignoreCb(cfdp::ConditionCode code) { +void FaultHandlerMock::ignoreCb(cfdp::ConditionCode code) { auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::IGNORE_ERROR); info.callCount++; info.condCodes.push(code); } -CfdpFaultHandlerMock::FaultInfo& CfdpFaultHandlerMock::getFhInfo(cfdp::FaultHandlerCodes fhCode) { +FaultHandlerMock::FaultInfo& FaultHandlerMock::getFhInfo(cfdp::FaultHandlerCodes fhCode) { return fhInfoMap.at(fhCode); } -void CfdpFaultHandlerMock::reset() { fhInfoMap.clear(); } +void FaultHandlerMock::reset() { fhInfoMap.clear(); } -bool CfdpFaultHandlerMock::faultCbWasCalled() const { +bool FaultHandlerMock::faultCbWasCalled() const { return std::any_of(fhInfoMap.begin(), fhInfoMap.end(), [](const std::pair& pair) { return pair.second.callCount > 0; }); } + +} // namespace cfdp diff --git a/unittests/mocks/CfdpFaultHandlerMock.h b/unittests/mocks/cfdp/FaultHandlerMock.h similarity index 56% rename from unittests/mocks/CfdpFaultHandlerMock.h rename to unittests/mocks/cfdp/FaultHandlerMock.h index 721cf7e0..a35d3d2b 100644 --- a/unittests/mocks/CfdpFaultHandlerMock.h +++ b/unittests/mocks/cfdp/FaultHandlerMock.h @@ -1,24 +1,26 @@ -#ifndef FSFW_TESTS_CFDPFAULTHANDLERMOCK_H -#define FSFW_TESTS_CFDPFAULTHANDLERMOCK_H +#ifndef FSFW_TESTS_FAULTHANDLERMOCK_H +#define FSFW_TESTS_FAULTHANDLERMOCK_H #include #include #include "fsfw/cfdp/handler/FaultHandlerBase.h" -class CfdpFaultHandlerMock : public cfdp::FaultHandlerBase { +namespace cfdp { + +class FaultHandlerMock : public FaultHandlerBase { public: struct FaultInfo { size_t callCount = 0; std::queue condCodes; }; - void noticeOfSuspensionCb(cfdp::ConditionCode code) override; - void noticeOfCancellationCb(cfdp::ConditionCode code) override; - void abandonCb(cfdp::ConditionCode code) override; - void ignoreCb(cfdp::ConditionCode code) override; + void noticeOfSuspensionCb(ConditionCode code) override; + void noticeOfCancellationCb(ConditionCode code) override; + void abandonCb(ConditionCode code) override; + void ignoreCb(ConditionCode code) override; - FaultInfo& getFhInfo(cfdp::FaultHandlerCodes fhCode); + FaultInfo& getFhInfo(FaultHandlerCodes fhCode); [[nodiscard]] bool faultCbWasCalled() const; void reset(); @@ -29,4 +31,7 @@ class CfdpFaultHandlerMock : public cfdp::FaultHandlerBase { std::pair{cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION, FaultInfo()}, std::pair{cfdp::FaultHandlerCodes::ABANDON_TRANSACTION, FaultInfo()}}; }; -#endif // FSFW_TESTS_CFDPFAULTHANDLERMOCK_H + +} // namespace cfdp + +#endif // FSFW_TESTS_FAULTHANDLERMOCK_H diff --git a/unittests/mocks/cfdp/RemoteConfigTableMock.cpp b/unittests/mocks/cfdp/RemoteConfigTableMock.cpp new file mode 100644 index 00000000..83827a36 --- /dev/null +++ b/unittests/mocks/cfdp/RemoteConfigTableMock.cpp @@ -0,0 +1,6 @@ +#include "RemoteConfigTableMock.h" + +bool cfdp::RemoteConfigTableMock::getRemoteCfg(cfdp::EntityId remoteId, + cfdp::RemoteEntityCfg *cfg) { + return false; +} diff --git a/unittests/mocks/cfdp/RemoteConfigTableMock.h b/unittests/mocks/cfdp/RemoteConfigTableMock.h new file mode 100644 index 00000000..7ac25ba7 --- /dev/null +++ b/unittests/mocks/cfdp/RemoteConfigTableMock.h @@ -0,0 +1,15 @@ +#ifndef FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H +#define FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H + +#include "fsfw/cfdp/handler/RemoteConfigTableIF.h" + +namespace cfdp { + +class RemoteConfigTableMock: public RemoteConfigTableIF { + public: + bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg *cfg) override; +}; + +} + +#endif // FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mocks/cfdp/UserMock.cpp new file mode 100644 index 00000000..c8b3b940 --- /dev/null +++ b/unittests/mocks/cfdp/UserMock.cpp @@ -0,0 +1,16 @@ +#include "UserMock.h" + +cfdp::UserMock::UserMock(HasFileSystemIF& vfs) : UserBase(vfs) {} + +void cfdp::UserMock::transactionIndication(cfdp::TransactionId id) {} +void cfdp::UserMock::eofSentIndication(cfdp::TransactionId id) {} +void cfdp::UserMock::abandonedIndication(cfdp::TransactionId id, cfdp::ConditionCode code, + uint64_t progress) {} +void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {} +void cfdp::UserMock::transactionFinishedIndication() {} +void cfdp::UserMock::metadataRecvdIndication() {} +void cfdp::UserMock::fileSegmentRecvdIndication() {} +void cfdp::UserMock::reportIndication() {} +void cfdp::UserMock::suspendedIndication() {} +void cfdp::UserMock::resumedIndication() {} + diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mocks/cfdp/UserMock.h new file mode 100644 index 00000000..b32e698a --- /dev/null +++ b/unittests/mocks/cfdp/UserMock.h @@ -0,0 +1,25 @@ +#ifndef FSFW_TESTS_CFDP_USERMOCK_H +#define FSFW_TESTS_CFDP_USERMOCK_H + +#include "fsfw/cfdp/handler/UserBase.h" + +namespace cfdp { + +class UserMock: public UserBase { + explicit UserMock(HasFileSystemIF& vfs); + public: + void transactionIndication(TransactionId id) override; + void eofSentIndication(TransactionId id) override; + void abandonedIndication(TransactionId id, ConditionCode code, uint64_t progress) override; + void eofRecvIndication(TransactionId id) override; + void transactionFinishedIndication() override; + void metadataRecvdIndication() override; + void fileSegmentRecvdIndication() override; + void reportIndication() override; + void suspendedIndication() override; + void resumedIndication() override; +}; + +} + +#endif // FSFW_TESTS_CFDP_USERMOCK_H From 507c6ddff124604d15a542a8b640541b69f45701 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Aug 2022 21:03:56 +0200 Subject: [PATCH 213/532] added some param structs --- src/fsfw/cfdp/definitions.h | 4 +- src/fsfw/cfdp/handler/StatusReportIF.h | 12 ++++++ src/fsfw/cfdp/handler/UserBase.h | 42 +++++++++++++++++-- src/fsfw/cfdp/pdu/FinishedInfo.cpp | 13 +++--- src/fsfw/cfdp/pdu/FinishedInfo.h | 16 +++---- src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp | 4 +- src/fsfw/cfdp/tlv/Tlv.h | 16 +++---- unittests/cfdp/pdu/testFinishedPdu.cpp | 20 ++++----- unittests/mocks/cfdp/CMakeLists.txt | 3 +- unittests/mocks/cfdp/RemoteConfigTableMock.h | 4 +- unittests/mocks/cfdp/UserMock.cpp | 5 +-- unittests/mocks/cfdp/UserMock.h | 10 ++--- 12 files changed, 98 insertions(+), 51 deletions(-) create mode 100644 src/fsfw/cfdp/handler/StatusReportIF.h diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 4bd149e2..80eb7340 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -109,9 +109,9 @@ enum AckTransactionStatus { UNRECOGNIZED = 0b11 }; -enum FinishedDeliveryCode { DATA_COMPLETE = 0, DATA_INCOMPLETE = 1 }; +enum FileDeliveryCode { DATA_COMPLETE = 0, DATA_INCOMPLETE = 1 }; -enum FinishedFileStatus { +enum FileDeliveryStatus { DISCARDED_DELIBERATELY = 0, DISCARDED_FILESTORE_REJECTION = 1, RETAINED_IN_FILESTORE = 2, diff --git a/src/fsfw/cfdp/handler/StatusReportIF.h b/src/fsfw/cfdp/handler/StatusReportIF.h new file mode 100644 index 00000000..1bf98628 --- /dev/null +++ b/src/fsfw/cfdp/handler/StatusReportIF.h @@ -0,0 +1,12 @@ +#ifndef FSFW_CFDP_HANDLER_STATUSREPORTIF_H +#define FSFW_CFDP_HANDLER_STATUSREPORTIF_H + +namespace cfdp { + +class StatusReportIF { + virtual ~StatusReportIF() = default; +}; + +} // namespace cfdp + +#endif // FSFW_CFDP_HANDLER_STATUSREPORTIF_H diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index dd3c7424..6835600c 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -1,11 +1,47 @@ #ifndef FSFW_CFDP_USERBASE_H #define FSFW_CFDP_USERBASE_H +#include +#include + +#include "StatusReportIF.h" #include "fsfw/cfdp/VarLenFields.h" +#include "fsfw/cfdp/tlv/FilestoreResponseTlv.h" +#include "fsfw/cfdp/tlv/MessageToUserTlv.h" #include "fsfw/filesystem/HasFileSystemIF.h" namespace cfdp { +struct TransactionFinishedParams { + TransactionFinishedParams(TransactionId id, ConditionCode code, FileDeliveryStatus status, + FileDeliveryCode delivCode) + : id(std::move(id)), condCode(code), status(status), deliveryCode(delivCode) {} + + TransactionId id; + ConditionCode condCode; + FileDeliveryStatus status; + FileDeliveryCode deliveryCode; + std::pair fsResponses; + StatusReportIF* statusReport = nullptr; +}; + +struct MetadataRecvParams { + TransactionId id; + EntityId sourceId; + size_t fileSize; + const char* sourceFileName; + const char* destFileName; + std::pair msgsToUser; +}; + +struct FileSegmentRecvdParams { + TransactionId id; + size_t offset; + size_t length; + std::optional recContState = std::nullopt; + std::pair segmentMetadata; +}; + class UserBase { public: /** @@ -30,9 +66,9 @@ class UserBase { virtual void eofRecvIndication(TransactionId id) = 0; // TODO: Parameters - virtual void transactionFinishedIndication() = 0; - virtual void metadataRecvdIndication() = 0; - virtual void fileSegmentRecvdIndication() = 0; + virtual void transactionFinishedIndication(TransactionFinishedParams params) = 0; + virtual void metadataRecvdIndication(MetadataRecvParams params) = 0; + virtual void fileSegmentRecvdIndication(FileSegmentRecvdParams params) = 0; virtual void reportIndication() = 0; virtual void suspendedIndication() = 0; virtual void resumedIndication() = 0; diff --git a/src/fsfw/cfdp/pdu/FinishedInfo.cpp b/src/fsfw/cfdp/pdu/FinishedInfo.cpp index c32372a1..ca16768b 100644 --- a/src/fsfw/cfdp/pdu/FinishedInfo.cpp +++ b/src/fsfw/cfdp/pdu/FinishedInfo.cpp @@ -2,9 +2,8 @@ FinishedInfo::FinishedInfo() {} -FinishedInfo::FinishedInfo(cfdp::ConditionCode conditionCode, - cfdp::FinishedDeliveryCode deliveryCode, - cfdp::FinishedFileStatus fileStatus) +FinishedInfo::FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FileDeliveryCode deliveryCode, + cfdp::FileDeliveryStatus fileStatus) : conditionCode(conditionCode), deliveryCode(deliveryCode), fileStatus(fileStatus) {} size_t FinishedInfo::getSerializedSize() const { @@ -83,13 +82,13 @@ void FinishedInfo::setConditionCode(cfdp::ConditionCode conditionCode) { this->conditionCode = conditionCode; } -cfdp::FinishedDeliveryCode FinishedInfo::getDeliveryCode() const { return deliveryCode; } +cfdp::FileDeliveryCode FinishedInfo::getDeliveryCode() const { return deliveryCode; } -void FinishedInfo::setDeliveryCode(cfdp::FinishedDeliveryCode deliveryCode) { +void FinishedInfo::setDeliveryCode(cfdp::FileDeliveryCode deliveryCode) { this->deliveryCode = deliveryCode; } -cfdp::FinishedFileStatus FinishedInfo::getFileStatus() const { return fileStatus; } +cfdp::FileDeliveryStatus FinishedInfo::getFileStatus() const { return fileStatus; } void FinishedInfo::setFilestoreResponsesArrayLen(size_t fsResponsesLen) { this->fsResponsesLen = fsResponsesLen; @@ -97,6 +96,6 @@ void FinishedInfo::setFilestoreResponsesArrayLen(size_t fsResponsesLen) { size_t FinishedInfo::getFsResponsesLen() const { return fsResponsesLen; } -void FinishedInfo::setFileStatus(cfdp::FinishedFileStatus fileStatus) { +void FinishedInfo::setFileStatus(cfdp::FileDeliveryStatus fileStatus) { this->fileStatus = fileStatus; } diff --git a/src/fsfw/cfdp/pdu/FinishedInfo.h b/src/fsfw/cfdp/pdu/FinishedInfo.h index 3f1758e8..49d7c64d 100644 --- a/src/fsfw/cfdp/pdu/FinishedInfo.h +++ b/src/fsfw/cfdp/pdu/FinishedInfo.h @@ -8,8 +8,8 @@ class FinishedInfo { public: FinishedInfo(); - FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FinishedDeliveryCode deliveryCode, - cfdp::FinishedFileStatus fileStatus); + FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FileDeliveryCode deliveryCode, + cfdp::FileDeliveryStatus fileStatus); [[nodiscard]] size_t getSerializedSize() const; @@ -27,15 +27,15 @@ class FinishedInfo { ReturnValue_t getFaultLocation(EntityIdTlv** entityId); [[nodiscard]] cfdp::ConditionCode getConditionCode() const; void setConditionCode(cfdp::ConditionCode conditionCode); - [[nodiscard]] cfdp::FinishedDeliveryCode getDeliveryCode() const; - void setDeliveryCode(cfdp::FinishedDeliveryCode deliveryCode); - [[nodiscard]] cfdp::FinishedFileStatus getFileStatus() const; - void setFileStatus(cfdp::FinishedFileStatus fileStatus); + [[nodiscard]] cfdp::FileDeliveryCode getDeliveryCode() const; + void setDeliveryCode(cfdp::FileDeliveryCode deliveryCode); + [[nodiscard]] cfdp::FileDeliveryStatus getFileStatus() const; + void setFileStatus(cfdp::FileDeliveryStatus fileStatus); private: cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD; - cfdp::FinishedDeliveryCode deliveryCode = cfdp::FinishedDeliveryCode::DATA_COMPLETE; - cfdp::FinishedFileStatus fileStatus = cfdp::FinishedFileStatus::DISCARDED_DELIBERATELY; + cfdp::FileDeliveryCode deliveryCode = cfdp::FileDeliveryCode::DATA_COMPLETE; + cfdp::FileDeliveryStatus fileStatus = cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY; FilestoreResponseTlv** fsResponses = nullptr; size_t fsResponsesLen = 0; size_t fsResponsesMaxLen = 0; diff --git a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp index 7776778b..6eec494e 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp @@ -18,8 +18,8 @@ ReturnValue_t FinishPduDeserializer::parseData() { uint8_t firstByte = *buf; auto condCode = static_cast((firstByte >> 4) & 0x0f); finishedInfo.setConditionCode(condCode); - finishedInfo.setDeliveryCode(static_cast(firstByte >> 2 & 0b1)); - finishedInfo.setFileStatus(static_cast(firstByte & 0b11)); + finishedInfo.setDeliveryCode(static_cast(firstByte >> 2 & 0b1)); + finishedInfo.setFileStatus(static_cast(firstByte & 0b11)); buf += 1; remSize -= 1; currentIdx += 1; diff --git a/src/fsfw/cfdp/tlv/Tlv.h b/src/fsfw/cfdp/tlv/Tlv.h index a67c6dd1..2bdc56f5 100644 --- a/src/fsfw/cfdp/tlv/Tlv.h +++ b/src/fsfw/cfdp/tlv/Tlv.h @@ -27,10 +27,10 @@ class Tlv : public TlvIF { * - INVALID_TLV_TYPE * - SerializeIF returncode on wrong serialization parameters */ - 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 Deserialize a LV field from a raw buffer. Zero-copy implementation @@ -41,15 +41,15 @@ class Tlv : public TlvIF { * - INVALID_TLV_TYPE * - SerializeIF returncode on wrong deserialization parameters */ - 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; void setValue(uint8_t *value, size_t len); - const uint8_t *getValue() const; + [[nodiscard]] const uint8_t *getValue() const; void setType(TlvTypes type); - TlvTypes getType() const override; - uint8_t getLengthField() const override; + [[nodiscard]] TlvTypes getType() const override; + [[nodiscard]] uint8_t getLengthField() const override; private: bool checkType(uint8_t rawType); diff --git a/unittests/cfdp/pdu/testFinishedPdu.cpp b/unittests/cfdp/pdu/testFinishedPdu.cpp index c2aa3bb1..d117ed58 100644 --- a/unittests/cfdp/pdu/testFinishedPdu.cpp +++ b/unittests/cfdp/pdu/testFinishedPdu.cpp @@ -18,8 +18,8 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { cfdp::Lv emptyFsMsg; FinishedInfo info(cfdp::ConditionCode::INACTIVITY_DETECTED, - cfdp::FinishedDeliveryCode::DATA_INCOMPLETE, - cfdp::FinishedFileStatus::DISCARDED_DELIBERATELY); + cfdp::FileDeliveryCode::DATA_INCOMPLETE, + cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY); SECTION("Serialize") { FinishPduSerializer serializer(pduConf, info); @@ -29,8 +29,8 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { REQUIRE(((fnBuffer[1] << 8) | fnBuffer[2]) == 2); REQUIRE(fnBuffer[10] == cfdp::FileDirectives::FINISH); REQUIRE(((fnBuffer[sz - 1] >> 4) & 0x0f) == cfdp::ConditionCode::INACTIVITY_DETECTED); - REQUIRE(((fnBuffer[sz - 1] >> 2) & 0x01) == cfdp::FinishedDeliveryCode::DATA_INCOMPLETE); - REQUIRE((fnBuffer[sz - 1] & 0b11) == cfdp::FinishedFileStatus::DISCARDED_DELIBERATELY); + REQUIRE(((fnBuffer[sz - 1] >> 2) & 0x01) == cfdp::FileDeliveryCode::DATA_INCOMPLETE); + REQUIRE((fnBuffer[sz - 1] & 0b11) == cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY); REQUIRE(sz == 12); // Add a filestore response @@ -73,10 +73,10 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { info.setConditionCode(cfdp::ConditionCode::FILESTORE_REJECTION); REQUIRE(serializer.getSerializedSize() == 12 + 14 + 15 + 4); REQUIRE(sz == 12 + 14 + 15 + 4); - info.setFileStatus(cfdp::FinishedFileStatus::DISCARDED_FILESTORE_REJECTION); - REQUIRE(info.getFileStatus() == cfdp::FinishedFileStatus::DISCARDED_FILESTORE_REJECTION); - info.setDeliveryCode(cfdp::FinishedDeliveryCode::DATA_INCOMPLETE); - REQUIRE(info.getDeliveryCode() == cfdp::FinishedDeliveryCode::DATA_INCOMPLETE); + info.setFileStatus(cfdp::FileDeliveryStatus::DISCARDED_FILESTORE_REJECTION); + REQUIRE(info.getFileStatus() == cfdp::FileDeliveryStatus::DISCARDED_FILESTORE_REJECTION); + info.setDeliveryCode(cfdp::FileDeliveryCode::DATA_INCOMPLETE); + REQUIRE(info.getDeliveryCode() == cfdp::FileDeliveryCode::DATA_INCOMPLETE); for (size_t maxSz = 0; maxSz < 45; maxSz++) { sz = 0; buffer = fnBuffer.data(); @@ -93,9 +93,9 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { FinishPduDeserializer deserializer(fnBuffer.data(), fnBuffer.size(), emptyInfo); result = deserializer.parseData(); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(emptyInfo.getFileStatus() == cfdp::FinishedFileStatus::DISCARDED_DELIBERATELY); + REQUIRE(emptyInfo.getFileStatus() == cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY); REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::INACTIVITY_DETECTED); - REQUIRE(emptyInfo.getDeliveryCode() == cfdp::FinishedDeliveryCode::DATA_INCOMPLETE); + REQUIRE(emptyInfo.getDeliveryCode() == cfdp::FileDeliveryCode::DATA_INCOMPLETE); // Add a filestore response sz = 0; diff --git a/unittests/mocks/cfdp/CMakeLists.txt b/unittests/mocks/cfdp/CMakeLists.txt index 0fa0890c..769e06ae 100644 --- a/unittests/mocks/cfdp/CMakeLists.txt +++ b/unittests/mocks/cfdp/CMakeLists.txt @@ -1 +1,2 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE FaultHandlerMock.cpp UserMock.cpp RemoteConfigTableMock.cpp) +target_sources(${FSFW_TEST_TGT} PRIVATE FaultHandlerMock.cpp UserMock.cpp + RemoteConfigTableMock.cpp) diff --git a/unittests/mocks/cfdp/RemoteConfigTableMock.h b/unittests/mocks/cfdp/RemoteConfigTableMock.h index 7ac25ba7..e3e954e4 100644 --- a/unittests/mocks/cfdp/RemoteConfigTableMock.h +++ b/unittests/mocks/cfdp/RemoteConfigTableMock.h @@ -5,11 +5,11 @@ namespace cfdp { -class RemoteConfigTableMock: public RemoteConfigTableIF { +class RemoteConfigTableMock : public RemoteConfigTableIF { public: bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg *cfg) override; }; -} +} // namespace cfdp #endif // FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mocks/cfdp/UserMock.cpp index c8b3b940..8037b21f 100644 --- a/unittests/mocks/cfdp/UserMock.cpp +++ b/unittests/mocks/cfdp/UserMock.cpp @@ -7,10 +7,9 @@ void cfdp::UserMock::eofSentIndication(cfdp::TransactionId id) {} void cfdp::UserMock::abandonedIndication(cfdp::TransactionId id, cfdp::ConditionCode code, uint64_t progress) {} void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {} -void cfdp::UserMock::transactionFinishedIndication() {} -void cfdp::UserMock::metadataRecvdIndication() {} +void cfdp::UserMock::transactionFinishedIndication(TransactionFinishedParams finishedParams) {} +void cfdp::UserMock::metadataRecvdIndication(MetadataRecvParams params) {} void cfdp::UserMock::fileSegmentRecvdIndication() {} void cfdp::UserMock::reportIndication() {} void cfdp::UserMock::suspendedIndication() {} void cfdp::UserMock::resumedIndication() {} - diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mocks/cfdp/UserMock.h index b32e698a..9a67073d 100644 --- a/unittests/mocks/cfdp/UserMock.h +++ b/unittests/mocks/cfdp/UserMock.h @@ -2,24 +2,24 @@ #define FSFW_TESTS_CFDP_USERMOCK_H #include "fsfw/cfdp/handler/UserBase.h" - namespace cfdp { -class UserMock: public UserBase { +class UserMock : public UserBase { explicit UserMock(HasFileSystemIF& vfs); + public: void transactionIndication(TransactionId id) override; void eofSentIndication(TransactionId id) override; void abandonedIndication(TransactionId id, ConditionCode code, uint64_t progress) override; void eofRecvIndication(TransactionId id) override; - void transactionFinishedIndication() override; - void metadataRecvdIndication() override; + void transactionFinishedIndication(TransactionFinishedParams params) override; + void metadataRecvdIndication(MetadataRecvParams params) override; void fileSegmentRecvdIndication() override; void reportIndication() override; void suspendedIndication() override; void resumedIndication() override; }; -} +} // namespace cfdp #endif // FSFW_TESTS_CFDP_USERMOCK_H From 96dfe46e2552e069e29fed0b9d5483aa43f6355b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 10 Aug 2022 09:39:57 +0200 Subject: [PATCH 214/532] added string LV tests --- src/fsfw/cfdp.h | 3 + src/fsfw/cfdp/handler/UserBase.cpp | 12 + src/fsfw/cfdp/handler/UserBase.h | 6 +- src/fsfw/cfdp/tlv/CMakeLists.txt | 1 + src/fsfw/cfdp/tlv/Lv.cpp | 11 +- src/fsfw/cfdp/tlv/Lv.h | 12 +- src/fsfw/cfdp/tlv/MessageToUserTlv.cpp | 5 +- src/fsfw/cfdp/tlv/MessageToUserTlv.h | 3 + src/fsfw/cfdp/tlv/StringLv.cpp | 7 + src/fsfw/cfdp/tlv/StringLv.h | 18 ++ src/fsfw/serialize/SerialBufferAdapter.cpp | 27 +- src/fsfw/serialize/SerialBufferAdapter.h | 18 +- unittests/cfdp/CMakeLists.txt | 3 +- unittests/cfdp/handler/testDestHandler.cpp | 1 + unittests/cfdp/handler/testDistributor.cpp | 5 +- unittests/cfdp/testLvs.cpp | 105 +++++++ unittests/cfdp/testOtherTlvs.cpp | 137 +++++++++ unittests/cfdp/testTlv.cpp | 130 ++++++++ unittests/cfdp/testTlvsLvs.cpp | 330 --------------------- unittests/mocks/cfdp/UserMock.cpp | 2 +- unittests/mocks/cfdp/UserMock.h | 2 +- 21 files changed, 466 insertions(+), 372 deletions(-) create mode 100644 src/fsfw/cfdp/tlv/StringLv.cpp create mode 100644 src/fsfw/cfdp/tlv/StringLv.h create mode 100644 unittests/cfdp/testLvs.cpp create mode 100644 unittests/cfdp/testOtherTlvs.cpp create mode 100644 unittests/cfdp/testTlv.cpp delete mode 100644 unittests/cfdp/testTlvsLvs.cpp diff --git a/src/fsfw/cfdp.h b/src/fsfw/cfdp.h index 421a7fe1..28ddfec2 100644 --- a/src/fsfw/cfdp.h +++ b/src/fsfw/cfdp.h @@ -4,5 +4,8 @@ #include "cfdp/definitions.h" #include "cfdp/handler/DestHandler.h" #include "cfdp/handler/FaultHandlerBase.h" +#include "cfdp/tlv/Lv.h" +#include "cfdp/tlv/StringLv.h" +#include "cfdp/tlv/Tlv.h" #endif // FSFW_CFDP_H diff --git a/src/fsfw/cfdp/handler/UserBase.cpp b/src/fsfw/cfdp/handler/UserBase.cpp index 212396fb..1cb726fe 100644 --- a/src/fsfw/cfdp/handler/UserBase.cpp +++ b/src/fsfw/cfdp/handler/UserBase.cpp @@ -1,3 +1,15 @@ #include "UserBase.h" +#include +#include +void cfdp::testFunc() { + std::vector testVec; + testVec.reserve(10); + std::array customMsg = {1, 2, 3, 4}; + MessageToUserTlv tlv0(customMsg.data(), customMsg.size()); + std::cout << testVec.size() << std::endl; + testVec[0] = &tlv0; + FilestoreResponseTlv tlv1(); +} + cfdp::UserBase::UserBase(HasFileSystemIF& vfs) : vfs(vfs) {} diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index 6835600c..333c7b6b 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -3,6 +3,7 @@ #include #include +#include #include "StatusReportIF.h" #include "fsfw/cfdp/VarLenFields.h" @@ -12,6 +13,8 @@ namespace cfdp { +void testFunc(); + struct TransactionFinishedParams { TransactionFinishedParams(TransactionId id, ConditionCode code, FileDeliveryStatus status, FileDeliveryCode delivCode) @@ -31,7 +34,8 @@ struct MetadataRecvParams { size_t fileSize; const char* sourceFileName; const char* destFileName; - std::pair msgsToUser; + std::vector msgsToUser; + // std::pair msgsToUser; }; struct FileSegmentRecvdParams { diff --git a/src/fsfw/cfdp/tlv/CMakeLists.txt b/src/fsfw/cfdp/tlv/CMakeLists.txt index cdf7b44a..617b1b0f 100644 --- a/src/fsfw/cfdp/tlv/CMakeLists.txt +++ b/src/fsfw/cfdp/tlv/CMakeLists.txt @@ -5,6 +5,7 @@ target_sources( FilestoreResponseTlv.cpp Lv.cpp Tlv.cpp + StringLv.cpp FlowLabelTlv.cpp MessageToUserTlv.cpp FaultHandlerOverrideTlv.cpp) diff --git a/src/fsfw/cfdp/tlv/Lv.cpp b/src/fsfw/cfdp/tlv/Lv.cpp index 09075094..1f7ecefd 100644 --- a/src/fsfw/cfdp/tlv/Lv.cpp +++ b/src/fsfw/cfdp/tlv/Lv.cpp @@ -6,9 +6,8 @@ cfdp::Lv::Lv(const uint8_t* value, size_t size) : value(value, size, true) { } } -cfdp::Lv::Lv(const char* value, size_t size) - : value(reinterpret_cast(value), size, true) { - if (size > 0) { +cfdp::Lv::Lv(const std::vector& data) : value(data.data(), data.size(), true) { + if (!data.empty()) { zeroLen = false; } } @@ -24,11 +23,11 @@ cfdp::Lv::Lv(const Lv& other) cfdp::Lv& cfdp::Lv::operator=(const Lv& other) { size_t otherSize = 0; - uint8_t* value = const_cast(other.getValue(&otherSize)); - if (value == nullptr or otherSize == 0) { + auto* otherVal = const_cast(other.getValue(&otherSize)); + if (otherVal == nullptr or otherSize == 0) { this->zeroLen = true; } - this->value.setBuffer(value, otherSize); + this->value.setBuffer(otherVal, otherSize); return *this; } diff --git a/src/fsfw/cfdp/tlv/Lv.h b/src/fsfw/cfdp/tlv/Lv.h index 4a110f90..efabfdef 100644 --- a/src/fsfw/cfdp/tlv/Lv.h +++ b/src/fsfw/cfdp/tlv/Lv.h @@ -1,5 +1,7 @@ -#ifndef FSFW_SRC_FSFW_CFDP_LV_H_ -#define FSFW_SRC_FSFW_CFDP_LV_H_ +#ifndef FSFW_CFDP_LV_H_ +#define FSFW_CFDP_LV_H_ + +#include #include "fsfw/serialize/SerialBufferAdapter.h" @@ -12,12 +14,10 @@ namespace cfdp { */ class Lv : public SerializeIF { public: + explicit Lv(const std::vector& data); Lv(const uint8_t* value, size_t size); - Lv(const char* value, size_t size); Lv(); - // Delete copy ctor and assingment ctor for now because this class contains a reference to - // data Lv(const Lv&); Lv& operator=(const Lv&); @@ -51,4 +51,4 @@ class Lv : public SerializeIF { } // namespace cfdp -#endif /* FSFW_SRC_FSFW_CFDP_LV_H_ */ +#endif /* FSFW_CFDP_LV_H_ */ diff --git a/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp b/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp index 9034552b..c6bf3633 100644 --- a/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp +++ b/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp @@ -1,6 +1,9 @@ #include "MessageToUserTlv.h" -MessageToUserTlv::MessageToUserTlv(uint8_t *value, size_t size) +MessageToUserTlv::MessageToUserTlv(uint8_t* value, size_t size) : Tlv(cfdp::TlvTypes::MSG_TO_USER, value, size) {} MessageToUserTlv::MessageToUserTlv() : Tlv() {} + +MessageToUserTlv::MessageToUserTlv(const std::vector& data) + : Tlv(cfdp::TlvTypes::MSG_TO_USER, data.data(), data.size()) {} diff --git a/src/fsfw/cfdp/tlv/MessageToUserTlv.h b/src/fsfw/cfdp/tlv/MessageToUserTlv.h index 1d00bf31..e7f63ed2 100644 --- a/src/fsfw/cfdp/tlv/MessageToUserTlv.h +++ b/src/fsfw/cfdp/tlv/MessageToUserTlv.h @@ -1,12 +1,15 @@ #ifndef FSFW_SRC_FSFW_CFDP_TLV_MESSAGETOUSERTLV_H_ #define FSFW_SRC_FSFW_CFDP_TLV_MESSAGETOUSERTLV_H_ +#include + #include "Tlv.h" class MessageToUserTlv : public cfdp::Tlv { public: MessageToUserTlv(); MessageToUserTlv(uint8_t* value, size_t size); + explicit MessageToUserTlv(const std::vector& data); private: }; diff --git a/src/fsfw/cfdp/tlv/StringLv.cpp b/src/fsfw/cfdp/tlv/StringLv.cpp new file mode 100644 index 00000000..abbdb34a --- /dev/null +++ b/src/fsfw/cfdp/tlv/StringLv.cpp @@ -0,0 +1,7 @@ +#include "StringLv.h" + +cfdp::StringLv::StringLv(const std::string& fileName) + : Lv(reinterpret_cast(fileName.data()), fileName.size()) {} + +cfdp::StringLv::StringLv(const char* filename, size_t len) + : Lv(reinterpret_cast(filename), len) {} diff --git a/src/fsfw/cfdp/tlv/StringLv.h b/src/fsfw/cfdp/tlv/StringLv.h new file mode 100644 index 00000000..86c2d738 --- /dev/null +++ b/src/fsfw/cfdp/tlv/StringLv.h @@ -0,0 +1,18 @@ +#ifndef FSFW_CFDP_STRINGLV_H +#define FSFW_CFDP_STRINGLV_H + +#include + +#include "Lv.h" + +namespace cfdp { + +class StringLv : public Lv { + public: + explicit StringLv(const std::string& fileName); + explicit StringLv(const char* filename, size_t len); +}; + +} // namespace cfdp + +#endif // FSFW_CFDP_STRINGLV_H diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 83129982..86e20e25 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -21,15 +21,15 @@ 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, +ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer_, size_t* size, size_t maxSize, Endianness streamEndianness) const { if (serializeLength) { ReturnValue_t result = - SerializeAdapter::serialize(&bufferLength, buffer, size, maxSize, streamEndianness); + SerializeAdapter::serialize(&bufferLength, buffer_, size, maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -40,16 +40,16 @@ ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, size_t* } if (this->constBuffer != nullptr) { - std::memcpy(*buffer, this->constBuffer, bufferLength); + std::memcpy(*buffer_, this->constBuffer, bufferLength); } else if (this->buffer != nullptr) { // This will propably be never reached, constBuffer should always be // set if non-const buffer is set. - std::memcpy(*buffer, this->buffer, bufferLength); + std::memcpy(*buffer_, this->buffer, bufferLength); } else { return HasReturnvaluesIF::RETURN_FAILED; } *size += bufferLength; - (*buffer) += bufferLength; + (*buffer_) += bufferLength; return HasReturnvaluesIF::RETURN_OK; } @@ -63,7 +63,7 @@ size_t SerialBufferAdapter::getSerializedSize() const { } template -ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, size_t* size, +ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer_, size_t* size, Endianness streamEndianness) { if (this->buffer == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; @@ -72,7 +72,7 @@ ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, if (serializeLength) { count_t lengthField = 0; ReturnValue_t result = - SerializeAdapter::deSerialize(&lengthField, buffer, size, streamEndianness); + SerializeAdapter::deSerialize(&lengthField, buffer_, size, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -84,8 +84,8 @@ ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, if (bufferLength <= *size) { *size -= bufferLength; - std::memcpy(this->buffer, *buffer, bufferLength); - (*buffer) += bufferLength; + std::memcpy(this->buffer, *buffer_, bufferLength); + (*buffer_) += bufferLength; return HasReturnvaluesIF::RETURN_OK; } else { return STREAM_TOO_SHORT; @@ -119,10 +119,9 @@ 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::setBuffer(const uint8_t* data, count_t len) { + this->constBuffer = data; + this->bufferLength = len; } // forward Template declaration for linker diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index 3b95fa20..7859135a 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.h +++ b/src/fsfw/serialize/SerialBufferAdapter.h @@ -40,12 +40,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. @@ -53,18 +53,18 @@ class SerialBufferAdapter : public SerializeIF { * If a length field is present, it is ignored, as the size should have * been set in the constructor. If the size is not known beforehand, * consider using SerialFixedArrayListAdapter instead. - * @param buffer [out] Resulting buffer + * @param buffer_ [out] Resulting buffer * @param size remaining size to deserialize, should be larger than buffer * + size field size * @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 setBuffer(const uint8_t* buffer, count_t bufferLength); private: bool serializeLength = false; diff --git a/unittests/cfdp/CMakeLists.txt b/unittests/cfdp/CMakeLists.txt index 402381f4..1867a534 100644 --- a/unittests/cfdp/CMakeLists.txt +++ b/unittests/cfdp/CMakeLists.txt @@ -1,4 +1,5 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE testCfdp.cpp testTlvsLvs.cpp) +target_sources(${FSFW_TEST_TGT} PRIVATE testCfdp.cpp testOtherTlvs.cpp + testTlv.cpp testLvs.cpp) add_subdirectory(handler) add_subdirectory(pdu) diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index d963b6c7..7d641a38 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -9,6 +9,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { auto fhMock = FaultHandlerMock(); auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock); // auto destHandler = DestHandler(); + cfdp::testFunc(); SECTION("State") {} } \ No newline at end of file diff --git a/unittests/cfdp/handler/testDistributor.cpp b/unittests/cfdp/handler/testDistributor.cpp index 2e94a55e..161e21cc 100644 --- a/unittests/cfdp/handler/testDistributor.cpp +++ b/unittests/cfdp/handler/testDistributor.cpp @@ -2,6 +2,7 @@ #include "fsfw/cfdp/CfdpDistributor.h" #include "fsfw/cfdp/pdu/MetadataPduCreator.h" +#include "fsfw/cfdp/tlv/StringLv.h" #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tcdistribution/definitions.h" #include "mocks/AcceptsTcMock.h" @@ -26,9 +27,9 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { cfdp::TransactionSeqNum seqNum(UnsignedByteField(12)); auto pduConf = PduConfig(sourceId, destId, cfdp::TransmissionModes::UNACKNOWLEDGED, seqNum); std::string sourceFileString = "hello.txt"; - cfdp::Lv sourceFileName(sourceFileString.c_str(), sourceFileString.size()); + cfdp::StringLv sourceFileName(sourceFileString); std::string destFileString = "hello2.txt"; - cfdp::Lv destFileName(destFileString.c_str(), sourceFileString.size()); + cfdp::StringLv destFileName(destFileString); MetadataInfo metadataInfo(false, cfdp::ChecksumType::CRC_32, fileSize, sourceFileName, destFileName); MetadataPduCreator creator(pduConf, metadataInfo); diff --git a/unittests/cfdp/testLvs.cpp b/unittests/cfdp/testLvs.cpp new file mode 100644 index 00000000..b93458ed --- /dev/null +++ b/unittests/cfdp/testLvs.cpp @@ -0,0 +1,105 @@ +#include +#include + +#include "fsfw/cfdp.h" + +TEST_CASE("CFDP TLV", "[cfdp][lv]") { + using namespace cfdp; + ReturnValue_t result; + std::array rawBuf{}; + uint8_t* serPtr = rawBuf.data(); + const uint8_t* deserPtr = rawBuf.data(); + size_t deserSize = 0; + cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::TWO_BYTES, 0x0ff0); + + SECTION("LV Serialization") { + std::array lvRawBuf{}; + serPtr = lvRawBuf.data(); + REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), + SerializeIF::Endianness::NETWORK) == result::OK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(deserSize == 2); + + auto lv = cfdp::Lv(lvRawBuf.data(), 2); + REQUIRE(lv.getSerializedSize() == 3); + + SECTION("Copy") { + auto lvCopy = cfdp::Lv(lv); + REQUIRE(lvCopy.getSerializedSize() == 3); + REQUIRE(lv.getValue(nullptr) == lvCopy.getValue(nullptr)); + } + + serPtr = rawBuf.data(); + deserSize = 0; + REQUIRE(lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == + result::OK); + REQUIRE(deserSize == 3); + REQUIRE(rawBuf[0] == 2); + uint16_t sourceIdRaw = 0; + REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, rawBuf.data() + 1, &deserSize, + SerializeIF::Endianness::BIG) == result::OK); + REQUIRE(sourceIdRaw == 0x0ff0); + } + + SECTION("Empty Serialization") { + auto lvEmpty = Lv(); + REQUIRE(lvEmpty.getSerializedSize() == 1); + serPtr = rawBuf.data(); + deserSize = 0; + result = + lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(deserSize == 1); + deserPtr = rawBuf.data(); + result = lvEmpty.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(lvEmpty.getSerializedSize() == 1); + } + + SECTION("Uninit LV") { + std::array lvRawBuf{}; + serPtr = lvRawBuf.data(); + REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), + SerializeIF::Endianness::NETWORK) == result::OK); + auto lv = cfdp::Lv(lvRawBuf.data(), 2); + serPtr = rawBuf.data(); + deserSize = 0; + result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + Lv uninitLv; + deserPtr = rawBuf.data(); + deserSize = 3; + result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(uninitLv.getSerializedSize() == 3); + const uint8_t* storedValue = uninitLv.getValue(nullptr); + uint16_t sourceIdRaw = 0; + REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, storedValue, &deserSize, + SerializeIF::Endianness::BIG) == result::OK); + REQUIRE(sourceIdRaw == 0x0ff0); + } + + SECTION("Invalid Input") { + Lv uninitLv; + REQUIRE(uninitLv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::BIG) == + HasReturnvaluesIF::RETURN_FAILED); + serPtr = rawBuf.data(); + deserSize = 0; + REQUIRE(uninitLv.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::BIG) == + SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(uninitLv.serialize(nullptr, nullptr, 12, SerializeIF::Endianness::BIG)); + deserSize = 0; + REQUIRE(uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG) == + SerializeIF::STREAM_TOO_SHORT); + } + + SECTION("String LV") { + std::string filename = "hello.txt"; + StringLv sourceFileName(filename); + REQUIRE(sourceFileName.getSerializedSize() == 1 + filename.size()); + REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == result::OK); + REQUIRE(rawBuf[0] == filename.size()); + std::string filenameFromRaw(reinterpret_cast(rawBuf.data() + 1), filename.size()); + REQUIRE(filenameFromRaw == filename); + } +} diff --git a/unittests/cfdp/testOtherTlvs.cpp b/unittests/cfdp/testOtherTlvs.cpp new file mode 100644 index 00000000..3551fcdf --- /dev/null +++ b/unittests/cfdp/testOtherTlvs.cpp @@ -0,0 +1,137 @@ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "fsfw/cfdp/pdu/PduConfig.h" +#include "fsfw/cfdp/tlv/Lv.h" +#include "fsfw/cfdp/tlv/Tlv.h" +#include "fsfw/globalfunctions/arrayprinter.h" + +TEST_CASE("CFDP LV", "[cfdp][lv]") { + using namespace cfdp; + ReturnValue_t result; + std::array rawBuf{}; + uint8_t* serPtr = rawBuf.data(); + const uint8_t* deserPtr = rawBuf.data(); + size_t deserSize = 0; + cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::TWO_BYTES, 0x0ff0); + + SECTION("Filestore Response TLV") { + std::string name = "hello.txt"; + cfdp::Lv firstName(reinterpret_cast(name.data()), name.size()); + std::string name2 = "hello2.txt"; + cfdp::Lv secondName(reinterpret_cast(name2.data()), name2.size()); + std::string msg = "12345"; + cfdp::Lv fsMsg(reinterpret_cast(msg.data()), msg.size()); + FilestoreResponseTlv response(cfdp::FilestoreActionCode::APPEND_FILE, cfdp::FSR_SUCCESS, + firstName, &fsMsg); + response.setSecondFileName(&secondName); + REQUIRE(response.getLengthField() == 10 + 11 + 6 + 1); + REQUIRE(response.getSerializedSize() == response.getLengthField() + 2); + + cfdp::Tlv rawResponse; + std::array serBuf = {}; + result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(), + SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); + cfdp::Lv emptyMsg; + cfdp::Lv emptySecondName; + FilestoreResponseTlv emptyTlv(firstName, &emptyMsg); + emptyTlv.setSecondFileName(&emptySecondName); + result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(emptyTlv.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); + REQUIRE(emptyTlv.getStatusCode() == cfdp::FSR_SUCCESS); + size_t firstNameLen = 0; + const char* firstNamePtr = + reinterpret_cast(emptyTlv.getFirstFileName().getValue(&firstNameLen)); + auto helloString = std::string(firstNamePtr, firstNameLen); + REQUIRE(helloString == "hello.txt"); + } + + SECTION("Filestore Request TLV") { + std::string name = "hello.txt"; + cfdp::Lv firstName(reinterpret_cast(name.data()), name.size()); + std::string name2 = "hello2.txt"; + cfdp::Lv secondName(reinterpret_cast(name2.data()), name2.size()); + FilestoreRequestTlv request(cfdp::FilestoreActionCode::APPEND_FILE, firstName); + + // second name not set yet + REQUIRE(request.getLengthField() == 10 + 1); + REQUIRE(request.getSerializedSize() == request.getLengthField() + 2); + + std::array serBuf = {}; + uint8_t* ptr = serBuf.data(); + size_t sz = 0; + result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK); + REQUIRE(result == cfdp::FILESTORE_REQUIRES_SECOND_FILE); + + ptr = serBuf.data(); + sz = 0; + request.setSecondFileName(&secondName); + size_t expectedSz = request.getLengthField(); + REQUIRE(expectedSz == 10 + 11 + 1); + REQUIRE(request.getSerializedSize() == expectedSz + 2); + result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(sz == expectedSz + 2); + + FilestoreRequestTlv emptyRequest(firstName); + emptyRequest.setSecondFileName(&secondName); + const uint8_t* constptr = serBuf.data(); + result = emptyRequest.deSerialize(&constptr, &sz, SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + + cfdp::Tlv rawRequest; + ptr = serBuf.data(); + sz = 0; + result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(), + SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); + + emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE); + result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); + REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); + } + + SECTION("Other") { + MessageToUserTlv emptyTlv; + uint8_t flowLabel = 1; + FlowLabelTlv flowLabelTlv(&flowLabel, 1); + + FaultHandlerOverrideTlv faultOverrideTlv(cfdp::ConditionCode::FILESTORE_REJECTION, + cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION); + size_t sz = 0; + result = + faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); + REQUIRE(faultOverrideTlv.getSerializedSize() == 3); + REQUIRE(sz == 3); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + + FaultHandlerOverrideTlv emptyOverrideTlv; + result = emptyOverrideTlv.deSerialize(&deserPtr, &sz, SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + + EntityId entId(cfdp::WidthInBytes::TWO_BYTES, 0x42); + EntityId emptyId; + EntityIdTlv idTlv(emptyId); + serPtr = rawBuf.data(); + result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); + cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + deserPtr = rawBuf.data(); + result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + } +} diff --git a/unittests/cfdp/testTlv.cpp b/unittests/cfdp/testTlv.cpp new file mode 100644 index 00000000..5b6e0a63 --- /dev/null +++ b/unittests/cfdp/testTlv.cpp @@ -0,0 +1,130 @@ +#include +#include + +#include "fsfw/cfdp.h" + +TEST_CASE("CFDP TLV", "[cfdp][tlv]") { + using namespace cfdp; + ReturnValue_t result; + std::array rawBuf{}; + uint8_t* serPtr = rawBuf.data(); + const uint8_t* deserPtr = rawBuf.data(); + size_t deserSize = 0; + cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::TWO_BYTES, 0x0ff0); + + SECTION("Entity ID Serialization") { + REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(), + SerializeIF::Endianness::NETWORK) == result::OK); + REQUIRE(deserSize == 2); + } + + SECTION("TLV Serialization") { + std::array tlvBuf{}; + REQUIRE(sourceId.serializeBe(tlvBuf.data(), deserSize, tlvBuf.size()) == result::OK); + auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvBuf.data(), deserSize); + REQUIRE(tlv.getSerializedSize() == 4); + REQUIRE(tlv.getLengthField() == 2); + deserSize = 0; + REQUIRE(tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == + result::OK); + REQUIRE(deserSize == 4); + REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); + REQUIRE(rawBuf[1] == 2); + uint16_t entityId = 0; + REQUIRE(SerializeAdapter::deSerialize(&entityId, rawBuf.data() + 2, &deserSize, + SerializeIF::Endianness::NETWORK) == result::OK); + REQUIRE(entityId == 0x0ff0); + } + + SECTION("TLV Other Value") { + auto tlv = Tlv(TlvTypes::ENTITY_ID, rawBuf.data(), deserSize); + // Set new value + sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 12); + REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(), + SerializeIF::Endianness::NETWORK) == result::OK); + tlv.setValue(rawBuf.data(), cfdp::WidthInBytes::FOUR_BYTES); + serPtr = rawBuf.data(); + deserSize = 0; + result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); + REQUIRE(rawBuf[1] == 4); + + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + } + + SECTION("TLV Invalid") { + auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, rawBuf.data(), 0); + REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), + SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); + tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3); + REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), + SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); + REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) != + HasReturnvaluesIF::RETURN_OK); + REQUIRE(tlvInvalid.getSerializedSize() == 0); + REQUIRE(tlvInvalid.serialize(nullptr, nullptr, 0, SerializeIF::Endianness::NETWORK) != + HasReturnvaluesIF::RETURN_OK); + } + + SECTION("TLV Zero Length Field") { + Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); + REQUIRE(zeroLenField.getSerializedSize() == 2); + serPtr = rawBuf.data(); + deserSize = 0; + REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), + SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); + REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER); + REQUIRE(rawBuf[1] == 0); + } + + SECTION("TLV Deserialization") { + // Serialization was tested before, generate raw data now + std::array tlvRawBuf{}; + serPtr = tlvRawBuf.data(); + result = + sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK); + auto tlvSerialization = Tlv(TlvTypes::ENTITY_ID, tlvRawBuf.data(), deserSize); + serPtr = rawBuf.data(); + deserSize = 0; + result = tlvSerialization.serialize(&serPtr, &deserSize, rawBuf.size(), + SerializeIF::Endianness::NETWORK); + Tlv tlv; + deserPtr = rawBuf.data(); + result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(tlv.getSerializedSize() == 4); + REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID); + deserPtr = tlv.getValue(); + uint16_t entityId = 0; + deserSize = 0; + SerializeAdapter::deSerialize(&entityId, deserPtr, &deserSize, + SerializeIF::Endianness::NETWORK); + REQUIRE(entityId == 0x0ff0); + + REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != + HasReturnvaluesIF::RETURN_OK); + deserPtr = rawBuf.data(); + deserSize = 0; + REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) == + SerializeIF::STREAM_TOO_SHORT); + // Set invalid TLV + rawBuf[0] = TlvTypes::INVALID_TLV; + deserSize = 4; + REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) != + HasReturnvaluesIF::RETURN_OK); + + Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); + serPtr = rawBuf.data(); + deserSize = 0; + REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), + SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); + deserPtr = rawBuf.data(); + result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); + REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(zeroLenField.getSerializedSize() == 2); + REQUIRE(deserSize == 0); + } +} diff --git a/unittests/cfdp/testTlvsLvs.cpp b/unittests/cfdp/testTlvsLvs.cpp deleted file mode 100644 index 7536069f..00000000 --- a/unittests/cfdp/testTlvsLvs.cpp +++ /dev/null @@ -1,330 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "fsfw/cfdp/pdu/PduConfig.h" -#include "fsfw/cfdp/tlv/Lv.h" -#include "fsfw/cfdp/tlv/Tlv.h" -#include "fsfw/globalfunctions/arrayprinter.h" - -TEST_CASE("CFDP TLV LV", "[cfdp]") { - using namespace cfdp; - ReturnValue_t result; - std::array rawBuf{}; - uint8_t* serPtr = rawBuf.data(); - const uint8_t* deserPtr = rawBuf.data(); - size_t deserSize = 0; - cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::TWO_BYTES, 0x0ff0); - - SECTION("TLV Serialization") { - std::array tlvRawBuf{}; - serPtr = tlvRawBuf.data(); - result = - sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(deserSize == 2); - auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvRawBuf.data(), deserSize); - REQUIRE(tlv.getSerializedSize() == 4); - REQUIRE(tlv.getLengthField() == 2); - serPtr = rawBuf.data(); - deserSize = 0; - result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(deserSize == 4); - REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); - REQUIRE(rawBuf[1] == 2); - uint16_t entityId = 0; - SerializeAdapter::deSerialize(&entityId, rawBuf.data() + 2, &deserSize, - SerializeIF::Endianness::NETWORK); - REQUIRE(entityId == 0x0ff0); - - // Set new value - sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 12); - serPtr = tlvRawBuf.data(); - deserSize = 0; - result = - sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK); - tlv.setValue(tlvRawBuf.data(), cfdp::WidthInBytes::FOUR_BYTES); - serPtr = rawBuf.data(); - deserSize = 0; - result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); - REQUIRE(rawBuf[1] == 4); - - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - - serPtr = rawBuf.data(); - deserSize = 0; - auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, tlvRawBuf.data(), 0); - REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); - tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3); - REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); - REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); - REQUIRE(tlvInvalid.getSerializedSize() == 0); - REQUIRE(tlvInvalid.serialize(nullptr, nullptr, 0, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); - - Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); - REQUIRE(zeroLenField.getSerializedSize() == 2); - serPtr = rawBuf.data(); - deserSize = 0; - REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); - REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER); - REQUIRE(rawBuf[1] == 0); - } - - SECTION("TLV Deserialization") { - // Serialization was tested before, generate raw data now - std::array tlvRawBuf{}; - serPtr = tlvRawBuf.data(); - result = - sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK); - auto tlvSerialization = Tlv(TlvTypes::ENTITY_ID, tlvRawBuf.data(), deserSize); - serPtr = rawBuf.data(); - deserSize = 0; - result = tlvSerialization.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK); - Tlv tlv; - deserPtr = rawBuf.data(); - result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(tlv.getSerializedSize() == 4); - REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID); - deserPtr = tlv.getValue(); - uint16_t entityId = 0; - deserSize = 0; - SerializeAdapter::deSerialize(&entityId, deserPtr, &deserSize, - SerializeIF::Endianness::NETWORK); - REQUIRE(entityId == 0x0ff0); - - REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); - deserPtr = rawBuf.data(); - deserSize = 0; - REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) == - SerializeIF::STREAM_TOO_SHORT); - // Set invalid TLV - rawBuf[0] = TlvTypes::INVALID_TLV; - deserSize = 4; - REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); - - Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); - serPtr = rawBuf.data(); - deserSize = 0; - REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); - deserPtr = rawBuf.data(); - result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(zeroLenField.getSerializedSize() == 2); - REQUIRE(deserSize == 0); - } - - SECTION("LV Serialization") { - std::array lvRawBuf{}; - serPtr = lvRawBuf.data(); - result = - sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(deserSize == 2); - auto lv = cfdp::Lv(lvRawBuf.data(), 2); - auto lvCopy = cfdp::Lv(lv); - REQUIRE(lv.getSerializedSize() == 3); - REQUIRE(lvCopy.getSerializedSize() == 3); - REQUIRE(lv.getValue(nullptr) == lvCopy.getValue(nullptr)); - serPtr = rawBuf.data(); - deserSize = 0; - result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(deserSize == 3); - REQUIRE(rawBuf[0] == 2); - uint16_t sourceIdRaw = 0; - result = SerializeAdapter::deSerialize(&sourceIdRaw, rawBuf.data() + 1, &deserSize, - SerializeIF::Endianness::BIG); - REQUIRE(sourceIdRaw == 0x0ff0); - - auto lvEmpty = Lv(); - REQUIRE(lvEmpty.getSerializedSize() == 1); - serPtr = rawBuf.data(); - deserSize = 0; - result = - lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(deserSize == 1); - } - - SECTION("LV Deserialization") { - std::array lvRawBuf{}; - serPtr = lvRawBuf.data(); - result = - sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), SerializeIF::Endianness::NETWORK); - auto lv = cfdp::Lv(lvRawBuf.data(), 2); - serPtr = rawBuf.data(); - deserSize = 0; - result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - - Lv uninitLv; - deserPtr = rawBuf.data(); - deserSize = 3; - result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(uninitLv.getSerializedSize() == 3); - const uint8_t* storedValue = uninitLv.getValue(nullptr); - uint16_t sourceIdRaw = 0; - result = SerializeAdapter::deSerialize(&sourceIdRaw, storedValue, &deserSize, - SerializeIF::Endianness::BIG); - REQUIRE(sourceIdRaw == 0x0ff0); - - auto lvEmpty = Lv(); - REQUIRE(lvEmpty.getSerializedSize() == 1); - serPtr = rawBuf.data(); - deserSize = 0; - result = - lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(deserSize == 1); - deserPtr = rawBuf.data(); - result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(uninitLv.getSerializedSize() == 1); - - REQUIRE(uninitLv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_FAILED); - serPtr = rawBuf.data(); - deserSize = 0; - REQUIRE(uninitLv.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::BIG) == - SerializeIF::BUFFER_TOO_SHORT); - REQUIRE(uninitLv.serialize(nullptr, nullptr, 12, SerializeIF::Endianness::BIG)); - deserSize = 0; - REQUIRE(uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG) == - SerializeIF::STREAM_TOO_SHORT); - } - - SECTION("Filestore Response TLV") { - std::string name = "hello.txt"; - cfdp::Lv firstName(reinterpret_cast(name.data()), name.size()); - std::string name2 = "hello2.txt"; - cfdp::Lv secondName(reinterpret_cast(name2.data()), name2.size()); - std::string msg = "12345"; - cfdp::Lv fsMsg(reinterpret_cast(msg.data()), msg.size()); - FilestoreResponseTlv response(cfdp::FilestoreActionCode::APPEND_FILE, cfdp::FSR_SUCCESS, - firstName, &fsMsg); - response.setSecondFileName(&secondName); - REQUIRE(response.getLengthField() == 10 + 11 + 6 + 1); - REQUIRE(response.getSerializedSize() == response.getLengthField() + 2); - - cfdp::Tlv rawResponse; - std::array serBuf = {}; - result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(), - SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); - cfdp::Lv emptyMsg; - cfdp::Lv emptySecondName; - FilestoreResponseTlv emptyTlv(firstName, &emptyMsg); - emptyTlv.setSecondFileName(&emptySecondName); - result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(emptyTlv.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); - REQUIRE(emptyTlv.getStatusCode() == cfdp::FSR_SUCCESS); - size_t firstNameLen = 0; - const char* firstNamePtr = - reinterpret_cast(emptyTlv.getFirstFileName().getValue(&firstNameLen)); - auto helloString = std::string(firstNamePtr, firstNameLen); - REQUIRE(helloString == "hello.txt"); - } - - SECTION("Filestore Request TLV") { - std::string name = "hello.txt"; - cfdp::Lv firstName(reinterpret_cast(name.data()), name.size()); - std::string name2 = "hello2.txt"; - cfdp::Lv secondName(reinterpret_cast(name2.data()), name2.size()); - FilestoreRequestTlv request(cfdp::FilestoreActionCode::APPEND_FILE, firstName); - - // second name not set yet - REQUIRE(request.getLengthField() == 10 + 1); - REQUIRE(request.getSerializedSize() == request.getLengthField() + 2); - - std::array serBuf = {}; - uint8_t* ptr = serBuf.data(); - size_t sz = 0; - result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == cfdp::FILESTORE_REQUIRES_SECOND_FILE); - - ptr = serBuf.data(); - sz = 0; - request.setSecondFileName(&secondName); - size_t expectedSz = request.getLengthField(); - REQUIRE(expectedSz == 10 + 11 + 1); - REQUIRE(request.getSerializedSize() == expectedSz + 2); - result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(sz == expectedSz + 2); - - FilestoreRequestTlv emptyRequest(firstName); - emptyRequest.setSecondFileName(&secondName); - const uint8_t* constptr = serBuf.data(); - result = emptyRequest.deSerialize(&constptr, &sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - - cfdp::Tlv rawRequest; - ptr = serBuf.data(); - sz = 0; - result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(), - SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); - - emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE); - result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); - REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); - } - - SECTION("Other") { - MessageToUserTlv emptyTlv; - uint8_t flowLabel = 1; - FlowLabelTlv flowLabelTlv(&flowLabel, 1); - - FaultHandlerOverrideTlv faultOverrideTlv(cfdp::ConditionCode::FILESTORE_REJECTION, - cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION); - size_t sz = 0; - result = - faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(faultOverrideTlv.getSerializedSize() == 3); - REQUIRE(sz == 3); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - - FaultHandlerOverrideTlv emptyOverrideTlv; - result = emptyOverrideTlv.deSerialize(&deserPtr, &sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - - EntityId entId(cfdp::WidthInBytes::TWO_BYTES, 0x42); - EntityId emptyId; - EntityIdTlv idTlv(emptyId); - serPtr = rawBuf.data(); - result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - deserPtr = rawBuf.data(); - result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - } -} diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mocks/cfdp/UserMock.cpp index 8037b21f..a38ceefc 100644 --- a/unittests/mocks/cfdp/UserMock.cpp +++ b/unittests/mocks/cfdp/UserMock.cpp @@ -9,7 +9,7 @@ void cfdp::UserMock::abandonedIndication(cfdp::TransactionId id, cfdp::Condition void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {} void cfdp::UserMock::transactionFinishedIndication(TransactionFinishedParams finishedParams) {} void cfdp::UserMock::metadataRecvdIndication(MetadataRecvParams params) {} -void cfdp::UserMock::fileSegmentRecvdIndication() {} +void cfdp::UserMock::fileSegmentRecvdIndication(FileSegmentRecvdParams params) {} void cfdp::UserMock::reportIndication() {} void cfdp::UserMock::suspendedIndication() {} void cfdp::UserMock::resumedIndication() {} diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mocks/cfdp/UserMock.h index 9a67073d..bcdff3c9 100644 --- a/unittests/mocks/cfdp/UserMock.h +++ b/unittests/mocks/cfdp/UserMock.h @@ -14,7 +14,7 @@ class UserMock : public UserBase { void eofRecvIndication(TransactionId id) override; void transactionFinishedIndication(TransactionFinishedParams params) override; void metadataRecvdIndication(MetadataRecvParams params) override; - void fileSegmentRecvdIndication() override; + void fileSegmentRecvdIndication(FileSegmentRecvdParams params) override; void reportIndication() override; void suspendedIndication() override; void resumedIndication() override; From e45a99143cdaf58175e20f9bcc896c5d66295ee7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 10 Aug 2022 09:45:24 +0200 Subject: [PATCH 215/532] added const char* test --- unittests/cfdp/testLvs.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/unittests/cfdp/testLvs.cpp b/unittests/cfdp/testLvs.cpp index b93458ed..c3f19d9c 100644 --- a/unittests/cfdp/testLvs.cpp +++ b/unittests/cfdp/testLvs.cpp @@ -93,7 +93,7 @@ TEST_CASE("CFDP TLV", "[cfdp][lv]") { SerializeIF::STREAM_TOO_SHORT); } - SECTION("String LV") { + SECTION("String LV String") { std::string filename = "hello.txt"; StringLv sourceFileName(filename); REQUIRE(sourceFileName.getSerializedSize() == 1 + filename.size()); @@ -102,4 +102,15 @@ TEST_CASE("CFDP TLV", "[cfdp][lv]") { std::string filenameFromRaw(reinterpret_cast(rawBuf.data() + 1), filename.size()); REQUIRE(filenameFromRaw == filename); } + + SECTION("String LV Const Char") { + const char filename[] = "hello.txt"; + StringLv sourceFileName(filename, sizeof(filename) - 1); + REQUIRE(sourceFileName.getSerializedSize() == 1 + sizeof(filename) - 1); + REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == result::OK); + REQUIRE(rawBuf[0] == sizeof(filename) - 1); + rawBuf[deserSize] = '\0'; + const char* filenameFromRaw = reinterpret_cast(rawBuf.data() + 1); + REQUIRE(std::strcmp(filename, filenameFromRaw) == 0); + } } From 3e1fd15613a5311a5e98f40216be21ce0bb5f0d6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 10 Aug 2022 10:34:02 +0200 Subject: [PATCH 216/532] completed all indication parameters --- src/fsfw/cfdp/handler/UserBase.cpp | 9 --------- src/fsfw/cfdp/handler/UserBase.h | 23 +++++++++------------- src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp | 4 ++-- src/fsfw/cfdp/tlv/FilestoreRequestTlv.h | 8 ++++---- src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp | 12 +++++------ src/fsfw/cfdp/tlv/FilestoreResponseTlv.h | 15 +++++++------- src/fsfw/cfdp/tlv/FilestoreTlvBase.h | 17 ++++++++-------- src/fsfw/cfdp/tlv/StringLv.cpp | 2 ++ src/fsfw/cfdp/tlv/StringLv.h | 1 + unittests/cfdp/handler/testDestHandler.cpp | 2 -- unittests/cfdp/pdu/testFinishedPdu.cpp | 8 ++++---- unittests/cfdp/pdu/testMetadataPdu.cpp | 3 +-- unittests/cfdp/testOtherTlvs.cpp | 12 +++++------ unittests/mocks/cfdp/UserMock.cpp | 10 ++++++---- unittests/mocks/cfdp/UserMock.h | 11 ++++++----- 15 files changed, 64 insertions(+), 73 deletions(-) diff --git a/src/fsfw/cfdp/handler/UserBase.cpp b/src/fsfw/cfdp/handler/UserBase.cpp index 1cb726fe..9e757896 100644 --- a/src/fsfw/cfdp/handler/UserBase.cpp +++ b/src/fsfw/cfdp/handler/UserBase.cpp @@ -2,14 +2,5 @@ #include #include -void cfdp::testFunc() { - std::vector testVec; - testVec.reserve(10); - std::array customMsg = {1, 2, 3, 4}; - MessageToUserTlv tlv0(customMsg.data(), customMsg.size()); - std::cout << testVec.size() << std::endl; - testVec[0] = &tlv0; - FilestoreResponseTlv tlv1(); -} cfdp::UserBase::UserBase(HasFileSystemIF& vfs) : vfs(vfs) {} diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index 333c7b6b..34af89a5 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -13,8 +13,6 @@ namespace cfdp { -void testFunc(); - struct TransactionFinishedParams { TransactionFinishedParams(TransactionId id, ConditionCode code, FileDeliveryStatus status, FileDeliveryCode delivCode) @@ -24,18 +22,17 @@ struct TransactionFinishedParams { ConditionCode condCode; FileDeliveryStatus status; FileDeliveryCode deliveryCode; - std::pair fsResponses; + std::vector fsResponses; StatusReportIF* statusReport = nullptr; }; -struct MetadataRecvParams { +struct MetadataRecvdParams { TransactionId id; EntityId sourceId; size_t fileSize; const char* sourceFileName; const char* destFileName; std::vector msgsToUser; - // std::pair msgsToUser; }; struct FileSegmentRecvdParams { @@ -65,17 +62,15 @@ class UserBase { virtual void transactionIndication(TransactionId id) = 0; virtual void eofSentIndication(TransactionId id) = 0; - - virtual void abandonedIndication(TransactionId id, ConditionCode code, uint64_t progress) = 0; - virtual void eofRecvIndication(TransactionId id) = 0; - - // TODO: Parameters virtual void transactionFinishedIndication(TransactionFinishedParams params) = 0; - virtual void metadataRecvdIndication(MetadataRecvParams params) = 0; + virtual void metadataRecvdIndication(MetadataRecvdParams params) = 0; virtual void fileSegmentRecvdIndication(FileSegmentRecvdParams params) = 0; - virtual void reportIndication() = 0; - virtual void suspendedIndication() = 0; - virtual void resumedIndication() = 0; + virtual void reportIndication(TransactionId id, StatusReportIF& report) = 0; + virtual void suspendedIndication(TransactionId id, ConditionCode code) = 0; + virtual void resumedIndication(TransactionId id, size_t progress) = 0; + virtual void faultIndication(TransactionId id, ConditionCode code, size_t progress) = 0; + virtual void abandonedIndication(TransactionId id, ConditionCode code, size_t progress) = 0; + virtual void eofRecvIndication(TransactionId id) = 0; private: HasFileSystemIF& vfs; diff --git a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp index 9ad7c645..eb7a2cd2 100644 --- a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp +++ b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp @@ -3,10 +3,10 @@ #include "fsfw/FSFW.h" FilestoreRequestTlv::FilestoreRequestTlv(cfdp::FilestoreActionCode actionCode, - cfdp::Lv &firstFileName) + cfdp::StringLv &firstFileName) : FilestoreTlvBase(actionCode, firstFileName) {} -FilestoreRequestTlv::FilestoreRequestTlv(cfdp::Lv &firstFileName) +FilestoreRequestTlv::FilestoreRequestTlv(cfdp::StringLv &firstFileName) : FilestoreTlvBase(cfdp::FilestoreActionCode::INVALID, firstFileName) {} void FilestoreRequestTlv::setSecondFileName(cfdp::Lv *secondFileName) { diff --git a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h index 5acb0ef4..94faaa07 100644 --- a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h +++ b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h @@ -9,9 +9,9 @@ class FilestoreRequestTlv : public cfdp::FilestoreTlvBase { public: - FilestoreRequestTlv(cfdp::FilestoreActionCode actionCode, cfdp::Lv &firstFileName); + FilestoreRequestTlv(cfdp::FilestoreActionCode actionCode, cfdp::StringLv &firstFileName); - FilestoreRequestTlv(cfdp::Lv &firstFileName); + explicit FilestoreRequestTlv(cfdp::StringLv &firstFileName); void setSecondFileName(cfdp::Lv *secondFileName); @@ -29,8 +29,8 @@ class FilestoreRequestTlv : public cfdp::FilestoreTlvBase { ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; - uint8_t getLengthField() const override; - cfdp::TlvTypes getType() const override; + [[nodiscard]] uint8_t getLengthField() const override; + [[nodiscard]] cfdp::TlvTypes getType() const override; private: cfdp::Lv *secondFileName = nullptr; diff --git a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp index 36945725..c4c72702 100644 --- a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp +++ b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp @@ -1,10 +1,10 @@ #include "FilestoreResponseTlv.h" FilestoreResponseTlv::FilestoreResponseTlv(cfdp::FilestoreActionCode actionCode, uint8_t statusCode, - cfdp::Lv &firstFileName, cfdp::Lv *fsMsg) + cfdp::StringLv &firstFileName, cfdp::Lv *fsMsg) : FilestoreTlvBase(actionCode, firstFileName), statusCode(statusCode), filestoreMsg(fsMsg) {} -FilestoreResponseTlv::FilestoreResponseTlv(cfdp::Lv &firstFileName, cfdp::Lv *fsMsg) +FilestoreResponseTlv::FilestoreResponseTlv(cfdp::StringLv &firstFileName, cfdp::Lv *fsMsg) : FilestoreTlvBase(firstFileName), statusCode(0), filestoreMsg(fsMsg) {} uint8_t FilestoreResponseTlv::getLengthField() const { @@ -20,12 +20,12 @@ uint8_t FilestoreResponseTlv::getLengthField() const { return 1 + firstFileName.getSerializedSize() + optFieldsLen; } -void FilestoreResponseTlv::setSecondFileName(cfdp::Lv *secondFileName) { - this->secondFileName = secondFileName; +void FilestoreResponseTlv::setSecondFileName(cfdp::StringLv *secondFileName_) { + this->secondFileName = secondFileName_; } -void FilestoreResponseTlv::setFilestoreMessage(cfdp::Lv *filestoreMsg) { - this->filestoreMsg = filestoreMsg; +void FilestoreResponseTlv::setFilestoreMessage(cfdp::Lv *filestoreMsg_) { + this->filestoreMsg = filestoreMsg_; } ReturnValue_t FilestoreResponseTlv::serialize(uint8_t **buffer, size_t *size, size_t maxSize, diff --git a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h index 7b68ba57..47868693 100644 --- a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h +++ b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h @@ -4,17 +4,18 @@ #include "Lv.h" #include "TlvIF.h" #include "fsfw/cfdp/tlv/FilestoreTlvBase.h" +#include "fsfw/cfdp/tlv/StringLv.h" #include "fsfw/cfdp/tlv/Tlv.h" class FilestoreResponseTlv : public cfdp::FilestoreTlvBase { public: - FilestoreResponseTlv(cfdp::Lv& firstFileName, cfdp::Lv* fsMsg); + FilestoreResponseTlv(cfdp::StringLv& firstFileName, cfdp::Lv* fsMsg); FilestoreResponseTlv(cfdp::FilestoreActionCode actionCode, uint8_t statusCode, - cfdp::Lv& firstFileName, cfdp::Lv* fsMsg); + cfdp::StringLv& firstFileName, cfdp::Lv* fsMsg); - uint8_t getStatusCode() const; - void setSecondFileName(cfdp::Lv* secondFileName); + [[nodiscard]] uint8_t getStatusCode() const; + void setSecondFileName(cfdp::StringLv* secondFileName); void setFilestoreMessage(cfdp::Lv* filestoreMsg); ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, @@ -31,12 +32,12 @@ class FilestoreResponseTlv : public cfdp::FilestoreTlvBase { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override; - uint8_t getLengthField() const override; - cfdp::TlvTypes getType() const override; + [[nodiscard]] uint8_t getLengthField() const override; + [[nodiscard]] cfdp::TlvTypes getType() const override; private: uint8_t statusCode; - cfdp::Lv* secondFileName = nullptr; + cfdp::StringLv* secondFileName = nullptr; cfdp::Lv* filestoreMsg = nullptr; ReturnValue_t deSerializeFromValue(const uint8_t** buffer, size_t* size, diff --git a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h index 04012cda..2db08946 100644 --- a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h +++ b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h @@ -11,6 +11,7 @@ #include #include +#include "StringLv.h" #include "fsfw/FSFW.h" namespace cfdp { @@ -65,8 +66,8 @@ static constexpr uint8_t FSR_DENY_DIR_NOT_ALLOWED = 0b0010; class FilestoreTlvBase : public TlvIF { public: - FilestoreTlvBase(cfdp::Lv& firstFileName) : firstFileName(firstFileName){}; - FilestoreTlvBase(FilestoreActionCode actionCode, cfdp::Lv& firstFileName) + explicit FilestoreTlvBase(cfdp::StringLv& firstFileName) : firstFileName(firstFileName){}; + FilestoreTlvBase(FilestoreActionCode actionCode, cfdp::StringLv& firstFileName) : actionCode(actionCode), firstFileName(firstFileName){}; ReturnValue_t commonSerialize(uint8_t** buffer, size_t* size, size_t maxSize, @@ -101,7 +102,7 @@ class FilestoreTlvBase : public TlvIF { if (*size < 3) { return SerializeIF::STREAM_TOO_SHORT; } - cfdp::TlvTypes type = static_cast(**buffer); + auto type = static_cast(**buffer); if (type != getType()) { return cfdp::INVALID_TLV_TYPE; } @@ -117,7 +118,7 @@ class FilestoreTlvBase : public TlvIF { return HasReturnvaluesIF::RETURN_OK; } - bool requiresSecondFileName() const { + [[nodiscard]] bool requiresSecondFileName() const { using namespace cfdp; if (actionCode == FilestoreActionCode::RENAME_FILE or actionCode == FilestoreActionCode::APPEND_FILE or @@ -141,9 +142,9 @@ class FilestoreTlvBase : public TlvIF { #endif } - FilestoreActionCode getActionCode() const { return actionCode; } + [[nodiscard]] FilestoreActionCode getActionCode() const { return actionCode; } - void setActionCode(FilestoreActionCode actionCode) { this->actionCode = actionCode; } + void setActionCode(FilestoreActionCode actionCode_) { this->actionCode = actionCode_; } cfdp::Lv& getFirstFileName() { return firstFileName; } @@ -160,11 +161,11 @@ class FilestoreTlvBase : public TlvIF { return result; } - size_t getSerializedSize() const override { return getLengthField() + 2; } + [[nodiscard]] size_t getSerializedSize() const override { return getLengthField() + 2; } protected: FilestoreActionCode actionCode = FilestoreActionCode::INVALID; - cfdp::Lv& firstFileName; + cfdp::StringLv& firstFileName; }; } // namespace cfdp diff --git a/src/fsfw/cfdp/tlv/StringLv.cpp b/src/fsfw/cfdp/tlv/StringLv.cpp index abbdb34a..60c278a7 100644 --- a/src/fsfw/cfdp/tlv/StringLv.cpp +++ b/src/fsfw/cfdp/tlv/StringLv.cpp @@ -5,3 +5,5 @@ cfdp::StringLv::StringLv(const std::string& fileName) cfdp::StringLv::StringLv(const char* filename, size_t len) : Lv(reinterpret_cast(filename), len) {} + +cfdp::StringLv::StringLv() : Lv() {} diff --git a/src/fsfw/cfdp/tlv/StringLv.h b/src/fsfw/cfdp/tlv/StringLv.h index 86c2d738..a6cc8e20 100644 --- a/src/fsfw/cfdp/tlv/StringLv.h +++ b/src/fsfw/cfdp/tlv/StringLv.h @@ -9,6 +9,7 @@ namespace cfdp { class StringLv : public Lv { public: + StringLv(); explicit StringLv(const std::string& fileName); explicit StringLv(const char* filename, size_t len); }; diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 7d641a38..32ed606d 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -8,8 +8,6 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { EntityId localId = EntityId(UnsignedByteField(2)); auto fhMock = FaultHandlerMock(); auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock); - // auto destHandler = DestHandler(); - cfdp::testFunc(); SECTION("State") {} } \ No newline at end of file diff --git a/unittests/cfdp/pdu/testFinishedPdu.cpp b/unittests/cfdp/pdu/testFinishedPdu.cpp index d117ed58..d5d17124 100644 --- a/unittests/cfdp/pdu/testFinishedPdu.cpp +++ b/unittests/cfdp/pdu/testFinishedPdu.cpp @@ -35,7 +35,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { // Add a filestore response std::string firstName = "hello.txt"; - cfdp::Lv firstNameLv(reinterpret_cast(firstName.data()), firstName.size()); + cfdp::StringLv firstNameLv(firstName); FilestoreResponseTlv response(cfdp::FilestoreActionCode::DELETE_FILE, cfdp::FSR_APPEND_FILE_1_NOT_EXISTS, firstNameLv, nullptr); FilestoreResponseTlv* responsePtr = &response; @@ -53,7 +53,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { // Add two filestore responses and a fault location parameter std::string secondName = "hello2.txt"; - cfdp::Lv secondNameLv(reinterpret_cast(secondName.data()), secondName.size()); + cfdp::StringLv secondNameLv(secondName); FilestoreResponseTlv response2(cfdp::FilestoreActionCode::DENY_FILE, cfdp::FSR_SUCCESS, secondNameLv, nullptr); REQUIRE(response2.getSerializedSize() == 15); @@ -101,7 +101,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { sz = 0; buffer = fnBuffer.data(); std::string firstName = "hello.txt"; - cfdp::Lv firstNameLv(reinterpret_cast(firstName.data()), firstName.size()); + cfdp::StringLv firstNameLv(firstName); FilestoreResponseTlv response(cfdp::FilestoreActionCode::DELETE_FILE, cfdp::FSR_NOT_PERFORMED, firstNameLv, nullptr); FilestoreResponseTlv* responsePtr = &response; @@ -130,7 +130,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { // Add two filestore responses and a fault location parameter std::string secondName = "hello2.txt"; - cfdp::Lv secondNameLv(reinterpret_cast(secondName.data()), secondName.size()); + cfdp::StringLv secondNameLv(secondName); FilestoreResponseTlv response2(cfdp::FilestoreActionCode::DENY_FILE, cfdp::FSR_SUCCESS, secondNameLv, nullptr); REQUIRE(response2.getSerializedSize() == 15); diff --git a/unittests/cfdp/pdu/testMetadataPdu.cpp b/unittests/cfdp/pdu/testMetadataPdu.cpp index dec3b479..0dbc4a70 100644 --- a/unittests/cfdp/pdu/testMetadataPdu.cpp +++ b/unittests/cfdp/pdu/testMetadataPdu.cpp @@ -20,8 +20,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); std::string firstFileName = "hello.txt"; - cfdp::Lv sourceFileName(reinterpret_cast(firstFileName.data()), - firstFileName.size()); + cfdp::StringLv sourceFileName(firstFileName); cfdp::Lv destFileName; FileSize fileSize(35); MetadataInfo info(false, ChecksumType::MODULAR, fileSize, sourceFileName, destFileName); diff --git a/unittests/cfdp/testOtherTlvs.cpp b/unittests/cfdp/testOtherTlvs.cpp index 3551fcdf..d8167e87 100644 --- a/unittests/cfdp/testOtherTlvs.cpp +++ b/unittests/cfdp/testOtherTlvs.cpp @@ -25,9 +25,9 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { SECTION("Filestore Response TLV") { std::string name = "hello.txt"; - cfdp::Lv firstName(reinterpret_cast(name.data()), name.size()); + cfdp::StringLv firstName(name); std::string name2 = "hello2.txt"; - cfdp::Lv secondName(reinterpret_cast(name2.data()), name2.size()); + cfdp::StringLv secondName(name2); std::string msg = "12345"; cfdp::Lv fsMsg(reinterpret_cast(msg.data()), msg.size()); FilestoreResponseTlv response(cfdp::FilestoreActionCode::APPEND_FILE, cfdp::FSR_SUCCESS, @@ -42,8 +42,8 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { SerializeIF::Endianness::NETWORK); REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); - cfdp::Lv emptyMsg; - cfdp::Lv emptySecondName; + cfdp::StringLv emptyMsg; + cfdp::StringLv emptySecondName; FilestoreResponseTlv emptyTlv(firstName, &emptyMsg); emptyTlv.setSecondFileName(&emptySecondName); result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK); @@ -59,9 +59,9 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { SECTION("Filestore Request TLV") { std::string name = "hello.txt"; - cfdp::Lv firstName(reinterpret_cast(name.data()), name.size()); + cfdp::StringLv firstName(name); std::string name2 = "hello2.txt"; - cfdp::Lv secondName(reinterpret_cast(name2.data()), name2.size()); + cfdp::StringLv secondName(name2); FilestoreRequestTlv request(cfdp::FilestoreActionCode::APPEND_FILE, firstName); // second name not set yet diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mocks/cfdp/UserMock.cpp index a38ceefc..bcef4e68 100644 --- a/unittests/mocks/cfdp/UserMock.cpp +++ b/unittests/mocks/cfdp/UserMock.cpp @@ -8,8 +8,10 @@ void cfdp::UserMock::abandonedIndication(cfdp::TransactionId id, cfdp::Condition uint64_t progress) {} void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {} void cfdp::UserMock::transactionFinishedIndication(TransactionFinishedParams finishedParams) {} -void cfdp::UserMock::metadataRecvdIndication(MetadataRecvParams params) {} +void cfdp::UserMock::metadataRecvdIndication(MetadataRecvdParams params) {} void cfdp::UserMock::fileSegmentRecvdIndication(FileSegmentRecvdParams params) {} -void cfdp::UserMock::reportIndication() {} -void cfdp::UserMock::suspendedIndication() {} -void cfdp::UserMock::resumedIndication() {} +void cfdp::UserMock::reportIndication(TransactionId id, StatusReportIF& report) {} +void cfdp::UserMock::suspendedIndication(TransactionId id, ConditionCode code) {} +void cfdp::UserMock::resumedIndication(TransactionId id, size_t progress) {} +void cfdp::UserMock::faultIndication(cfdp::TransactionId id, cfdp::ConditionCode code, + size_t progress) {} diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mocks/cfdp/UserMock.h index bcdff3c9..7106a844 100644 --- a/unittests/mocks/cfdp/UserMock.h +++ b/unittests/mocks/cfdp/UserMock.h @@ -10,14 +10,15 @@ class UserMock : public UserBase { public: void transactionIndication(TransactionId id) override; void eofSentIndication(TransactionId id) override; - void abandonedIndication(TransactionId id, ConditionCode code, uint64_t progress) override; + void abandonedIndication(TransactionId id, ConditionCode code, size_t progress) override; void eofRecvIndication(TransactionId id) override; void transactionFinishedIndication(TransactionFinishedParams params) override; - void metadataRecvdIndication(MetadataRecvParams params) override; + void metadataRecvdIndication(MetadataRecvdParams params) override; void fileSegmentRecvdIndication(FileSegmentRecvdParams params) override; - void reportIndication() override; - void suspendedIndication() override; - void resumedIndication() override; + void reportIndication(TransactionId id, StatusReportIF& report) override; + void suspendedIndication(TransactionId id, ConditionCode code) override; + void resumedIndication(TransactionId id, size_t progress) override; + void faultIndication(TransactionId id, ConditionCode code, size_t progress) override; }; } // namespace cfdp From 28c8248f26bdee6f81f8bfed2f6f31af678b1c89 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 10 Aug 2022 11:09:07 +0200 Subject: [PATCH 217/532] add FS mock and improve HasFilesystemIF --- src/fsfw/cfdp/handler/UserBase.cpp | 3 - src/fsfw/filesystem/HasFileSystemIF.h | 88 +++++++++++++++------- unittests/cfdp/handler/testDestHandler.cpp | 3 +- unittests/mocks/CMakeLists.txt | 3 +- unittests/mocks/FilesystemMock.cpp | 22 ++++++ unittests/mocks/FilesystemMock.h | 19 +++++ 6 files changed, 106 insertions(+), 32 deletions(-) create mode 100644 unittests/mocks/FilesystemMock.cpp create mode 100644 unittests/mocks/FilesystemMock.h diff --git a/src/fsfw/cfdp/handler/UserBase.cpp b/src/fsfw/cfdp/handler/UserBase.cpp index 9e757896..212396fb 100644 --- a/src/fsfw/cfdp/handler/UserBase.cpp +++ b/src/fsfw/cfdp/handler/UserBase.cpp @@ -1,6 +1,3 @@ #include "UserBase.h" -#include -#include - cfdp::UserBase::UserBase(HasFileSystemIF& vfs) : vfs(vfs) {} diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index 88a7db83..4fc8a941 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -4,10 +4,25 @@ #include #include "FileSystemArgsIF.h" +#include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/messageQueueDefinitions.h" #include "fsfw/returnvalues/FwClassIds.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" +struct FilesystemParams { + explicit FilesystemParams(const char* path) : path(path) {} + + const char* path; + FileSystemArgsIF* args = nullptr; +}; + +struct FileOpParams : public FilesystemParams { + FileOpParams(const char* path, size_t size) : FilesystemParams(path), size(size) {} + + size_t size; + size_t offset = 0; +}; + /** * @brief Generic interface for objects which expose a file system to enable * message based file handling. @@ -37,30 +52,47 @@ class HasFileSystemIF { //! [EXPORT] : P1: Sequence number missing static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_READ = MAKE_RETURN_CODE(16); - virtual ~HasFileSystemIF() {} + virtual ~HasFileSystemIF() = default; /** * Function to get the MessageQueueId_t of the implementing object * @return MessageQueueId_t of the object */ - virtual MessageQueueId_t getCommandQueue() const = 0; + [[nodiscard]] virtual MessageQueueId_t getCommandQueue() const { + return MessageQueueIF::NO_QUEUE; + } /** * @brief Generic function to append to file. - * @param dirname Directory of the file - * @param filename The filename of the file + * @param fileOpInfo General information: File name, size to write, offset, additional arguments * @param data The data to write to the file - * @param size The size of the data to write - * @param packetNumber Current packet number. Can be used to verify that - * there are no missing packets. - * @param args Any other arguments which an implementation might require. - * @param bytesWritten Actual bytes written to file - * For large files the write procedure must be split in multiple calls - * to writeToFile */ - virtual ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, - const uint8_t* data, size_t size, uint16_t packetNumber, - FileSystemArgsIF* args = nullptr) = 0; + virtual ReturnValue_t writeToFile(FileOpParams params, const uint8_t* data) = 0; + + /** + * @brief Generic function to read from a file. This variant takes a pointer to a buffer and + * performs pointer arithmetic by incrementing the pointer by the read size + * @param fileOpInfo General information: File name, size to write, offset, additional arguments + * @param buffer [in/out] Data will be read into the provided buffer, and the pointer will be + * incremented by the read length + * @param readSize [out] Will be incremented by the read length + * @param maxSize Maximum size of the provided buffer + * @param args + * @return + */ + virtual ReturnValue_t readFromFile(FileOpParams fileOpInfo, uint8_t** buffer, size_t& readSize, + size_t maxSize) = 0; + /** + * Variant of the @readFromFile which does not perform pointer arithmetic. + * @param fileOpInfo General information: File name, size to write, offset, additional arguments + * @param buf + * @param maxSize + * @return + */ + virtual ReturnValue_t readFromFile(FileOpParams fileOpInfo, uint8_t* buf, size_t maxSize) { + size_t dummy = 0; + return readFromFile(fileOpInfo, &buf, dummy, maxSize); + } /** * @brief Generic function to create a new file. @@ -71,9 +103,10 @@ class HasFileSystemIF { * @param args Any other arguments which an implementation might require * @return */ - virtual ReturnValue_t createFile(const char* repositoryPath, const char* filename, - const uint8_t* data = nullptr, size_t size = 0, - FileSystemArgsIF* args = nullptr) = 0; + virtual ReturnValue_t createFile(FilesystemParams params) { + return createFile(params, nullptr, 0); + } + virtual ReturnValue_t createFile(FilesystemParams params, const uint8_t* data, size_t size) = 0; /** * @brief Generic function to delete a file. @@ -82,8 +115,8 @@ class HasFileSystemIF { * @param args Any other arguments which an implementation might require * @return */ - virtual ReturnValue_t removeFile(const char* repositoryPath, const char* filename, - FileSystemArgsIF* args = nullptr) = 0; + virtual ReturnValue_t removeFile(const char* path, FileSystemArgsIF* args) = 0; + virtual ReturnValue_t removeFile(const char* path) { return removeFile(path, nullptr); } /** * @brief Generic function to create a directory @@ -93,21 +126,22 @@ class HasFileSystemIF { * @param args Any other arguments which an implementation might require * @return */ - virtual ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname, - bool createParentDirs, - FileSystemArgsIF* args = nullptr) = 0; + virtual ReturnValue_t createDirectory(FilesystemParams params, bool createParentDirs) = 0; /** * @brief Generic function to remove a directory * @param repositoryPath * @param args Any other arguments which an implementation might require */ - virtual ReturnValue_t removeDirectory(const char* repositoryPath, const char* dirname, - bool deleteRecurively = false, - FileSystemArgsIF* args = nullptr) = 0; + virtual ReturnValue_t removeDirectory(FilesystemParams params, bool deleteRecurively) = 0; + virtual ReturnValue_t removeDirectory(FilesystemParams params) { + return removeDirectory(params, false); + } - virtual ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename, - const char* newFilename, FileSystemArgsIF* args = nullptr) = 0; + virtual ReturnValue_t renameFile(const char* oldPath, char* newPath) { + return renameFile(oldPath, newPath, nullptr); + } + virtual ReturnValue_t renameFile(const char* oldPath, char* newPath, FileSystemArgsIF* args) = 0; }; #endif /* FSFW_MEMORY_HASFILESYSTEMIF_H_ */ diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 32ed606d..fc8ebc41 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -2,12 +2,13 @@ #include "fsfw/cfdp.h" #include "mocks/cfdp/FaultHandlerMock.h" - +#include "mocks/cfdp/UserMock.h" TEST_CASE("CFDP Dest Handler", "[cfdp]") { using namespace cfdp; EntityId localId = EntityId(UnsignedByteField(2)); auto fhMock = FaultHandlerMock(); auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock); + // auto userMock = UserMock(); SECTION("State") {} } \ No newline at end of file diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index e15f3d71..c40a727a 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -14,6 +14,7 @@ target_sources( PusDistributorMock.cpp CcsdsCheckerMock.cpp AcceptsTcMock.cpp - StorageManagerMock.cpp) + StorageManagerMock.cpp + FilesystemMock.cpp) add_subdirectory(cfdp) diff --git a/unittests/mocks/FilesystemMock.cpp b/unittests/mocks/FilesystemMock.cpp new file mode 100644 index 00000000..fe870155 --- /dev/null +++ b/unittests/mocks/FilesystemMock.cpp @@ -0,0 +1,22 @@ +#include "FilesystemMock.h" + +ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *data) { return 0; } +ReturnValue_t FilesystemMock::readFromFile(FileOpParams fileOpInfo, uint8_t **buffer, + size_t &readSize, size_t maxSize) { + return 0; +} +ReturnValue_t FilesystemMock::createFile(FilesystemParams params, const uint8_t *data, + size_t size) { + return 0; +} +ReturnValue_t FilesystemMock::removeFile(const char *path, FileSystemArgsIF *args) { return 0; } +ReturnValue_t FilesystemMock::createDirectory(FilesystemParams params, bool createParentDirs) { + return 0; +} +ReturnValue_t FilesystemMock::removeDirectory(FilesystemParams params, bool deleteRecurively) { + return 0; +} +ReturnValue_t FilesystemMock::renameFile(const char *oldPath, char *newPath, + FileSystemArgsIF *args) { + return 0; +} diff --git a/unittests/mocks/FilesystemMock.h b/unittests/mocks/FilesystemMock.h new file mode 100644 index 00000000..fa173bf5 --- /dev/null +++ b/unittests/mocks/FilesystemMock.h @@ -0,0 +1,19 @@ +#ifndef FSFW_MOCKS_FILESYSTEMMOCK_H +#define FSFW_MOCKS_FILESYSTEMMOCK_H + +#include "fsfw/filesystem.h" + +class FilesystemMock : public HasFileSystemIF { + public: + MessageQueueId_t getCommandQueue() const override; + ReturnValue_t writeToFile(FileOpParams params, const uint8_t *data) override; + ReturnValue_t readFromFile(FileOpParams fileOpInfo, uint8_t **buffer, size_t &readSize, + size_t maxSize) override; + ReturnValue_t createFile(FilesystemParams params, const uint8_t *data, size_t size) override; + ReturnValue_t removeFile(const char *path, FileSystemArgsIF *args) override; + ReturnValue_t createDirectory(FilesystemParams params, bool createParentDirs) override; + ReturnValue_t removeDirectory(FilesystemParams params, bool deleteRecurively) override; + ReturnValue_t renameFile(const char *oldPath, char *newPath, FileSystemArgsIF *args) override; +}; + +#endif // FSFW_MOCKS_FILESYSTEMMOCK_H From a2e0646ed4d0e1b9932acbae3d973de16a160aa2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 10 Aug 2022 13:05:07 +0200 Subject: [PATCH 218/532] fix duplicate naming error --- unittests/cfdp/testLvs.cpp | 2 +- unittests/cfdp/testOtherTlvs.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unittests/cfdp/testLvs.cpp b/unittests/cfdp/testLvs.cpp index c3f19d9c..27a9dad7 100644 --- a/unittests/cfdp/testLvs.cpp +++ b/unittests/cfdp/testLvs.cpp @@ -3,7 +3,7 @@ #include "fsfw/cfdp.h" -TEST_CASE("CFDP TLV", "[cfdp][lv]") { +TEST_CASE("CFDP LV", "[cfdp][lv]") { using namespace cfdp; ReturnValue_t result; std::array rawBuf{}; diff --git a/unittests/cfdp/testOtherTlvs.cpp b/unittests/cfdp/testOtherTlvs.cpp index d8167e87..6393c230 100644 --- a/unittests/cfdp/testOtherTlvs.cpp +++ b/unittests/cfdp/testOtherTlvs.cpp @@ -14,7 +14,7 @@ #include "fsfw/cfdp/tlv/Tlv.h" #include "fsfw/globalfunctions/arrayprinter.h" -TEST_CASE("CFDP LV", "[cfdp][lv]") { +TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { using namespace cfdp; ReturnValue_t result; std::array rawBuf{}; From 46a4203d00e74986939d57694a6fff6c3e671339 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 10 Aug 2022 13:36:41 +0200 Subject: [PATCH 219/532] testLvs fix --- unittests/cfdp/testLvs.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/unittests/cfdp/testLvs.cpp b/unittests/cfdp/testLvs.cpp index 27a9dad7..2adc84b8 100644 --- a/unittests/cfdp/testLvs.cpp +++ b/unittests/cfdp/testLvs.cpp @@ -5,7 +5,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { using namespace cfdp; - ReturnValue_t result; + ReturnValue_t result = result::OK; std::array rawBuf{}; uint8_t* serPtr = rawBuf.data(); const uint8_t* deserPtr = rawBuf.data(); @@ -17,7 +17,6 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { serPtr = lvRawBuf.data(); REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), SerializeIF::Endianness::NETWORK) == result::OK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); REQUIRE(deserSize == 2); auto lv = cfdp::Lv(lvRawBuf.data(), 2); From 3df116156048d68ee8fce50f4fa43b281804e11d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 10 Aug 2022 15:03:53 +0200 Subject: [PATCH 220/532] this should do the job --- unittests/cfdp/handler/testDestHandler.cpp | 1 + unittests/mocks/FilesystemMock.cpp | 27 +++++++++++++++++++++- unittests/mocks/FilesystemMock.h | 24 ++++++++++++++++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index fc8ebc41..0d9fe9f5 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -3,6 +3,7 @@ #include "fsfw/cfdp.h" #include "mocks/cfdp/FaultHandlerMock.h" #include "mocks/cfdp/UserMock.h" + TEST_CASE("CFDP Dest Handler", "[cfdp]") { using namespace cfdp; EntityId localId = EntityId(UnsignedByteField(2)); diff --git a/unittests/mocks/FilesystemMock.cpp b/unittests/mocks/FilesystemMock.cpp index fe870155..5cf833c0 100644 --- a/unittests/mocks/FilesystemMock.cpp +++ b/unittests/mocks/FilesystemMock.cpp @@ -1,6 +1,31 @@ #include "FilesystemMock.h" -ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *data) { return 0; } +ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *data) { + std::string filename(params.path); + auto iter = fileMap.find(filename); + if (iter == fileMap.end()) { + FileSegmentQueue queue; + queue.push(FileWriteInfo(filename, params.offset, data, params.size)); + FileInfo info; + info.fileSegQueue = queue; + info.fileRaw.insert(info.fileRaw.end(), data, data + params.size); + fileMap.emplace(filename, info); + } else { + FileInfo& info = iter->second; + info.fileSegQueue.push(FileWriteInfo(filename, params.offset, data, params.size)); + // Easiest case: append data to the end + if(params.offset == info.fileRaw.size()) { + info.fileRaw.insert(info.fileRaw.end(), data, data + params.size); + } else { + size_t totalNewLen = params.offset + params.size; + if(totalNewLen > info.fileRaw.size()) { + info.fileRaw.resize(params.offset + params.size); + } + std::copy(data, data + params.size, info.fileRaw.begin() + static_cast(params.offset)); + } + } + return HasReturnvaluesIF::RETURN_OK; +} ReturnValue_t FilesystemMock::readFromFile(FileOpParams fileOpInfo, uint8_t **buffer, size_t &readSize, size_t maxSize) { return 0; diff --git a/unittests/mocks/FilesystemMock.h b/unittests/mocks/FilesystemMock.h index fa173bf5..fbd157b0 100644 --- a/unittests/mocks/FilesystemMock.h +++ b/unittests/mocks/FilesystemMock.h @@ -1,11 +1,33 @@ #ifndef FSFW_MOCKS_FILESYSTEMMOCK_H #define FSFW_MOCKS_FILESYSTEMMOCK_H +#include +#include +#include +#include + #include "fsfw/filesystem.h" class FilesystemMock : public HasFileSystemIF { public: - MessageQueueId_t getCommandQueue() const override; + struct FileWriteInfo { + FileWriteInfo(std::string filename, size_t offset, const uint8_t* data, size_t len) + : filename(std::move(filename)), offset(offset) { + this->data.insert(this->data.end(), data, data + len); + } + std::string filename; + size_t offset; + std::vector data; + }; + using FileSegmentQueue = std::queue; + + struct FileInfo { + FileSegmentQueue fileSegQueue; + std::vector fileRaw; + }; + + std::map fileMap; + ReturnValue_t writeToFile(FileOpParams params, const uint8_t *data) override; ReturnValue_t readFromFile(FileOpParams fileOpInfo, uint8_t **buffer, size_t &readSize, size_t maxSize) override; From aca8b53a59f80215a8bbba4f140aa2dec3aeca3d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 10 Aug 2022 17:03:23 +0200 Subject: [PATCH 221/532] start host FS impl --- src/fsfw_hal/CMakeLists.txt | 1 + src/fsfw_hal/host/CMakeLists.txt | 2 +- src/fsfw_hal/host/HostFilesystem.cpp | 99 +++++++++++++++++++++++ src/fsfw_hal/host/HostFilesystem.h | 24 ++++++ unittests/hal/CMakeLists.txt | 3 +- unittests/hal/testCommandExecutor.cpp | 2 +- unittests/hal/testHostFilesystem.cpp | 5 ++ unittests/mocks/FilesystemMock.cpp | 109 ++++++++++++++++++++------ unittests/mocks/FilesystemMock.h | 38 ++++++++- 9 files changed, 252 insertions(+), 31 deletions(-) create mode 100644 src/fsfw_hal/host/HostFilesystem.cpp create mode 100644 src/fsfw_hal/host/HostFilesystem.h create mode 100644 unittests/hal/testHostFilesystem.cpp diff --git a/src/fsfw_hal/CMakeLists.txt b/src/fsfw_hal/CMakeLists.txt index 057ab3a6..24d712aa 100644 --- a/src/fsfw_hal/CMakeLists.txt +++ b/src/fsfw_hal/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(devicehandlers) add_subdirectory(common) +add_subdirectory(host) if(UNIX) add_subdirectory(linux) diff --git a/src/fsfw_hal/host/CMakeLists.txt b/src/fsfw_hal/host/CMakeLists.txt index 8b137891..95b79675 100644 --- a/src/fsfw_hal/host/CMakeLists.txt +++ b/src/fsfw_hal/host/CMakeLists.txt @@ -1 +1 @@ - +target_sources(${LIB_FSFW_NAME} PUBLIC HostFilesystem.cpp) diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp new file mode 100644 index 00000000..879b9377 --- /dev/null +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -0,0 +1,99 @@ +#include "HostFilesystem.h" + +#include +#include + +#include "fsfw/serialize.h" + +using namespace std::filesystem; +using namespace std; + +HostFilesystem::HostFilesystem() = default; + +ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *data) { + if (params.path == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + path path(params.path); + if (not exists(path)) { + return HasFileSystemIF::FILE_DOES_NOT_EXIST; + } + ofstream file(path, ios::binary | ios::out); + if (file.fail()) { + return HasFileSystemIF::GENERIC_FILE_ERROR; + } + file.seekp(static_cast(params.offset)); + file.write(reinterpret_cast(data), static_cast(params.size)); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, + size_t maxSize) { + if (params.path == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + path path(params.path); + if (not exists(path)) { + return HasFileSystemIF::FILE_DOES_NOT_EXIST; + } + ifstream file(path); + if (file.fail()) { + return HasFileSystemIF::GENERIC_FILE_ERROR; + } + auto readLen = static_cast(params.offset); + file.seekg(readLen); + if (readSize + params.size > maxSize) { + return SerializeIF::BUFFER_TOO_SHORT; + } + file.read(reinterpret_cast(*buffer), readLen); + readSize += readLen; + *buffer += readLen; + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t HostFilesystem::createFile(FilesystemParams params, const uint8_t *data, + size_t size) { + if (params.path == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + path path(params.path); + if (exists(path)) { + return HasFileSystemIF::FILE_ALREADY_EXISTS; + } + ofstream file(path); + if (file.fail()) { + return HasFileSystemIF::GENERIC_FILE_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t HostFilesystem::removeFile(const char *path_, FileSystemArgsIF *args) { + if (path_ == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + path path(path_); + if (not exists(path)) { + return HasFileSystemIF::FILE_DOES_NOT_EXIST; + } + if (remove(path, errorCode)) { + return HasReturnvaluesIF::RETURN_OK; + } + return HasFileSystemIF::GENERIC_FILE_ERROR; +} +ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool createParentDirs) { + if (params.path == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + path dirPath(params.path); + if (createParentDirs) { + create_directories(dirPath, errorCode); + } + return 0; +} +ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool deleteRecurively) { + return 0; +} +ReturnValue_t HostFilesystem::renameFile(const char *oldPath, char *newPath, + FileSystemArgsIF *args) { + return 0; +} diff --git a/src/fsfw_hal/host/HostFilesystem.h b/src/fsfw_hal/host/HostFilesystem.h new file mode 100644 index 00000000..2dd8f2f5 --- /dev/null +++ b/src/fsfw_hal/host/HostFilesystem.h @@ -0,0 +1,24 @@ +#ifndef FSFW_HAL_HOSTFILESYSTEM_H +#define FSFW_HAL_HOSTFILESYSTEM_H + +#include + +#include "fsfw/filesystem/HasFileSystemIF.h" + +class HostFilesystem : public HasFileSystemIF { + public: + HostFilesystem(); + ReturnValue_t writeToFile(FileOpParams params, const uint8_t *data) override; + ReturnValue_t readFromFile(FileOpParams fileOpInfo, uint8_t **buffer, size_t &readSize, + size_t maxSize) override; + ReturnValue_t createFile(FilesystemParams params, const uint8_t *data, size_t size) override; + ReturnValue_t removeFile(const char *path, FileSystemArgsIF *args) override; + ReturnValue_t createDirectory(FilesystemParams params, bool createParentDirs) override; + ReturnValue_t removeDirectory(FilesystemParams params, bool deleteRecurively) override; + ReturnValue_t renameFile(const char *oldPath, char *newPath, FileSystemArgsIF *args) override; + + std::error_code errorCode; + + private: +}; +#endif // FSFW_HAL_HOSTFILESYSTEM_H diff --git a/unittests/hal/CMakeLists.txt b/unittests/hal/CMakeLists.txt index 152bb39f..5e2887b2 100644 --- a/unittests/hal/CMakeLists.txt +++ b/unittests/hal/CMakeLists.txt @@ -1 +1,2 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE testCommandExecutor.cpp) +target_sources(${FSFW_TEST_TGT} PRIVATE testCommandExecutor.cpp + testHostFilesystem.cpp) diff --git a/unittests/hal/testCommandExecutor.cpp b/unittests/hal/testCommandExecutor.cpp index d34f67aa..6c2bb1fe 100644 --- a/unittests/hal/testCommandExecutor.cpp +++ b/unittests/hal/testCommandExecutor.cpp @@ -15,7 +15,7 @@ static const char TEST_FILE_NAME[] = "/tmp/fsfw-unittest-test.txt"; -TEST_CASE("Command Executor", "[cmd-exec]") { +TEST_CASE("Command Executor", "[hal][linux]") { // Check blocking mode first CommandExecutor cmdExecutor(1024); std::string cmd = "echo \"test\" >> " + std::string(TEST_FILE_NAME); diff --git a/unittests/hal/testHostFilesystem.cpp b/unittests/hal/testHostFilesystem.cpp new file mode 100644 index 00000000..19af1c6b --- /dev/null +++ b/unittests/hal/testHostFilesystem.cpp @@ -0,0 +1,5 @@ +#include + +#include "fsfw_hal/host/HostFilesystem.h" + +TEST_CASE("Host Filesystem", "[hal][host]") { auto hostFs = HostFilesystem(); } \ No newline at end of file diff --git a/unittests/mocks/FilesystemMock.cpp b/unittests/mocks/FilesystemMock.cpp index 5cf833c0..e4efd086 100644 --- a/unittests/mocks/FilesystemMock.cpp +++ b/unittests/mocks/FilesystemMock.cpp @@ -1,6 +1,76 @@ #include "FilesystemMock.h" +#include "fsfw/serialize/SerializeIF.h" + ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *data) { + createOrAddToFile(params, data); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, + size_t maxSize) { + std::string filename(params.path); + auto iter = fileMap.find(filename); + if (iter == fileMap.end()) { + return HasFileSystemIF::FILE_DOES_NOT_EXIST; + } else { + FileInfo &info = iter->second; + size_t readLen = params.size; + if (params.offset + params.size > info.fileRaw.size()) { + if (params.offset > info.fileRaw.size()) { + return HasReturnvaluesIF::RETURN_OK; + } + readLen = info.fileRaw.size() - params.offset; + } + if (readSize + readLen > maxSize) { + return SerializeIF::STREAM_TOO_SHORT; + } + std::copy(info.fileRaw.data() + params.offset, info.fileRaw.data() + readLen, *buffer); + *buffer += readLen; + readSize += readLen; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FilesystemMock::createFile(FilesystemParams params, const uint8_t *data, + size_t size) { + FileOpParams params2(params.path, size); + createOrAddToFile(params2, data); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FilesystemMock::removeFile(const char *path, FileSystemArgsIF *args) { + std::string filename(path); + auto iter = fileMap.find(filename); + if (iter == fileMap.end()) { + return HasFileSystemIF::FILE_DOES_NOT_EXIST; + } else { + fileMap.erase(iter); + return HasReturnvaluesIF::RETURN_OK; + } +} + +ReturnValue_t FilesystemMock::createDirectory(FilesystemParams params, bool createParentDirs) { + std::string dirPath = params.path; + dirMap[dirPath].createCallCount++; + dirMap[dirPath].wihParentDir.push(createParentDirs); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FilesystemMock::removeDirectory(FilesystemParams params, bool deleteRecurively) { + std::string dirPath = params.path; + dirMap[dirPath].delCallCount++; + dirMap[dirPath].recursiveDeletion.push(deleteRecurively); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FilesystemMock::renameFile(const char *oldPath, char *newPath, + FileSystemArgsIF *args) { + renameQueue.push(RenameInfo(oldPath, newPath)); + return HasReturnvaluesIF::RETURN_OK; +} + +void FilesystemMock::createOrAddToFile(FileOpParams params, const uint8_t *data) { std::string filename(params.path); auto iter = fileMap.find(filename); if (iter == fileMap.end()) { @@ -8,40 +78,31 @@ ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *da queue.push(FileWriteInfo(filename, params.offset, data, params.size)); FileInfo info; info.fileSegQueue = queue; - info.fileRaw.insert(info.fileRaw.end(), data, data + params.size); + if (data != nullptr) { + info.fileRaw.insert(info.fileRaw.end(), data, data + params.size); + } fileMap.emplace(filename, info); } else { - FileInfo& info = iter->second; + FileInfo &info = iter->second; info.fileSegQueue.push(FileWriteInfo(filename, params.offset, data, params.size)); + if (data == nullptr) { + return; + } // Easiest case: append data to the end - if(params.offset == info.fileRaw.size()) { + if (params.offset == info.fileRaw.size()) { info.fileRaw.insert(info.fileRaw.end(), data, data + params.size); } else { size_t totalNewLen = params.offset + params.size; - if(totalNewLen > info.fileRaw.size()) { + if (totalNewLen > info.fileRaw.size()) { info.fileRaw.resize(params.offset + params.size); } - std::copy(data, data + params.size, info.fileRaw.begin() + static_cast(params.offset)); + std::copy(data, data + params.size, + info.fileRaw.begin() + static_cast(params.offset)); } } - return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FilesystemMock::readFromFile(FileOpParams fileOpInfo, uint8_t **buffer, - size_t &readSize, size_t maxSize) { - return 0; -} -ReturnValue_t FilesystemMock::createFile(FilesystemParams params, const uint8_t *data, - size_t size) { - return 0; -} -ReturnValue_t FilesystemMock::removeFile(const char *path, FileSystemArgsIF *args) { return 0; } -ReturnValue_t FilesystemMock::createDirectory(FilesystemParams params, bool createParentDirs) { - return 0; -} -ReturnValue_t FilesystemMock::removeDirectory(FilesystemParams params, bool deleteRecurively) { - return 0; -} -ReturnValue_t FilesystemMock::renameFile(const char *oldPath, char *newPath, - FileSystemArgsIF *args) { - return 0; + +void FilesystemMock::reset() { + fileMap.clear(); + dirMap.clear(); } diff --git a/unittests/mocks/FilesystemMock.h b/unittests/mocks/FilesystemMock.h index fbd157b0..b02928c7 100644 --- a/unittests/mocks/FilesystemMock.h +++ b/unittests/mocks/FilesystemMock.h @@ -1,18 +1,26 @@ #ifndef FSFW_MOCKS_FILESYSTEMMOCK_H #define FSFW_MOCKS_FILESYSTEMMOCK_H +#include #include #include -#include #include #include "fsfw/filesystem.h" +/** + * This mock models a filesystem in the RAM. It can be used to verify correct behaviour of + * a component using a filesystem without relying on an actual OS filesystem implementation. + * + * Please note that this object does not actually check paths for validity. The file API was + * built in a way to allow reading a file back after it was written while also remembering + * the specific file segments which were inserted in write calls. + */ class FilesystemMock : public HasFileSystemIF { public: struct FileWriteInfo { - FileWriteInfo(std::string filename, size_t offset, const uint8_t* data, size_t len) - : filename(std::move(filename)), offset(offset) { + FileWriteInfo(std::string filename, size_t offset, const uint8_t *data, size_t len) + : filename(std::move(filename)), offset(offset) { this->data.insert(this->data.end(), data, data + len); } std::string filename; @@ -28,14 +36,36 @@ class FilesystemMock : public HasFileSystemIF { std::map fileMap; + struct DirInfo { + size_t createCallCount = 0; + size_t delCallCount = 0; + std::queue wihParentDir; + std::queue recursiveDeletion; + }; + std::map dirMap; + + struct RenameInfo { + RenameInfo(std::string oldName, std::string newName) + : oldName(std::move(oldName)), newName(std::move(newName)) {} + + std::string oldName; + std::string newName; + }; + std::queue renameQueue; + ReturnValue_t writeToFile(FileOpParams params, const uint8_t *data) override; - ReturnValue_t readFromFile(FileOpParams fileOpInfo, uint8_t **buffer, size_t &readSize, + ReturnValue_t readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, size_t maxSize) override; ReturnValue_t createFile(FilesystemParams params, const uint8_t *data, size_t size) override; ReturnValue_t removeFile(const char *path, FileSystemArgsIF *args) override; ReturnValue_t createDirectory(FilesystemParams params, bool createParentDirs) override; ReturnValue_t removeDirectory(FilesystemParams params, bool deleteRecurively) override; ReturnValue_t renameFile(const char *oldPath, char *newPath, FileSystemArgsIF *args) override; + + void reset(); + + private: + void createOrAddToFile(FileOpParams params, const uint8_t *data); }; #endif // FSFW_MOCKS_FILESYSTEMMOCK_H From 20eee2c469425d94537e6429ea2481760658bf58 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 Aug 2022 09:32:18 +0200 Subject: [PATCH 222/532] finished host FS impl --- src/fsfw/filesystem/HasFileSystemIF.h | 25 ++++++----- src/fsfw_hal/host/HostFilesystem.cpp | 62 ++++++++++++++++++++++++--- src/fsfw_hal/host/HostFilesystem.h | 2 +- unittests/mocks/FilesystemMock.cpp | 3 +- unittests/mocks/FilesystemMock.h | 2 +- 5 files changed, 73 insertions(+), 21 deletions(-) diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index 4fc8a941..a9f2b8ea 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -34,18 +34,23 @@ class HasFileSystemIF { //! [EXPORT] : P1: Can be file system specific error code static constexpr ReturnValue_t GENERIC_FILE_ERROR = MAKE_RETURN_CODE(0); + static constexpr ReturnValue_t GENERIC_DIR_ERROR = MAKE_RETURN_CODE(1); + static constexpr ReturnValue_t GENERIC_RENAME_ERROR = MAKE_RETURN_CODE(3); + //! [EXPORT] : File system is currently busy - static constexpr ReturnValue_t IS_BUSY = MAKE_RETURN_CODE(1); + static constexpr ReturnValue_t IS_BUSY = MAKE_RETURN_CODE(4); //! [EXPORT] : Invalid parameters like file name or repository path - static constexpr ReturnValue_t INVALID_PARAMETERS = MAKE_RETURN_CODE(2); + static constexpr ReturnValue_t INVALID_PARAMETERS = MAKE_RETURN_CODE(5); - static constexpr ReturnValue_t FILE_DOES_NOT_EXIST = MAKE_RETURN_CODE(5); - static constexpr ReturnValue_t FILE_ALREADY_EXISTS = MAKE_RETURN_CODE(6); - static constexpr ReturnValue_t FILE_LOCKED = MAKE_RETURN_CODE(7); + static constexpr ReturnValue_t FILE_DOES_NOT_EXIST = MAKE_RETURN_CODE(7); + static constexpr ReturnValue_t FILE_ALREADY_EXISTS = MAKE_RETURN_CODE(8); + static constexpr ReturnValue_t NOT_A_FILE = MAKE_RETURN_CODE(9); + static constexpr ReturnValue_t FILE_LOCKED = MAKE_RETURN_CODE(10); - static constexpr ReturnValue_t DIRECTORY_DOES_NOT_EXIST = MAKE_RETURN_CODE(10); - static constexpr ReturnValue_t DIRECTORY_ALREADY_EXISTS = MAKE_RETURN_CODE(11); - static constexpr ReturnValue_t DIRECTORY_NOT_EMPTY = MAKE_RETURN_CODE(12); + static constexpr ReturnValue_t DIRECTORY_DOES_NOT_EXIST = MAKE_RETURN_CODE(15); + static constexpr ReturnValue_t DIRECTORY_ALREADY_EXISTS = MAKE_RETURN_CODE(16); + static constexpr ReturnValue_t NOT_A_DIRECTORY = MAKE_RETURN_CODE(17); + static constexpr ReturnValue_t DIRECTORY_NOT_EMPTY = MAKE_RETURN_CODE(18); //! [EXPORT] : P1: Sequence number missing static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_WRITE = MAKE_RETURN_CODE(15); @@ -139,9 +144,9 @@ class HasFileSystemIF { } virtual ReturnValue_t renameFile(const char* oldPath, char* newPath) { - return renameFile(oldPath, newPath, nullptr); + return rename(oldPath, newPath, nullptr); } - virtual ReturnValue_t renameFile(const char* oldPath, char* newPath, FileSystemArgsIF* args) = 0; + virtual ReturnValue_t rename(const char* oldPath, char* newPath, FileSystemArgsIF* args) = 0; }; #endif /* FSFW_MEMORY_HASFILESYSTEMIF_H_ */ diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp index 879b9377..c4a00baf 100644 --- a/src/fsfw_hal/host/HostFilesystem.cpp +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -80,20 +80,68 @@ ReturnValue_t HostFilesystem::removeFile(const char *path_, FileSystemArgsIF *ar } return HasFileSystemIF::GENERIC_FILE_ERROR; } + ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool createParentDirs) { if (params.path == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } path dirPath(params.path); - if (createParentDirs) { - create_directories(dirPath, errorCode); + + if (exists(dirPath)) { + return HasFileSystemIF::DIRECTORY_ALREADY_EXISTS; } - return 0; + if (is_regular_file(dirPath)) { + return HasFileSystemIF::NOT_A_DIRECTORY; + } + if (createParentDirs) { + if (create_directories(dirPath, errorCode)) { + return HasReturnvaluesIF::RETURN_OK; + } + return HasFileSystemIF::GENERIC_DIR_ERROR; + } + if (create_directory(dirPath, errorCode)) { + return HasReturnvaluesIF::RETURN_OK; + } + return HasFileSystemIF::GENERIC_DIR_ERROR; } + ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool deleteRecurively) { - return 0; + if (params.path == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + path dirPath(params.path); + if (not exists(dirPath)) { + return HasFileSystemIF::DIRECTORY_DOES_NOT_EXIST; + } + if (is_regular_file(dirPath)) { + return HasFileSystemIF::NOT_A_DIRECTORY; + } + if (deleteRecurively) { + if (remove_all(dirPath, errorCode)) { + return HasReturnvaluesIF::RETURN_OK; + } + } else { + if (remove(dirPath, errorCode)) { + return HasReturnvaluesIF::RETURN_OK; + } + } + // Error handling + if (errorCode == std::errc::directory_not_empty) { + return HasFileSystemIF::DIRECTORY_NOT_EMPTY; + } + return HasFileSystemIF::GENERIC_DIR_ERROR; } -ReturnValue_t HostFilesystem::renameFile(const char *oldPath, char *newPath, - FileSystemArgsIF *args) { - return 0; + +ReturnValue_t HostFilesystem::rename(const char *oldPath_, char *newPath_, FileSystemArgsIF *args) { + if (oldPath_ == nullptr or newPath_ == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + path oldPath(oldPath_); + path newPath(newPath_); + errorCode.clear(); + std::filesystem::rename(oldPath, newPath, errorCode); + if (errorCode) { + return HasFileSystemIF::GENERIC_RENAME_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw_hal/host/HostFilesystem.h b/src/fsfw_hal/host/HostFilesystem.h index 2dd8f2f5..01e37f08 100644 --- a/src/fsfw_hal/host/HostFilesystem.h +++ b/src/fsfw_hal/host/HostFilesystem.h @@ -15,7 +15,7 @@ class HostFilesystem : public HasFileSystemIF { ReturnValue_t removeFile(const char *path, FileSystemArgsIF *args) override; ReturnValue_t createDirectory(FilesystemParams params, bool createParentDirs) override; ReturnValue_t removeDirectory(FilesystemParams params, bool deleteRecurively) override; - ReturnValue_t renameFile(const char *oldPath, char *newPath, FileSystemArgsIF *args) override; + ReturnValue_t rename(const char *oldPath, char *newPath, FileSystemArgsIF *args) override; std::error_code errorCode; diff --git a/unittests/mocks/FilesystemMock.cpp b/unittests/mocks/FilesystemMock.cpp index e4efd086..b52c744f 100644 --- a/unittests/mocks/FilesystemMock.cpp +++ b/unittests/mocks/FilesystemMock.cpp @@ -64,8 +64,7 @@ ReturnValue_t FilesystemMock::removeDirectory(FilesystemParams params, bool dele return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FilesystemMock::renameFile(const char *oldPath, char *newPath, - FileSystemArgsIF *args) { +ReturnValue_t FilesystemMock::rename(const char *oldPath, char *newPath, FileSystemArgsIF *args) { renameQueue.push(RenameInfo(oldPath, newPath)); return HasReturnvaluesIF::RETURN_OK; } diff --git a/unittests/mocks/FilesystemMock.h b/unittests/mocks/FilesystemMock.h index b02928c7..a1af45f0 100644 --- a/unittests/mocks/FilesystemMock.h +++ b/unittests/mocks/FilesystemMock.h @@ -60,7 +60,7 @@ class FilesystemMock : public HasFileSystemIF { ReturnValue_t removeFile(const char *path, FileSystemArgsIF *args) override; ReturnValue_t createDirectory(FilesystemParams params, bool createParentDirs) override; ReturnValue_t removeDirectory(FilesystemParams params, bool deleteRecurively) override; - ReturnValue_t renameFile(const char *oldPath, char *newPath, FileSystemArgsIF *args) override; + ReturnValue_t rename(const char *oldPath, char *newPath, FileSystemArgsIF *args) override; void reset(); From e796e025b6d5fca1adc2ad81752aa290dc926a3f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 Aug 2022 09:59:14 +0200 Subject: [PATCH 223/532] continue host fs unittests --- src/fsfw_hal/host/HostFilesystem.h | 3 ++- unittests/hal/testHostFilesystem.cpp | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/fsfw_hal/host/HostFilesystem.h b/src/fsfw_hal/host/HostFilesystem.h index 01e37f08..4dda3ff7 100644 --- a/src/fsfw_hal/host/HostFilesystem.h +++ b/src/fsfw_hal/host/HostFilesystem.h @@ -18,7 +18,8 @@ class HostFilesystem : public HasFileSystemIF { ReturnValue_t rename(const char *oldPath, char *newPath, FileSystemArgsIF *args) override; std::error_code errorCode; - + using HasFileSystemIF::createFile; + using HasFileSystemIF::removeFile; private: }; #endif // FSFW_HAL_HOSTFILESYSTEM_H diff --git a/unittests/hal/testHostFilesystem.cpp b/unittests/hal/testHostFilesystem.cpp index 19af1c6b..a7166b01 100644 --- a/unittests/hal/testHostFilesystem.cpp +++ b/unittests/hal/testHostFilesystem.cpp @@ -1,5 +1,28 @@ #include #include "fsfw_hal/host/HostFilesystem.h" +#include -TEST_CASE("Host Filesystem", "[hal][host]") { auto hostFs = HostFilesystem(); } \ No newline at end of file +TEST_CASE("Host Filesystem", "[hal][host]") { + namespace fs = std::filesystem; + auto hostFs = HostFilesystem(); + auto tmpDir = fs::temp_directory_path(); + + SECTION("Create file") { + fs::path file = tmpDir / "hello.txt"; + FilesystemParams params(file.c_str()); + REQUIRE(hostFs.createFile(params) == result::OK); + REQUIRE(fs::exists(file)); + REQUIRE_NOTHROW(fs::remove(file)); + } + + SECTION("Remove File") { + fs::path file = tmpDir / "hello.txt"; + FilesystemParams params(file.c_str()); + REQUIRE(hostFs.createFile(params) == result::OK); + REQUIRE(fs::exists(file)); + REQUIRE(hostFs.removeFile(file.c_str()) == result::OK); + REQUIRE(not fs::exists(file)); + } + +} \ No newline at end of file From 8aaabc5d73bb2d9a555afaa94672823d224aa5b3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 Aug 2022 10:10:05 +0200 Subject: [PATCH 224/532] basic host FS unittests --- src/fsfw/filesystem/HasFileSystemIF.h | 8 ++++-- src/fsfw_hal/host/HostFilesystem.cpp | 3 ++- src/fsfw_hal/host/HostFilesystem.h | 6 ++++- unittests/hal/testHostFilesystem.cpp | 36 ++++++++++++++++++++++++++- unittests/mocks/FilesystemMock.cpp | 3 ++- unittests/mocks/FilesystemMock.h | 2 +- 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index a9f2b8ea..9771dda0 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -132,6 +132,9 @@ class HasFileSystemIF { * @return */ virtual ReturnValue_t createDirectory(FilesystemParams params, bool createParentDirs) = 0; + virtual ReturnValue_t createDirectory(FilesystemParams params) { + return createDirectory(params, false); + } /** * @brief Generic function to remove a directory @@ -143,10 +146,11 @@ class HasFileSystemIF { return removeDirectory(params, false); } - virtual ReturnValue_t renameFile(const char* oldPath, char* newPath) { + virtual ReturnValue_t rename(const char* oldPath, const char* newPath) { return rename(oldPath, newPath, nullptr); } - virtual ReturnValue_t rename(const char* oldPath, char* newPath, FileSystemArgsIF* args) = 0; + virtual ReturnValue_t rename(const char* oldPath, const char* newPath, + FileSystemArgsIF* args) = 0; }; #endif /* FSFW_MEMORY_HASFILESYSTEMIF_H_ */ diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp index c4a00baf..8a861d47 100644 --- a/src/fsfw_hal/host/HostFilesystem.cpp +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -132,7 +132,8 @@ ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool dele return HasFileSystemIF::GENERIC_DIR_ERROR; } -ReturnValue_t HostFilesystem::rename(const char *oldPath_, char *newPath_, FileSystemArgsIF *args) { +ReturnValue_t HostFilesystem::rename(const char *oldPath_, const char *newPath_, + FileSystemArgsIF *args) { if (oldPath_ == nullptr or newPath_ == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/src/fsfw_hal/host/HostFilesystem.h b/src/fsfw_hal/host/HostFilesystem.h index 4dda3ff7..c35e0fda 100644 --- a/src/fsfw_hal/host/HostFilesystem.h +++ b/src/fsfw_hal/host/HostFilesystem.h @@ -15,11 +15,15 @@ class HostFilesystem : public HasFileSystemIF { ReturnValue_t removeFile(const char *path, FileSystemArgsIF *args) override; ReturnValue_t createDirectory(FilesystemParams params, bool createParentDirs) override; ReturnValue_t removeDirectory(FilesystemParams params, bool deleteRecurively) override; - ReturnValue_t rename(const char *oldPath, char *newPath, FileSystemArgsIF *args) override; + ReturnValue_t rename(const char *oldPath, const char *newPath, FileSystemArgsIF *args) override; std::error_code errorCode; + using HasFileSystemIF::createDirectory; using HasFileSystemIF::createFile; + using HasFileSystemIF::removeDirectory; using HasFileSystemIF::removeFile; + using HasFileSystemIF::rename; + private: }; #endif // FSFW_HAL_HOSTFILESYSTEM_H diff --git a/unittests/hal/testHostFilesystem.cpp b/unittests/hal/testHostFilesystem.cpp index a7166b01..d3fd880a 100644 --- a/unittests/hal/testHostFilesystem.cpp +++ b/unittests/hal/testHostFilesystem.cpp @@ -1,17 +1,22 @@ #include +#include #include "fsfw_hal/host/HostFilesystem.h" -#include TEST_CASE("Host Filesystem", "[hal][host]") { namespace fs = std::filesystem; auto hostFs = HostFilesystem(); auto tmpDir = fs::temp_directory_path(); + fs::path file0 = tmpDir / "hello.txt"; + fs::path file1 = tmpDir / "hello.txt"; + REQUIRE_NOTHROW(fs::remove(file0)); + REQUIRE_NOTHROW(fs::remove(file1)); SECTION("Create file") { fs::path file = tmpDir / "hello.txt"; FilesystemParams params(file.c_str()); REQUIRE(hostFs.createFile(params) == result::OK); + CHECK(fs::is_regular_file(file)); REQUIRE(fs::exists(file)); REQUIRE_NOTHROW(fs::remove(file)); } @@ -20,9 +25,38 @@ TEST_CASE("Host Filesystem", "[hal][host]") { fs::path file = tmpDir / "hello.txt"; FilesystemParams params(file.c_str()); REQUIRE(hostFs.createFile(params) == result::OK); + CHECK(fs::is_regular_file(file)); REQUIRE(fs::exists(file)); REQUIRE(hostFs.removeFile(file.c_str()) == result::OK); REQUIRE(not fs::exists(file)); } + SECTION("Create Directory") { + fs::path dirPath = tmpDir / "test_dir"; + FilesystemParams params(dirPath.c_str()); + REQUIRE(hostFs.createDirectory(params) == result::OK); + CHECK(fs::is_directory(dirPath)); + REQUIRE(fs::exists(dirPath)); + REQUIRE_NOTHROW(fs::remove(dirPath)); + } + + SECTION("Remove Directory") { + fs::path dirPath = tmpDir / "test_dir"; + FilesystemParams params(dirPath.c_str()); + REQUIRE(hostFs.createDirectory(params) == result::OK); + REQUIRE(fs::exists(dirPath)); + REQUIRE(hostFs.removeDirectory(params) == result::OK); + REQUIRE(not fs::exists(dirPath)); + } + + SECTION("Rename File") { + fs::path file = tmpDir / "hello.txt"; + fs::path newFile = tmpDir / "hello2.txt"; + FilesystemParams params(file.c_str()); + REQUIRE(hostFs.createFile(params) == result::OK); + CHECK(fs::is_regular_file(file)); + REQUIRE(fs::exists(file)); + REQUIRE(hostFs.rename(file.c_str(), newFile.c_str()) == result::OK); + REQUIRE_NOTHROW(fs::remove(newFile)); + } } \ No newline at end of file diff --git a/unittests/mocks/FilesystemMock.cpp b/unittests/mocks/FilesystemMock.cpp index b52c744f..5b195ffc 100644 --- a/unittests/mocks/FilesystemMock.cpp +++ b/unittests/mocks/FilesystemMock.cpp @@ -64,7 +64,8 @@ ReturnValue_t FilesystemMock::removeDirectory(FilesystemParams params, bool dele return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FilesystemMock::rename(const char *oldPath, char *newPath, FileSystemArgsIF *args) { +ReturnValue_t FilesystemMock::rename(const char *oldPath, const char *newPath, + FileSystemArgsIF *args) { renameQueue.push(RenameInfo(oldPath, newPath)); return HasReturnvaluesIF::RETURN_OK; } diff --git a/unittests/mocks/FilesystemMock.h b/unittests/mocks/FilesystemMock.h index a1af45f0..f7c53eda 100644 --- a/unittests/mocks/FilesystemMock.h +++ b/unittests/mocks/FilesystemMock.h @@ -60,7 +60,7 @@ class FilesystemMock : public HasFileSystemIF { ReturnValue_t removeFile(const char *path, FileSystemArgsIF *args) override; ReturnValue_t createDirectory(FilesystemParams params, bool createParentDirs) override; ReturnValue_t removeDirectory(FilesystemParams params, bool deleteRecurively) override; - ReturnValue_t rename(const char *oldPath, char *newPath, FileSystemArgsIF *args) override; + ReturnValue_t rename(const char *oldPath, const char *newPath, FileSystemArgsIF *args) override; void reset(); From c12492df03da5cb529190336bd8269bd75bc6ba0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 Aug 2022 10:19:25 +0200 Subject: [PATCH 225/532] continued host FS test --- src/fsfw/filesystem/HasFileSystemIF.h | 13 +++++- src/fsfw_hal/host/HostFilesystem.cpp | 8 ++-- unittests/hal/testHostFilesystem.cpp | 67 ++++++++++++++++----------- unittests/mocks/FilesystemMock.cpp | 4 +- 4 files changed, 56 insertions(+), 36 deletions(-) diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index 9771dda0..2f262285 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -16,9 +16,18 @@ struct FilesystemParams { FileSystemArgsIF* args = nullptr; }; -struct FileOpParams : public FilesystemParams { - FileOpParams(const char* path, size_t size) : FilesystemParams(path), size(size) {} +struct FileOpParams { + FileOpParams(const char* path, size_t size) : fsParams(path), size(size) {} + [[nodiscard]] const char* path() const { + return fsParams.path; + } + + [[nodiscard]] FileSystemArgsIF* args() const { + return fsParams.args; + } + + FilesystemParams fsParams; size_t size; size_t offset = 0; }; diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp index 8a861d47..72cff2ed 100644 --- a/src/fsfw_hal/host/HostFilesystem.cpp +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -11,10 +11,10 @@ using namespace std; HostFilesystem::HostFilesystem() = default; ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *data) { - if (params.path == nullptr) { + if (params.path() == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } - path path(params.path); + path path(params.path()); if (not exists(path)) { return HasFileSystemIF::FILE_DOES_NOT_EXIST; } @@ -29,10 +29,10 @@ ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *da ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, size_t maxSize) { - if (params.path == nullptr) { + if (params.path() == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } - path path(params.path); + path path(params.path()); if (not exists(path)) { return HasFileSystemIF::FILE_DOES_NOT_EXIST; } diff --git a/unittests/hal/testHostFilesystem.cpp b/unittests/hal/testHostFilesystem.cpp index d3fd880a..ba3b1338 100644 --- a/unittests/hal/testHostFilesystem.cpp +++ b/unittests/hal/testHostFilesystem.cpp @@ -8,55 +8,66 @@ TEST_CASE("Host Filesystem", "[hal][host]") { auto hostFs = HostFilesystem(); auto tmpDir = fs::temp_directory_path(); fs::path file0 = tmpDir / "hello.txt"; - fs::path file1 = tmpDir / "hello.txt"; + fs::path file1 = tmpDir / "hello2.txt"; + fs::path dir0 = tmpDir / "test_dir"; REQUIRE_NOTHROW(fs::remove(file0)); REQUIRE_NOTHROW(fs::remove(file1)); + REQUIRE_NOTHROW(fs::remove(dir0)); SECTION("Create file") { - fs::path file = tmpDir / "hello.txt"; - FilesystemParams params(file.c_str()); + FilesystemParams params(file0.c_str()); REQUIRE(hostFs.createFile(params) == result::OK); - CHECK(fs::is_regular_file(file)); - REQUIRE(fs::exists(file)); - REQUIRE_NOTHROW(fs::remove(file)); + CHECK(fs::is_regular_file(file0)); + REQUIRE(fs::exists(file0)); + REQUIRE_NOTHROW(fs::remove(file0)); } SECTION("Remove File") { - fs::path file = tmpDir / "hello.txt"; - FilesystemParams params(file.c_str()); + FilesystemParams params(file0.c_str()); REQUIRE(hostFs.createFile(params) == result::OK); - CHECK(fs::is_regular_file(file)); - REQUIRE(fs::exists(file)); - REQUIRE(hostFs.removeFile(file.c_str()) == result::OK); - REQUIRE(not fs::exists(file)); + CHECK(fs::is_regular_file(file0)); + REQUIRE(fs::exists(file0)); + REQUIRE(hostFs.removeFile(file0.c_str()) == result::OK); + REQUIRE(not fs::exists(file0)); } SECTION("Create Directory") { - fs::path dirPath = tmpDir / "test_dir"; - FilesystemParams params(dirPath.c_str()); + FilesystemParams params(dir0.c_str()); REQUIRE(hostFs.createDirectory(params) == result::OK); - CHECK(fs::is_directory(dirPath)); - REQUIRE(fs::exists(dirPath)); - REQUIRE_NOTHROW(fs::remove(dirPath)); + CHECK(fs::is_directory(dir0)); + REQUIRE(fs::exists(dir0)); + REQUIRE_NOTHROW(fs::remove(dir0)); } SECTION("Remove Directory") { - fs::path dirPath = tmpDir / "test_dir"; - FilesystemParams params(dirPath.c_str()); + FilesystemParams params(dir0.c_str()); REQUIRE(hostFs.createDirectory(params) == result::OK); - REQUIRE(fs::exists(dirPath)); + REQUIRE(fs::exists(dir0)); REQUIRE(hostFs.removeDirectory(params) == result::OK); - REQUIRE(not fs::exists(dirPath)); + REQUIRE(not fs::exists(dir0)); } SECTION("Rename File") { - fs::path file = tmpDir / "hello.txt"; - fs::path newFile = tmpDir / "hello2.txt"; - FilesystemParams params(file.c_str()); + FilesystemParams params(file0.c_str()); REQUIRE(hostFs.createFile(params) == result::OK); - CHECK(fs::is_regular_file(file)); - REQUIRE(fs::exists(file)); - REQUIRE(hostFs.rename(file.c_str(), newFile.c_str()) == result::OK); - REQUIRE_NOTHROW(fs::remove(newFile)); + CHECK(fs::is_regular_file(file0)); + REQUIRE(fs::exists(file0)); + REQUIRE(hostFs.rename(file0.c_str(), file1.c_str()) == result::OK); + REQUIRE_NOTHROW(fs::remove(file1)); } + + SECTION("Write To File") { + std::string data = "hello world!"; + FileOpParams params(file0.c_str(), data.size()); + REQUIRE(hostFs.createFile(params.fsParams) == result::OK); + CHECK(fs::is_regular_file(file0)); + REQUIRE(fs::exists(file0)); + hostFs.writeToFile(params, reinterpret_cast(data.c_str())); + // TODO: Read back file and verify content + REQUIRE_NOTHROW(fs::remove(file1)); + } + + REQUIRE_NOTHROW(fs::remove(file0)); + REQUIRE_NOTHROW(fs::remove(file1)); + REQUIRE_NOTHROW(fs::remove(dir0)); } \ No newline at end of file diff --git a/unittests/mocks/FilesystemMock.cpp b/unittests/mocks/FilesystemMock.cpp index 5b195ffc..02620fd5 100644 --- a/unittests/mocks/FilesystemMock.cpp +++ b/unittests/mocks/FilesystemMock.cpp @@ -9,7 +9,7 @@ ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *da ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, size_t maxSize) { - std::string filename(params.path); + std::string filename(params.path()); auto iter = fileMap.find(filename); if (iter == fileMap.end()) { return HasFileSystemIF::FILE_DOES_NOT_EXIST; @@ -71,7 +71,7 @@ ReturnValue_t FilesystemMock::rename(const char *oldPath, const char *newPath, } void FilesystemMock::createOrAddToFile(FileOpParams params, const uint8_t *data) { - std::string filename(params.path); + std::string filename(params.path()); auto iter = fileMap.find(filename); if (iter == fileMap.end()) { FileSegmentQueue queue; From 8b4253bc46818852d4ea7913540366b69338452e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 Aug 2022 13:02:30 +0200 Subject: [PATCH 226/532] update cmakelists.txt --- CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfae2acb..1f99086b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,11 @@ option(FSFW_ADD_INTERNAL_TESTS "Add internal unit tests" ON) option(FSFW_ADD_UNITTESTS "Add regular unittests. Requires Catch2" OFF) option(FSFW_ADD_HAL "Add Hardware Abstraction Layer" ON) +if(UNIX) + option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add Linux peripheral drivers" OFF) + option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Attempt to add Linux GPIOD drivers" OFF) +endif() + # Optional sources option(FSFW_ADD_PUS "Compile with PUS sources" ON) option(FSFW_ADD_MONITORING "Compile with monitoring components" ON) @@ -183,7 +188,10 @@ if(FSFW_BUILD_TESTS) endif() endif() -message(STATUS "${MSG_PREFIX} Finding and/or providing ETL library") +message( + STATUS + "${MSG_PREFIX} Finding and/or providing etl library with version ${FSFW_ETL_LIB_MAJOR_VERSION}" +) # Check whether the user has already installed ETL first find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET) @@ -191,7 +199,7 @@ find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET) if(NOT ${FSFW_ETL_LIB_NAME}_FOUND) message( STATUS - "No ETL installation was found with find_package. Installing and providing " + "${MSG_PREFIX} No ETL installation was found with find_package. Installing and providing " "etl with FindPackage") include(FetchContent) From b28c26b288ca9e261a95d9564202336fb3c5cf5c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 Aug 2022 10:49:00 +0200 Subject: [PATCH 227/532] group MGM data in local pool vectors --- CMakeLists.txt | 6 +++++ .../devicehandlers/MgmLIS3MDLHandler.cpp | 27 ++++++++----------- .../devicehandlers/MgmLIS3MDLHandler.h | 2 ++ .../devicehandlers/MgmRM3100Handler.cpp | 11 ++++---- .../devicehandlers/MgmRM3100Handler.h | 1 + .../devicedefinitions/MgmLIS3HandlerDefs.h | 14 ++++------ .../devicedefinitions/MgmRM3100HandlerDefs.h | 14 ++++------ 7 files changed, 35 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfae2acb..95c00f28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,12 @@ option(FSFW_ADD_INTERNAL_TESTS "Add internal unit tests" ON) option(FSFW_ADD_UNITTESTS "Add regular unittests. Requires Catch2" OFF) option(FSFW_ADD_HAL "Add Hardware Abstraction Layer" ON) +if(UNIX) + option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add Linux peripheral drivers" + OFF) + option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Attempt to add Linux GPIOD drivers" OFF) +endif() + # Optional sources option(FSFW_ADD_PUS "Compile with PUS sources" ON) option(FSFW_ADD_MONITORING "Compile with monitoring components" ON) diff --git a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index 644b488d..5ddc3245 100644 --- a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -286,26 +286,22 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons PoolReadGuard readHelper(&dataset); if (readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + if (std::abs(mgmX) > absLimitX or std::abs(mgmY) > absLimitY or + std::abs(mgmZ) > absLimitZ) { + dataset.fieldStrengths.setValid(false); + } if (std::abs(mgmX) < absLimitX) { - dataset.fieldStrengthX = mgmX; - dataset.fieldStrengthX.setValid(true); - } else { - dataset.fieldStrengthX.setValid(false); + dataset.fieldStrengths[0] = mgmX; } if (std::abs(mgmY) < absLimitY) { - dataset.fieldStrengthY = mgmY; - dataset.fieldStrengthY.setValid(true); - } else { - dataset.fieldStrengthY.setValid(false); + dataset.fieldStrengths[1] = mgmY; } if (std::abs(mgmZ) < absLimitZ) { - dataset.fieldStrengthZ = mgmZ; - dataset.fieldStrengthZ.setValid(true); - } else { - dataset.fieldStrengthZ.setValid(false); + dataset.fieldStrengths[2] = mgmZ; } + dataset.fieldStrengths.setValid(true); } break; } @@ -468,10 +464,9 @@ void MgmLIS3MDLHandler::modeChanged(void) { internalState = InternalState::STATE ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTH_Z, new PoolEntry({0.0})); - localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, new PoolEntry({0.0})); + localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTHS, &mgmXYZ); + localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, &temperature); + poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 10.0, false); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h index 42bd5d4c..3250a739 100644 --- a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h +++ b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h @@ -103,6 +103,8 @@ class MgmLIS3MDLHandler : public DeviceHandlerBase { CommunicationStep communicationStep = CommunicationStep::DATA; bool commandExecuted = false; + PoolEntry mgmXYZ = PoolEntry(3); + PoolEntry temperature = PoolEntry(); /*------------------------------------------------------------------------*/ /* Device specific commands and variables */ /*------------------------------------------------------------------------*/ diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index f9929d63..c329f5a6 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -309,9 +309,8 @@ void MgmRM3100Handler::modeChanged(void) { internalState = InternalState::NONE; ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Z, new PoolEntry({0.0})); + localDataPoolMap.emplace(RM3100::FIELD_STRENGTHS, &mgmXYZ); + poolManager.subscribeForPeriodicPacket(primaryDataset.getSid(), false, 10.0, false); return HasReturnvaluesIF::RETURN_OK; } @@ -354,9 +353,9 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) { // TODO: Sanity check on values? PoolReadGuard readGuard(&primaryDataset); if (readGuard.getReadResult() == HasReturnvaluesIF::RETURN_OK) { - primaryDataset.fieldStrengthX = fieldStrengthX; - primaryDataset.fieldStrengthY = fieldStrengthY; - primaryDataset.fieldStrengthZ = fieldStrengthZ; + primaryDataset.fieldStrengths[0] = fieldStrengthX; + primaryDataset.fieldStrengths[1] = fieldStrengthY; + primaryDataset.fieldStrengths[2] = fieldStrengthZ; primaryDataset.setValidity(true, true); } return RETURN_OK; diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h index d1048cb6..d45b2404 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.h @@ -85,6 +85,7 @@ class MgmRM3100Handler : public DeviceHandlerBase { bool goToNormalModeAtStartup = false; uint32_t transitionDelay; + PoolEntry mgmXYZ = PoolEntry(3); ReturnValue_t handleCycleCountConfigCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, size_t commandDataLen); diff --git a/src/fsfw_hal/devicehandlers/devicedefinitions/MgmLIS3HandlerDefs.h b/src/fsfw_hal/devicehandlers/devicedefinitions/MgmLIS3HandlerDefs.h index 3d78c5c9..34237637 100644 --- a/src/fsfw_hal/devicehandlers/devicedefinitions/MgmLIS3HandlerDefs.h +++ b/src/fsfw_hal/devicehandlers/devicedefinitions/MgmLIS3HandlerDefs.h @@ -139,12 +139,7 @@ static const uint8_t CTRL_REG5_DEFAULT = 0; static const uint32_t MGM_DATA_SET_ID = READ_CONFIG_AND_DATA; -enum MgmPoolIds : lp_id_t { - FIELD_STRENGTH_X, - FIELD_STRENGTH_Y, - FIELD_STRENGTH_Z, - TEMPERATURE_CELCIUS -}; +enum MgmPoolIds : lp_id_t { FIELD_STRENGTHS, TEMPERATURE_CELCIUS }; class MgmPrimaryDataset : public StaticLocalDataSet<4> { public: @@ -152,9 +147,10 @@ class MgmPrimaryDataset : public StaticLocalDataSet<4> { MgmPrimaryDataset(object_id_t mgmId) : StaticLocalDataSet(sid_t(mgmId, MGM_DATA_SET_ID)) {} - lp_var_t fieldStrengthX = lp_var_t(sid.objectId, FIELD_STRENGTH_X, this); - lp_var_t fieldStrengthY = lp_var_t(sid.objectId, FIELD_STRENGTH_Y, this); - lp_var_t fieldStrengthZ = lp_var_t(sid.objectId, FIELD_STRENGTH_Z, this); + /** + * Field strenghts in uT + */ + lp_vec_t fieldStrengths = lp_vec_t(sid.objectId, FIELD_STRENGTHS, this); lp_var_t temperature = lp_var_t(sid.objectId, TEMPERATURE_CELCIUS, this); }; diff --git a/src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h b/src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h index e3eaff22..a2aa8ab0 100644 --- a/src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h +++ b/src/fsfw_hal/devicehandlers/devicedefinitions/MgmRM3100HandlerDefs.h @@ -101,11 +101,7 @@ class CycleCountCommand : public SerialLinkedListAdapter { static constexpr uint32_t MGM_DATASET_ID = READ_DATA; -enum MgmPoolIds : lp_id_t { - FIELD_STRENGTH_X, - FIELD_STRENGTH_Y, - FIELD_STRENGTH_Z, -}; +enum MgmPoolIds : lp_id_t { FIELD_STRENGTHS }; class Rm3100PrimaryDataset : public StaticLocalDataSet<3> { public: @@ -113,10 +109,10 @@ class Rm3100PrimaryDataset : public StaticLocalDataSet<3> { Rm3100PrimaryDataset(object_id_t mgmId) : StaticLocalDataSet(sid_t(mgmId, MGM_DATASET_ID)) {} - // Field strengths in micro Tesla. - lp_var_t fieldStrengthX = lp_var_t(sid.objectId, FIELD_STRENGTH_X, this); - lp_var_t fieldStrengthY = lp_var_t(sid.objectId, FIELD_STRENGTH_Y, this); - lp_var_t fieldStrengthZ = lp_var_t(sid.objectId, FIELD_STRENGTH_Z, this); + /** + * Field strenghts in uT + */ + lp_vec_t fieldStrengths = lp_vec_t(sid.objectId, FIELD_STRENGTHS, this); }; } // namespace RM3100 From d3cabd8984a69febfcf53979cfc0320e628beb95 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 Aug 2022 11:26:29 +0200 Subject: [PATCH 228/532] afmt --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f99086b..5351aeb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,8 +119,9 @@ option(FSFW_ADD_UNITTESTS "Add regular unittests. Requires Catch2" OFF) option(FSFW_ADD_HAL "Add Hardware Abstraction Layer" ON) if(UNIX) - option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add Linux peripheral drivers" OFF) - option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Attempt to add Linux GPIOD drivers" OFF) + option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add Linux peripheral drivers" + OFF) + option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Attempt to add Linux GPIOD drivers" OFF) endif() # Optional sources From deeeef553b118192d45a921d6d3a1a3b5881ebd7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 Aug 2022 14:34:04 +0200 Subject: [PATCH 229/532] remove implicit machine endianness variants --- src/fsfw/serialize/SerializeIF.h | 26 ----------- unittests/serialize/testSerializeIF.cpp | 57 ------------------------- 2 files changed, 83 deletions(-) diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 5e7a2fb9..f20bf21f 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -68,13 +68,6 @@ class SerializeIF { size_t maxSize) const { return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); } - /** - * If endianness is not explicitly specified, use machine endianness - */ - [[nodiscard]] virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, - size_t maxSize) const { - return serialize(buffer, size, maxSize, SerializeIF::Endianness::MACHINE); - } /** * Gets the size of a object if it would be serialized in a buffer @@ -110,12 +103,6 @@ class SerializeIF { virtual ReturnValue_t deSerializeBe(const uint8_t **buffer, size_t *size) { return deSerialize(buffer, size, SerializeIF::Endianness::NETWORK); } - /** - * If endianness is not explicitly specified, use machine endianness - */ - virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size) { - return deSerialize(buffer, size, SerializeIF::Endianness::MACHINE); - } /** * Helper method which can be used if serialization should be performed without any additional @@ -139,13 +126,6 @@ class SerializeIF { size_t maxSize) const { return serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK); } - /** - * If endianness is not explicitly specified, use machine endianness - */ - [[nodiscard]] virtual ReturnValue_t serialize(uint8_t *buffer, size_t &serLen, - size_t maxSize) const { - return serialize(buffer, serLen, maxSize, SerializeIF::Endianness::MACHINE); - } /** * Helper methods which can be used if deserialization should be performed without any additional @@ -168,12 +148,6 @@ class SerializeIF { virtual ReturnValue_t deSerializeBe(const uint8_t *buffer, size_t &deserSize, size_t maxSize) { return deSerialize(buffer, deserSize, maxSize, SerializeIF::Endianness::NETWORK); } - /** - * If endianness is not explicitly specified, use machine endianness - */ - virtual ReturnValue_t deSerialize(const uint8_t *buffer, size_t &deserSize, size_t maxSize) { - return deSerialize(buffer, deserSize, maxSize, SerializeIF::Endianness::MACHINE); - } }; #endif /* FSFW_SERIALIZE_SERIALIZEIF_H_ */ diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index 5200f8b7..7aafe98f 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -76,37 +76,6 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { CHECK(buf[2] == 3); CHECK(serLen == 3); } - - SECTION("Machine Endian Implicit") { - REQUIRE(simpleSer.SerializeIF::serialize(&ptr, &len, buf.size()) == - HasReturnvaluesIF::RETURN_OK); - CHECK(buf[0] == 1); -#if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN - CHECK(buf[1] == 3); - CHECK(buf[2] == 2); -#else - CHECK(buf[1] == 2); - CHECK(buf[2] == 3); -#endif - // Verify pointer arithmetic and size increment - CHECK(ptr == buf.data() + 3); - CHECK(len == 3); - } - - SECTION("Machine Endian Simple Implicit") { - size_t serLen = 0xff; - REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); - CHECK(buf[0] == 1); -#if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN - CHECK(buf[1] == 3); - CHECK(buf[2] == 2); -#else - CHECK(buf[1] == 2); - CHECK(buf[2] == 3); -#endif - CHECK(serLen == 3); - } } TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { @@ -172,30 +141,4 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { CHECK(simpleSer.getU16() == 1); CHECK(deserLen == 3); } - - SECTION("Machine Endian Implicit") { - REQUIRE(simpleSer.SerializeIF::deSerialize(&ptr, &len) == HasReturnvaluesIF::RETURN_OK); - CHECK(simpleSer.getU8() == 5); -#if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN - CHECK(simpleSer.getU16() == 0x0100); -#else - CHECK(simpleSer.getU16() == 1); -#endif - // Verify pointer arithmetic and size increment - CHECK(ptr == buf.data() + 3); - CHECK(len == 0); - } - - SECTION("Machine Endian Simple Implicit") { - size_t deserLen = 0xff; - REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); - CHECK(simpleSer.getU8() == 5); -#if BYTE_ORDER_SYSTEM == LITTLE_ENDIAN - CHECK(simpleSer.getU16() == 0x0100); -#else - CHECK(simpleSer.getU16() == 1); -#endif - CHECK(deserLen == 3); - } } \ No newline at end of file From ca2efb60218b85414bc3857d1ce57a6f798f6c23 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 Aug 2022 15:02:05 +0200 Subject: [PATCH 230/532] remove object ID --- src/fsfw/util/ObjectId.h | 57 --------------------------------- unittests/util/CMakeLists.txt | 1 - unittests/util/testObjectId.cpp | 26 --------------- 3 files changed, 84 deletions(-) delete mode 100644 src/fsfw/util/ObjectId.h delete mode 100644 unittests/util/testObjectId.cpp diff --git a/src/fsfw/util/ObjectId.h b/src/fsfw/util/ObjectId.h deleted file mode 100644 index 5b1cf461..00000000 --- a/src/fsfw/util/ObjectId.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef FSFW_UTIL_OBJECTID_H -#define FSFW_UTIL_OBJECTID_H - -#include "fsfw/objectmanager.h" -#include "UnsignedByteField.h" - -#include - -class ObjectId: public UnsignedByteField { - public: - ObjectId(object_id_t id, const char* name): UnsignedByteField(id), name_(name) {} - - [[nodiscard]] const char* name() const { - return name_; - } - - [[nodiscard]] object_id_t id() const { - return getValue(); - } - - bool operator==(const ObjectId& other) const { - return id() == other.id(); - } - - bool operator!=(const ObjectId& other) const { - return id() != other.id(); - } - - bool operator<(const ObjectId& other) const { - return id() < other.id(); - } - - bool operator>(const ObjectId& other) const { - return id() > other.id(); - } - - bool operator>=(const ObjectId& other) const { - return id() >= other.id(); - } - - bool operator<=(const ObjectId& other) const { - return id() <= other.id(); - } - private: - const char* name_; -}; - -template<> -struct std::hash -{ - std::size_t operator()(ObjectId const& s) const noexcept - { - return std::hash{}(s.id()); - } -}; - -#endif // FSFW_UTIL_OBJECTID_H diff --git a/unittests/util/CMakeLists.txt b/unittests/util/CMakeLists.txt index b79b77db..d4caa4d5 100644 --- a/unittests/util/CMakeLists.txt +++ b/unittests/util/CMakeLists.txt @@ -1,4 +1,3 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testUnsignedByteField.cpp - testObjectId.cpp ) diff --git a/unittests/util/testObjectId.cpp b/unittests/util/testObjectId.cpp deleted file mode 100644 index cead2c15..00000000 --- a/unittests/util/testObjectId.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include - -#include "fsfw/util/ObjectId.h" -#include - -TEST_CASE("Object Id", "[object-id]") { - auto objectId = ObjectId(10, "TEST_ID"); - std::map testMap; - - SECTION("State") { - CHECK(objectId.id() == 10); - CHECK(std::strcmp(objectId.name(), "TEST_ID") == 0); - } - - SECTION("ID as map key") { - auto insertPair = testMap.emplace(objectId, 10); - CHECK(insertPair.second); - auto iter = testMap.find(objectId); - CHECK(iter != testMap.end()); - CHECK(std::strcmp(iter->first.name(), "TEST_ID") == 0); - CHECK(iter->second == 10); - auto otherIdSameName = ObjectId(12, "TEST_ID"); - insertPair = testMap.emplace(otherIdSameName, 10); - CHECK(insertPair.second); - } -} \ No newline at end of file From 9d64b96e9a1375f920707a720cfd664f5937322e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 Aug 2022 15:02:39 +0200 Subject: [PATCH 231/532] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f83c5078..bf50b683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +## Added + +- Add new `UnsignedByteField` class + # [v5.0.0] 25.07.2022 ## Changes From 9e064fe800676f2b0919d64b51e8b9d8418b97e5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 Aug 2022 19:16:31 +0200 Subject: [PATCH 232/532] fix unittests --- src/fsfw/tmtcpacket/ccsds/PacketId.h | 3 ++ src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h | 3 ++ src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 7 ---- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 6 ++-- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 8 ----- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 6 ++-- src/fsfw/util/UnsignedByteField.h | 35 ++++++++----------- .../devicehandlers/MgmLIS3MDLHandler.cpp | 3 +- .../devicehandlers/MgmRM3100Handler.cpp | 5 +-- unittests/tmtcpacket/testCcsds.cpp | 16 +++++---- unittests/tmtcpacket/testPusTcCreator.cpp | 14 ++++---- unittests/tmtcpacket/testPusTcReader.cpp | 8 ++--- unittests/tmtcpacket/testPusTmCreator.cpp | 12 +++---- unittests/tmtcpacket/testPusTmReader.cpp | 10 +++--- unittests/tmtcpacket/testZcTmWriter.cpp | 4 +-- unittests/util/testUnsignedByteField.cpp | 12 ++++--- 16 files changed, 73 insertions(+), 79 deletions(-) diff --git a/src/fsfw/tmtcpacket/ccsds/PacketId.h b/src/fsfw/tmtcpacket/ccsds/PacketId.h index 2c77652c..518b2d41 100644 --- a/src/fsfw/tmtcpacket/ccsds/PacketId.h +++ b/src/fsfw/tmtcpacket/ccsds/PacketId.h @@ -79,6 +79,9 @@ struct PacketId : public SerializeIF { ccsds::PacketType packetType = ccsds::PacketType::TM; bool secHeaderFlag = false; uint16_t apid = 0; + + using SerializeIF::deSerialize; + using SerializeIF::serialize; }; #endif // FSFW_TMTCPACKET_PACKETID_H diff --git a/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h b/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h index cd4e153e..a1e73460 100644 --- a/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h +++ b/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h @@ -55,6 +55,9 @@ struct PacketSeqCtrl : public SerializeIF { ccsds::SequenceFlags seqFlags = ccsds::SequenceFlags::CONTINUATION; uint16_t seqCount = 0; + + using SerializeIF::deSerialize; + using SerializeIF::serialize; }; #endif // FSFW_TMTCPACKET_PACKETSEQCTRL_H diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 2e786e6e..e1b96945 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -103,13 +103,6 @@ ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF &serializable) { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize) const { - return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); -} - -ReturnValue_t PusTcCreator::serialize(uint8_t *buffer, size_t &serLen, size_t maxSize) const { - return SerializeIF::serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK); -} void PusTcCreator::setup() { spCreator.setPacketType(ccsds::PacketType::TC); spCreator.setSecHeaderFlag(); diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index ea6c1d58..72691c40 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -40,8 +40,6 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF PusTcParams &getPusParams(); SpacePacketParams &getSpParams(); - ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize) const override; - ReturnValue_t serialize(uint8_t *buffer, size_t &serLen, size_t maxSize) const override; [[nodiscard]] size_t getSerializedSize() const override; [[nodiscard]] uint16_t getPacketIdRaw() const override; @@ -55,7 +53,11 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF ReturnValue_t setRawUserData(const uint8_t *data, size_t len) override; ReturnValue_t setSerializableUserData(SerializeIF &serializable) override; + // Load all big endian helpers into the class namespace + using SerializeIF::serializeBe; + private: + // Forbidden to use, enforce big endian serialization ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; // Forbidden to use diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 64dbbfeb..44172de3 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -150,11 +150,3 @@ void PusTmCreator::setSubservice(uint8_t subservice) { pusParams.secHeader.subservice = subservice; } bool PusTmCreator::crcCalculationEnabled() const { return calculateCrcOnSerialization; } - -ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize) const { - return serialize(buffer, size, maxSize, SerializeIF::Endianness::NETWORK); -} - -ReturnValue_t PusTmCreator::serialize(uint8_t* buffer, size_t& serLen, size_t maxSize) const { - return SerializeIF::serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK); -} \ No newline at end of file diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 9f3dcd24..706a7b70 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -82,9 +82,6 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF uint8_t getScTimeRefStatus() override; uint16_t getMessageTypeCounter() override; uint16_t getDestId() override; - // Override these to use default big endianness - ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize) const override; - ReturnValue_t serialize(uint8_t* buffer, size_t& serLen, size_t maxSize) const override; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; @@ -92,6 +89,9 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override; ReturnValue_t setSerializableUserData(SerializeIF& serializable) override; + // Load all big endian (network endian) helpers into scope + using SerializeIF::serializeBe; + private: // Forbidden to use ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, diff --git a/src/fsfw/util/UnsignedByteField.h b/src/fsfw/util/UnsignedByteField.h index b02e8b3a..3f4ee791 100644 --- a/src/fsfw/util/UnsignedByteField.h +++ b/src/fsfw/util/UnsignedByteField.h @@ -3,50 +3,45 @@ #include "fsfw/serialize.h" -template -class UnsignedByteField: public SerializeIF { +template +class UnsignedByteField : public SerializeIF { public: static_assert(std::is_unsigned::value); - explicit UnsignedByteField(T value): value(value) {} + explicit UnsignedByteField(T value) : value(value) {} [[nodiscard]] ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const override { + Endianness streamEndianness) const override { return SerializeAdapter::serialize(&value, buffer, size, maxSize, streamEndianness); } ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, - Endianness streamEndianness) override { + Endianness streamEndianness) override { return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness); } - [[nodiscard]] size_t getSerializedSize() const override { - return sizeof(T); - } + [[nodiscard]] size_t getSerializedSize() const override { return sizeof(T); } - [[nodiscard]] T getValue() const { - return value; - } + [[nodiscard]] T getValue() const { return value; } + + void setValue(T value_) { value = value_; } - void setValue(T value_) { - value = value_; - } private: T value; }; -class U32ByteField: public UnsignedByteField { +class U32ByteField : public UnsignedByteField { public: - explicit U32ByteField(uint32_t value): UnsignedByteField(value) {} + explicit U32ByteField(uint32_t value) : UnsignedByteField(value) {} }; -class U16ByteField: public UnsignedByteField { +class U16ByteField : public UnsignedByteField { public: - explicit U16ByteField(uint16_t value): UnsignedByteField(value) {} + explicit U16ByteField(uint16_t value) : UnsignedByteField(value) {} }; -class U8ByteField: public UnsignedByteField { +class U8ByteField : public UnsignedByteField { public: - explicit U8ByteField(uint8_t value): UnsignedByteField(value) {} + explicit U8ByteField(uint8_t value) : UnsignedByteField(value) {} }; #endif // FSFW_UTIL_UNSIGNEDBYTEFIELD_H diff --git a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index 5ddc3245..28d15e46 100644 --- a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -466,7 +466,8 @@ ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(localpool::DataPool &lo LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTHS, &mgmXYZ); localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, &temperature); - poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 10.0, false); + poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(dataset.getSid(), false, 10.0)); return HasReturnvaluesIF::RETURN_OK; } diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index c329f5a6..e8f61b9f 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -305,12 +305,13 @@ void MgmRM3100Handler::fillCommandAndReplyMap() { insertInCommandAndReplyMap(RM3100::READ_DATA, 3, &primaryDataset); } -void MgmRM3100Handler::modeChanged(void) { internalState = InternalState::NONE; } +void MgmRM3100Handler::modeChanged() { internalState = InternalState::NONE; } ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(RM3100::FIELD_STRENGTHS, &mgmXYZ); - poolManager.subscribeForPeriodicPacket(primaryDataset.getSid(), false, 10.0, false); + poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(primaryDataset.getSid(), false, 10.0)); return HasReturnvaluesIF::RETURN_OK; } diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp index 095020ae..7c88c0c6 100644 --- a/unittests/tmtcpacket/testCcsds.cpp +++ b/unittests/tmtcpacket/testCcsds.cpp @@ -60,9 +60,9 @@ TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { SECTION("Invalid Deser") { size_t deserLen = 0; - REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), deserLen, 1) == + REQUIRE(packetId.deSerialize(buf.data(), deserLen, 1, SerializeIF::Endianness::NETWORK) == SerializeIF::STREAM_TOO_SHORT); - REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), deserLen, 0) == + REQUIRE(packetId.deSerialize(buf.data(), deserLen, 0, SerializeIF::Endianness::NETWORK) == SerializeIF::STREAM_TOO_SHORT); } @@ -77,8 +77,8 @@ TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { buf[0] = 0x1a; buf[1] = 0xff; size_t deserLen = 0xff; - REQUIRE(packetId.SerializeIF::deSerialize(buf.data(), deserLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE(packetId.deSerialize(buf.data(), deserLen, buf.size(), + SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); CHECK(packetId.apid == 0x2ff); CHECK(deserLen == 2); CHECK(packetId.packetType == ccsds::PacketType::TC); @@ -113,7 +113,7 @@ TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") { buf[0] = 0xbf; buf[1] = 0xfe; size_t deserLen = 0xff; - REQUIRE(psc.SerializeIF::deSerialize(buf.data(), deserLen, buf.size()) == + REQUIRE(psc.deSerialize(buf.data(), deserLen, buf.size(), SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); CHECK(psc.seqFlags == ccsds::SequenceFlags::LAST_SEGMENT); CHECK(deserLen == 2); @@ -128,7 +128,9 @@ TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") { SECTION("Invalid Deser") { size_t deserLen = 0; - REQUIRE(psc.SerializeIF::deSerialize(buf.data(), deserLen, 1) == SerializeIF::STREAM_TOO_SHORT); - REQUIRE(psc.SerializeIF::deSerialize(buf.data(), deserLen, 0) == SerializeIF::STREAM_TOO_SHORT); + REQUIRE(psc.deSerialize(buf.data(), deserLen, 1, SerializeIF::Endianness::NETWORK) == + SerializeIF::STREAM_TOO_SHORT); + REQUIRE(psc.deSerialize(buf.data(), deserLen, 0, SerializeIF::Endianness::NETWORK) == + SerializeIF::STREAM_TOO_SHORT); } } diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index 5bc349a6..5aed24a0 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -34,7 +34,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { } SECTION("Serialized") { - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(serLen == 13); REQUIRE(buf[0] == 0x18); REQUIRE(buf[1] == 0x02); @@ -64,7 +64,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { auto& params = creator.getPusParams(); params.sourceId = 0x5ff; REQUIRE(creator.getSourceId() == 0x5ff); - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(((buf[9] << 8) | buf[10]) == 0x5ff); } @@ -76,7 +76,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { REQUIRE(creator.getSerializedSize() == 13); creator.updateSpLengthField(); REQUIRE(creator.getSerializedSize() == 16); - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(serLen == 16); REQUIRE(buf[11] == 1); REQUIRE(buf[12] == 2); @@ -88,7 +88,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { auto simpleSer = SimpleSerializable(); creator.setSerializableUserData(simpleSer); REQUIRE(creator.getSerializedSize() == 16); - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(serLen == 16); REQUIRE(buf[11] == 1); REQUIRE(buf[12] == 2); @@ -100,7 +100,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { auto simpleSer = SimpleSerializable(); creator.setSerializableUserData(simpleSer); REQUIRE(creator.getSerializedSize() == 16); - REQUIRE(creator.serialize(dataPtr, serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(serLen == 16); REQUIRE(buf[11] == 1); REQUIRE(buf[12] == 2); @@ -120,13 +120,13 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { for (size_t maxSize = 0; maxSize < reqSize; maxSize++) { dataPtr = buf.data(); serLen = 0; - REQUIRE(creator.serialize(&dataPtr, &serLen, maxSize) == SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, maxSize) == SerializeIF::BUFFER_TOO_SHORT); } } SECTION("Invalid PUS Version") { auto& params = creator.getPusParams(); params.pusVersion = 0; - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == PusIF::INVALID_PUS_VERSION); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == PusIF::INVALID_PUS_VERSION); } } \ No newline at end of file diff --git a/unittests/tmtcpacket/testPusTcReader.cpp b/unittests/tmtcpacket/testPusTcReader.cpp index 3245218a..1c3469f2 100644 --- a/unittests/tmtcpacket/testPusTcReader.cpp +++ b/unittests/tmtcpacket/testPusTcReader.cpp @@ -16,7 +16,7 @@ TEST_CASE("PUS TC Reader", "[pus-tc-reader]") { PusTcReader reader; SECTION("State") { - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.isNull()); REQUIRE(not reader); PusTcReader* readerPtr = nullptr; @@ -55,14 +55,14 @@ TEST_CASE("PUS TC Reader", "[pus-tc-reader]") { } SECTION("Invalid CRC") { - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); buf[11] = 0x00; REQUIRE(reader.parseDataWithCrcCheck() == PusIF::INVALID_CRC_16); } SECTION("Invalid CRC but no check") { - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); buf[11] = 0x00; REQUIRE(reader.parseDataWithoutCrcCheck() == HasReturnvaluesIF::RETURN_OK); @@ -72,7 +72,7 @@ TEST_CASE("PUS TC Reader", "[pus-tc-reader]") { auto& params = creator.getPusParams(); std::array data{1, 2, 3}; creator.setRawUserData(data.data(), data.size()); - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); const uint8_t* userDataPtr = reader.getUserData(); diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index f32e060f..4c958911 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -90,7 +90,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { REQUIRE(creator.getApid() == 0x3ff); REQUIRE(creator.getDestId() == 0xfff); REQUIRE(creator.getMessageTypeCounter() == 0x313); - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); // Message Sequence Count REQUIRE(((buf[9] << 8) | buf[10]) == 0x313); // Destination ID @@ -108,8 +108,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { std::array data{1, 2, 3}; creator.setRawUserData(data.data(), data.size()); REQUIRE(creator.getFullPacketLen() == 25); - REQUIRE(creator.SerializeIF::serialize(&dataPtr, &serLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[20] == 1); REQUIRE(buf[21] == 2); REQUIRE(buf[22] == 3); @@ -119,7 +118,8 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { auto simpleSer = SimpleSerializable(); creator.setSerializableUserData(simpleSer); REQUIRE(creator.getFullPacketLen() == 25); - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size(), SerializeIF::Endianness::NETWORK) == + HasReturnvaluesIF::RETURN_OK); REQUIRE(buf[20] == 1); REQUIRE(buf[21] == 2); REQUIRE(buf[22] == 3); @@ -143,7 +143,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { for (size_t maxSize = 0; maxSize < reqSize; maxSize++) { dataPtr = buf.data(); serLen = 0; - REQUIRE(creator.SerializeIF::serialize(&dataPtr, &serLen, maxSize) == + REQUIRE(creator.serialize(&dataPtr, &serLen, maxSize, SerializeIF::Endianness::NETWORK) == SerializeIF::BUFFER_TOO_SHORT); } } @@ -151,7 +151,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { SECTION("No CRC Generation") { creator.disableCrcCalculation(); REQUIRE(not creator.crcCalculationEnabled()); - REQUIRE(creator.serialize(dataPtr, serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(serLen == 22); REQUIRE(buf[20] == 0x00); REQUIRE(buf[21] == 0x00); diff --git a/unittests/tmtcpacket/testPusTmReader.cpp b/unittests/tmtcpacket/testPusTmReader.cpp index 7967dba6..67659442 100644 --- a/unittests/tmtcpacket/testPusTmReader.cpp +++ b/unittests/tmtcpacket/testPusTmReader.cpp @@ -62,7 +62,7 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { } SECTION("Invalid CRC") { - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); buf[20] = 0; REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.parseDataWithCrcCheck() == PusIF::INVALID_CRC_16); @@ -74,7 +74,7 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { } SECTION("Invalid CRC ignored") { - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); buf[20] = 0; REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.parseDataWithoutCrcCheck() == HasReturnvaluesIF::RETURN_OK); @@ -83,7 +83,7 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { SECTION("Read with source data") { std::array data{1, 2, 3}; creator.setRawUserData(data.data(), data.size()); - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.getUserDataLen() == 3); @@ -94,7 +94,7 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { } SECTION("Invalid stream lengths") { - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); for (size_t i = 0; i < serLen - 1; i++) { REQUIRE(reader.setReadOnlyData(buf.data(), i) == SerializeIF::STREAM_TOO_SHORT); } @@ -102,7 +102,7 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { SECTION("Reading timestamp fails") { timeStamperAndReader.nextDeserFails = true; - REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_FAILED); } diff --git a/unittests/tmtcpacket/testZcTmWriter.cpp b/unittests/tmtcpacket/testZcTmWriter.cpp index fc013590..da596250 100644 --- a/unittests/tmtcpacket/testZcTmWriter.cpp +++ b/unittests/tmtcpacket/testZcTmWriter.cpp @@ -18,7 +18,7 @@ TEST_CASE("TM ZC Helper", "[tm-zc-helper]") { size_t serLen = 0; SECTION("No Crash For Uninitialized Object") { - REQUIRE(creator.serialize(dataPtr, serLen, buf.size()) == result::OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == result::OK); PusTmZeroCopyWriter writer(timeStamper, dataPtr, serLen); REQUIRE(writer.getSequenceCount() == 22); writer.setSequenceCount(23); @@ -28,7 +28,7 @@ TEST_CASE("TM ZC Helper", "[tm-zc-helper]") { } SECTION("Basic") { - REQUIRE(creator.serialize(dataPtr, serLen, buf.size()) == result::OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == result::OK); PusTmZeroCopyWriter writer(timeStamper, dataPtr, serLen); REQUIRE(writer.parseDataWithoutCrcCheck() == result::OK); REQUIRE(writer.getSequenceCount() == 22); diff --git a/unittests/util/testUnsignedByteField.cpp b/unittests/util/testUnsignedByteField.cpp index 9a67c092..83ffd3c6 100644 --- a/unittests/util/testUnsignedByteField.cpp +++ b/unittests/util/testUnsignedByteField.cpp @@ -1,10 +1,9 @@ +#include #include #include "fsfw/util/UnsignedByteField.h" -#include - TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { auto testByteField = UnsignedByteField(10); auto u32ByteField = U32ByteField(10); @@ -28,7 +27,8 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { } SECTION("Serialize U32") { - CHECK(testByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(testByteField.serializeBe(buf.data(), serLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); CHECK(serLen == 4); CHECK(buf[0] == 0); CHECK(buf[3] == 10); @@ -60,7 +60,8 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { buf[2] = 0x30; buf[3] = 0x20; size_t deserLen = 0; - CHECK(testByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(testByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); CHECK(testByteField.getValue() == 0x50403020); } @@ -68,7 +69,8 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { buf[0] = 0x50; buf[1] = 0x40; size_t deserLen = 0; - CHECK(u16ByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(u16ByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == + HasReturnvaluesIF::RETURN_OK); CHECK(u16ByteField.getValue() == 0x5040); } } \ No newline at end of file From 62fe75ee40b52e708dce907153226f9f014e2c4d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 Aug 2022 20:28:16 +0200 Subject: [PATCH 233/532] perform renaming --- .../PollingSequenceFactory.cpp | 2 +- src/fsfw/action/ActionHelper.cpp | 24 +-- src/fsfw/action/ActionHelper.h | 6 +- src/fsfw/action/ActionMessage.cpp | 2 +- src/fsfw/action/ActionMessage.h | 4 +- src/fsfw/action/CommandActionHelper.cpp | 30 ++-- src/fsfw/action/SimpleActionHelper.cpp | 8 +- src/fsfw/action/SimpleActionHelper.h | 4 +- src/fsfw/cfdp/CFDPHandler.cpp | 12 +- src/fsfw/cfdp/CFDPHandler.h | 3 +- src/fsfw/cfdp/FileSize.h | 6 +- src/fsfw/cfdp/definitions.h | 18 +- src/fsfw/cfdp/pdu/AckPduDeserializer.cpp | 4 +- src/fsfw/cfdp/pdu/AckPduSerializer.cpp | 6 +- src/fsfw/cfdp/pdu/EofPduDeserializer.cpp | 8 +- src/fsfw/cfdp/pdu/EofPduSerializer.cpp | 4 +- src/fsfw/cfdp/pdu/FileDataDeserializer.cpp | 6 +- src/fsfw/cfdp/pdu/FileDataInfo.cpp | 4 +- src/fsfw/cfdp/pdu/FileDataSerializer.cpp | 6 +- .../cfdp/pdu/FileDirectiveDeserializer.cpp | 4 +- src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp | 6 +- src/fsfw/cfdp/pdu/FinishedInfo.cpp | 10 +- src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp | 10 +- src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp | 6 +- src/fsfw/cfdp/pdu/HeaderDeserializer.cpp | 4 +- src/fsfw/cfdp/pdu/HeaderDeserializer.h | 4 +- src/fsfw/cfdp/pdu/HeaderSerializer.cpp | 12 +- .../cfdp/pdu/KeepAlivePduDeserializer.cpp | 2 +- src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp | 2 +- src/fsfw/cfdp/pdu/MetadataInfo.cpp | 4 +- src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp | 10 +- src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp | 10 +- src/fsfw/cfdp/pdu/NakPduDeserializer.cpp | 10 +- src/fsfw/cfdp/pdu/NakPduSerializer.cpp | 10 +- src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp | 4 +- src/fsfw/cfdp/pdu/PromptPduSerializer.cpp | 2 +- src/fsfw/cfdp/pdu/VarLenField.cpp | 18 +- src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp | 6 +- src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp | 12 +- src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp | 12 +- src/fsfw/cfdp/tlv/FilestoreTlvBase.h | 10 +- src/fsfw/cfdp/tlv/Lv.cpp | 10 +- src/fsfw/cfdp/tlv/Tlv.cpp | 12 +- src/fsfw/container/ArrayList.h | 2 +- src/fsfw/container/FIFOBase.tpp | 10 +- src/fsfw/container/FixedMap.h | 20 +-- src/fsfw/container/FixedOrderedMultimap.h | 2 +- src/fsfw/container/FixedOrderedMultimap.tpp | 12 +- src/fsfw/container/IndexedRingMemoryArray.h | 44 ++--- src/fsfw/container/PlacementFactory.h | 4 +- src/fsfw/container/RingBufferBase.h | 8 +- src/fsfw/container/SimpleRingBuffer.cpp | 22 +-- src/fsfw/container/SimpleRingBuffer.h | 4 +- src/fsfw/controller/ControllerBase.cpp | 24 +-- src/fsfw/controller/ControllerBase.h | 3 +- .../controller/ExtendedControllerBase.cpp | 22 +-- src/fsfw/coordinates/Sgp4Propagator.cpp | 4 +- src/fsfw/datalinklayer/DataLinkLayer.cpp | 22 +-- src/fsfw/datalinklayer/DataLinkLayer.h | 2 +- src/fsfw/datalinklayer/Farm1StateOpen.cpp | 2 +- .../datalinklayer/MapPacketExtraction.cpp | 12 +- src/fsfw/datalinklayer/MapPacketExtraction.h | 2 +- .../datalinklayer/VirtualChannelReception.cpp | 18 +- .../datalinklayer/VirtualChannelReception.h | 4 +- src/fsfw/datapool/PoolDataSetBase.cpp | 32 ++-- src/fsfw/datapool/PoolDataSetBase.h | 6 +- src/fsfw/datapool/PoolReadGuard.h | 4 +- src/fsfw/datapool/ReadCommitIFAttorney.h | 4 +- src/fsfw/datapoollocal/HasLocalDataPoolIF.h | 6 +- .../datapoollocal/LocalDataPoolManager.cpp | 96 +++++------ src/fsfw/datapoollocal/LocalDataPoolManager.h | 6 +- .../datapoollocal/LocalPoolDataSetBase.cpp | 16 +- src/fsfw/datapoollocal/LocalPoolObjectBase.h | 2 +- src/fsfw/datapoollocal/LocalPoolVariable.tpp | 12 +- src/fsfw/datapoollocal/LocalPoolVector.tpp | 16 +- src/fsfw/datapoollocal/SharedLocalDataSet.cpp | 4 +- src/fsfw/devicehandlers/AssemblyBase.cpp | 24 +-- src/fsfw/devicehandlers/AssemblyBase.h | 2 +- src/fsfw/devicehandlers/ChildHandlerBase.cpp | 6 +- .../devicehandlers/DeviceCommunicationIF.h | 2 +- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 158 +++++++++--------- src/fsfw/devicehandlers/DeviceHandlerBase.h | 23 ++- .../DeviceHandlerFailureIsolation.cpp | 16 +- .../DeviceTmReportingWrapper.cpp | 8 +- src/fsfw/devicehandlers/HealthDevice.cpp | 6 +- src/fsfw/events/EventManager.cpp | 12 +- .../events/eventmatching/EventMatchTree.cpp | 10 +- .../events/eventmatching/EventMatchTree.h | 2 +- src/fsfw/fdir/FailureIsolationBase.cpp | 14 +- src/fsfw/fdir/FailureIsolationBase.h | 3 +- src/fsfw/fdir/FaultCounter.cpp | 2 +- src/fsfw/globalfunctions/AsciiConverter.cpp | 10 +- src/fsfw/globalfunctions/AsciiConverter.h | 2 +- src/fsfw/globalfunctions/DleEncoder.cpp | 8 +- src/fsfw/globalfunctions/DleEncoder.h | 2 +- src/fsfw/globalfunctions/Type.cpp | 14 +- src/fsfw/globalfunctions/matching/MatchTree.h | 28 ++-- .../globalfunctions/matching/RangeMatcher.h | 8 +- src/fsfw/health/HealthHelper.cpp | 16 +- src/fsfw/health/HealthHelper.h | 4 +- src/fsfw/health/HealthTable.cpp | 18 +- src/fsfw/housekeeping/HousekeepingSetPacket.h | 4 +- src/fsfw/housekeeping/HousekeepingSnapshot.h | 4 +- .../internalerror/InternalErrorReporter.cpp | 8 +- src/fsfw/ipc/MutexGuard.h | 4 +- src/fsfw/memory/GenericFileSystemMessage.cpp | 4 +- src/fsfw/memory/HasMemoryIF.h | 4 +- src/fsfw/memory/MemoryHelper.cpp | 22 +-- src/fsfw/memory/MemoryHelper.h | 2 +- src/fsfw/modes/HasModesIF.h | 2 +- src/fsfw/modes/ModeHelper.cpp | 8 +- src/fsfw/monitoring/AbsLimitMonitor.h | 4 +- src/fsfw/monitoring/LimitMonitor.h | 4 +- .../monitoring/LimitViolationReporter.cpp | 10 +- src/fsfw/monitoring/MonitorBase.h | 6 +- src/fsfw/monitoring/MonitorReporter.h | 6 +- src/fsfw/monitoring/TriplexMonitor.h | 14 +- src/fsfw/monitoring/TwoValueLimitMonitor.h | 2 +- src/fsfw/objectmanager/ObjectManager.cpp | 10 +- src/fsfw/objectmanager/ObjectManagerIF.h | 2 +- src/fsfw/objectmanager/SystemObject.cpp | 4 +- src/fsfw/objectmanager/SystemObjectIF.h | 2 +- src/fsfw/osal/common/TcpIpBase.cpp | 4 +- src/fsfw/osal/common/TcpTmTcBridge.cpp | 14 +- src/fsfw/osal/common/TcpTmTcServer.cpp | 34 ++-- src/fsfw/osal/common/TcpTmTcServer.h | 2 +- src/fsfw/osal/common/UdpTcPollingTask.cpp | 14 +- src/fsfw/osal/common/UdpTmTcBridge.cpp | 14 +- src/fsfw/osal/freertos/BinSemaphUsingTask.cpp | 8 +- src/fsfw/osal/freertos/BinSemaphUsingTask.h | 6 +- src/fsfw/osal/freertos/BinarySemaphore.cpp | 6 +- src/fsfw/osal/freertos/Clock.cpp | 22 +-- .../osal/freertos/CountingSemaphUsingTask.cpp | 8 +- src/fsfw/osal/freertos/FixedTimeslotTask.cpp | 4 +- src/fsfw/osal/freertos/MessageQueue.cpp | 6 +- src/fsfw/osal/freertos/Mutex.cpp | 4 +- src/fsfw/osal/freertos/PeriodicTask.cpp | 4 +- src/fsfw/osal/freertos/QueueMapManager.cpp | 4 +- src/fsfw/osal/freertos/TaskFactory.cpp | 6 +- src/fsfw/osal/host/Clock.cpp | 28 ++-- src/fsfw/osal/host/FixedTimeslotTask.cpp | 4 +- src/fsfw/osal/host/MessageQueue.cpp | 12 +- src/fsfw/osal/host/Mutex.cpp | 8 +- src/fsfw/osal/host/PeriodicTask.cpp | 4 +- src/fsfw/osal/host/QueueFactory.cpp | 2 +- src/fsfw/osal/host/QueueMapManager.cpp | 4 +- src/fsfw/osal/host/TaskFactory.cpp | 4 +- src/fsfw/osal/host/taskHelpers.cpp | 4 +- src/fsfw/osal/linux/BinarySemaphore.cpp | 18 +- src/fsfw/osal/linux/Clock.cpp | 36 ++-- src/fsfw/osal/linux/CountingSemaphore.cpp | 6 +- src/fsfw/osal/linux/FixedTimeslotTask.cpp | 2 +- src/fsfw/osal/linux/InternalErrorCodes.cpp | 2 +- src/fsfw/osal/linux/MessageQueue.cpp | 34 ++-- src/fsfw/osal/linux/Mutex.cpp | 8 +- src/fsfw/osal/linux/PeriodicPosixTask.cpp | 4 +- src/fsfw/osal/linux/PosixThread.cpp | 8 +- src/fsfw/osal/linux/TaskFactory.cpp | 2 +- src/fsfw/osal/rtems/BinarySemaphore.cpp | 4 +- src/fsfw/osal/rtems/Clock.cpp | 42 ++--- src/fsfw/osal/rtems/CpuUsage.cpp | 20 +-- src/fsfw/osal/rtems/FixedTimeslotTask.cpp | 4 +- src/fsfw/osal/rtems/InternalErrorCodes.cpp | 2 +- src/fsfw/osal/rtems/MessageQueue.cpp | 18 +- src/fsfw/osal/rtems/Mutex.cpp | 8 +- src/fsfw/osal/rtems/PeriodicTask.cpp | 4 +- src/fsfw/osal/rtems/QueueFactory.cpp | 12 +- src/fsfw/osal/rtems/RTEMSTaskBase.cpp | 18 +- src/fsfw/osal/rtems/TaskFactory.cpp | 4 +- src/fsfw/osal/windows/winTaskHelpers.cpp | 6 +- src/fsfw/parameters/ParameterHelper.cpp | 28 ++-- src/fsfw/parameters/ParameterWrapper.cpp | 28 ++-- src/fsfw/parameters/ParameterWrapper.h | 2 +- src/fsfw/power/DummyPowerSwitcher.cpp | 8 +- src/fsfw/power/Fuse.cpp | 38 ++--- src/fsfw/power/Fuse.h | 1 - src/fsfw/power/PowerComponent.cpp | 6 +- src/fsfw/power/PowerSensor.cpp | 22 +-- src/fsfw/power/PowerSwitchIF.h | 6 +- src/fsfw/power/PowerSwitcher.cpp | 10 +- src/fsfw/power/PowerSwitcher.h | 2 +- src/fsfw/power/PowerSwitcherComponent.cpp | 16 +- src/fsfw/power/PowerSwitcherComponent.h | 1 - src/fsfw/pus/CService200ModeCommanding.cpp | 18 +- src/fsfw/pus/CService201HealthCommanding.cpp | 10 +- .../pus/Service11TelecommandScheduling.tpp | 82 ++++----- src/fsfw/pus/Service17Test.cpp | 6 +- .../pus/Service1TelecommandVerification.cpp | 8 +- .../pus/Service1TelecommandVerification.h | 3 +- src/fsfw/pus/Service20ParameterManagement.cpp | 28 ++-- src/fsfw/pus/Service2DeviceAccess.cpp | 10 +- src/fsfw/pus/Service3Housekeeping.cpp | 36 ++-- src/fsfw/pus/Service5EventReporting.cpp | 18 +- src/fsfw/pus/Service8FunctionManagement.cpp | 14 +- src/fsfw/pus/Service9TimeManagement.cpp | 10 +- src/fsfw/pus/servicepackets/Service1Packets.h | 20 +-- src/fsfw/pus/servicepackets/Service5Packets.h | 10 +- src/fsfw/returnvalues/HasReturnvaluesIF.h | 38 ++--- src/fsfw/rmap/RmapDeviceCommunicationIF.cpp | 4 +- src/fsfw/serialize/SerialArrayListAdapter.h | 6 +- src/fsfw/serialize/SerialBufferAdapter.cpp | 12 +- src/fsfw/serialize/SerialLinkedListAdapter.h | 10 +- src/fsfw/serialize/SerializeAdapter.h | 16 +- src/fsfw/serialize/SerializeIF.h | 4 +- .../storagemanager/ConstStorageAccessor.cpp | 6 +- src/fsfw/storagemanager/LocalPool.cpp | 26 +-- src/fsfw/storagemanager/StorageAccessor.cpp | 12 +- src/fsfw/storagemanager/StorageManagerIF.h | 10 +- src/fsfw/subsystem/Subsystem.cpp | 80 ++++----- src/fsfw/subsystem/SubsystemBase.cpp | 50 +++--- src/fsfw/subsystem/SubsystemBase.h | 1 - src/fsfw/subsystem/modes/ModeDefinitions.h | 12 +- src/fsfw/subsystem/modes/ModeStore.cpp | 12 +- src/fsfw/tasks/ExecutableObjectIF.h | 2 +- src/fsfw/tasks/FixedSlotSequence.cpp | 12 +- src/fsfw/tasks/FixedTimeslotTaskBase.cpp | 4 +- src/fsfw/tasks/FixedTimeslotTaskIF.h | 6 +- src/fsfw/tasks/PeriodicTaskBase.cpp | 8 +- src/fsfw/tasks/PeriodicTaskIF.h | 4 +- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 16 +- src/fsfw/tcdistribution/CCSDSDistributorIF.h | 4 +- src/fsfw/tcdistribution/CFDPDistributor.cpp | 12 +- src/fsfw/tcdistribution/CFDPDistributorIF.h | 2 +- src/fsfw/tcdistribution/PUSDistributor.cpp | 18 +- src/fsfw/tcdistribution/PUSDistributorIF.h | 2 +- src/fsfw/tcdistribution/TcDistributor.cpp | 10 +- src/fsfw/tcdistribution/TcDistributor.h | 6 +- src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp | 2 +- src/fsfw/tcdistribution/TcPacketCheckCFDP.h | 2 +- src/fsfw/tcdistribution/TcPacketCheckPUS.cpp | 4 +- src/fsfw/tcdistribution/TcPacketCheckPUS.h | 2 +- .../thermal/AbstractTemperatureSensor.cpp | 16 +- src/fsfw/thermal/Heater.cpp | 36 ++-- src/fsfw/thermal/RedundantHeater.cpp | 2 +- src/fsfw/thermal/TemperatureSensor.h | 4 +- src/fsfw/thermal/ThermalComponent.cpp | 10 +- src/fsfw/thermal/ThermalComponentCore.cpp | 8 +- src/fsfw/thermal/ThermalModule.cpp | 2 +- src/fsfw/thermal/ThermalMonitorReporter.cpp | 8 +- src/fsfw/timemanager/CCSDSTime.cpp | 74 ++++---- src/fsfw/timemanager/CCSDSTime.h | 2 +- src/fsfw/timemanager/Clock.h | 6 +- src/fsfw/timemanager/ClockCommon.cpp | 28 ++-- src/fsfw/timemanager/TimeStamper.cpp | 4 +- src/fsfw/tmstorage/TmStoreMessage.cpp | 16 +- src/fsfw/tmstorage/TmStorePackets.h | 30 ++-- .../tmtcpacket/RedirectableDataPointerIF.h | 2 +- src/fsfw/tmtcpacket/SpacePacketBase.cpp | 8 +- src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp | 14 +- .../packetmatcher/PacketMatchTree.cpp | 18 +- .../packetmatcher/PacketMatchTree.h | 2 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp | 6 +- .../tmtcpacket/pus/tc/TcPacketStoredBase.cpp | 6 +- .../tmtcpacket/pus/tc/TcPacketStoredPus.cpp | 6 +- .../tmtcpacket/pus/tm/TmPacketMinimal.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp | 10 +- .../tmtcpacket/pus/tm/TmPacketStoredBase.cpp | 8 +- .../tmtcpacket/pus/tm/TmPacketStoredPusA.cpp | 4 +- .../tmtcpacket/pus/tm/TmPacketStoredPusC.cpp | 4 +- .../tmtcservices/CommandingServiceBase.cpp | 48 +++--- src/fsfw/tmtcservices/CommandingServiceBase.h | 11 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 20 +-- src/fsfw/tmtcservices/PusServiceBase.h | 5 +- src/fsfw/tmtcservices/SpacePacketParser.cpp | 4 +- src/fsfw/tmtcservices/TmTcBridge.cpp | 42 ++--- src/fsfw/tmtcservices/TmTcBridge.h | 5 +- .../tmtcservices/VerificationReporter.cpp | 8 +- src/fsfw_hal/common/gpio/GpioCookie.cpp | 8 +- src/fsfw_hal/common/gpio/GpioIF.h | 4 +- .../devicehandlers/GyroL3GD20Handler.cpp | 14 +- .../devicehandlers/MgmLIS3MDLHandler.cpp | 26 +-- .../devicehandlers/MgmRM3100Handler.cpp | 22 +-- src/fsfw_hal/linux/CommandExecutor.cpp | 20 +-- src/fsfw_hal/linux/CommandExecutor.h | 16 +- src/fsfw_hal/linux/UnixFileGuard.h | 2 +- src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp | 48 +++--- src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h | 2 +- src/fsfw_hal/linux/i2c/I2cComIF.cpp | 42 ++--- src/fsfw_hal/linux/i2c/I2cComIF.h | 2 +- src/fsfw_hal/linux/rpi/GpioRPi.cpp | 6 +- src/fsfw_hal/linux/spi/SpiComIF.cpp | 46 ++--- src/fsfw_hal/linux/uart/UartComIF.cpp | 52 +++--- src/fsfw_hal/linux/uio/UioMapper.cpp | 18 +- .../stm32h7/devicetest/GyroL3GD20H.cpp | 70 ++++---- src/fsfw_hal/stm32h7/spi/SpiComIF.cpp | 52 +++--- .../integration/assemblies/TestAssembly.cpp | 18 +- .../integration/controller/TestController.cpp | 6 +- .../integration/devices/TestDeviceHandler.cpp | 52 +++--- .../integration/devices/TestEchoComIF.cpp | 14 +- src/fsfw_tests/integration/task/TestTask.cpp | 10 +- .../internal/InternalUnitTester.cpp | 2 +- src/fsfw_tests/internal/InternalUnitTester.h | 2 +- src/fsfw_tests/internal/UnittDefinitions.cpp | 2 +- src/fsfw_tests/internal/osal/testMq.cpp | 8 +- src/fsfw_tests/internal/osal/testMutex.cpp | 4 +- .../internal/osal/testSemaphore.cpp | 10 +- .../serialize/IntTestSerialization.cpp | 14 +- unittests/action/TestActionHelper.cpp | 18 +- unittests/action/TestActionHelper.h | 2 +- unittests/cfdp/testAckPdu.cpp | 14 +- unittests/cfdp/testCfdp.cpp | 42 ++--- unittests/cfdp/testEofPdu.cpp | 18 +- unittests/cfdp/testFileData.cpp | 20 +-- unittests/cfdp/testFinishedPdu.cpp | 24 +-- unittests/cfdp/testKeepAlivePdu.cpp | 18 +- unittests/cfdp/testMetadataPdu.cpp | 20 +-- unittests/cfdp/testNakPdu.cpp | 30 ++-- unittests/cfdp/testPromptPdu.cpp | 14 +- unittests/cfdp/testTlvsLvs.cpp | 66 ++++---- unittests/container/RingBufferTest.cpp | 148 ++++++++-------- unittests/container/TestArrayList.cpp | 8 +- unittests/container/TestDynamicFifo.cpp | 46 ++--- unittests/container/TestFifo.cpp | 40 ++--- unittests/container/TestFixedArrayList.cpp | 4 +- unittests/container/TestFixedMap.cpp | 32 ++-- .../container/TestFixedOrderedMultimap.cpp | 36 ++-- unittests/container/TestPlacementFactory.cpp | 8 +- unittests/datapoollocal/DataSetTest.cpp | 44 ++--- .../datapoollocal/LocalPoolManagerTest.cpp | 144 ++++++++-------- .../datapoollocal/LocalPoolOwnerBase.cpp | 14 +- .../datapoollocal/LocalPoolVariableTest.cpp | 20 +-- .../datapoollocal/LocalPoolVectorTest.cpp | 16 +- unittests/devicehandler/ComIFMock.cpp | 12 +- .../devicehandler/DeviceHandlerCommander.cpp | 16 +- .../devicehandler/DeviceHandlerCommander.h | 5 +- unittests/devicehandler/DeviceHandlerMock.cpp | 10 +- .../devicehandler/TestDeviceHandlerBase.cpp | 10 +- unittests/globalfunctions/testDleEncoder.cpp | 6 +- unittests/hal/testCommandExecutor.cpp | 18 +- .../TestInternalErrorReporter.cpp | 16 +- unittests/mocks/MessageQueueMockBase.h | 6 +- unittests/mocks/PeriodicTaskIFMock.h | 4 +- unittests/mocks/PowerSwitcherMock.cpp | 8 +- unittests/osal/TestClock.cpp | 24 +-- unittests/osal/TestMessageQueue.cpp | 16 +- unittests/power/testPowerSwitcher.cpp | 2 +- .../serialize/testSerialBufferAdapter.cpp | 2 +- .../serialize/testSerialLinkedPacket.cpp | 4 +- unittests/serialize/testSerializeIF.cpp | 32 ++-- unittests/storagemanager/TestNewAccessor.cpp | 52 +++--- unittests/storagemanager/TestPool.cpp | 58 +++---- .../PollingSequenceFactory.cpp | 6 +- unittests/timemanager/TestCCSDSTime.cpp | 24 +-- unittests/timemanager/TestCountdown.cpp | 4 +- 345 files changed, 2451 insertions(+), 2473 deletions(-) diff --git a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp index b7f1fb3e..c8baaf34 100644 --- a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp +++ b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp @@ -19,7 +19,7 @@ ReturnValue_t pst::pollingSequenceInitDefault( sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::returnvalue::FAILED; } } diff --git a/src/fsfw/action/ActionHelper.cpp b/src/fsfw/action/ActionHelper.cpp index bee68b40..fd6c8afb 100644 --- a/src/fsfw/action/ActionHelper.cpp +++ b/src/fsfw/action/ActionHelper.cpp @@ -12,7 +12,7 @@ ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) { if (command->getCommand() == ActionMessage::EXECUTE_ACTION) { ActionId_t currentAction = ActionMessage::getActionId(command); prepareExecution(command->getSender(), currentAction, ActionMessage::getStoreId(command)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return CommandMessage::UNKNOWN_COMMAND; } @@ -21,7 +21,7 @@ ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) { ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) { ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (queueToUse_ != nullptr) { setQueueToUse(queueToUse_); @@ -35,10 +35,10 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) { sif::printWarning("ActionHelper::initialize: No queue set\n"); #endif #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void ActionHelper::step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, @@ -62,7 +62,7 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act const uint8_t* dataPtr = nullptr; size_t size = 0; ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { CommandMessage reply; ActionMessage::setStepReply(&reply, actionId, 0, result); queueToUse->sendMessage(commandedBy, &reply); @@ -75,7 +75,7 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act ActionMessage::setCompletionReply(&reply, actionId, true, result); queueToUse->sendMessage(commandedBy, &reply); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { CommandMessage reply; ActionMessage::setStepReply(&reply, actionId, 0, result); queueToUse->sendMessage(commandedBy, &reply); @@ -91,11 +91,11 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep size_t maxSize = data->getSerializedSize(); if (maxSize == 0) { /* No error, there's simply nothing to report. */ - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t size = 0; ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, maxSize, &dataPtr); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "ActionHelper::reportData: Getting free element from IPC store failed!" << std::endl; @@ -107,7 +107,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep return result; } result = data->serialize(&dataPtr, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeAddress); return result; } @@ -124,7 +124,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep result = queueToUse->sendMessage(reportTo, &reply); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeAddress); } return result; @@ -137,7 +137,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep CommandMessage reply; store_address_t storeAddress; ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "ActionHelper::reportData: Adding data to IPC store failed!" << std::endl; #else @@ -158,7 +158,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep result = queueToUse->sendMessage(reportTo, &reply); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeAddress); } return result; diff --git a/src/fsfw/action/ActionHelper.h b/src/fsfw/action/ActionHelper.h index a9910b05..16abb212 100644 --- a/src/fsfw/action/ActionHelper.h +++ b/src/fsfw/action/ActionHelper.h @@ -36,7 +36,7 @@ class ActionHelper { * send to the sender of the message automatically. * * @param command Pointer to a command message received by the owner - * @return HasReturnvaluesIF::RETURN_OK if the message is a action message, + * @return returnvalue::OK if the message is a action message, * CommandMessage::UNKNOW_COMMAND if this message ID is unkown */ ReturnValue_t handleActionMessage(CommandMessage* command); @@ -58,7 +58,7 @@ class ActionHelper { * @param result Result of the execution */ void step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + ReturnValue_t result = returnvalue::OK); /** * Function to be called by the owner to send a action completion message * @param success Specify whether action was completed successfully or not. @@ -67,7 +67,7 @@ class ActionHelper { * @param result Result of the execution */ void finish(bool success, MessageQueueId_t reportTo, ActionId_t commandId, - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + ReturnValue_t result = returnvalue::OK); /** * Function to be called by the owner if an action does report data. * Takes a SerializeIF* pointer and serializes it into the IPC store. diff --git a/src/fsfw/action/ActionMessage.cpp b/src/fsfw/action/ActionMessage.cpp index 7fc68558..33088055 100644 --- a/src/fsfw/action/ActionMessage.cpp +++ b/src/fsfw/action/ActionMessage.cpp @@ -25,7 +25,7 @@ store_address_t ActionMessage::getStoreId(const CommandMessage* message) { void ActionMessage::setStepReply(CommandMessage* message, ActionId_t fid, uint8_t step, ReturnValue_t result) { - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { message->setCommand(STEP_SUCCESS); } else { message->setCommand(STEP_FAILED); diff --git a/src/fsfw/action/ActionMessage.h b/src/fsfw/action/ActionMessage.h index bd12cc19..38e3aa99 100644 --- a/src/fsfw/action/ActionMessage.h +++ b/src/fsfw/action/ActionMessage.h @@ -33,12 +33,12 @@ class ActionMessage { static store_address_t getStoreId(const CommandMessage* message); static void setStepReply(CommandMessage* message, ActionId_t fid, uint8_t step, - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + ReturnValue_t result = returnvalue::OK); static uint8_t getStep(const CommandMessage* message); static ReturnValue_t getReturnCode(const CommandMessage* message); static void setDataReply(CommandMessage* message, ActionId_t actionId, store_address_t data); static void setCompletionReply(CommandMessage* message, ActionId_t fid, bool success, - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + ReturnValue_t result = returnvalue::OK); static void clear(CommandMessage* message); }; diff --git a/src/fsfw/action/CommandActionHelper.cpp b/src/fsfw/action/CommandActionHelper.cpp index a06bc44c..831cd862 100644 --- a/src/fsfw/action/CommandActionHelper.cpp +++ b/src/fsfw/action/CommandActionHelper.cpp @@ -16,12 +16,12 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId uint8_t *storePointer; size_t maxSize = data->getSerializedSize(); ReturnValue_t result = ipcStore->getFreeElement(&storeId, maxSize, &storePointer); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t size = 0; result = data->serialize(&storePointer, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return sendCommand(receiver->getCommandQueue(), actionId, storeId); @@ -35,7 +35,7 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId } store_address_t storeId; ReturnValue_t result = ipcStore->addData(&storeId, data, size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return sendCommand(receiver->getCommandQueue(), actionId, storeId); @@ -46,7 +46,7 @@ ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId, ActionI CommandMessage command; ActionMessage::setCommand(&command, actionId, storeId); ReturnValue_t result = queueToUse->sendMessage(queueId, &command); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeId); } lastTarget = queueId; @@ -57,44 +57,44 @@ ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId, ActionI ReturnValue_t CommandActionHelper::initialize() { ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } queueToUse = owner->getCommandQueuePtr(); if (queueToUse == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CommandActionHelper::handleReply(CommandMessage *reply) { if (reply->getSender() != lastTarget) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } switch (reply->getCommand()) { case ActionMessage::COMPLETION_SUCCESS: commandCount--; owner->completionSuccessfulReceived(ActionMessage::getActionId(reply)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case ActionMessage::COMPLETION_FAILED: commandCount--; owner->completionFailedReceived(ActionMessage::getActionId(reply), ActionMessage::getReturnCode(reply)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case ActionMessage::STEP_SUCCESS: owner->stepSuccessfulReceived(ActionMessage::getActionId(reply), ActionMessage::getStep(reply)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case ActionMessage::STEP_FAILED: commandCount--; owner->stepFailedReceived(ActionMessage::getActionId(reply), ActionMessage::getStep(reply), ActionMessage::getReturnCode(reply)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case ActionMessage::DATA_REPLY: extractDataForOwner(ActionMessage::getActionId(reply), ActionMessage::getStoreId(reply)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -104,7 +104,7 @@ void CommandActionHelper::extractDataForOwner(ActionId_t actionId, store_address const uint8_t *data = nullptr; size_t size = 0; ReturnValue_t result = ipcStore->getData(storeId, &data, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } owner->dataReceived(actionId, data, size); diff --git a/src/fsfw/action/SimpleActionHelper.cpp b/src/fsfw/action/SimpleActionHelper.cpp index fc7e064e..b9b9922e 100644 --- a/src/fsfw/action/SimpleActionHelper.cpp +++ b/src/fsfw/action/SimpleActionHelper.cpp @@ -9,7 +9,7 @@ void SimpleActionHelper::step(ReturnValue_t result) { // STEP_OFFESET is subtracted to compensate for adding offset in base // method, which is not necessary here. ActionHelper::step(stepCount - STEP_OFFSET, lastCommander, lastAction, result); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { resetHelper(); } } @@ -41,7 +41,7 @@ void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId const uint8_t* dataPtr = nullptr; size_t size = 0; ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ActionMessage::setStepReply(&reply, actionId, 0, result); queueToUse->sendMessage(commandedBy, &reply); return; @@ -51,12 +51,12 @@ void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId result = owner->executeAction(actionId, commandedBy, dataPtr, size); ipcStore->deleteData(dataAddress); switch (result) { - case HasReturnvaluesIF::RETURN_OK: + case returnvalue::OK: isExecuting = true; stepCount++; break; case HasActionsIF::EXECUTION_FINISHED: - ActionMessage::setCompletionReply(&reply, actionId, true, HasReturnvaluesIF::RETURN_OK); + ActionMessage::setCompletionReply(&reply, actionId, true, returnvalue::OK); queueToUse->sendMessage(commandedBy, &reply); break; default: diff --git a/src/fsfw/action/SimpleActionHelper.h b/src/fsfw/action/SimpleActionHelper.h index 973c7cf2..cfe05231 100644 --- a/src/fsfw/action/SimpleActionHelper.h +++ b/src/fsfw/action/SimpleActionHelper.h @@ -12,8 +12,8 @@ class SimpleActionHelper : public ActionHelper { public: SimpleActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue); ~SimpleActionHelper() override; - void step(ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); - void finish(ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + void step(ReturnValue_t result = returnvalue::OK); + void finish(ReturnValue_t result = returnvalue::OK); ReturnValue_t reportData(SerializeIF* data); protected: diff --git a/src/fsfw/cfdp/CFDPHandler.cpp b/src/fsfw/cfdp/CFDPHandler.cpp index 96baa98c..d5cdbb46 100644 --- a/src/fsfw/cfdp/CFDPHandler.cpp +++ b/src/fsfw/cfdp/CFDPHandler.cpp @@ -20,11 +20,11 @@ CFDPHandler::~CFDPHandler() {} ReturnValue_t CFDPHandler::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } this->distributor->registerHandler(this); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) { @@ -38,18 +38,18 @@ ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) { // TODO read out packet from store using storeId - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CFDPHandler::performOperation(uint8_t opCode) { - ReturnValue_t status = RETURN_OK; + ReturnValue_t status = returnvalue::OK; CommandMessage currentMessage; - for (status = this->requestQueue->receiveMessage(¤tMessage); status == RETURN_OK; + for (status = this->requestQueue->receiveMessage(¤tMessage); status == returnvalue::OK; status = this->requestQueue->receiveMessage(¤tMessage)) { store_address_t storeId = CFDPMessage::getStoreId(¤tMessage); this->handleRequest(storeId); } - return RETURN_OK; + return returnvalue::OK; } uint16_t CFDPHandler::getIdentifier() { return 0; } diff --git a/src/fsfw/cfdp/CFDPHandler.h b/src/fsfw/cfdp/CFDPHandler.h index abbac6b6..6888f9d7 100644 --- a/src/fsfw/cfdp/CFDPHandler.h +++ b/src/fsfw/cfdp/CFDPHandler.h @@ -14,8 +14,7 @@ void setStaticFrameworkObjectIds(); class CFDPHandler : public ExecutableObjectIF, public AcceptsTelecommandsIF, - public SystemObject, - public HasReturnvaluesIF { + public SystemObject { friend void(Factory::setStaticFrameworkObjectIds)(); public: diff --git a/src/fsfw/cfdp/FileSize.h b/src/fsfw/cfdp/FileSize.h index 6dae9683..756b0e0a 100644 --- a/src/fsfw/cfdp/FileSize.h +++ b/src/fsfw/cfdp/FileSize.h @@ -43,7 +43,7 @@ struct FileSize : public SerializeIF { uint32_t sizeTmp = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&sizeTmp, buffer, size, streamEndianness); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { fileSize = sizeTmp; } return result; @@ -53,11 +53,11 @@ struct FileSize : public SerializeIF { ReturnValue_t setFileSize(uint64_t fileSize, bool largeFile) { if (not largeFile and fileSize > UINT32_MAX) { // TODO: emit warning here - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->fileSize = fileSize; this->largeFile = largeFile; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool isLargeFile() const { return largeFile; } diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 7e023881..b8827f63 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -16,27 +16,27 @@ static constexpr uint8_t VERSION_BITS = 0b00100000; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; static constexpr ReturnValue_t INVALID_TLV_TYPE = - result::makeCode(CFDP_CLASS_ID, 1); + returnvalue::makeCode(CFDP_CLASS_ID, 1); static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = - result::makeCode(CFDP_CLASS_ID, 2); + returnvalue::makeCode(CFDP_CLASS_ID, 2); static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = - result::makeCode(CFDP_CLASS_ID, 3); + returnvalue::makeCode(CFDP_CLASS_ID, 3); static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = - result::makeCode(CFDP_CLASS_ID, 4); + returnvalue::makeCode(CFDP_CLASS_ID, 4); //! Can not parse options. This can also occur because there are options //! available but the user did not pass a valid options array static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = - result::makeCode(CFDP_CLASS_ID, 5); + returnvalue::makeCode(CFDP_CLASS_ID, 5); static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = - result::makeCode(CFDP_CLASS_ID, 6); + returnvalue::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES = - result::makeCode(CFDP_CLASS_ID, 6); + returnvalue::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = - result::makeCode(CFDP_CLASS_ID, 8); + returnvalue::makeCode(CFDP_CLASS_ID, 8); //! Can not parse filestore response because user did not pass a valid instance //! or remaining size is invalid static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE = - result::makeCode(CFDP_CLASS_ID, 9); + returnvalue::makeCode(CFDP_CLASS_ID, 9); //! Checksum types according to the SANA Checksum Types registry //! https://sanaregistry.org/r/checksum_identifiers/ diff --git a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp index f5babf4b..24357a38 100644 --- a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp @@ -5,7 +5,7 @@ AckPduDeserializer::AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, Ac ReturnValue_t AckPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); @@ -15,7 +15,7 @@ ReturnValue_t AckPduDeserializer::parseData() { if (not checkAndSetCodes(rawPtr[currentIdx], rawPtr[currentIdx + 1])) { return cfdp::INVALID_ACK_DIRECTIVE_FIELDS; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool AckPduDeserializer::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) { diff --git a/src/fsfw/cfdp/pdu/AckPduSerializer.cpp b/src/fsfw/cfdp/pdu/AckPduSerializer.cpp index d19418f1..b06f4f00 100644 --- a/src/fsfw/cfdp/pdu/AckPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/AckPduSerializer.cpp @@ -11,7 +11,7 @@ ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } cfdp::FileDirectives ackedDirective = ackInfo.getAckedDirective(); @@ -21,7 +21,7 @@ ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t if (ackedDirective != cfdp::FileDirectives::FINISH and ackedDirective != cfdp::FileDirectives::EOF_DIRECTIVE) { // TODO: better returncode - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size + 2 > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; @@ -32,5 +32,5 @@ ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t **buffer = ackedConditionCode << 4 | transactionStatus; *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp index e1ab8dc9..1a70e225 100644 --- a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp @@ -8,7 +8,7 @@ EofPduDeserializer::EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, Eo ReturnValue_t EofPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -31,7 +31,7 @@ ReturnValue_t EofPduDeserializer::parseData() { uint32_t checksum = 0; auto endianness = getEndianness(); result = SerializeAdapter::deSerialize(&checksum, &bufPtr, &deserLen, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } info.setChecksum(checksum); @@ -44,7 +44,7 @@ ReturnValue_t EofPduDeserializer::parseData() { result = SerializeAdapter::deSerialize(&fileSizeValue, &bufPtr, &deserLen, endianness); info.setFileSize(fileSizeValue, false); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) { @@ -61,7 +61,7 @@ ReturnValue_t EofPduDeserializer::parseData() { " given TLV pointer invalid"); #endif #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } result = tlvPtr->deSerialize(&bufPtr, &deserLen, endianness); } diff --git a/src/fsfw/cfdp/pdu/EofPduSerializer.cpp b/src/fsfw/cfdp/pdu/EofPduSerializer.cpp index e9fe0ca0..aafd332e 100644 --- a/src/fsfw/cfdp/pdu/EofPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduSerializer.cpp @@ -16,7 +16,7 @@ ReturnValue_t EofPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + 1 > maxSize) { @@ -27,7 +27,7 @@ ReturnValue_t EofPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t *size += 1; uint32_t checksum = info.getChecksum(); result = SerializeAdapter::serialize(&checksum, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (info.getFileSize().isLargeFile()) { diff --git a/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp b/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp index 240c4188..274f8b8a 100644 --- a/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp @@ -6,7 +6,7 @@ FileDataDeserializer::FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize ReturnValue_t FileDataDeserializer::parseData() { ReturnValue_t result = HeaderDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = HeaderDeserializer::getHeaderSize(); @@ -32,13 +32,13 @@ ReturnValue_t FileDataDeserializer::parseData() { } } result = info.getOffset().deSerialize(&buf, &remSize, this->getEndianness()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (remSize > 0) { info.setFileData(buf, remSize); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } SerializeIF::Endianness FileDataDeserializer::getEndianness() const { return endianness; } diff --git a/src/fsfw/cfdp/pdu/FileDataInfo.cpp b/src/fsfw/cfdp/pdu/FileDataInfo.cpp index c410adce..39b6472d 100644 --- a/src/fsfw/cfdp/pdu/FileDataInfo.cpp +++ b/src/fsfw/cfdp/pdu/FileDataInfo.cpp @@ -50,11 +50,11 @@ ReturnValue_t FileDataInfo::addSegmentMetadataInfo(cfdp::RecordContinuationState this->segmentMetadataFlag = cfdp::SegmentMetadataFlag::PRESENT; this->recContState = recContState; if (segmentMetadataLen > 63) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->segmentMetadata = segmentMetadata; this->segmentMetadataLen = segmentMetadataLen; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } const uint8_t *FileDataInfo::getFileData(size_t *fileSize) const { diff --git a/src/fsfw/cfdp/pdu/FileDataSerializer.cpp b/src/fsfw/cfdp/pdu/FileDataSerializer.cpp index 837b418b..bdc2d42f 100644 --- a/src/fsfw/cfdp/pdu/FileDataSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDataSerializer.cpp @@ -17,7 +17,7 @@ void FileDataSerializer::update() { ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { ReturnValue_t result = HeaderSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + this->getSerializedSize() > maxSize) { @@ -36,7 +36,7 @@ ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size } cfdp::FileSize& offset = info.getOffset(); result = offset.serialize(this->getLargeFileFlag(), buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t fileSize = 0; @@ -47,7 +47,7 @@ ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size std::memcpy(*buffer, readOnlyPtr, fileSize); *buffer += fileSize; *size += fileSize; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t FileDataSerializer::getSerializedSize() const { diff --git a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp b/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp index 3c0552f7..9d2a1e0a 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp @@ -7,7 +7,7 @@ cfdp::FileDirectives FileDirectiveDeserializer::getFileDirective() const { retur ReturnValue_t FileDirectiveDeserializer::parseData() { ReturnValue_t result = HeaderDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (this->getPduDataFieldLen() < 1) { @@ -21,7 +21,7 @@ ReturnValue_t FileDirectiveDeserializer::parseData() { return cfdp::INVALID_DIRECTIVE_FIELDS; } setFileDirective(static_cast(rawPtr[currentIdx])); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t FileDirectiveDeserializer::getHeaderSize() const { diff --git a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp b/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp index 98b2d0a2..5845ba56 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp @@ -13,13 +13,13 @@ size_t FileDirectiveSerializer::getSerializedSize() const { ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (FileDirectiveSerializer::getWholePduSize() > maxSize) { return BUFFER_TOO_SHORT; } ReturnValue_t result = HeaderSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -29,7 +29,7 @@ ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, **buffer = directiveCode; *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FileDirectiveSerializer::setDirectiveDataFieldLen(size_t len) { diff --git a/src/fsfw/cfdp/pdu/FinishedInfo.cpp b/src/fsfw/cfdp/pdu/FinishedInfo.cpp index c32372a1..ea4ffa89 100644 --- a/src/fsfw/cfdp/pdu/FinishedInfo.cpp +++ b/src/fsfw/cfdp/pdu/FinishedInfo.cpp @@ -46,14 +46,14 @@ ReturnValue_t FinishedInfo::setFilestoreResponsesArray(FilestoreResponseTlv** fs if (maxFsResponsesLen != nullptr) { this->fsResponsesMaxLen = *maxFsResponsesLen; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FinishedInfo::getFilestoreResonses(FilestoreResponseTlv*** fsResponses, size_t* fsResponsesLen, size_t* fsResponsesMaxLen) { if (fsResponses == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *fsResponses = this->fsResponses; if (fsResponsesLen != nullptr) { @@ -62,7 +62,7 @@ ReturnValue_t FinishedInfo::getFilestoreResonses(FilestoreResponseTlv*** fsRespo if (fsResponsesMaxLen != nullptr) { *fsResponsesMaxLen = this->fsResponsesMaxLen; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FinishedInfo::setFaultLocation(EntityIdTlv* faultLocation) { @@ -71,10 +71,10 @@ void FinishedInfo::setFaultLocation(EntityIdTlv* faultLocation) { ReturnValue_t FinishedInfo::getFaultLocation(EntityIdTlv** faultLocation) { if (this->faultLocation == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *faultLocation = this->faultLocation; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } cfdp::ConditionCode FinishedInfo::getConditionCode() const { return conditionCode; } diff --git a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp index feeca617..7d16394e 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp @@ -6,7 +6,7 @@ FinishPduDeserializer::FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSi ReturnValue_t FinishPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); @@ -33,7 +33,7 @@ FinishedInfo& FinishPduDeserializer::getInfo() { return finishedInfo; } ReturnValue_t FinishPduDeserializer::parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf, cfdp::ConditionCode conditionCode) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; size_t fsResponsesIdx = 0; auto endianness = getEndianness(); FilestoreResponseTlv** fsResponseArray = nullptr; @@ -60,7 +60,7 @@ ReturnValue_t FinishPduDeserializer::parseTlvs(size_t remLen, size_t currentIdx, return cfdp::FINISHED_CANT_PARSE_FS_RESPONSES; } result = fsResponseArray[fsResponsesIdx]->deSerialize(&buf, &remLen, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } fsResponsesIdx += 1; @@ -72,11 +72,11 @@ ReturnValue_t FinishPduDeserializer::parseTlvs(size_t remLen, size_t currentIdx, return cfdp::INVALID_TLV_TYPE; } result = finishedInfo.getFaultLocation(&faultLocation); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = faultLocation->deSerialize(&buf, &remLen, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } else { diff --git a/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp index 115a2c9c..ccc86908 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp @@ -17,7 +17,7 @@ ReturnValue_t FinishPduSerializer::serialize(uint8_t **buffer, size_t *size, siz Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + 1 >= maxSize) { @@ -34,13 +34,13 @@ ReturnValue_t FinishPduSerializer::serialize(uint8_t **buffer, size_t *size, siz finishInfo.getFilestoreResonses(&fsResponsesArray, &fsResponsesArrayLen, nullptr); for (size_t idx = 0; idx < fsResponsesArrayLen; idx++) { result = fsResponsesArray[idx]->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } } EntityIdTlv *entityId = nullptr; - if (finishInfo.getFaultLocation(&entityId) == HasReturnvaluesIF::RETURN_OK) { + if (finishInfo.getFaultLocation(&entityId) == returnvalue::OK) { result = entityId->serialize(buffer, size, maxSize, streamEndianness); } return result; diff --git a/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp b/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp index 70f397f8..2dbfed27 100644 --- a/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp @@ -18,7 +18,7 @@ ReturnValue_t HeaderDeserializer::setData(uint8_t *dataPtr, size_t maxSize, void if (dataPtr == nullptr) { // Allowed for now this->fixedHeader = nullptr; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } this->fixedHeader = reinterpret_cast(const_cast(dataPtr)); sourceIdRaw = static_cast(&fixedHeader->variableFieldsStart); @@ -27,7 +27,7 @@ ReturnValue_t HeaderDeserializer::setData(uint8_t *dataPtr, size_t maxSize, void seqNumRaw = static_cast(sourceIdRaw) + static_cast(widthEntityIds); destIdRaw = static_cast(seqNumRaw) + static_cast(widthSeqNum); this->maxSize = maxSize; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t HeaderDeserializer::getHeaderSize() const { diff --git a/src/fsfw/cfdp/pdu/HeaderDeserializer.h b/src/fsfw/cfdp/pdu/HeaderDeserializer.h index ed033697..70a7908c 100644 --- a/src/fsfw/cfdp/pdu/HeaderDeserializer.h +++ b/src/fsfw/cfdp/pdu/HeaderDeserializer.h @@ -37,7 +37,7 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF * This needs to be called before accessing the PDU fields to avoid segmentation faults. * @return * - RETURN_OK on parse success - * - RETURN_FAILED Invalid raw data + * - returnvalue::FAILED Invalid raw data * - SerializeIF::BUFFER_TOO_SHORT if buffer is shorter than expected */ virtual ReturnValue_t parseData(); @@ -61,7 +61,7 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF void getDestId(cfdp::EntityId& destId) const override; void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const override; - ReturnValue_t deserResult = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t deserResult = returnvalue::OK; /** * Can also be used to reset the pointer to a nullptr, but the getter functions will not diff --git a/src/fsfw/cfdp/pdu/HeaderSerializer.cpp b/src/fsfw/cfdp/pdu/HeaderSerializer.cpp index 041fb714..5721ad69 100644 --- a/src/fsfw/cfdp/pdu/HeaderSerializer.cpp +++ b/src/fsfw/cfdp/pdu/HeaderSerializer.cpp @@ -15,7 +15,7 @@ HeaderSerializer::HeaderSerializer(PduConfig &pduConf, cfdp::PduType pduType, ReturnValue_t HeaderSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (maxSize < this->getSerializedSize()) { return BUFFER_TOO_SHORT; @@ -32,19 +32,19 @@ ReturnValue_t HeaderSerializer::serialize(uint8_t **buffer, size_t *size, size_t *buffer += 1; *size += 4; ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t HeaderSerializer::getSerializedSize() const { @@ -55,7 +55,7 @@ size_t HeaderSerializer::getSerializedSize() const { ReturnValue_t HeaderSerializer::deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) { // We could implement this, but I prefer dedicated classes - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } size_t HeaderSerializer::getWholePduSize() const { diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp index 15f80549..79c908cf 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp @@ -6,7 +6,7 @@ KeepAlivePduDeserializer::KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t ReturnValue_t KeepAlivePduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp index e635ce06..5db4664c 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp @@ -19,7 +19,7 @@ ReturnValue_t KeepAlivePduSerializer::serialize(uint8_t **buffer, size_t *size, Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return progress.serialize(this->getLargeFileFlag(), buffer, size, maxSize, streamEndianness); diff --git a/src/fsfw/cfdp/pdu/MetadataInfo.cpp b/src/fsfw/cfdp/pdu/MetadataInfo.cpp index a2ca6972..572460cd 100644 --- a/src/fsfw/cfdp/pdu/MetadataInfo.cpp +++ b/src/fsfw/cfdp/pdu/MetadataInfo.cpp @@ -39,7 +39,7 @@ cfdp::FileSize& MetadataInfo::getFileSize() { return fileSize; } ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray, size_t* optionsLen, size_t* maxOptsLen) { if (optionsArray == nullptr or this->optionsArray == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *optionsArray = this->optionsArray; if (optionsLen != nullptr) { @@ -48,7 +48,7 @@ ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray, size_t* option if (maxOptsLen != nullptr) { *maxOptsLen = this->maxOptionsLen; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool MetadataInfo::hasOptions() const { diff --git a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp b/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp index 161eb63a..be9f4ed7 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp @@ -6,7 +6,7 @@ MetadataPduDeserializer::MetadataPduDeserializer(const uint8_t* pduBuf, size_t m ReturnValue_t MetadataPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); @@ -21,15 +21,15 @@ ReturnValue_t MetadataPduDeserializer::parseData() { buf += 1; auto endianness = getEndianness(); result = info.getFileSize().deSerialize(&buf, &remSize, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = info.getSourceFileName().deSerialize(&buf, &remSize, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = info.getDestFileName().deSerialize(&buf, &remSize, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -47,7 +47,7 @@ ReturnValue_t MetadataPduDeserializer::parseData() { return cfdp::METADATA_CANT_PARSE_OPTIONS; } result = optionsArray[optsIdx]->deSerialize(&buf, &remSize, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } optsIdx++; diff --git a/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp b/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp index f5c4de0a..041b9b84 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp @@ -17,7 +17,7 @@ ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, s Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + 1 >= maxSize) { @@ -27,15 +27,15 @@ ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, s *buffer += 1; *size += 1; result = info.getFileSize().serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = info.getSourceFileName().serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = info.getDestFileName().serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -45,7 +45,7 @@ ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, s info.getOptions(&optsArray, &optsLen, nullptr); for (size_t idx = 0; idx < optsLen; idx++) { result = optsArray[idx]->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } diff --git a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp b/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp index 9d5f074c..8acc9fc9 100644 --- a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp @@ -5,7 +5,7 @@ NakPduDeserializer::NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, Na ReturnValue_t NakPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); @@ -16,11 +16,11 @@ ReturnValue_t NakPduDeserializer::parseData() { } result = nakInfo.getStartOfScope().deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = nakInfo.getEndOfScope().deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } nakInfo.setSegmentRequestLen(0); @@ -39,12 +39,12 @@ ReturnValue_t NakPduDeserializer::parseData() { } result = segReqs[idx].first.deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = segReqs[idx].second.deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } idx++; diff --git a/src/fsfw/cfdp/pdu/NakPduSerializer.cpp b/src/fsfw/cfdp/pdu/NakPduSerializer.cpp index 95f1bc98..e8634df7 100644 --- a/src/fsfw/cfdp/pdu/NakPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/NakPduSerializer.cpp @@ -17,15 +17,15 @@ ReturnValue_t NakPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = nakInfo.getStartOfScope().serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = nakInfo.getEndOfScope().serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (nakInfo.hasSegmentRequests()) { @@ -34,11 +34,11 @@ ReturnValue_t NakPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t nakInfo.getSegmentRequests(&segmentRequests, &segmentRequestLen, nullptr); for (size_t idx = 0; idx < segmentRequestLen; idx++) { result = segmentRequests[idx].first.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = segmentRequests[idx].second.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } diff --git a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp b/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp index 6a6f5505..7e9e328d 100644 --- a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp @@ -9,7 +9,7 @@ cfdp::PromptResponseRequired PromptPduDeserializer::getPromptResponseRequired() ReturnValue_t PromptPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); @@ -17,5 +17,5 @@ ReturnValue_t PromptPduDeserializer::parseData() { return SerializeIF::STREAM_TOO_SHORT; } responseRequired = static_cast((rawPtr[currentIdx] >> 7) & 0x01); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp b/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp index a7287563..e5d5bca7 100644 --- a/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp @@ -13,7 +13,7 @@ ReturnValue_t PromptPduSerializer::serialize(uint8_t **buffer, size_t *size, siz Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + 1 > maxSize) { diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/pdu/VarLenField.cpp index b11c3b09..f0059270 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.cpp +++ b/src/fsfw/cfdp/pdu/VarLenField.cpp @@ -6,7 +6,7 @@ cfdp::VarLenField::VarLenField(cfdp::WidthInBytes width, size_t value) : VarLenField() { ReturnValue_t result = this->setValue(width, value); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_DISABLE_PRINTOUT == 0 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "cfdp::VarLenField: Setting value failed" << std::endl; @@ -25,21 +25,21 @@ ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, size_ switch (widthInBytes) { case (cfdp::WidthInBytes::ONE_BYTE): { if (value > UINT8_MAX) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->value.oneByte = value; break; } case (cfdp::WidthInBytes::TWO_BYTES): { if (value > UINT16_MAX) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->value.twoBytes = value; break; } case (cfdp::WidthInBytes::FOUR_BYTES): { if (value > UINT32_MAX) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->value.fourBytes = value; break; @@ -49,7 +49,7 @@ ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, size_ } } this->width = widthInBytes; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t cfdp::VarLenField::getValue() const { @@ -77,7 +77,7 @@ ReturnValue_t cfdp::VarLenField::serialize(uint8_t **buffer, size_t *size, size_ **buffer = value.oneByte; *size += 1; *buffer += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (cfdp::WidthInBytes::TWO_BYTES): { return SerializeAdapter::serialize(&value.twoBytes, buffer, size, maxSize, streamEndianness); @@ -86,7 +86,7 @@ ReturnValue_t cfdp::VarLenField::serialize(uint8_t **buffer, size_t *size, size_ return SerializeAdapter::serialize(&value.fourBytes, buffer, size, maxSize, streamEndianness); } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } } @@ -105,7 +105,7 @@ ReturnValue_t cfdp::VarLenField::deSerialize(const uint8_t **buffer, size_t *siz case (cfdp::WidthInBytes::ONE_BYTE): { value.oneByte = **buffer; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (cfdp::WidthInBytes::TWO_BYTES): { return SerializeAdapter::deSerialize(&value.twoBytes, buffer, size, streamEndianness); @@ -114,7 +114,7 @@ ReturnValue_t cfdp::VarLenField::deSerialize(const uint8_t **buffer, size_t *siz return SerializeAdapter::deSerialize(&value.fourBytes, buffer, size, streamEndianness); } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } } diff --git a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp index f5f777ea..bbcb61d2 100644 --- a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp +++ b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp @@ -22,7 +22,7 @@ ReturnValue_t FaultHandlerOverrideTlv::serialize(uint8_t **buffer, size_t *size, **buffer = this->conditionCode << 4 | this->handlerCode; *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t FaultHandlerOverrideTlv::getSerializedSize() const { return getLengthField() + 2; } @@ -40,7 +40,7 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_ *size -= 1; size_t detectedSize = **buffer; if (detectedSize != getLengthField()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *buffer += 1; *size += 1; @@ -48,7 +48,7 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_ this->handlerCode = static_cast(**buffer & 0x0f); *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } cfdp::TlvTypes FaultHandlerOverrideTlv::getType() const { return cfdp::TlvTypes::FAULT_HANDLER; } diff --git a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp index 9ad7c645..941e8f5d 100644 --- a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp +++ b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp @@ -16,11 +16,11 @@ void FilestoreRequestTlv::setSecondFileName(cfdp::Lv *secondFileName) { ReturnValue_t FilestoreRequestTlv::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { ReturnValue_t result = commonSerialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = firstFileName.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (requiresSecondFileName()) { @@ -30,13 +30,13 @@ ReturnValue_t FilestoreRequestTlv::serialize(uint8_t **buffer, size_t *size, siz } secondFileName->serialize(buffer, size, maxSize, streamEndianness); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilestoreRequestTlv::deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) { ReturnValue_t result = commonDeserialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return deSerializeFromValue(buffer, size, streamEndianness); @@ -63,13 +63,13 @@ ReturnValue_t FilestoreRequestTlv::deSerializeFromValue(const uint8_t **buffer, *buffer += 1; *size -= 1; ReturnValue_t result = firstFileName.deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (requiresSecondFileName()) { if (secondFileName == nullptr) { secondFileNameMissing(); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } result = secondFileName->deSerialize(buffer, size, streamEndianness); } diff --git a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp index 36945725..53aaaf8f 100644 --- a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp +++ b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp @@ -32,11 +32,11 @@ ReturnValue_t FilestoreResponseTlv::serialize(uint8_t **buffer, size_t *size, si Endianness streamEndianness) const { ReturnValue_t result = commonSerialize(buffer, size, maxSize, streamEndianness, true, this->statusCode); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = firstFileName.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (requiresSecondFileName()) { @@ -61,7 +61,7 @@ ReturnValue_t FilestoreResponseTlv::serialize(uint8_t **buffer, size_t *size, si ReturnValue_t FilestoreResponseTlv::deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) { ReturnValue_t result = commonDeserialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return deSerializeFromValue(buffer, size, streamEndianness); @@ -75,7 +75,7 @@ ReturnValue_t FilestoreResponseTlv::deSerializeFromValue(const uint8_t **buffer, *buffer += 1; *size -= 1; ReturnValue_t result = firstFileName.deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (requiresSecondFileName()) { @@ -83,7 +83,7 @@ ReturnValue_t FilestoreResponseTlv::deSerializeFromValue(const uint8_t **buffer, return cfdp::FILESTORE_REQUIRES_SECOND_FILE; } result = secondFileName->deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -98,7 +98,7 @@ ReturnValue_t FilestoreResponseTlv::deSerializeFromValue(const uint8_t **buffer, *size -= 1; *buffer += 1; // Ignore empty filestore message - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return filestoreMsg->deSerialize(buffer, size, streamEndianness); } diff --git a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h index 04012cda..c37cb0ad 100644 --- a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h +++ b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h @@ -73,7 +73,7 @@ class FilestoreTlvBase : public TlvIF { Endianness streamEndianness, bool isResponse = false, uint8_t responseStatusCode = 0) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (maxSize < 3) { return SerializeIF::BUFFER_TOO_SHORT; @@ -90,13 +90,13 @@ class FilestoreTlvBase : public TlvIF { } *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t commonDeserialize(const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size < 3) { return SerializeIF::STREAM_TOO_SHORT; @@ -114,7 +114,7 @@ class FilestoreTlvBase : public TlvIF { if (remainingLength == 0) { return SerializeIF::STREAM_TOO_SHORT; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool requiresSecondFileName() const { @@ -152,7 +152,7 @@ class FilestoreTlvBase : public TlvIF { size_t serSize = 0; uint8_t* valueStart = buffer + 2; ReturnValue_t result = this->serialize(&buffer, &serSize, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } tlv.setValue(valueStart, serSize - 2); diff --git a/src/fsfw/cfdp/tlv/Lv.cpp b/src/fsfw/cfdp/tlv/Lv.cpp index 1bb16301..9c72b260 100644 --- a/src/fsfw/cfdp/tlv/Lv.cpp +++ b/src/fsfw/cfdp/tlv/Lv.cpp @@ -31,13 +31,13 @@ ReturnValue_t cfdp::Lv::serialize(uint8_t** buffer, size_t* size, size_t maxSize return BUFFER_TOO_SHORT; } if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (zeroLen) { **buffer = 0; *size += 1; *buffer += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return value.serialize(buffer, size, maxSize, streamEndianness); } @@ -54,7 +54,7 @@ size_t cfdp::Lv::getSerializedSize() const { ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size < 1) { return SerializeIF::STREAM_TOO_SHORT; @@ -64,7 +64,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size, zeroLen = true; *buffer += 1; *size -= 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else if (*size < lengthField + 1) { return SerializeIF::STREAM_TOO_SHORT; } @@ -73,7 +73,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size, value.setBuffer(const_cast(*buffer + 1), lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } const uint8_t* cfdp::Lv::getValue(size_t* size) const { diff --git a/src/fsfw/cfdp/tlv/Tlv.cpp b/src/fsfw/cfdp/tlv/Tlv.cpp index f37ff8d5..3a394741 100644 --- a/src/fsfw/cfdp/tlv/Tlv.cpp +++ b/src/fsfw/cfdp/tlv/Tlv.cpp @@ -12,7 +12,7 @@ cfdp::Tlv::Tlv() : value(static_cast(nullptr), 0, true) {} ReturnValue_t cfdp::Tlv::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size + 2 > maxSize) { return BUFFER_TOO_SHORT; @@ -28,10 +28,10 @@ ReturnValue_t cfdp::Tlv::serialize(uint8_t **buffer, size_t *size, size_t maxSiz **buffer = 0; *size += 1; *buffer += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } if (value.getConstBuffer() == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return value.serialize(buffer, size, maxSize, streamEndianness); } @@ -48,7 +48,7 @@ size_t cfdp::Tlv::getSerializedSize() const { ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size < 2) { return STREAM_TOO_SHORT; @@ -68,7 +68,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, zeroLen = true; *buffer += 1; *size -= 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } if (lengthField + 1 > *size) { return SerializeIF::STREAM_TOO_SHORT; @@ -78,7 +78,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, value.setBuffer(const_cast(*buffer + 1), lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } const uint8_t *cfdp::Tlv::getValue() const { return value.getConstBuffer(); } diff --git a/src/fsfw/container/ArrayList.h b/src/fsfw/container/ArrayList.h index 11f40039..522ddf3b 100644 --- a/src/fsfw/container/ArrayList.h +++ b/src/fsfw/container/ArrayList.h @@ -191,7 +191,7 @@ class ArrayList { } entries[size] = entry; ++size; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } /** diff --git a/src/fsfw/container/FIFOBase.tpp b/src/fsfw/container/FIFOBase.tpp index 91804b6c..63727869 100644 --- a/src/fsfw/container/FIFOBase.tpp +++ b/src/fsfw/container/FIFOBase.tpp @@ -17,7 +17,7 @@ inline ReturnValue_t FIFOBase::insert(T value) { values[writeIndex] = value; writeIndex = next(writeIndex); ++currentSize; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } }; @@ -27,12 +27,12 @@ inline ReturnValue_t FIFOBase::retrieve(T* value) { return EMPTY; } else { if (value == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *value = values[readIndex]; readIndex = next(readIndex); --currentSize; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } }; @@ -42,10 +42,10 @@ inline ReturnValue_t FIFOBase::peek(T* value) { return EMPTY; } else { if (value == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *value = values[readIndex]; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } }; diff --git a/src/fsfw/container/FixedMap.h b/src/fsfw/container/FixedMap.h index 48822cd5..c6b2c9b5 100644 --- a/src/fsfw/container/FixedMap.h +++ b/src/fsfw/container/FixedMap.h @@ -75,7 +75,7 @@ class FixedMap : public SerializeIF { uint32_t size() const { return _size; } ReturnValue_t insert(key_t key, T value, Iterator* storedValue = nullptr) { - if (exists(key) == HasReturnvaluesIF::RETURN_OK) { + if (exists(key) == returnvalue::OK) { return KEY_ALREADY_EXISTS; } if (_size == theMap.maxSize()) { @@ -87,7 +87,7 @@ class FixedMap : public SerializeIF { *storedValue = Iterator(&theMap[_size]); } ++_size; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t insert(std::pair pair) { return insert(pair.first, pair.second); } @@ -95,7 +95,7 @@ class FixedMap : public SerializeIF { ReturnValue_t exists(key_t key) const { ReturnValue_t result = KEY_DOES_NOT_EXIST; if (findIndex(key) < _size) { - result = HasReturnvaluesIF::RETURN_OK; + result = returnvalue::OK; } return result; } @@ -108,7 +108,7 @@ class FixedMap : public SerializeIF { theMap[i] = theMap[_size - 1]; --_size; --((*iter).value); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t erase(key_t key) { @@ -118,14 +118,14 @@ class FixedMap : public SerializeIF { } theMap[i] = theMap[_size - 1]; --_size; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } T* findValue(key_t key) const { return &theMap[findIndex(key)].second; } Iterator find(key_t key) const { ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return end(); } return Iterator(&theMap[findIndex(key)]); @@ -133,11 +133,11 @@ class FixedMap : public SerializeIF { ReturnValue_t find(key_t key, T** value) const { ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *value = &theMap[findIndex(key)].second; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool empty() { @@ -165,7 +165,7 @@ class FixedMap : public SerializeIF { ReturnValue_t result = SerializeAdapter::serialize(&this->_size, buffer, size, maxSize, streamEndianness); uint32_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->_size)) { + while ((result == returnvalue::OK) && (i < this->_size)) { result = SerializeAdapter::serialize(&theMap[i].first, buffer, size, maxSize, streamEndianness); result = @@ -195,7 +195,7 @@ class FixedMap : public SerializeIF { return SerializeIF::TOO_MANY_ELEMENTS; } uint32_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->_size)) { + while ((result == returnvalue::OK) && (i < this->_size)) { result = SerializeAdapter::deSerialize(&theMap[i].first, buffer, size, streamEndianness); result = SerializeAdapter::deSerialize(&theMap[i].second, buffer, size, streamEndianness); ++i; diff --git a/src/fsfw/container/FixedOrderedMultimap.h b/src/fsfw/container/FixedOrderedMultimap.h index 3ef8f8f1..f402d622 100644 --- a/src/fsfw/container/FixedOrderedMultimap.h +++ b/src/fsfw/container/FixedOrderedMultimap.h @@ -148,7 +148,7 @@ class FixedOrderedMultimap { */ Iterator find(key_t key) const { ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return end(); } return Iterator(&theMap[findFirstIndex(key)]); diff --git a/src/fsfw/container/FixedOrderedMultimap.tpp b/src/fsfw/container/FixedOrderedMultimap.tpp index fd58bc44..cfdb5331 100644 --- a/src/fsfw/container/FixedOrderedMultimap.tpp +++ b/src/fsfw/container/FixedOrderedMultimap.tpp @@ -16,7 +16,7 @@ inline ReturnValue_t FixedOrderedMultimap::insert(key_t k if (storedValue != nullptr) { *storedValue = Iterator(&theMap[position]); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template inline ReturnValue_t FixedOrderedMultimap::insert(std::pair pair) { @@ -27,7 +27,7 @@ template inline ReturnValue_t FixedOrderedMultimap::exists(key_t key) const { ReturnValue_t result = KEY_DOES_NOT_EXIST; if (findFirstIndex(key) < _size) { - result = HasReturnvaluesIF::RETURN_OK; + result = returnvalue::OK; } return result; } @@ -44,7 +44,7 @@ inline ReturnValue_t FixedOrderedMultimap::erase(Iterator } else { *iter = begin(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template @@ -57,17 +57,17 @@ inline ReturnValue_t FixedOrderedMultimap::erase(key_t ke removeFromPosition(i); i = findFirstIndex(key, i); } while (i < _size); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template inline ReturnValue_t FixedOrderedMultimap::find(key_t key, T **value) const { ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *value = &theMap[findFirstIndex(key)].second; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template diff --git a/src/fsfw/container/IndexedRingMemoryArray.h b/src/fsfw/container/IndexedRingMemoryArray.h index b76e7d56..4ad72592 100644 --- a/src/fsfw/container/IndexedRingMemoryArray.h +++ b/src/fsfw/container/IndexedRingMemoryArray.h @@ -52,15 +52,15 @@ class Index : public SerializeIF { Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&blockStartAddress, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = indexType.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&this->size, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = @@ -71,19 +71,19 @@ class Index : public SerializeIF { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&blockStartAddress, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = indexType.deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&this->size, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&this->storedPackets, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return result; @@ -449,13 +449,13 @@ class IndexedRingMemoryArray : public SerializeIF, public ArrayList, ui // Check Next Block if (!isNextBlockWritable()) { // The Index is full and does not overwrite old - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // Next block can be written, update Metadata currentWriteBlock = getNextWrite(); currentWriteBlock->setSize(0); currentWriteBlock->setStoredPackets(0); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } /** @@ -475,21 +475,21 @@ class IndexedRingMemoryArray : public SerializeIF, public ArrayList, ui additionalInfo->serialize(buffer, size, maxSize, streamEndianness); } ReturnValue_t result = currentWriteBlock->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&this->size, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } uint32_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->size)) { + while ((result == returnvalue::OK) && (i < this->size)) { result = SerializeAdapter::serialize(&this->entries[i], buffer, size, maxSize, streamEndianness); ++i; } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } uint16_t crc = Calculate_CRC(crcBuffer, (*size - oldSize)); @@ -523,44 +523,44 @@ class IndexedRingMemoryArray : public SerializeIF, public ArrayList, ui */ ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (additionalInfo != NULL) { result = additionalInfo->deSerialize(buffer, size, streamEndianness); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } Index tempIndex; result = tempIndex.deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } uint32_t tempSize = 0; result = SerializeAdapter::deSerialize(&tempSize, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (this->size != tempSize) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint32_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->size)) { + while ((result == returnvalue::OK) && (i < this->size)) { result = SerializeAdapter::deSerialize(&this->entries[i], buffer, size, streamEndianness); ++i; } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } typename IndexedRingMemoryArray::Iterator cmp(&tempIndex); for (typename IndexedRingMemoryArray::Iterator it = this->begin(); it != this->end(); ++it) { if (*(cmp.value) == *(it.value)) { currentWriteBlock = it; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } // Reached if current write block iterator is not found - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint32_t getIndexAddress() const { return indexAddress; } diff --git a/src/fsfw/container/PlacementFactory.h b/src/fsfw/container/PlacementFactory.h index 936be59d..e59fc134 100644 --- a/src/fsfw/container/PlacementFactory.h +++ b/src/fsfw/container/PlacementFactory.h @@ -40,7 +40,7 @@ class PlacementFactory { store_address_t tempId; uint8_t* pData = nullptr; ReturnValue_t result = dataBackend->getFreeElement(&tempId, sizeof(T), &pData); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return nullptr; } T* temp = new (pData) T(std::forward(args)...); @@ -56,7 +56,7 @@ class PlacementFactory { template ReturnValue_t destroy(T* thisElement) { if (thisElement == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // Need to call destructor first, in case something was allocated by the object (shouldn't do // that, however). diff --git a/src/fsfw/container/RingBufferBase.h b/src/fsfw/container/RingBufferBase.h index 98207698..77a0583b 100644 --- a/src/fsfw/container/RingBufferBase.h +++ b/src/fsfw/container/RingBufferBase.h @@ -58,18 +58,18 @@ class RingBufferBase { ReturnValue_t readData(uint32_t amount, uint8_t n = 0) { if (getAvailableReadData(n) >= amount) { incrementRead(amount, n); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t writeData(uint32_t amount) { if (availableWriteSpace() >= amount or overwriteOld) { incrementWrite(amount); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/container/SimpleRingBuffer.cpp b/src/fsfw/container/SimpleRingBuffer.cpp index c104ea97..a006df46 100644 --- a/src/fsfw/container/SimpleRingBuffer.cpp +++ b/src/fsfw/container/SimpleRingBuffer.cpp @@ -32,14 +32,14 @@ ReturnValue_t SimpleRingBuffer::getFreeElement(uint8_t** writePointer, size_t am size_t amountTillWrap = writeTillWrap(); if (amountTillWrap < amount) { if ((amount - amountTillWrap + excessBytes) > maxExcessBytes) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } excessBytes = amount - amountTillWrap; } *writePointer = &buffer[write]; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -52,7 +52,7 @@ void SimpleRingBuffer::confirmBytesWritten(size_t amount) { ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) { if (data == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (amount > getMaxSize()) { #if FSFW_VERBOSE_LEVEL >= 1 @@ -62,7 +62,7 @@ ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) { sif::printError("SimpleRingBuffer::writeData: Amount of data too large\n"); #endif #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (availableWriteSpace() >= amount or overwriteOld) { size_t amountTillWrap = writeTillWrap(); @@ -74,9 +74,9 @@ ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) { memcpy(buffer, data + amountTillWrap, amount - amountTillWrap); } incrementWrite(amount); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -89,7 +89,7 @@ ReturnValue_t SimpleRingBuffer::readData(uint8_t* data, size_t amount, bool incr // more data available than amount specified. amount = availableData; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } if (trueAmount != nullptr) { @@ -105,7 +105,7 @@ ReturnValue_t SimpleRingBuffer::readData(uint8_t* data, size_t amount, bool incr if (incrementReadPtr) { deleteData(amount, readRemaining); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t SimpleRingBuffer::getExcessBytes() const { return excessBytes; } @@ -124,12 +124,12 @@ ReturnValue_t SimpleRingBuffer::deleteData(size_t amount, bool deleteRemaining, if (deleteRemaining) { amount = availableData; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } if (trueAmount != nullptr) { *trueAmount = amount; } incrementRead(amount, READ_PTR); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/container/SimpleRingBuffer.h b/src/fsfw/container/SimpleRingBuffer.h index b9762451..7495e31c 100644 --- a/src/fsfw/container/SimpleRingBuffer.h +++ b/src/fsfw/container/SimpleRingBuffer.h @@ -48,7 +48,7 @@ class SimpleRingBuffer : public RingBufferBase<> { * @param data * @param amount * @return -@c RETURN_OK if write operation was successful - * -@c RETURN_FAILED if + * -@c returnvalue::FAILED if */ ReturnValue_t writeData(const uint8_t* data, size_t amount); @@ -96,7 +96,7 @@ class SimpleRingBuffer : public RingBufferBase<> { * to the passed value. * @return * - @c RETURN_OK if data was read successfully - * - @c RETURN_FAILED if not enough data was available and readRemaining + * - @c returnvalue::FAILED if not enough data was available and readRemaining * was set to false. */ ReturnValue_t readData(uint8_t* data, size_t amount, bool incrementReadPtr = false, diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp index 7a8b6bc4..a9d19ef2 100644 --- a/src/fsfw/controller/ControllerBase.cpp +++ b/src/fsfw/controller/ControllerBase.cpp @@ -20,7 +20,7 @@ ControllerBase::~ControllerBase() { QueueFactory::instance()->deleteMessageQueue ReturnValue_t ControllerBase::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -28,7 +28,7 @@ ReturnValue_t ControllerBase::initialize() { if (parentId != objects::NO_OBJECT) { auto* parent = ObjectManager::instance()->get(parentId); if (parent == nullptr) { - return RETURN_FAILED; + return returnvalue::FAILED; } parentQueue = parent->getCommandQueue(); @@ -36,16 +36,16 @@ ReturnValue_t ControllerBase::initialize() { } result = healthHelper.initialize(parentQueue); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = modeHelper.initialize(parentQueue); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return RETURN_OK; + return returnvalue::OK; } MessageQueueId_t ControllerBase::getCommandQueue() const { return commandQueue->getId(); } @@ -53,19 +53,19 @@ MessageQueueId_t ControllerBase::getCommandQueue() const { return commandQueue-> void ControllerBase::handleQueue() { CommandMessage command; ReturnValue_t result; - for (result = commandQueue->receiveMessage(&command); result == RETURN_OK; + for (result = commandQueue->receiveMessage(&command); result == returnvalue::OK; result = commandQueue->receiveMessage(&command)) { result = modeHelper.handleModeCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = healthHelper.handleHealthCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = handleCommandMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } command.setToUnknownCommand(); @@ -96,7 +96,7 @@ void ControllerBase::announceMode(bool recursive) { triggerEvent(MODE_INFO, mode ReturnValue_t ControllerBase::performOperation(uint8_t opCode) { handleQueue(); performControlOperation(); - return RETURN_OK; + return returnvalue::OK; } void ControllerBase::modeChanged(Mode_t mode_, Submode_t submode_) {} @@ -106,7 +106,7 @@ ReturnValue_t ControllerBase::setHealth(HealthState health) { case HEALTHY: case EXTERNAL_CONTROL: healthHelper.setHealth(health); - return RETURN_OK; + return returnvalue::OK; default: return INVALID_HEALTH_STATE; } @@ -117,4 +117,4 @@ void ControllerBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; } void ControllerBase::changeHK(Mode_t mode_, Submode_t submode_, bool enable) {} -ReturnValue_t ControllerBase::initializeAfterTaskCreation() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t ControllerBase::initializeAfterTaskCreation() { return returnvalue::OK; } diff --git a/src/fsfw/controller/ControllerBase.h b/src/fsfw/controller/ControllerBase.h index 550659b8..56c28585 100644 --- a/src/fsfw/controller/ControllerBase.h +++ b/src/fsfw/controller/ControllerBase.h @@ -18,8 +18,7 @@ class ControllerBase : public HasModesIF, public HasHealthIF, public ExecutableObjectIF, - public SystemObject, - public HasReturnvaluesIF { + public SystemObject { public: static const Mode_t MODE_NORMAL = 2; diff --git a/src/fsfw/controller/ExtendedControllerBase.cpp b/src/fsfw/controller/ExtendedControllerBase.cpp index 64b39a31..4d5c90c8 100644 --- a/src/fsfw/controller/ExtendedControllerBase.cpp +++ b/src/fsfw/controller/ExtendedControllerBase.cpp @@ -12,7 +12,7 @@ ReturnValue_t ExtendedControllerBase::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t *data, size_t size) { /* Needs to be overriden and implemented by child class. */ - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } object_id_t ExtendedControllerBase::getObjectId() const { return SystemObject::getObjectId(); } @@ -23,7 +23,7 @@ uint32_t ExtendedControllerBase::getPeriodicOperationFrequency() const { ReturnValue_t ExtendedControllerBase::handleCommandMessage(CommandMessage *message) { ReturnValue_t result = actionHelper.handleActionMessage(message); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return result; } return poolManager.handleHousekeepingMessage(message); @@ -32,30 +32,30 @@ ReturnValue_t ExtendedControllerBase::handleCommandMessage(CommandMessage *messa void ExtendedControllerBase::handleQueue() { CommandMessage command; ReturnValue_t result; - for (result = commandQueue->receiveMessage(&command); result == RETURN_OK; + for (result = commandQueue->receiveMessage(&command); result == returnvalue::OK; result = commandQueue->receiveMessage(&command)) { result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = modeHelper.handleModeCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = healthHelper.handleHealthCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = poolManager.handleHousekeepingMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = handleCommandMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } command.setToUnknownCommand(); @@ -65,11 +65,11 @@ void ExtendedControllerBase::handleQueue() { ReturnValue_t ExtendedControllerBase::initialize() { ReturnValue_t result = ControllerBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -86,7 +86,7 @@ ReturnValue_t ExtendedControllerBase::performOperation(uint8_t opCode) { /* We do this after performing control operation because variables will be set changed in this function. */ poolManager.performHkOperation(); - return RETURN_OK; + return returnvalue::OK; } MessageQueueId_t ExtendedControllerBase::getCommandQueue() const { return commandQueue->getId(); } diff --git a/src/fsfw/coordinates/Sgp4Propagator.cpp b/src/fsfw/coordinates/Sgp4Propagator.cpp index 4a43842c..e79ffef5 100644 --- a/src/fsfw/coordinates/Sgp4Propagator.cpp +++ b/src/fsfw/coordinates/Sgp4Propagator.cpp @@ -152,7 +152,7 @@ ReturnValue_t Sgp4Propagator::initialize(const uint8_t* line1, const uint8_t* li return MAKE_RETURN_CODE(result); } else { initialized = true; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } @@ -195,6 +195,6 @@ ReturnValue_t Sgp4Propagator::propagate(double* position, double* velocity, time if (result != 0) { return MAKE_RETURN_CODE(result || 0xB0); } else { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } diff --git a/src/fsfw/datalinklayer/DataLinkLayer.cpp b/src/fsfw/datalinklayer/DataLinkLayer.cpp index ca607478..6fe3e664 100644 --- a/src/fsfw/datalinklayer/DataLinkLayer.cpp +++ b/src/fsfw/datalinklayer/DataLinkLayer.cpp @@ -28,7 +28,7 @@ ReturnValue_t DataLinkLayer::frameDelimitingAndFillRemoval() { TcTransferFrame frame_candidate(frameBuffer); this->currentFrame = frame_candidate; // should work with shallow copy. - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DataLinkLayer::frameValidationCheck() { @@ -59,14 +59,14 @@ ReturnValue_t DataLinkLayer::frameValidationCheck() { if (USE_CRC) { return this->frameCheckCRC(); } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DataLinkLayer::frameCheckCRC() { uint16_t checkValue = CRC::crc16ccitt(this->currentFrame.getFullFrame(), this->currentFrame.getFullSize()); if (checkValue == 0) { - return RETURN_OK; + return returnvalue::OK; } else { return CRC_FAILED; } @@ -74,7 +74,7 @@ ReturnValue_t DataLinkLayer::frameCheckCRC() { ReturnValue_t DataLinkLayer::allFramesReception() { ReturnValue_t status = this->frameDelimitingAndFillRemoval(); - if (status != RETURN_OK) { + if (status != returnvalue::OK) { return status; } return this->frameValidationCheck(); @@ -90,7 +90,7 @@ ReturnValue_t DataLinkLayer::virtualChannelDemultiplexing() { virtualChannelIterator iter = virtualChannels.find(vcId); if (iter == virtualChannels.end()) { // Do not report because passive board will get this error all the time. - return RETURN_OK; + return returnvalue::OK; } else { return (iter->second)->frameAcceptanceAndReportingMechanism(¤tFrame, clcw); } @@ -99,7 +99,7 @@ ReturnValue_t DataLinkLayer::virtualChannelDemultiplexing() { ReturnValue_t DataLinkLayer::processFrame(uint16_t length) { receivedDataLength = length; ReturnValue_t status = allFramesReception(); - if (status != RETURN_OK) { + if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DataLinkLayer::processFrame: frame reception failed. " "Error code: " @@ -117,14 +117,14 @@ ReturnValue_t DataLinkLayer::addVirtualChannel(uint8_t virtualChannelId, std::pair returnValue = virtualChannels.insert( std::pair(virtualChannelId, object)); if (returnValue.second == true) { - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t DataLinkLayer::initialize() { - ReturnValue_t returnValue = RETURN_FAILED; + ReturnValue_t returnValue = returnvalue::FAILED; // Set Virtual Channel ID to first virtual channel instance in this DataLinkLayer instance to // avoid faulty information (e.g. 0) in the VCID. if (virtualChannels.begin() != virtualChannels.end()) { @@ -133,13 +133,13 @@ ReturnValue_t DataLinkLayer::initialize() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DataLinkLayer::initialize: No VC assigned to this DLL instance! " << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } for (virtualChannelIterator iterator = virtualChannels.begin(); iterator != virtualChannels.end(); iterator++) { returnValue = iterator->second->initialize(); - if (returnValue != RETURN_OK) break; + if (returnValue != returnvalue::OK) break; } return returnValue; } diff --git a/src/fsfw/datalinklayer/DataLinkLayer.h b/src/fsfw/datalinklayer/DataLinkLayer.h index 8735feb6..64d33016 100644 --- a/src/fsfw/datalinklayer/DataLinkLayer.h +++ b/src/fsfw/datalinklayer/DataLinkLayer.h @@ -61,7 +61,7 @@ class DataLinkLayer : public CCSDSReturnValuesIF { * handle Frames directed to this VC. * @param virtualChannelId Id of the VC. Shall be smaller than 64. * @param object Reference to the object that handles the Frame. - * @return @c RETURN_OK on success, @c RETURN_FAILED otherwise. + * @return @c RETURN_OK on success, @c returnvalue::FAILED otherwise. */ ReturnValue_t addVirtualChannel(uint8_t virtualChannelId, VirtualChannelReceptionIF* object); /** diff --git a/src/fsfw/datalinklayer/Farm1StateOpen.cpp b/src/fsfw/datalinklayer/Farm1StateOpen.cpp index cf3339a7..b27f609c 100644 --- a/src/fsfw/datalinklayer/Farm1StateOpen.cpp +++ b/src/fsfw/datalinklayer/Farm1StateOpen.cpp @@ -11,7 +11,7 @@ ReturnValue_t Farm1StateOpen::handleADFrame(TcTransferFrame* frame, ClcwIF* clcw if (diff == 0) { myVC->vR++; clcw->setRetransmitFlag(false); - return RETURN_OK; + return returnvalue::OK; } else if (diff < myVC->positiveWindow && diff > 0) { clcw->setRetransmitFlag(true); return NS_POSITIVE_W; diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.cpp b/src/fsfw/datalinklayer/MapPacketExtraction.cpp index 57aa2f08..a2ee51e8 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.cpp +++ b/src/fsfw/datalinklayer/MapPacketExtraction.cpp @@ -31,7 +31,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) { if (packetLength <= MAX_PACKET_SIZE) { memcpy(packetBuffer, frame->getDataField(), packetLength); bufferPosition = &packetBuffer[packetLength]; - status = RETURN_OK; + status = returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Packet too large! Size: " @@ -52,7 +52,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) { status = sendCompletePacket(packetBuffer, packetLength); clearBuffers(); } - status = RETURN_OK; + status = returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Packet too large! Size: " @@ -95,7 +95,7 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(TcTransferFrame* frame) status = sendCompletePacket(packet.getWholeData(), packet.getFullSize()); totalLength -= packet.getFullSize(); position += packet.getFullSize(); - status = RETURN_OK; + status = returnvalue::OK; } else { status = DATA_CORRUPTED; totalLength = 0; @@ -110,7 +110,7 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(TcTransferFrame* frame) ReturnValue_t MapPacketExtraction::sendCompletePacket(uint8_t* data, uint32_t size) { store_address_t store_id; ReturnValue_t status = this->packetStore->addData(&store_id, data, size); - if (status == RETURN_OK) { + if (status == returnvalue::OK) { TmTcMessage message(store_id); status = MessageQueueSenderIF::sendMessage(tcQueueId, &message); } @@ -130,9 +130,9 @@ ReturnValue_t MapPacketExtraction::initialize() { ObjectManager::instance()->get(packetDestination); if ((packetStore != NULL) && (distributor != NULL)) { tcQueueId = distributor->getRequestQueue(); - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.h b/src/fsfw/datalinklayer/MapPacketExtraction.h index c2673b2e..54faaf04 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.h +++ b/src/fsfw/datalinklayer/MapPacketExtraction.h @@ -63,7 +63,7 @@ class MapPacketExtraction : public MapPacketExtractionIF { ReturnValue_t extractPackets(TcTransferFrame* frame); /** * The #packetStore and the default destination of #tcQueue are initialized here. - * @return @c RETURN_OK on success, @c RETURN_FAILED otherwise. + * @return @c RETURN_OK on success, @c returnvalue::FAILED otherwise. */ ReturnValue_t initialize(); /** diff --git a/src/fsfw/datalinklayer/VirtualChannelReception.cpp b/src/fsfw/datalinklayer/VirtualChannelReception.cpp index 258bc1e6..4c44cf01 100644 --- a/src/fsfw/datalinklayer/VirtualChannelReception.cpp +++ b/src/fsfw/datalinklayer/VirtualChannelReception.cpp @@ -57,18 +57,18 @@ ReturnValue_t VirtualChannelReception::doFARM(TcTransferFrame* frame, ClcwIF* cl ReturnValue_t VirtualChannelReception::frameAcceptanceAndReportingMechanism(TcTransferFrame* frame, ClcwIF* clcw) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; result = doFARM(frame, &internalClcw); internalClcw.setReceiverFrameSequenceNumber(vR); internalClcw.setFarmBCount(farmBCounter); clcw->setWhole(internalClcw.getAsWhole()); switch (result) { - case RETURN_OK: + case returnvalue::OK: return mapDemultiplexing(frame); case BC_IS_SET_VR_COMMAND: case BC_IS_UNLOCK_COMMAND: // Need to catch these codes to avoid error reporting later. - return RETURN_OK; + return returnvalue::OK; default: break; } @@ -79,15 +79,15 @@ ReturnValue_t VirtualChannelReception::addMapChannel(uint8_t mapId, MapPacketExt std::pair returnValue = mapChannels.insert(std::pair(mapId, object)); if (returnValue.second == true) { - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t VirtualChannelReception::handleBDFrame(TcTransferFrame* frame, ClcwIF* clcw) { farmBCounter++; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t VirtualChannelReception::handleBCFrame(TcTransferFrame* frame, ClcwIF* clcw) { @@ -107,18 +107,18 @@ ReturnValue_t VirtualChannelReception::handleBCFrame(TcTransferFrame* frame, Clc uint8_t VirtualChannelReception::getChannelId() const { return channelId; } ReturnValue_t VirtualChannelReception::initialize() { - ReturnValue_t returnValue = RETURN_FAILED; + ReturnValue_t returnValue = returnvalue::FAILED; if ((slidingWindowWidth > 254) || (slidingWindowWidth % 2 != 0)) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VirtualChannelReception::initialize: Illegal sliding window width: " << (int)slidingWindowWidth << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } for (mapChannelIterator iterator = mapChannels.begin(); iterator != mapChannels.end(); iterator++) { returnValue = iterator->second->initialize(); - if (returnValue != RETURN_OK) break; + if (returnValue != returnvalue::OK) break; } return returnValue; } diff --git a/src/fsfw/datalinklayer/VirtualChannelReception.h b/src/fsfw/datalinklayer/VirtualChannelReception.h index 6dc17dd8..d425123a 100644 --- a/src/fsfw/datalinklayer/VirtualChannelReception.h +++ b/src/fsfw/datalinklayer/VirtualChannelReception.h @@ -102,13 +102,13 @@ class VirtualChannelReception : public VirtualChannelReceptionIF, public CCSDSRe * Helper method to simplify adding a mapChannel during construction. * @param mapId The mapId of the object to add. * @param object Pointer to the MapPacketExtraction object itself. - * @return @c RETURN_OK if the channel was successfully inserted, @c RETURN_FAILED otherwise. + * @return @c RETURN_OK if the channel was successfully inserted, @c returnvalue::FAILED otherwise. */ ReturnValue_t addMapChannel(uint8_t mapId, MapPacketExtractionIF* object); /** * The initialization routine checks the set #slidingWindowWidth and initializes all MAP * channels. - * @return @c RETURN_OK on successful initialization, @c RETURN_FAILED otherwise. + * @return @c RETURN_OK on successful initialization, @c returnvalue::FAILED otherwise. */ ReturnValue_t initialize(); /** diff --git a/src/fsfw/datapool/PoolDataSetBase.cpp b/src/fsfw/datapool/PoolDataSetBase.cpp index b31f4725..0df21d2a 100644 --- a/src/fsfw/datapool/PoolDataSetBase.cpp +++ b/src/fsfw/datapool/PoolDataSetBase.cpp @@ -14,7 +14,7 @@ PoolDataSetBase::~PoolDataSetBase() {} ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF* variable) { if (registeredVariables == nullptr) { /* Underlying container invalid */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (state != States::STATE_SET_UNINITIALISED) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -42,17 +42,17 @@ ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF* variable) { } registeredVariables[fillCount] = variable; fillCount++; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; ReturnValue_t error = result; if (state == States::STATE_SET_UNINITIALISED) { lockDataPool(timeoutType, lockTimeout); for (uint16_t count = 0; count < fillCount; count++) { result = readVariable(count); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { error = result; } } @@ -71,7 +71,7 @@ ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t l result = SET_WAS_ALREADY_READ; } - if (error != HasReturnvaluesIF::RETURN_OK) { + if (error != returnvalue::OK) { result = error; } return result; @@ -80,10 +80,10 @@ ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t l uint16_t PoolDataSetBase::getFillCount() const { return fillCount; } ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (registeredVariables[count] == nullptr) { /* Configuration error. */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } /* These checks are often performed by the respective variable implementation too, but I guess @@ -98,7 +98,7 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) { result = ReadCommitIFAttorney::readWithoutLock(registeredVariables[count]); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { result = INVALID_PARAMETER_DEFINITION; } } @@ -108,7 +108,7 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) { ReturnValue_t PoolDataSetBase::commit(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { if (state == States::STATE_SET_WAS_READ) { handleAlreadyReadDatasetCommit(timeoutType, lockTimeout); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return handleUnreadDatasetCommit(timeoutType, lockTimeout); } @@ -134,7 +134,7 @@ void PoolDataSetBase::handleAlreadyReadDatasetCommit(MutexIF::TimeoutType timeou ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; lockDataPool(timeoutType, lockTimeout); for (uint16_t count = 0; count < fillCount; count++) { if ((registeredVariables[count]->getReadWriteMode() == PoolVariableIF::VAR_WRITE) and @@ -165,17 +165,17 @@ ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(MutexIF::TimeoutType ti ReturnValue_t PoolDataSetBase::lockDataPool(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } -ReturnValue_t PoolDataSetBase::unlockDataPool() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t PoolDataSetBase::unlockDataPool() { return returnvalue::OK; } ReturnValue_t PoolDataSetBase::serialize(uint8_t** buffer, size_t* size, const size_t maxSize, SerializeIF::Endianness streamEndianness) const { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (uint16_t count = 0; count < fillCount; count++) { result = registeredVariables[count]->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -184,10 +184,10 @@ ReturnValue_t PoolDataSetBase::serialize(uint8_t** buffer, size_t* size, const s ReturnValue_t PoolDataSetBase::deSerialize(const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (uint16_t count = 0; count < fillCount; count++) { result = registeredVariables[count]->deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } diff --git a/src/fsfw/datapool/PoolDataSetBase.h b/src/fsfw/datapool/PoolDataSetBase.h index dc6ec135..79a1095b 100644 --- a/src/fsfw/datapool/PoolDataSetBase.h +++ b/src/fsfw/datapool/PoolDataSetBase.h @@ -29,20 +29,20 @@ * @author Bastian Baetz * @ingroup data_pool */ -class PoolDataSetBase : public PoolDataSetIF, public SerializeIF, public HasReturnvaluesIF { +class PoolDataSetBase : public PoolDataSetIF, public SerializeIF { public: /** * @brief Creates an empty dataset. Use registerVariable or * supply a pointer to this dataset to PoolVariable * initializations to register pool variables. */ - PoolDataSetBase(PoolVariableIF** registeredVariablesArray, const size_t maxFillCount); + PoolDataSetBase(PoolVariableIF** registeredVariablesArray, size_t maxFillCount); /* Forbidden for now */ PoolDataSetBase(const PoolDataSetBase& otherSet) = delete; const PoolDataSetBase& operator=(const PoolDataSetBase& otherSet) = delete; - virtual ~PoolDataSetBase(); + ~PoolDataSetBase() override; /** * @brief The read call initializes reading out all registered variables. diff --git a/src/fsfw/datapool/PoolReadGuard.h b/src/fsfw/datapool/PoolReadGuard.h index 24d98933..f9bf35fe 100644 --- a/src/fsfw/datapool/PoolReadGuard.h +++ b/src/fsfw/datapool/PoolReadGuard.h @@ -17,7 +17,7 @@ class PoolReadGuard { : readObject(readObject), mutexTimeout(mutexTimeout) { if (readObject != nullptr) { readResult = readObject->read(timeoutType, mutexTimeout); - if (readResult != HasReturnvaluesIF::RETURN_OK) { + if (readResult != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PoolReadHelper: Read failed!" << std::endl; @@ -47,7 +47,7 @@ class PoolReadGuard { private: ReadCommitIF* readObject = nullptr; - ReturnValue_t readResult = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t readResult = returnvalue::OK; bool noCommit = false; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; uint32_t mutexTimeout = 20; diff --git a/src/fsfw/datapool/ReadCommitIFAttorney.h b/src/fsfw/datapool/ReadCommitIFAttorney.h index ea39ffe5..361ac6e4 100644 --- a/src/fsfw/datapool/ReadCommitIFAttorney.h +++ b/src/fsfw/datapool/ReadCommitIFAttorney.h @@ -12,14 +12,14 @@ class ReadCommitIFAttorney { private: static ReturnValue_t readWithoutLock(ReadCommitIF* readCommitIF) { if (readCommitIF == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return readCommitIF->readWithoutLock(); } static ReturnValue_t commitWithoutLock(ReadCommitIF* readCommitIF) { if (readCommitIF == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return readCommitIF->commitWithoutLock(); } diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h index a2925a46..2cf20e0b 100644 --- a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h +++ b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h @@ -111,10 +111,10 @@ class HasLocalDataPoolIF { * These function can be implemented by pool owner, if they are required * and used by the housekeeping message interface. * */ - virtual ReturnValue_t addDataSet(sid_t sid) { return HasReturnvaluesIF::RETURN_FAILED; }; - virtual ReturnValue_t removeDataSet(sid_t sid) { return HasReturnvaluesIF::RETURN_FAILED; }; + virtual ReturnValue_t addDataSet(sid_t sid) { return returnvalue::FAILED; }; + virtual ReturnValue_t removeDataSet(sid_t sid) { return returnvalue::FAILED; }; virtual ReturnValue_t changeCollectionInterval(sid_t sid, float newIntervalSeconds) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; }; /** diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 9b7f800f..497e4ef3 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -22,14 +22,14 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQue : appendValidityBuffer(appendValidityBuffer) { if (owner == nullptr) { printWarningOrError(sif::OutputTypes::OUT_WARNING, "LocalDataPoolManager", - HasReturnvaluesIF::RETURN_FAILED, "Invalid supplied owner"); + returnvalue::FAILED, "Invalid supplied owner"); return; } this->owner = owner; mutex = MutexFactory::instance()->createMutex(); if (mutex == nullptr) { printWarningOrError(sif::OutputTypes::OUT_ERROR, "LocalDataPoolManager", - HasReturnvaluesIF::RETURN_FAILED, "Could not create mutex"); + returnvalue::FAILED, "Could not create mutex"); } hkQueue = queueToUse; @@ -51,9 +51,9 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore == nullptr) { /* Error, all destinations invalid */ - printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", HasReturnvaluesIF::RETURN_FAILED, + printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", returnvalue::FAILED, "Could not set IPC store."); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (defaultHkDestination != objects::NO_OBJECT) { @@ -67,7 +67,7 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::initializeAfterTaskCreation(uint8_t nonDiagInvlFactor) { @@ -78,19 +78,19 @@ ReturnValue_t LocalDataPoolManager::initializeAfterTaskCreation(uint8_t nonDiagI ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() { if (not mapInitialized) { ReturnValue_t result = owner->initializeLocalDataPool(localPoolMap, *this); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { mapInitialized = true; } return result; } printWarningOrError(sif::OutputTypes::OUT_WARNING, "initializeHousekeepingPoolEntriesOnce", - HasReturnvaluesIF::RETURN_FAILED, "The map should only be initialized once"); - return HasReturnvaluesIF::RETURN_OK; + returnvalue::FAILED, "The map should only be initialized once"); + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::performHkOperation() { - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; for (auto& receiver : hkReceivers) { switch (receiver.reportingType) { case (ReportingType::PERIODIC): { @@ -115,7 +115,7 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() { } default: // This should never happen. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } resetHkUpdateResetHelper(); @@ -125,7 +125,7 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() { ReturnValue_t LocalDataPoolManager::handleHkUpdate(HkReceiver& receiver, ReturnValue_t& status) { if (receiver.dataType == DataType::LOCAL_POOL_VARIABLE) { /* Update packets shall only be generated from datasets. */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, receiver.dataId.sid); @@ -135,12 +135,12 @@ ReturnValue_t LocalDataPoolManager::handleHkUpdate(HkReceiver& receiver, ReturnV if (dataSet->hasChanged()) { /* Prepare and send update notification */ ReturnValue_t result = generateHousekeepingPacket(receiver.dataId.sid, dataSet, true); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } } handleChangeResetLogic(receiver.dataType, receiver.dataId, dataSet); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receiver, @@ -160,7 +160,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive HousekeepingMessage::setUpdateNotificationVariableCommand( ¬ification, gp_id_t(owner->getObjectId(), receiver.dataId.localPoolId)); ReturnValue_t result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } toReset = poolObj; @@ -179,7 +179,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive CommandMessage notification; HousekeepingMessage::setUpdateNotificationSetCommand(¬ification, receiver.dataId.sid); ReturnValue_t result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } toReset = dataSet; @@ -188,7 +188,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive if (toReset != nullptr) { handleChangeResetLogic(receiver.dataType, receiver.dataId, toReset); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& receiver, @@ -205,7 +205,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei } if (not poolObj->hasChanged()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } /* Prepare and send update snapshot */ @@ -219,7 +219,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei store_address_t storeId; ReturnValue_t result = addUpdateToStore(updatePacket, storeId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -227,7 +227,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei HousekeepingMessage::setUpdateSnapshotVariableCommand( ¬ification, gp_id_t(owner->getObjectId(), receiver.dataId.localPoolId), storeId); result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } toReset = poolObj; @@ -241,7 +241,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei } if (not dataSet->hasChanged()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } /* Prepare and send update snapshot */ @@ -255,14 +255,14 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei store_address_t storeId; ReturnValue_t result = addUpdateToStore(updatePacket, storeId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } CommandMessage notification; HousekeepingMessage::setUpdateSnapshotSetCommand(¬ification, receiver.dataId.sid, storeId); result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } toReset = dataSet; @@ -270,7 +270,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei if (toReset != nullptr) { handleChangeResetLogic(receiver.dataType, receiver.dataId, toReset); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::addUpdateToStore(HousekeepingSnapshot& updatePacket, @@ -279,7 +279,7 @@ ReturnValue_t LocalDataPoolManager::addUpdateToStore(HousekeepingSnapshot& updat uint8_t* storePtr = nullptr; ReturnValue_t result = ipcStore->getFreeElement(&storeId, updatePacket.getSerializedSize(), &storePtr); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t serializedSize = 0; @@ -362,7 +362,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool e } hkReceivers.push_back(hkReceiver); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid, bool isDiagnostics, @@ -391,7 +391,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid, bool isD hkReceivers.push_back(hkReceiver); handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::subscribeForSetUpdateMessage(const uint32_t setId, @@ -412,7 +412,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForSetUpdateMessage(const uint32_t hkReceivers.push_back(hkReceiver); handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::subscribeForVariableUpdateMessage( @@ -432,7 +432,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForVariableUpdateMessage( hkReceivers.push_back(hkReceiver); handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void LocalDataPoolManager::handleHkUpdateResetListInsertion(DataType dataType, DataId dataId) { @@ -470,7 +470,7 @@ void LocalDataPoolManager::handleHkUpdateResetListInsertion(DataType dataType, D ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* message) { Command_t command = message->getCommand(); sid_t sid = HousekeepingMessage::getSid(message); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (command) { // Houskeeping interface handling. case (HousekeepingMessage::ENABLE_PERIODIC_DIAGNOSTICS_GENERATION): { @@ -495,7 +495,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me case (HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): { result = generateSetStructurePacket(sid, true); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return result; } break; @@ -503,7 +503,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me case (HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): { result = generateSetStructurePacket(sid, false); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return result; } break; @@ -543,12 +543,12 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me /* Notification handling */ case (HousekeepingMessage::UPDATE_NOTIFICATION_SET): { owner->handleChangedDataset(sid); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE): { gp_id_t globPoolId = HousekeepingMessage::getUpdateNotificationVariableCommand(message); owner->handleChangedPoolVariable(globPoolId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (HousekeepingMessage::UPDATE_SNAPSHOT_SET): { store_address_t storeId; @@ -558,7 +558,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me if (clearMessage) { message->clear(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE): { store_address_t storeId; @@ -568,7 +568,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me if (clearMessage) { message->clear(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } default: @@ -576,7 +576,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me } CommandMessage reply; - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { HousekeepingMessage::setHkRequestFailureReply(&reply, sid, result); } else { HousekeepingMessage::setHkRequestSuccessReply(&reply, sid); @@ -593,7 +593,7 @@ ReturnValue_t LocalDataPoolManager::printPoolEntry(lp_id_t localPoolId) { return localpool::POOL_ENTRY_NOT_FOUND; } poolIter->second->print(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MutexIF* LocalDataPoolManager::getMutexHandle() { return mutex; } @@ -616,7 +616,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, size_t serializedSize = 0; ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, storeId, forDownlink, &serializedSize); - if (result != HasReturnvaluesIF::RETURN_OK or serializedSize == 0) { + if (result != returnvalue::OK or serializedSize == 0) { return result; } @@ -653,7 +653,7 @@ ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore(HousekeepingPacke uint8_t* dataPtr = nullptr; const size_t maxSize = hkPacket.getSerializedSize(); ReturnValue_t result = ipcStore->getFreeElement(&storeId, maxSize, &dataPtr); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -693,7 +693,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { } ReturnValue_t result = generateHousekeepingPacket(sid, dataSet, true); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { /* Configuration error */ #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalDataPoolManager::performPeriodicHkOperation: HK generation failed." @@ -724,7 +724,7 @@ ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid, bool ena } LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enable); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, float newCollectionInterval, @@ -750,7 +750,7 @@ ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, float ne } periodicHelper->changeCollectionInterval(newCollectionInterval); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool isDiagnostics) { @@ -778,9 +778,9 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i uint8_t* storePtr = nullptr; store_address_t storeId; ReturnValue_t result = ipcStore->getFreeElement(&storeId, expectedSize, &storePtr); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { printWarningOrError(sif::OutputTypes::OUT_ERROR, "generateSetStructurePacket", - HasReturnvaluesIF::RETURN_FAILED, + returnvalue::FAILED, "Could not get free element from IPC store."); return result; } @@ -788,13 +788,13 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i // Serialize set packet into store. size_t size = 0; result = setPacket.serialize(&storePtr, &size, expectedSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeId); return result; } if (expectedSize != size) { printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateSetStructurePacket", - HasReturnvaluesIF::RETURN_FAILED, + returnvalue::FAILED, "Expected size is not equal to serialized size"); } @@ -807,7 +807,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i } result = hkQueue->reply(&reply); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeId); } return result; @@ -835,7 +835,7 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, errorPrint = "Dataset not found"; } else if (error == POOLOBJECT_NOT_FOUND) { errorPrint = "Pool Object not found"; - } else if (error == HasReturnvaluesIF::RETURN_FAILED) { + } else if (error == returnvalue::FAILED) { if (outputType == sif::OutputTypes::OUT_WARNING) { errorPrint = "Generic Warning"; } else { diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/datapoollocal/LocalDataPoolManager.h index e7ec0b6f..bb2ea564 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.h @@ -376,7 +376,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces ReturnValue_t addUpdateToStore(HousekeepingSnapshot& updatePacket, store_address_t& storeId); void printWarningOrError(sif::OutputTypes outputType, const char* functionName, - ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED, + ReturnValue_t errorCode = returnvalue::FAILED, const char* errorPrint = nullptr); }; @@ -384,7 +384,7 @@ template inline ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, PoolEntry** poolEntry) { if (poolEntry == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } auto poolIter = localPoolMap.find(localPoolId); @@ -400,7 +400,7 @@ inline ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, localpool::POOL_ENTRY_TYPE_CONFLICT); return localpool::POOL_ENTRY_TYPE_CONFLICT; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } #endif /* FSFW_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ */ diff --git a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp index 62fdb184..38aad828 100644 --- a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp @@ -85,13 +85,13 @@ ReturnValue_t LocalPoolDataSetBase::lockDataPool(MutexIF::TimeoutType timeoutTyp if (mutexIfSingleDataCreator != nullptr) { return mutexIfSingleDataCreator->lockMutex(timeoutType, timeoutMs); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer( uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; const uint8_t validityMaskSize = std::ceil(static_cast(fillCount) / 8.0); uint8_t *validityPtr = nullptr; #if defined(_MSC_VER) || defined(__clang__) @@ -119,7 +119,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer( } result = registeredVariables[count]->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -135,10 +135,10 @@ ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer( ReturnValue_t LocalPoolDataSetBase::deSerializeWithValidityBuffer( const uint8_t **buffer, size_t *size, SerializeIF::Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (uint16_t count = 0; count < fillCount; count++) { result = registeredVariables[count]->deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -169,7 +169,7 @@ ReturnValue_t LocalPoolDataSetBase::unlockDataPool() { if (mutexIfSingleDataCreator != nullptr) { return mutexIfSingleDataCreator->unlockMutex(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size_t *size, @@ -185,7 +185,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size lp_id_t currentPoolId = registeredVariables[count]->getDataPoolId(); auto result = SerializeAdapter::serialize(¤tPoolId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: " << "Serialization error!" << std::endl; @@ -197,7 +197,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size return result; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint8_t LocalPoolDataSetBase::getLocalPoolIdsSerializedSize(bool serializeFillCount) const { diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.h b/src/fsfw/datapoollocal/LocalPoolObjectBase.h index b2ffa4c1..f454fea3 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.h +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.h @@ -15,7 +15,7 @@ class HasLocalDataPoolIF; * @brief This class serves as a non-template base for pool objects like pool variables * or pool vectors. */ -class LocalPoolObjectBase : public PoolVariableIF, public HasReturnvaluesIF, public MarkChangedIF { +class LocalPoolObjectBase : public PoolVariableIF, public MarkChangedIF { public: LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet, pool_rwm_t setReadWriteMode); diff --git a/src/fsfw/datapoollocal/LocalPoolVariable.tpp b/src/fsfw/datapoollocal/LocalPoolVariable.tpp index f800dfd3..969a047b 100644 --- a/src/fsfw/datapoollocal/LocalPoolVariable.tpp +++ b/src/fsfw/datapoollocal/LocalPoolVariable.tpp @@ -29,7 +29,7 @@ inline ReturnValue_t LocalPoolVariable::read(MutexIF::TimeoutType timeoutType } MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager); ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = readWithoutLock(); @@ -49,7 +49,7 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { object_id_t ownerObjectId = hkManager->getCreatorObjectId(); reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId); return result; @@ -57,7 +57,7 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { this->value = *(poolEntry->getDataPtr()); this->valid = poolEntry->getValid(); - return RETURN_OK; + return returnvalue::OK; } template @@ -75,7 +75,7 @@ inline ReturnValue_t LocalPoolVariable::commit(MutexIF::TimeoutType timeoutTy } MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager); ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = commitWithoutLock(); @@ -95,7 +95,7 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { object_id_t ownerObjectId = hkManager->getCreatorObjectId(); reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId); return result; @@ -103,7 +103,7 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { *(poolEntry->getDataPtr()) = this->value; poolEntry->setValid(this->valid); - return RETURN_OK; + return returnvalue::OK; } template diff --git a/src/fsfw/datapoollocal/LocalPoolVector.tpp b/src/fsfw/datapoollocal/LocalPoolVector.tpp index a2c2b752..939405a9 100644 --- a/src/fsfw/datapoollocal/LocalPoolVector.tpp +++ b/src/fsfw/datapoollocal/LocalPoolVector.tpp @@ -43,14 +43,14 @@ inline ReturnValue_t LocalPoolVector::readWithoutLock() { LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); memset(this->value, 0, vectorSize * sizeof(T)); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { object_id_t targetObjectId = hkManager->getCreatorObjectId(); reportReadCommitError("LocalPoolVector", result, true, targetObjectId, localPoolId); return result; } std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize()); this->valid = poolEntry->getValid(); - return RETURN_OK; + return returnvalue::OK; } template @@ -79,14 +79,14 @@ inline ReturnValue_t LocalPoolVector::commitWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { object_id_t targetObjectId = hkManager->getCreatorObjectId(); reportReadCommitError("LocalPoolVector", result, false, targetObjectId, localPoolId); return result; } std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize()); poolEntry->setValid(this->valid); - return RETURN_OK; + return returnvalue::OK; } template @@ -131,10 +131,10 @@ template inline ReturnValue_t LocalPoolVector::serialize( uint8_t** buffer, size_t* size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (uint16_t i = 0; i < vectorSize; i++) { result = SerializeAdapter::serialize(&(value[i]), buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { break; } } @@ -149,10 +149,10 @@ inline size_t LocalPoolVector::getSerializedSize() const { template inline ReturnValue_t LocalPoolVector::deSerialize( const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (uint16_t i = 0; i < vectorSize; i++) { result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { break; } } diff --git a/src/fsfw/datapoollocal/SharedLocalDataSet.cpp b/src/fsfw/datapoollocal/SharedLocalDataSet.cpp index 248c1577..6d0b0b11 100644 --- a/src/fsfw/datapoollocal/SharedLocalDataSet.cpp +++ b/src/fsfw/datapoollocal/SharedLocalDataSet.cpp @@ -20,7 +20,7 @@ ReturnValue_t SharedLocalDataSet::lockDataset(MutexIF::TimeoutType timeoutType, if (datasetLock != nullptr) { return datasetLock->lockMutex(timeoutType, mutexTimeout); } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } SharedLocalDataSet::~SharedLocalDataSet() { MutexFactory::instance()->deleteMutex(datasetLock); } @@ -29,5 +29,5 @@ ReturnValue_t SharedLocalDataSet::unlockDataset() { if (datasetLock != nullptr) { return datasetLock->unlockMutex(); } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } diff --git a/src/fsfw/devicehandlers/AssemblyBase.cpp b/src/fsfw/devicehandlers/AssemblyBase.cpp index c29022e5..63178ab9 100644 --- a/src/fsfw/devicehandlers/AssemblyBase.cpp +++ b/src/fsfw/devicehandlers/AssemblyBase.cpp @@ -50,7 +50,7 @@ bool AssemblyBase::isInTransition() { bool AssemblyBase::handleChildrenChanged() { if (childrenChangedMode) { ReturnValue_t result = checkChildrenState(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { handleChildrenLostMode(result); } return true; @@ -116,7 +116,7 @@ void AssemblyBase::handleChildrenTransition() { break; } ReturnValue_t result = checkChildrenState(); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { handleModeReached(); } else { handleModeTransitionFailed(result); @@ -149,7 +149,7 @@ void AssemblyBase::handleModeTransitionFailed(ReturnValue_t result) { void AssemblyBase::sendHealthCommand(MessageQueueId_t sendTo, HealthState health) { CommandMessage command; HealthMessage::setHealthMessage(&command, HealthMessage::HEALTH_SET, health); - if (commandQueue->sendMessage(sendTo, &command) == RETURN_OK) { + if (commandQueue->sendMessage(sendTo, &command) == returnvalue::OK) { commandsOutstanding++; } } @@ -164,25 +164,25 @@ ReturnValue_t AssemblyBase::checkChildrenState() { ReturnValue_t AssemblyBase::checkChildrenStateOff() { for (const auto& childIter : childrenMap) { - if (checkChildOff(childIter.first) != RETURN_OK) { + if (checkChildOff(childIter.first) != returnvalue::OK) { return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE; } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t AssemblyBase::checkChildOff(uint32_t objectId) { ChildInfo childInfo = childrenMap.find(objectId)->second; if (healthHelper.healthTable->isCommandable(objectId)) { if (childInfo.submode != SUBMODE_NONE) { - return RETURN_FAILED; + return returnvalue::FAILED; } else { if ((childInfo.mode != MODE_OFF) && (childInfo.mode != DeviceHandlerIF::MODE_ERROR_ON)) { - return RETURN_FAILED; + return returnvalue::FAILED; } } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t AssemblyBase::checkModeCommand(Mode_t mode, Submode_t submode, @@ -192,7 +192,7 @@ ReturnValue_t AssemblyBase::checkModeCommand(Mode_t mode, Submode_t submode, if (submode != SUBMODE_NONE) { return INVALID_SUBMODE; } - return RETURN_OK; + return returnvalue::OK; } if ((mode != MODE_ON) && (mode != DeviceHandlerIF::MODE_NORMAL)) { @@ -212,7 +212,7 @@ ReturnValue_t AssemblyBase::handleHealthReply(CommandMessage* message) { if (health != EXTERNAL_CONTROL) { updateChildChangedHealth(message->getSender(), true); } - return RETURN_OK; + return returnvalue::OK; } if (message->getCommand() == HealthMessage::REPLY_HEALTH_SET || (message->getCommand() == CommandMessage::REPLY_REJECTED && @@ -220,9 +220,9 @@ ReturnValue_t AssemblyBase::handleHealthReply(CommandMessage* message) { if (isInTransition()) { commandsOutstanding--; } - return RETURN_OK; + return returnvalue::OK; } - return RETURN_FAILED; + return returnvalue::FAILED; } bool AssemblyBase::checkAndHandleRecovery() { diff --git a/src/fsfw/devicehandlers/AssemblyBase.h b/src/fsfw/devicehandlers/AssemblyBase.h index 3e235928..92feb6ae 100644 --- a/src/fsfw/devicehandlers/AssemblyBase.h +++ b/src/fsfw/devicehandlers/AssemblyBase.h @@ -79,7 +79,7 @@ class AssemblyBase : public SubsystemBase { * @param submode The targeted submmode * @return Any information why this combination is invalid from HasModesIF * like HasModesIF::INVALID_SUBMODE. - * On success return HasReturnvaluesIF::RETURN_OK + * On success return returnvalue::OK */ virtual ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) = 0; diff --git a/src/fsfw/devicehandlers/ChildHandlerBase.cpp b/src/fsfw/devicehandlers/ChildHandlerBase.cpp index be4f4798..ecd4cfc8 100644 --- a/src/fsfw/devicehandlers/ChildHandlerBase.cpp +++ b/src/fsfw/devicehandlers/ChildHandlerBase.cpp @@ -19,7 +19,7 @@ ChildHandlerBase::~ChildHandlerBase() {} ReturnValue_t ChildHandlerBase::initialize() { ReturnValue_t result = DeviceHandlerBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -28,7 +28,7 @@ ReturnValue_t ChildHandlerBase::initialize() { if (parentId != objects::NO_OBJECT) { SubsystemBase* parent = ObjectManager::instance()->get(parentId); if (parent == NULL) { - return RETURN_FAILED; + return returnvalue::FAILED; } parentQueue = parent->getCommandQueue(); @@ -39,5 +39,5 @@ ReturnValue_t ChildHandlerBase::initialize() { modeHelper.setParentQueue(parentQueue); - return RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/devicehandlers/DeviceCommunicationIF.h b/src/fsfw/devicehandlers/DeviceCommunicationIF.h index 7a860411..5af3f3f0 100644 --- a/src/fsfw/devicehandlers/DeviceCommunicationIF.h +++ b/src/fsfw/devicehandlers/DeviceCommunicationIF.h @@ -34,7 +34,7 @@ * @ingroup interfaces * @ingroup comm */ -class DeviceCommunicationIF : public HasReturnvaluesIF { +class DeviceCommunicationIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_COMMUNICATION_IF; diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index cf457a03..a93aca0d 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -32,7 +32,7 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device parameterHelper(this), actionHelper(this, nullptr), poolManager(this, nullptr), - childTransitionFailure(RETURN_OK), + childTransitionFailure(returnvalue::OK), fdirInstance(fdirInstance), defaultFDIRUsed(fdirInstance == nullptr), switchOffWasReported(false), @@ -46,7 +46,7 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device cookieInfo.pendingCommand = deviceCommandMap.end(); if (comCookie == nullptr) { printWarningOrError(sif::OutputTypes::OUT_ERROR, "DeviceHandlerBase", - HasReturnvaluesIF::RETURN_FAILED, "Invalid cookie"); + returnvalue::FAILED, "Invalid cookie"); } if (this->fdirInstance == nullptr) { this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId, defaultFdirParentId); @@ -79,7 +79,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { this->lastStep = this->pstStep; if (getComAction() == CommunicationAction::NOTHING) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } if (getComAction() == CommunicationAction::PERFORM_OPERATION) { @@ -90,11 +90,11 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { decrementDeviceReplyMap(); fdirInstance->checkForFailures(); performOperationHook(); - return RETURN_OK; + return returnvalue::OK; } if (mode == MODE_OFF) { - return RETURN_OK; + return returnvalue::OK; } switch (getComAction()) { @@ -120,12 +120,12 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { default: break; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DeviceHandlerBase::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -138,7 +138,7 @@ ReturnValue_t DeviceHandlerBase::initialize() { } result = communicationInterface->initializeInterface(comCookie); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, "ComIF initialization failed"); return result; @@ -192,30 +192,30 @@ ReturnValue_t DeviceHandlerBase::initialize() { } result = healthHelper.initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = modeHelper.initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = fdirInstance->initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = parameterHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = poolManager.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -224,14 +224,14 @@ ReturnValue_t DeviceHandlerBase::initialize() { if (thermalSet != nullptr) { // Set temperature target state to NON_OP. result = thermalSet->read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; thermalSet->heaterRequest.setValid(true); thermalSet->commit(); } } - return RETURN_OK; + return returnvalue::OK; } void DeviceHandlerBase::decrementDeviceReplyMap() { @@ -265,42 +265,42 @@ void DeviceHandlerBase::readCommandQueue() { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return; } result = healthHelper.handleHealthCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = modeHelper.handleModeCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = parameterHelper.handleParameterMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = poolManager.handleHousekeepingMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = handleDeviceHandlerMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = letChildHandleMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } @@ -328,7 +328,7 @@ void DeviceHandlerBase::doStateMachine() { sprintf(printout, "Transition timeout (%lu) occured !", static_cast(childTransitionDelay)); /* Common configuration error for development, so print it */ - printWarningOrError(sif::OutputTypes::OUT_WARNING, "doStateMachine", RETURN_FAILED, + printWarningOrError(sif::OutputTypes::OUT_WARNING, "doStateMachine", returnvalue::FAILED, printout); #endif triggerEvent(MODE_TRANSITION_FAILED, childTransitionFailure, 0); @@ -407,7 +407,7 @@ ReturnValue_t DeviceHandlerBase::isModeCombinationValid(Mode_t mode, Submode_t s case MODE_NORMAL: case MODE_RAW: if (submode == SUBMODE_NONE) { - return RETURN_OK; + return returnvalue::OK; } else { return INVALID_SUBMODE; } @@ -444,9 +444,9 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, info.countdown = countdown; auto resultPair = deviceReplyMap.emplace(replyId, info); if (resultPair.second) { - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } @@ -461,9 +461,9 @@ ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceComm info.alternativeReplyId = alternativeReplyId; auto resultPair = deviceCommandMap.emplace(deviceCommand, info); if (resultPair.second) { - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } @@ -499,7 +499,7 @@ ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceRep } info->delayCycles = delayCycles; info->periodic = periodic; - return RETURN_OK; + return returnvalue::OK; } } @@ -529,17 +529,17 @@ ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandI } } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t DeviceHandlerBase::setReplyDataset(DeviceCommandId_t replyId, LocalPoolDataSetBase* dataSet) { auto replyIter = deviceReplyMap.find(replyId); if (replyIter == deviceReplyMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } replyIter->second.dataSet = dataSet; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void DeviceHandlerBase::callChildStatemachine() { @@ -578,7 +578,7 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) { if (mode == MODE_OFF and thermalSet != nullptr) { ReturnValue_t result = thermalSet->read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { if (thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) { thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; } @@ -593,7 +593,7 @@ void DeviceHandlerBase::setMode(Mode_t newMode) { setMode(newMode, submode); } void DeviceHandlerBase::replyReturnvalueToCommand(ReturnValue_t status, uint32_t parameter) { // This is actually the reply protocol for raw and misc DH commands. - if (status == RETURN_OK) { + if (status == returnvalue::OK) { CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, parameter); commandQueue->reply(&reply); } else { @@ -606,7 +606,7 @@ void DeviceHandlerBase::replyToCommand(ReturnValue_t status, uint32_t parameter) // Check if we reply to a raw command. if (cookieInfo.pendingCommand->first == RAW_COMMAND_ID) { if (status == NO_REPLY_EXPECTED) { - status = RETURN_OK; + status = returnvalue::OK; } replyReturnvalueToCommand(status, parameter); // Always delete data from a raw command. @@ -617,7 +617,7 @@ void DeviceHandlerBase::replyToCommand(ReturnValue_t status, uint32_t parameter) if (cookieInfo.pendingCommand->second.sendReplyTo != NO_COMMANDER) { MessageQueueId_t queueId = cookieInfo.pendingCommand->second.sendReplyTo; if (status == NO_REPLY_EXPECTED) { - actionHelper.finish(true, queueId, cookieInfo.pendingCommand->first, RETURN_OK); + actionHelper.finish(true, queueId, cookieInfo.pendingCommand->first, returnvalue::OK); } else { actionHelper.step(1, queueId, cookieInfo.pendingCommand->first, status); } @@ -635,7 +635,7 @@ void DeviceHandlerBase::replyToReply(const DeviceCommandId_t command, DeviceRepl DeviceCommandInfo* info = &replyInfo.command->second; if (info == nullptr) { printWarningOrError(sif::OutputTypes::OUT_ERROR, "replyToReply", - HasReturnvaluesIF::RETURN_FAILED, "Command pointer not found"); + returnvalue::FAILED, "Command pointer not found"); return; } @@ -649,7 +649,7 @@ void DeviceHandlerBase::replyToReply(const DeviceCommandId_t command, DeviceRepl // Don't send any replies in that case. if (info->sendReplyTo != NO_COMMANDER) { bool success = false; - if (status == HasReturnvaluesIF::RETURN_OK) { + if (status == returnvalue::OK) { success = true; } actionHelper.finish(success, info->sendReplyTo, command, status); @@ -662,7 +662,7 @@ void DeviceHandlerBase::doSendWrite() { if (cookieInfo.state == COOKIE_WRITE_READY) { ReturnValue_t result = communicationInterface->sendMessage(comCookie, rawPacket, rawPacketLen); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { cookieInfo.state = COOKIE_WRITE_SENT; } else { // always generate a failure event, so that FDIR knows what's up @@ -680,7 +680,7 @@ void DeviceHandlerBase::doGetWrite() { } cookieInfo.state = COOKIE_UNUSED; ReturnValue_t result = communicationInterface->getSendSuccess(comCookie); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { if (wiretappingMode == RAW) { replyRawData(rawPacket, rawPacketLen, requestedRawTraffic, true); } @@ -694,7 +694,7 @@ void DeviceHandlerBase::doGetWrite() { // always generate a failure event, so that FDIR knows what's up triggerEvent(DEVICE_SENDING_COMMAND_FAILED, result, cookieInfo.pendingCommand->first); } - if (result != RETURN_OK) { + if (result != returnvalue::OK) { cookieInfo.pendingCommand->second.isExecuting = false; } replyToCommand(result); @@ -704,7 +704,7 @@ void DeviceHandlerBase::doSendRead() { ReturnValue_t result; result = doSendReadHook(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return; } @@ -715,7 +715,7 @@ void DeviceHandlerBase::doSendRead() { result = communicationInterface->requestReceiveMessage(comCookie, replyLen); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { cookieInfo.state = COOKIE_READ_SENT; } else { triggerEvent(DEVICE_REQUESTING_REPLY_FAILED, result); @@ -741,7 +741,7 @@ void DeviceHandlerBase::doGetRead() { ReturnValue_t result = communicationInterface->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { triggerEvent(DEVICE_REQUESTING_REPLY_FAILED, result); // I think we can allow to ignore one missedReply. ignoreMissedRepliesCount++; @@ -764,7 +764,7 @@ void DeviceHandlerBase::doGetRead() { } void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedDataLen) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; DeviceCommandId_t foundId = DeviceHandlerIF::NO_COMMAND_ID; size_t foundLen = 0; /* The loop may not execute more often than the number of received bytes @@ -773,7 +773,7 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedD for (uint32_t count = 0; count < receivedDataLen; count++) { result = scanForReply(receivedData, remainingLength, &foundId, &foundLen); switch (result) { - case RETURN_OK: + case returnvalue::OK: handleReply(receivedData, foundId, foundLen); if (foundLen == 0) { printWarningOrError(sif::OutputTypes::OUT_WARNING, "parseReply", @@ -783,7 +783,7 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedD break; case APERIODIC_REPLY: { result = interpretDeviceReply(foundId, receivedData); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { replyRawReplyIfnotWiretapped(receivedData, foundLen); triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result, foundId); } @@ -846,7 +846,7 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, DeviceCommandId resetDelayCyclesControlledReply(info); } - if (result != RETURN_OK) { + if (result != returnvalue::OK) { // Report failed interpretation to FDIR. replyRawReplyIfnotWiretapped(receivedData, foundLen); triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result, foundId); @@ -887,12 +887,12 @@ ReturnValue_t DeviceHandlerBase::getStorageData(store_address_t storageAddress, if (IPCStore == nullptr) { *data = nullptr; *len = 0; - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t result = IPCStore->modifyData(storageAddress, data, &lenTmp); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { *len = lenTmp; - return RETURN_OK; + return returnvalue::OK; } else { triggerEvent(StorageManagerIF::GET_DATA_FAILED, result, storageAddress.raw); *data = nullptr; @@ -909,7 +909,7 @@ void DeviceHandlerBase::replyRawData(const uint8_t* data, size_t len, MessageQue store_address_t address; ReturnValue_t result = IPCStore->addData(&address, data, len); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { triggerEvent(StorageManagerIF::STORE_DATA_FAILED, result); return; } @@ -921,7 +921,7 @@ void DeviceHandlerBase::replyRawData(const uint8_t* data, size_t len, MessageQue result = commandQueue->sendMessage(sendTo, &command); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { IPCStore->deleteData(address); // Silently discard data, this indicates heavy TM traffic which // should not be increased by additional events. @@ -957,7 +957,7 @@ MessageQueueId_t DeviceHandlerBase::getCommandQueue() const { return commandQueu void DeviceHandlerBase::buildRawDeviceCommand(CommandMessage* commandMessage) { storedRawData = DeviceHandlerMessage::getStoreAddress(commandMessage); ReturnValue_t result = getStorageData(storedRawData, &rawPacket, &rawPacketLen); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { replyReturnvalueToCommand(result, RAW_COMMAND_ID); storedRawData.raw = StorageManagerIF::INVALID_ADDRESS; } else { @@ -974,7 +974,7 @@ void DeviceHandlerBase::commandSwitch(ReturnValue_t onOff) { const uint8_t* switches; uint8_t numberOfSwitches = 0; ReturnValue_t result = getSwitches(&switches, &numberOfSwitches); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { while (numberOfSwitches > 0) { powerSwitcher->sendSwitchCommand(switches[numberOfSwitches - 1], onOff); numberOfSwitches--; @@ -982,7 +982,7 @@ void DeviceHandlerBase::commandSwitch(ReturnValue_t onOff) { } } -ReturnValue_t DeviceHandlerBase::doSendReadHook() { return RETURN_OK; } +ReturnValue_t DeviceHandlerBase::doSendReadHook() { return returnvalue::OK; } ReturnValue_t DeviceHandlerBase::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { return DeviceHandlerBase::NO_SWITCH; @@ -1011,7 +1011,7 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(DeviceCommandMap::iterato info->countdown->resetTimer(); } info->active = true; - return RETURN_OK; + return returnvalue::OK; } else { return NO_REPLY_EXPECTED; } @@ -1029,7 +1029,7 @@ ReturnValue_t DeviceHandlerBase::getStateOfSwitches(void) { const uint8_t* switches; ReturnValue_t result = getSwitches(&switches, &numberOfSwitches); - if ((result == RETURN_OK) && (numberOfSwitches != 0)) { + if ((result == returnvalue::OK) && (numberOfSwitches != 0)) { while (numberOfSwitches > 0) { if (powerSwitcher->getSwitchState(switches[numberOfSwitches - 1]) == PowerSwitchIF::SWITCH_OFF) { @@ -1074,7 +1074,7 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode, Submode_ if ((commandedMode == MODE_ON) && (mode == MODE_OFF) and (thermalSet != nullptr)) { ReturnValue_t result = thermalSet->read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { if ((thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) and (not ThermalComponentIF::isOperational(thermalSet->thermalState.value))) { triggerEvent(ThermalComponentIF::TEMP_NOT_IN_OP_RANGE, thermalSet->thermalState.value); @@ -1134,7 +1134,7 @@ void DeviceHandlerBase::handleTransitionToOnMode(Mode_t commandedMode, Submode_t triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode); if (thermalSet != nullptr) { ReturnValue_t result = thermalSet->read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { if (thermalSet->heaterRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { thermalSet->heaterRequest = ThermalComponentIF::STATE_REQUEST_OPERATIONAL; thermalSet->commit(); @@ -1169,7 +1169,7 @@ HasHealthIF::HealthState DeviceHandlerBase::getHealth() { return healthHelper.ge ReturnValue_t DeviceHandlerBase::setHealth(HealthState health) { healthHelper.setHealth(health); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void DeviceHandlerBase::checkSwitchState() { @@ -1191,7 +1191,7 @@ ReturnValue_t DeviceHandlerBase::acceptExternalDeviceCommands() { if ((mode != MODE_ON) && (mode != MODE_NORMAL)) { return WRONG_MODE_FOR_COMMAND; } - return RETURN_OK; + return returnvalue::OK; } void DeviceHandlerBase::replyRawReplyIfnotWiretapped(const uint8_t* data, size_t len) { @@ -1220,10 +1220,10 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(CommandMessage* mess default: replyReturnvalueToCommand(INVALID_COMMAND_PARAMETER); wiretappingMode = OFF; - return RETURN_OK; + return returnvalue::OK; } - replyReturnvalueToCommand(RETURN_OK); - return RETURN_OK; + replyReturnvalueToCommand(returnvalue::OK); + return returnvalue::OK; case DeviceHandlerMessage::CMD_RAW: if ((mode != MODE_RAW)) { DeviceHandlerMessage::clear(message); @@ -1231,9 +1231,9 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(CommandMessage* mess } else { buildRawDeviceCommand(message); } - return RETURN_OK; + return returnvalue::OK; default: - return RETURN_FAILED; + return returnvalue::FAILED; } } @@ -1254,7 +1254,7 @@ bool DeviceHandlerBase::isAwaitingReply() { } ReturnValue_t DeviceHandlerBase::letChildHandleMessage(CommandMessage* message) { - return RETURN_FAILED; + return returnvalue::FAILED; } void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t replyId, @@ -1316,7 +1316,7 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t r ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { ReturnValue_t result = acceptExternalDeviceCommands(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } DeviceCommandMap::iterator iter = deviceCommandMap.find(actionId); @@ -1327,7 +1327,7 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueue } else { result = buildCommandFromCommand(actionId, data, size); } - if (result == RETURN_OK) { + if (result == returnvalue::OK) { iter->second.sendReplyTo = commandedBy; iter->second.isExecuting = true; cookieInfo.pendingCommand = iter; @@ -1345,7 +1345,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { if (result == BUSY) { /* So we can track misconfigurations */ printWarningOrError(sif::OutputTypes::OUT_WARNING, "buildInternalCommand", - HasReturnvaluesIF::RETURN_FAILED, "Busy."); + returnvalue::FAILED, "Busy."); /* No need to report this */ result = NOTHING_TO_SEND; } @@ -1361,7 +1361,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { if (result == NOTHING_TO_SEND) { return; } - if (result == RETURN_OK) { + if (result == returnvalue::OK) { DeviceCommandMap::iterator iter = deviceCommandMap.find(deviceCommandId); if (iter == deviceCommandMap.end()) { #if FSFW_VERBOSE_LEVEL >= 1 @@ -1378,7 +1378,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { sprintf(output, "Command 0x%08x is executing", static_cast(deviceCommandId)); // so we can track misconfigurations printWarningOrError(sif::OutputTypes::OUT_WARNING, "buildInternalCommand", - HasReturnvaluesIF::RETURN_FAILED, output); + returnvalue::FAILED, output); #endif // this is an internal command, no need to report a failure here, // missed reply will track if a reply is too late, otherwise, it's ok @@ -1390,7 +1390,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { cookieInfo.state = COOKIE_WRITE_READY; } } - if (result != RETURN_OK) { + if (result != returnvalue::OK) { triggerEvent(DEVICE_BUILDING_COMMAND_FAILED, result, deviceCommandId); } } @@ -1466,7 +1466,7 @@ ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(localpool::DataPool& lo localDataPoolMap.emplace(thermalSet->heaterRequestPoolId, new PoolEntry); } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() { @@ -1480,7 +1480,7 @@ ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() { if (setStartupImmediately) { startTransition(MODE_ON, SUBMODE_NONE); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } LocalPoolDataSetBase* DeviceHandlerBase::getDataSetHandle(sid_t sid) { @@ -1518,7 +1518,7 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const ch if (errorPrint == nullptr) { if (errorCode == ObjectManagerIF::CHILD_INIT_FAILED) { errorPrint = "Initialization error"; - } else if (errorCode == HasReturnvaluesIF::RETURN_FAILED) { + } else if (errorCode == returnvalue::FAILED) { if (errorType == sif::OutputTypes::OUT_WARNING) { errorPrint = "Generic Warning"; } else { diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index e29e6596..35a33eab 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -78,7 +78,6 @@ class StorageManagerIF; * @ingroup devices */ class DeviceHandlerBase : public DeviceHandlerIF, - public HasReturnvaluesIF, public ExecutableObjectIF, public SystemObject, public HasModesIF, @@ -359,7 +358,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * buffer is scanned at previous position + foundLen. * @return * - @c RETURN_OK a valid packet was found at @c start, @c foundLen is valid - * - @c RETURN_FAILED no reply could be found starting at @c start, + * - @c returnvalue::FAILED no reply could be found starting at @c start, * implies @c foundLen is not valid, base class will call scanForReply() * again with ++start * - @c DeviceHandlerIF::INVALID_DATA a packet was found but it is invalid, @@ -391,7 +390,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * - @c RETURN_OK when the reply was interpreted. * - @c IGNORE_REPLY_DATA Ignore the reply and don't reset reply cycle * counter. - * - @c RETURN_FAILED when the reply could not be interpreted, + * - @c returnvalue::FAILED when the reply could not be interpreted, * e.g. logical errors or range violations occurred */ virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) = 0; @@ -452,7 +451,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * to provide a pointer to a Countdown object which will signal the timeout * when expired * @return - @c RETURN_OK when the command was successfully inserted, - * - @c RETURN_FAILED else. + * - @c returnvalue::FAILED else. */ ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, LocalPoolDataSetBase *replyDataSet = nullptr, @@ -473,7 +472,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * to provide a pointer to a Countdown object which will signal the timeout * when expired * @return - @c RETURN_OK when the command was successfully inserted, - * - @c RETURN_FAILED else. + * - @c returnvalue::FAILED else. */ ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, LocalPoolDataSetBase *dataSet = nullptr, size_t replyLen = 0, @@ -483,7 +482,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @brief A simple command to add a command to the commandList. * @param deviceCommand The command to add * @return - @c RETURN_OK when the command was successfully inserted, - * - @c RETURN_FAILED else. + * - @c returnvalue::FAILED else. */ ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand, bool useAlternativeReply = false, @@ -520,7 +519,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * by the device repeatedly without request) or not. Default is aperiodic (0). * Warning: The setting always overrides the value that was entered in the map. * @return - @c RETURN_OK when the command was successfully inserted, - * - @c RETURN_FAILED else. + * - @c returnvalue::FAILED else. */ ReturnValue_t updateReplyMapEntry(DeviceCommandId_t deviceReply, uint16_t delayCycles, uint16_t maxDelayCycles, bool periodic = false); @@ -604,7 +603,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param submode * @return * - @c RETURN_OK if valid - * - @c RETURN_FAILED if invalid + * - @c returnvalue::FAILED if invalid */ virtual ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode); /** @@ -624,7 +623,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param[out] numberOfSwitches length of returned array * @return * - @c RETURN_OK if the parameters were set - * - @c RETURN_FAILED if no switches exist + * - @c returnvalue::FAILED if no switches exist */ virtual ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches); @@ -1033,7 +1032,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * by #switches are on * - @c PowerSwitchIF::SWITCH_OFF one of the switches specified by * #switches are off - * - @c PowerSwitchIF::RETURN_FAILED if an error occured + * - @c PowerSwitchIF::returnvalue::FAILED if an error occured */ ReturnValue_t getStateOfSwitches(); @@ -1275,7 +1274,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param[out] len * @return * - @c RETURN_OK @c data is valid - * - @c RETURN_FAILED IPCStore is nullptr + * - @c returnvalue::FAILED IPCStore is nullptr * - the return value from the IPCStore if it was not @c RETURN_OK */ ReturnValue_t getStorageData(store_address_t storageAddress, uint8_t **data, size_t *len); @@ -1306,7 +1305,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param errorPrint */ void printWarningOrError(sif::OutputTypes errorType, const char *functionName, - ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED, + ReturnValue_t errorCode = returnvalue::FAILED, const char *errorPrint = nullptr); }; diff --git a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp index 48783c20..a3ac9ff7 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -23,9 +23,9 @@ DeviceHandlerFailureIsolation::~DeviceHandlerFailureIsolation() {} ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event) { if (isFdirInActionOrAreWeFaulty(event)) { - return RETURN_OK; + return returnvalue::OK; } - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; switch (event->getEvent()) { case HasModesIF::MODE_TRANSITION_FAILED: case HasModesIF::OBJECT_IN_INVALID_MODE: @@ -48,7 +48,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event) // The two above should never be confirmed. case DeviceHandlerIF::DEVICE_MISSED_REPLY: result = sendConfirmationRequest(event); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { break; } // else @@ -72,7 +72,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event) case PowerSwitchIF::SWITCH_WENT_OFF: if (powerConfirmation != MessageQueueIF::NO_QUEUE) { result = sendConfirmationRequest(event, powerConfirmation); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { setFdirState(DEVICE_MIGHT_BE_OFF); } } @@ -106,9 +106,9 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event) // break; default: // We don't know the event, someone else should handle it. - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } void DeviceHandlerFailureIsolation::eventConfirmed(EventMessage* event) { @@ -162,7 +162,7 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() { ReturnValue_t DeviceHandlerFailureIsolation::initialize() { ReturnValue_t result = FailureIsolationBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerFailureIsolation::initialize: Could not" " initialize FailureIsolationBase." @@ -176,7 +176,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::initialize() { powerConfirmation = power->getEventReceptionQueue(); } - return RETURN_OK; + return returnvalue::OK; } void DeviceHandlerFailureIsolation::setFdirState(FDIRState state) { diff --git a/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp b/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp index 3da431dc..dc987e6d 100644 --- a/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp +++ b/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp @@ -12,11 +12,11 @@ ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&objectId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&actionId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return data->serialize(buffer, size, maxSize, streamEndianness); @@ -29,11 +29,11 @@ size_t DeviceTmReportingWrapper::getSerializedSize() const { ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&objectId, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&actionId, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return data->deSerialize(buffer, size, streamEndianness); diff --git a/src/fsfw/devicehandlers/HealthDevice.cpp b/src/fsfw/devicehandlers/HealthDevice.cpp index a626fa6c..4c09964a 100644 --- a/src/fsfw/devicehandlers/HealthDevice.cpp +++ b/src/fsfw/devicehandlers/HealthDevice.cpp @@ -16,7 +16,7 @@ HealthDevice::~HealthDevice() { QueueFactory::instance()->deleteMessageQueue(com ReturnValue_t HealthDevice::performOperation(uint8_t opCode) { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { result = healthHelper.handleHealthCommand(&command); } return result; @@ -24,7 +24,7 @@ ReturnValue_t HealthDevice::performOperation(uint8_t opCode) { ReturnValue_t HealthDevice::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (parentQueue != 0) { @@ -50,7 +50,7 @@ bool HealthDevice::hasHealthChanged() { ReturnValue_t HealthDevice::setHealth(HealthState health) { healthHelper.setHealth(health); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } HasHealthIF::HealthState HealthDevice::getHealth() { return healthHelper.getHealth(); } diff --git a/src/fsfw/events/EventManager.cpp b/src/fsfw/events/EventManager.cpp index 47270d2a..f4466817 100644 --- a/src/fsfw/events/EventManager.cpp +++ b/src/fsfw/events/EventManager.cpp @@ -30,18 +30,18 @@ EventManager::~EventManager() { MessageQueueId_t EventManager::getEventReportQueue() { return eventReportQueue->getId(); } ReturnValue_t EventManager::performOperation(uint8_t opCode) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while (result == HasReturnvaluesIF::RETURN_OK) { + ReturnValue_t result = returnvalue::OK; + while (result == returnvalue::OK) { EventMessage message; result = eventReportQueue->receiveMessage(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { #if FSFW_OBJ_EVENT_TRANSLATION == 1 printEvent(&message); #endif notifyListeners(&message); } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void EventManager::notifyListeners(EventMessage* message) { @@ -59,9 +59,9 @@ ReturnValue_t EventManager::registerListener(MessageQueueId_t listener, auto result = listenerList.insert(std::pair( listener, EventMatchTree(&factoryBackend, forwardAllButSelected))); if (!result.second) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t EventManager::subscribeToEvent(MessageQueueId_t listener, EventId_t event) { diff --git a/src/fsfw/events/eventmatching/EventMatchTree.cpp b/src/fsfw/events/eventmatching/EventMatchTree.cpp index b564e305..cd3da6a2 100644 --- a/src/fsfw/events/eventmatching/EventMatchTree.cpp +++ b/src/fsfw/events/eventmatching/EventMatchTree.cpp @@ -31,12 +31,12 @@ ReturnValue_t EventMatchTree::addMatch(EventId_t idFrom, EventId_t idTo, bool id iterator lastTest; ReturnValue_t result = findOrInsertRangeMatcher( begin(), idFrom, idTo, idInverted, &lastTest); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (reporterFrom == 0) { // No need to add another AND branch - return RETURN_OK; + return returnvalue::OK; } if (reporterTo == 0) { reporterTo = reporterFrom; @@ -95,7 +95,7 @@ inline ReturnValue_t EventMatchTree::findOrInsertRangeMatcher(iterator start, VA if ((matcher->rangeMatcher.lowerBound == idFrom) && (matcher->rangeMatcher.upperBound == idTo) && (matcher->rangeMatcher.inverted == inverted)) { - return RETURN_OK; + return returnvalue::OK; } else { iter = iter.right(); } @@ -115,9 +115,9 @@ inline ReturnValue_t EventMatchTree::findOrInsertRangeMatcher(iterator start, VA *lastTest = insert(attachToBranch, *lastTest, newNode); if (*lastTest == end()) { // This actaully never fails, so creating a dedicated returncode seems an overshoot. - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } template diff --git a/src/fsfw/events/eventmatching/EventMatchTree.h b/src/fsfw/events/eventmatching/EventMatchTree.h index 010e0623..7561e27d 100644 --- a/src/fsfw/events/eventmatching/EventMatchTree.h +++ b/src/fsfw/events/eventmatching/EventMatchTree.h @@ -7,7 +7,7 @@ #include "../../returnvalues/HasReturnvaluesIF.h" class StorageManagerIF; -class EventMatchTree : public MatchTree, public HasReturnvaluesIF { +class EventMatchTree : public MatchTree { public: EventMatchTree(StorageManagerIF* storageBackend, bool invertedMatch); virtual ~EventMatchTree(); diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index 3e6d5dcf..28df16d8 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -35,15 +35,15 @@ ReturnValue_t FailureIsolationBase::initialize() { " been initialized!" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t result = manager->registerListener(eventQueue->getId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (ownerId != objects::NO_OBJECT) { result = manager->subscribeToAllEventsFrom(eventQueue->getId(), ownerId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } owner = ObjectManager::instance()->get(ownerId); @@ -68,16 +68,16 @@ ReturnValue_t FailureIsolationBase::initialize() { sif::error << "Make sure it implements ConfirmsFailuresIF." << std::endl; #endif return ObjectManagerIF::CHILD_INIT_FAILED; - return RETURN_FAILED; + return returnvalue::FAILED; } eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue()); } - return RETURN_OK; + return returnvalue::OK; } void FailureIsolationBase::checkForFailures() { EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK; result = eventQueue->receiveMessage(&event)) { if (event.getSender() == eventQueue->getId()) { // We already got this event, because we sent it. @@ -124,7 +124,7 @@ ReturnValue_t FailureIsolationBase::sendConfirmationRequest(EventMessage* event, } else if (faultTreeParent != objects::NO_OBJECT) { return eventQueue->sendToDefault(event); } - return RETURN_FAILED; + return returnvalue::FAILED; } void FailureIsolationBase::eventConfirmed(EventMessage* event) {} diff --git a/src/fsfw/fdir/FailureIsolationBase.h b/src/fsfw/fdir/FailureIsolationBase.h index 85d18add..543d9fca 100644 --- a/src/fsfw/fdir/FailureIsolationBase.h +++ b/src/fsfw/fdir/FailureIsolationBase.h @@ -9,8 +9,7 @@ #include "ConfirmsFailuresIF.h" #include "FaultCounter.h" -class FailureIsolationBase : public HasReturnvaluesIF, - public ConfirmsFailuresIF, +class FailureIsolationBase : public ConfirmsFailuresIF, public HasParametersIF { public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FDIR_1; diff --git a/src/fsfw/fdir/FaultCounter.cpp b/src/fsfw/fdir/FaultCounter.cpp index 4515e5b1..eea08817 100644 --- a/src/fsfw/fdir/FaultCounter.cpp +++ b/src/fsfw/fdir/FaultCounter.cpp @@ -73,7 +73,7 @@ ReturnValue_t FaultCounter::getParameter(uint8_t domainId, uint8_t uniqueId, default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FaultCounter::setParameterDomain(uint8_t domain) { parameterDomain = domain; } diff --git a/src/fsfw/globalfunctions/AsciiConverter.cpp b/src/fsfw/globalfunctions/AsciiConverter.cpp index 6d49c777..b99814cb 100644 --- a/src/fsfw/globalfunctions/AsciiConverter.cpp +++ b/src/fsfw/globalfunctions/AsciiConverter.cpp @@ -44,7 +44,7 @@ ReturnValue_t AsciiConverter::scanAsciiHexByte(const uint8_t** dataPtr, uint8_t* *value = *value >> 4; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t AsciiConverter::scanAsciiDecimalNumber_(uint8_t const** dataPtr, uint8_t len, @@ -99,7 +99,7 @@ ReturnValue_t AsciiConverter::scanAsciiDecimalNumber_(uint8_t const** dataPtr, u *dataPtr = ptr; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t AsciiConverter::printFloat(uint8_t* buffer, uint32_t bufferLength, float value, @@ -124,7 +124,7 @@ ReturnValue_t AsciiConverter::printFloat(uint8_t* buffer, uint32_t bufferLength, ReturnValue_t result = printInteger(buffer + streamposition, bufferLength - streamposition - decimalPlaces - 1, value, &integerSize); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } streamposition += integerSize; @@ -161,7 +161,7 @@ ReturnValue_t AsciiConverter::printInteger(uint8_t* buffer, uint32_t bufferLengt } if (!leadingZeros && (value == 0)) { buffer[(*printedSize)++] = '0'; - return RETURN_OK; + return returnvalue::OK; } while (maximumNumber >= 1) { uint8_t number = value / maximumNumber; @@ -174,7 +174,7 @@ ReturnValue_t AsciiConverter::printInteger(uint8_t* buffer, uint32_t bufferLengt maximumNumber /= 10; } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t AsciiConverter::printSignedInteger(uint8_t* buffer, uint32_t bufferLength, diff --git a/src/fsfw/globalfunctions/AsciiConverter.h b/src/fsfw/globalfunctions/AsciiConverter.h index db382b61..7eb28882 100644 --- a/src/fsfw/globalfunctions/AsciiConverter.h +++ b/src/fsfw/globalfunctions/AsciiConverter.h @@ -3,7 +3,7 @@ #include "../returnvalues/HasReturnvaluesIF.h" -class AsciiConverter : public HasReturnvaluesIF { +class AsciiConverter { public: static const uint8_t INTERFACE_ID = CLASS_ID::ASCII_CONVERTER; static const ReturnValue_t TOO_LONG_FOR_TARGET_TYPE = MAKE_RETURN_CODE(1); diff --git a/src/fsfw/globalfunctions/DleEncoder.cpp b/src/fsfw/globalfunctions/DleEncoder.cpp index 23caf02a..c93b37c3 100644 --- a/src/fsfw/globalfunctions/DleEncoder.cpp +++ b/src/fsfw/globalfunctions/DleEncoder.cpp @@ -73,7 +73,7 @@ ReturnValue_t DleEncoder::encodeStreamEscaped(const uint8_t *sourceStream, size_ ++encodedIndex; } *encodedLen = encodedIndex; - return RETURN_OK; + return returnvalue::OK; } else { return STREAM_TOO_SHORT; } @@ -119,7 +119,7 @@ ReturnValue_t DleEncoder::encodeStreamNonEscaped(const uint8_t *sourceStream, si destStream[encodedIndex++] = ETX_CHAR; } *encodedLen = encodedIndex; - return RETURN_OK; + return returnvalue::OK; } else { return STREAM_TOO_SHORT; } @@ -191,7 +191,7 @@ ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_ case (ETX_CHAR): { *readLen = ++encodedIndex; *decodedLen = decodedIndex; - return RETURN_OK; + return returnvalue::OK; } default: { destStream[decodedIndex] = sourceStream[encodedIndex]; @@ -255,7 +255,7 @@ ReturnValue_t DleEncoder::decodeStreamNonEscaped(const uint8_t *sourceStream, // End of stream reached *readLen = encodedIndex + 2; *decodedLen = decodedIndex; - return RETURN_OK; + return returnvalue::OK; } else { *readLen = encodedIndex; return DECODING_ERROR; diff --git a/src/fsfw/globalfunctions/DleEncoder.h b/src/fsfw/globalfunctions/DleEncoder.h index 009c8656..a18527fb 100644 --- a/src/fsfw/globalfunctions/DleEncoder.h +++ b/src/fsfw/globalfunctions/DleEncoder.h @@ -30,7 +30,7 @@ * are escaped with DLE. If the receiver detects a DLE char, it needs to read the next char * to determine whether a start (STX) or end (ETX) of a frame has been detected. */ -class DleEncoder : public HasReturnvaluesIF { +class DleEncoder { public: /** * Create an encoder instance with the given configuration. diff --git a/src/fsfw/globalfunctions/Type.cpp b/src/fsfw/globalfunctions/Type.cpp index 71193673..42c6817e 100644 --- a/src/fsfw/globalfunctions/Type.cpp +++ b/src/fsfw/globalfunctions/Type.cpp @@ -52,12 +52,12 @@ ReturnValue_t Type::serialize(uint8_t** buffer, size_t* size, size_t maxSize, uint8_t ptc; uint8_t pfc; ReturnValue_t result = getPtcPfc(&ptc, &pfc); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&ptc, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -75,18 +75,18 @@ ReturnValue_t Type::deSerialize(const uint8_t** buffer, size_t* size, Endianness uint8_t ptc; uint8_t pfc; ReturnValue_t result = SerializeAdapter::deSerialize(&ptc, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&pfc, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } actualType = getActualType(ptc, pfc); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Type::getPtcPfc(uint8_t* ptc, uint8_t* pfc) const { @@ -124,9 +124,9 @@ ReturnValue_t Type::getPtcPfc(uint8_t* ptc, uint8_t* pfc) const { *pfc = 2; break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } Type::ActualType_t Type::getActualType(uint8_t ptc, uint8_t pfc) { diff --git a/src/fsfw/globalfunctions/matching/MatchTree.h b/src/fsfw/globalfunctions/matching/MatchTree.h index ec98e22a..0c31cf2a 100644 --- a/src/fsfw/globalfunctions/matching/MatchTree.h +++ b/src/fsfw/globalfunctions/matching/MatchTree.h @@ -40,34 +40,34 @@ class MatchTree : public SerializeableMatcherIF, public BinaryTreecountRight(iter); ReturnValue_t result = SerializeAdapter::serialize(&count, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (iter == this->end()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } result = iter->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (maxDepth > 0) { MatchTree temp(iter.left(), maxDepth - 1); result = temp.serialize(buffer, size, maxSize, streamEndianness); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } iter = iter.right(); while (iter != this->end()) { result = iter->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (maxDepth > 0) { MatchTree temp(iter.left(), maxDepth - 1); result = temp.serialize(buffer, size, maxSize, streamEndianness); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } iter = iter.right(); @@ -106,7 +106,7 @@ class MatchTree : public SerializeableMatcherIF, public BinaryTree, public BinaryTreeerase(position); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (children.first != this->end()) { result = removeElementAndAllChildren(children.first); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (children.second != this->end()) { result = removeElementAndAllChildren(children.second); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } // Delete element itself. @@ -143,13 +143,13 @@ class MatchTree : public SerializeableMatcherIF, public BinaryTreeend()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // Delete everything from the AND branch. - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (position.left() != this->end()) { result = removeElementAndAllChildren(position.left()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -176,7 +176,7 @@ class MatchTree : public SerializeableMatcherIF, public BinaryTree { SerializeIF::Endianness streamEndianness) const override { ReturnValue_t result = SerializeAdapter::serialize(&lowerBound, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&upperBound, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::serialize(&inverted, buffer, size, maxSize, streamEndianness); @@ -45,11 +45,11 @@ class RangeMatcher : public SerializeableMatcherIF { SerializeIF::Endianness streamEndianness) override { ReturnValue_t result = SerializeAdapter::deSerialize(&lowerBound, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&upperBound, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::deSerialize(&inverted, buffer, size, streamEndianness); diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index 0f51ddeb..bf1a92d2 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -11,13 +11,13 @@ ReturnValue_t HealthHelper::handleHealthCommand(CommandMessage* message) { switch (message->getCommand()) { case HealthMessage::HEALTH_SET: handleSetHealthCommand(message); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case HealthMessage::HEALTH_ANNOUNCE: { eventSender->forwardEvent(HasHealthIF::HEALTH_INFO, getHealth(), getHealth()); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -53,10 +53,10 @@ ReturnValue_t HealthHelper::initialize() { } ReturnValue_t result = healthTable->registerObject(objectId, HasHealthIF::HEALTHY); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void HealthHelper::setHealth(HasHealthIF::HealthState health) { @@ -76,7 +76,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health, CommandMessage information; HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO, health, oldHealth); if (MessageQueueSenderIF::sendMessage(parentQueue, &information, owner->getCommandQueue()) != - HasReturnvaluesIF::RETURN_OK) { + returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "HealthHelper::informParent: sending health reply failed." << std::endl; #endif @@ -89,13 +89,13 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) { return; } CommandMessage reply; - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { HealthMessage::setHealthMessage(&reply, HealthMessage::REPLY_HEALTH_SET); } else { reply.setReplyRejected(result, command->getCommand()); } if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()) != - HasReturnvaluesIF::RETURN_OK) { + returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "HealthHelper::handleHealthCommand: sending health " "reply failed." diff --git a/src/fsfw/health/HealthHelper.h b/src/fsfw/health/HealthHelper.h index 9b3b0e2b..0b9a9c78 100644 --- a/src/fsfw/health/HealthHelper.h +++ b/src/fsfw/health/HealthHelper.h @@ -56,7 +56,7 @@ class HealthHelper { * @param message * @return * -@c RETURN_OK if the message was handled - * -@c RETURN_FAILED if the message could not be handled + * -@c returnvalue::FAILED if the message could not be handled * (ie it was not a @c HEALTH_SET or @c HEALTH_READ message) */ ReturnValue_t handleHealthCommand(CommandMessage* message); @@ -90,7 +90,7 @@ class HealthHelper { * @return * -@c RETURN_OK if the Health Table was found and the object * could be registered - * -@c RETURN_FAILED else + * -@c returnvalue::FAILED else */ ReturnValue_t initialize(MessageQueueId_t parentQueue); diff --git a/src/fsfw/health/HealthTable.cpp b/src/fsfw/health/HealthTable.cpp index f4bda1c3..5fb45fb9 100644 --- a/src/fsfw/health/HealthTable.cpp +++ b/src/fsfw/health/HealthTable.cpp @@ -21,19 +21,19 @@ HealthTable::~HealthTable() { MutexFactory::instance()->deleteMutex(mutex); } ReturnValue_t HealthTable::registerObject(object_id_t object, HasHealthIF::HealthState initilialState) { if (healthMap.count(object) != 0) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } healthMap.emplace(object, initilialState); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t HealthTable::removeObject(object_id_t object) { mapIterator = healthMap.find(object); if (mapIterator == healthMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } healthMap.erase(mapIterator); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void HealthTable::setHealth(object_id_t object, HasHealthIF::HealthState newState) { @@ -76,7 +76,7 @@ void HealthTable::printAll(uint8_t* pointer, size_t maxSize) { uint16_t count = healthMap.size(); ReturnValue_t result = SerializeAdapter::serialize(&count, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "HealthTable::printAll: Serialization of health table failed" << std::endl; @@ -89,26 +89,26 @@ void HealthTable::printAll(uint8_t* pointer, size_t maxSize) { for (const auto& health : healthMap) { result = SerializeAdapter::serialize(&health.first, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } uint8_t healthValue = health.second; result = SerializeAdapter::serialize(&healthValue, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } } } ReturnValue_t HealthTable::iterate(HealthEntry* value, bool reset) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; MutexGuard(mutex, timeoutType, mutexTimeoutMs); if (reset) { mapIterator = healthMap.begin(); } if (mapIterator == healthMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *value = *mapIterator; mapIterator++; diff --git a/src/fsfw/housekeeping/HousekeepingSetPacket.h b/src/fsfw/housekeeping/HousekeepingSetPacket.h index 96eaaed9..fa039da8 100644 --- a/src/fsfw/housekeeping/HousekeepingSetPacket.h +++ b/src/fsfw/housekeeping/HousekeepingSetPacket.h @@ -22,7 +22,7 @@ class HousekeepingSetPacket : public SerialLinkedListAdapter { Endianness streamEndianness) const override { ReturnValue_t result = SerialLinkedListAdapter::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return dataSet->serializeLocalPoolIds(buffer, size, maxSize, streamEndianness); @@ -36,7 +36,7 @@ class HousekeepingSetPacket : public SerialLinkedListAdapter { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } private: diff --git a/src/fsfw/housekeeping/HousekeepingSnapshot.h b/src/fsfw/housekeeping/HousekeepingSnapshot.h index c3eabe80..fe9d3617 100644 --- a/src/fsfw/housekeeping/HousekeepingSnapshot.h +++ b/src/fsfw/housekeeping/HousekeepingSnapshot.h @@ -64,7 +64,7 @@ class HousekeepingSnapshot : public SerializeIF { *buffer += timeStampSize; } if (updateData == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return updateData->serialize(buffer, size, maxSize, streamEndianness); @@ -92,7 +92,7 @@ class HousekeepingSnapshot : public SerializeIF { } if (updateData == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size < updateData->getSerializedSize()) { return SerializeIF::STREAM_TOO_SHORT; diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index fa16ec3f..d0af62d8 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -52,7 +52,7 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { { PoolReadGuard readGuard(&internalErrorDataset); - if (readGuard.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + if (readGuard.getReadResult() == returnvalue::OK) { internalErrorDataset.queueHits.value += newQueueHits; internalErrorDataset.storeHits.value += newStoreHits; internalErrorDataset.tmHits.value += newTmHits; @@ -64,7 +64,7 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { } poolManager.performHkOperation(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void InternalErrorReporter::queueMessageNotSent() { incrementQueueHits(); } @@ -132,7 +132,7 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool poolManager.subscribeForPeriodicPacket(internalErrorSid, false, getPeriodicOperationFrequency(), true); internalErrorDataset.setValidity(true, true); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } dur_millis_t InternalErrorReporter::getPeriodicOperationFrequency() const { @@ -147,7 +147,7 @@ void InternalErrorReporter::setTaskIF(PeriodicTaskIF *task) { this->executingTas ReturnValue_t InternalErrorReporter::initialize() { ReturnValue_t result = poolManager.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SystemObject::initialize(); diff --git a/src/fsfw/ipc/MutexGuard.h b/src/fsfw/ipc/MutexGuard.h index f7b90663..f6d2f25f 100644 --- a/src/fsfw/ipc/MutexGuard.h +++ b/src/fsfw/ipc/MutexGuard.h @@ -30,7 +30,7 @@ class MutexGuard { timeoutMs); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - } else if (result != HasReturnvaluesIF::RETURN_OK) { + } else if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MutexGuard: Lock of Mutex failed with code " << result << std::endl; #else @@ -51,7 +51,7 @@ class MutexGuard { private: MutexIF* internalMutex; - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; }; #endif /* FRAMEWORK_IPC_MUTEXGUARD_H_ */ diff --git a/src/fsfw/memory/GenericFileSystemMessage.cpp b/src/fsfw/memory/GenericFileSystemMessage.cpp index 805c7dcc..cdbfeb62 100644 --- a/src/fsfw/memory/GenericFileSystemMessage.cpp +++ b/src/fsfw/memory/GenericFileSystemMessage.cpp @@ -157,10 +157,10 @@ ReturnValue_t GenericFileSystemMessage::clear(CommandMessage *message) { store_address_t storeId = GenericFileSystemMessage::getStoreId(message); auto ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return ipcStore->deleteData(storeId); } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/memory/HasMemoryIF.h b/src/fsfw/memory/HasMemoryIF.h index 7aa66377..342f7115 100644 --- a/src/fsfw/memory/HasMemoryIF.h +++ b/src/fsfw/memory/HasMemoryIF.h @@ -31,14 +31,14 @@ class HasMemoryIF { * startAddress is a proposal for an address, or the base address if multiple addresses are set. */ virtual ReturnValue_t setAddress(uint32_t* startAddress) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } static bool memAccessWasSuccessful(ReturnValue_t result) { switch (result) { case DO_IT_MYSELF: case POINTS_TO_MEMORY: case POINTS_TO_VARIABLE: - case HasReturnvaluesIF::RETURN_OK: + case returnvalue::OK: case ACTIVITY_COMPLETED: return true; default: diff --git a/src/fsfw/memory/MemoryHelper.cpp b/src/fsfw/memory/MemoryHelper.cpp index 462a818e..cf4d205d 100644 --- a/src/fsfw/memory/MemoryHelper.cpp +++ b/src/fsfw/memory/MemoryHelper.cpp @@ -24,13 +24,13 @@ ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) { switch (lastCommand) { case MemoryMessage::CMD_MEMORY_DUMP: handleMemoryCheckOrDump(message); - return RETURN_OK; + return returnvalue::OK; case MemoryMessage::CMD_MEMORY_LOAD: handleMemoryLoad(message); - return RETURN_OK; + return returnvalue::OK; case MemoryMessage::CMD_MEMORY_CHECK: handleMemoryCheckOrDump(message); - return RETURN_OK; + return returnvalue::OK; default: lastCommand = CommandMessage::CMD_NONE; return UNKNOWN_CMD; @@ -51,7 +51,7 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode, const uint8_t* dataToCo EndianConverter::convertBigEndian(copyHere, dataToCopy, size); break; case HasMemoryIF::ACTIVITY_COMPLETED: - case RETURN_OK: + case returnvalue::OK: break; default: ipcStore->deleteData(ipcAddress); @@ -75,7 +75,7 @@ void MemoryHelper::completeDump(ReturnValue_t errorCode, const uint8_t* dataToCo case HasMemoryIF::DO_IT_MYSELF: busy = true; return; - case HasReturnvaluesIF::RETURN_OK: + case returnvalue::OK: case HasMemoryIF::POINTS_TO_MEMORY: case HasMemoryIF::POINTS_TO_VARIABLE: //"data" must be valid pointer! @@ -118,7 +118,7 @@ void MemoryHelper::completeDump(ReturnValue_t errorCode, const uint8_t* dataToCo ipcStore->deleteData(ipcAddress); break; } - if (queueToUse->sendMessage(lastSender, &reply) != RETURN_OK) { + if (queueToUse->sendMessage(lastSender, &reply) != returnvalue::OK) { reply.clear(); } } @@ -148,7 +148,7 @@ void MemoryHelper::handleMemoryLoad(CommandMessage* message) { uint8_t* dataPointer = NULL; size_t size = 0; ReturnValue_t returnCode = ipcStore->getData(ipcAddress, &p_data, &size); - if (returnCode == RETURN_OK) { + if (returnCode == returnvalue::OK) { returnCode = workOnThis->handleMemoryLoad(address, p_data, size, &dataPointer); completeLoad(returnCode, p_data, size, dataPointer); } else { @@ -164,7 +164,7 @@ void MemoryHelper::handleMemoryCheckOrDump(CommandMessage* message) { uint32_t size = MemoryMessage::getLength(message); uint8_t* dataPointer = NULL; ReturnValue_t returnCode = ipcStore->getFreeElement(&ipcAddress, size, &reservedSpaceInIPC); - if (returnCode == RETURN_OK) { + if (returnCode == returnvalue::OK) { returnCode = workOnThis->handleMemoryDump(address, size, &dataPointer, reservedSpaceInIPC); completeDump(returnCode, dataPointer, size); } else { @@ -176,7 +176,7 @@ void MemoryHelper::handleMemoryCheckOrDump(CommandMessage* message) { ReturnValue_t MemoryHelper::initialize(MessageQueueIF* queueToUse_) { if (queueToUse_ == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->queueToUse = queueToUse_; return initialize(); @@ -185,8 +185,8 @@ ReturnValue_t MemoryHelper::initialize(MessageQueueIF* queueToUse_) { ReturnValue_t MemoryHelper::initialize() { ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore != nullptr) { - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/memory/MemoryHelper.h b/src/fsfw/memory/MemoryHelper.h index 7a645b79..3a51f7dc 100644 --- a/src/fsfw/memory/MemoryHelper.h +++ b/src/fsfw/memory/MemoryHelper.h @@ -10,7 +10,7 @@ /** * @brief TODO: documentation. */ -class MemoryHelper : public HasReturnvaluesIF { +class MemoryHelper { public: static const uint8_t INTERFACE_ID = CLASS_ID::MEMORY_HELPER; static const ReturnValue_t UNKNOWN_CMD = MAKE_RETURN_CODE(0xE0); diff --git a/src/fsfw/modes/HasModesIF.h b/src/fsfw/modes/HasModesIF.h index 0ebe77d8..03cc45bf 100644 --- a/src/fsfw/modes/HasModesIF.h +++ b/src/fsfw/modes/HasModesIF.h @@ -53,7 +53,7 @@ class HasModesIF { protected: virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } virtual void startTransition(Mode_t mode, Submode_t submode) {} diff --git a/src/fsfw/modes/ModeHelper.cpp b/src/fsfw/modes/ModeHelper.cpp index 2ea392ab..8c83012f 100644 --- a/src/fsfw/modes/ModeHelper.cpp +++ b/src/fsfw/modes/ModeHelper.cpp @@ -25,7 +25,7 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) { submode = ModeMessage::getSubmode(command); uint32_t timeout; ReturnValue_t result = owner->checkModeCommand(mode, submode, &timeout); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ModeMessage::setCantReachMode(&reply, result); MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()); break; @@ -55,9 +55,9 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) { owner->announceMode(true); break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ModeHelper::initialize(MessageQueueId_t parentQueueId) { @@ -99,7 +99,7 @@ void ModeHelper::setParentQueue(MessageQueueId_t parentQueueId) { this->parentQueueId = parentQueueId; } -ReturnValue_t ModeHelper::initialize(void) { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t ModeHelper::initialize(void) { return returnvalue::OK; } bool ModeHelper::isTimedOut() { return countdown.hasTimedOut(); } diff --git a/src/fsfw/monitoring/AbsLimitMonitor.h b/src/fsfw/monitoring/AbsLimitMonitor.h index c6400166..790808ee 100644 --- a/src/fsfw/monitoring/AbsLimitMonitor.h +++ b/src/fsfw/monitoring/AbsLimitMonitor.h @@ -29,7 +29,7 @@ class AbsLimitMonitor : public MonitorBase { return MonitoringIF::OUT_OF_RANGE; } } - return HasReturnvaluesIF::RETURN_OK; // We're not out of range. + return returnvalue::OK; // We're not out of range. } virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId, @@ -49,7 +49,7 @@ class AbsLimitMonitor : public MonitorBase { default: return this->INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool isOutOfLimits() { if (this->oldState == MonitoringIF::OUT_OF_RANGE) { diff --git a/src/fsfw/monitoring/LimitMonitor.h b/src/fsfw/monitoring/LimitMonitor.h index 229f1dc2..4fe9ee39 100644 --- a/src/fsfw/monitoring/LimitMonitor.h +++ b/src/fsfw/monitoring/LimitMonitor.h @@ -32,7 +32,7 @@ class LimitMonitor : public MonitorBase { *crossedLimit = lowerLimit; return MonitoringIF::BELOW_LOW_LIMIT; } else { - return HasReturnvaluesIF::RETURN_OK; // Within limits. + return returnvalue::OK; // Within limits. } } @@ -55,7 +55,7 @@ class LimitMonitor : public MonitorBase { default: return this->INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool isOutOfLimits() { if (this->oldState == MonitoringIF::ABOVE_HIGH_LIMIT or diff --git a/src/fsfw/monitoring/LimitViolationReporter.cpp b/src/fsfw/monitoring/LimitViolationReporter.cpp index 43ecf4d3..ec6fa2e6 100644 --- a/src/fsfw/monitoring/LimitViolationReporter.cpp +++ b/src/fsfw/monitoring/LimitViolationReporter.cpp @@ -7,7 +7,7 @@ ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF* data) { ReturnValue_t result = checkClassLoaded(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } store_address_t storeId; @@ -17,12 +17,12 @@ ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF return MonitoringIF::INVALID_SIZE; } result = ipcStore->getFreeElement(&storeId, maxSize, &dataTarget); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t size = 0; result = data->serialize(&dataTarget, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } CommandMessage report; @@ -42,10 +42,10 @@ ReturnValue_t LimitViolationReporter::checkClassLoaded() { if (ipcStore == nullptr) { ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // Lazy initialization. diff --git a/src/fsfw/monitoring/MonitorBase.h b/src/fsfw/monitoring/MonitorBase.h index b2653d75..dd0792b2 100644 --- a/src/fsfw/monitoring/MonitorBase.h +++ b/src/fsfw/monitoring/MonitorBase.h @@ -36,7 +36,7 @@ class MonitorBase : public MonitorReporter { // 2. If returning from fetch != OK, parameter is invalid. // Report (if oldState is != invalidity). - if (validity != HasReturnvaluesIF::RETURN_OK) { + if (validity != returnvalue::OK) { this->monitorStateIs(validity, sample, 0); } else { // 3. Otherwise, check sample. @@ -56,14 +56,14 @@ class MonitorBase : public MonitorReporter { protected: virtual ReturnValue_t fetchSample(T* sample) { ReturnValue_t result = poolVariable.read(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (not poolVariable.isValid()) { return MonitoringIF::INVALID; } *sample = poolVariable.value; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } LocalPoolVariable poolVariable; diff --git a/src/fsfw/monitoring/MonitorReporter.h b/src/fsfw/monitoring/MonitorReporter.h index bcbaf26d..09c39222 100644 --- a/src/fsfw/monitoring/MonitorReporter.h +++ b/src/fsfw/monitoring/MonitorReporter.h @@ -70,7 +70,7 @@ class MonitorReporter : public HasParametersIF { default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } virtual ReturnValue_t setToUnchecked() { return setToState(MonitoringIF::UNCHECKED); } virtual ReturnValue_t setToInvalid() { return setToState(MonitoringIF::INVALID); } @@ -135,7 +135,7 @@ class MonitorReporter : public HasParametersIF { case MonitoringIF::UNCHECKED: case MonitoringIF::UNSELECTED: case MonitoringIF::INVALID: - case HasReturnvaluesIF::RETURN_OK: + case returnvalue::OK: break; default: EventManagerIF::triggerEvent(reportingId, MonitoringIF::MONITOR_CHANGED_STATE, state); @@ -159,7 +159,7 @@ class MonitorReporter : public HasParametersIF { LimitViolationReporter::sendLimitViolationReport(&report); oldState = state; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } }; diff --git a/src/fsfw/monitoring/TriplexMonitor.h b/src/fsfw/monitoring/TriplexMonitor.h index 1d9182aa..e007ea5f 100644 --- a/src/fsfw/monitoring/TriplexMonitor.h +++ b/src/fsfw/monitoring/TriplexMonitor.h @@ -49,7 +49,7 @@ class TriplexMonitor : public HasParametersIF { nAvailable++; } } - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; switch (nAvailable) { case 3: result = doTriplexMonitoring(); @@ -67,9 +67,9 @@ class TriplexMonitor : public HasParametersIF { ReturnValue_t initialize() { healthTable = ObjectManager::instance()->get(objects::HEALTH_TABLE); if (healthTable == NULL) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper *parameterWrapper, @@ -84,7 +84,7 @@ class TriplexMonitor : public HasParametersIF { default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } protected: @@ -96,7 +96,7 @@ class TriplexMonitor : public HasParametersIF { HealthTableIF *healthTable; uint8_t domainId; ReturnValue_t doTriplexMonitoring() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; // Find middle value, by ordering indices uint8_t index[3] = {0, 1, 2}; if (values[index[0]].value > values[index[1]].value) { @@ -118,7 +118,7 @@ class TriplexMonitor : public HasParametersIF { if (values[index[2]] > (values[index[1]] + limit)) { EventManagerIF::triggerEvent(getRefereneceObject(index[2]), eventTripleCheck, HIGHEST_VALUE_OOL, 0); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { result = HIGHEST_VALUE_OOL; } else { result = BOTH_VALUES_OOL; @@ -142,7 +142,7 @@ class TriplexMonitor : public HasParametersIF { return DUPLEX_OOL; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } virtual bool checkObjectHealthState(uint8_t valueIndex) = 0; virtual object_id_t getRefereneceObject(uint8_t valueIndex) = 0; diff --git a/src/fsfw/monitoring/TwoValueLimitMonitor.h b/src/fsfw/monitoring/TwoValueLimitMonitor.h index 79b8c4bb..ad3f5c86 100644 --- a/src/fsfw/monitoring/TwoValueLimitMonitor.h +++ b/src/fsfw/monitoring/TwoValueLimitMonitor.h @@ -18,7 +18,7 @@ class TwoValueLimitMonitor : public LimitMonitor { ReturnValue_t doCheck(T lowSample, T highSample) { T crossedLimit; ReturnValue_t currentState = this->checkSample(lowSample, &crossedLimit); - if (currentState != HasReturnvaluesIF::RETURN_OK) { + if (currentState != returnvalue::OK) { return this->monitorStateIs(currentState, lowSample, crossedLimit); } currentState = this->checkSample(highSample, &crossedLimit); diff --git a/src/fsfw/objectmanager/ObjectManager.cpp b/src/fsfw/objectmanager/ObjectManager.cpp index 2017938a..7a32fcc6 100644 --- a/src/fsfw/objectmanager/ObjectManager.cpp +++ b/src/fsfw/objectmanager/ObjectManager.cpp @@ -36,7 +36,7 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) { // sif::debug << "ObjectManager::insert: Object " << std::hex // << (int)id << std::dec << " inserted." << std::endl; #endif - return this->RETURN_OK; + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::insert: Object ID " << std::hex << static_cast(id) @@ -59,7 +59,7 @@ ReturnValue_t ObjectManager::remove(object_id_t id) { // sif::debug << "ObjectManager::removeObject: Object " << std::hex // << (int)id << std::dec << " removed." << std::endl; #endif - return RETURN_OK; + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::removeObject: Requested object " << std::hex << (int)id @@ -90,11 +90,11 @@ void ObjectManager::initialize() { return; } objectFactoryFunction(factoryArgs); - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; uint32_t errorCount = 0; for (auto const& it : objectList) { result = it.second->initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 object_id_t var = it.first; sif::error << "ObjectManager::initialize: Object 0x" << std::hex << std::setw(8) @@ -116,7 +116,7 @@ void ObjectManager::initialize() { errorCount = 0; for (auto const& it : objectList) { result = it.second->checkObjectConnections(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::ObjectManager: Object 0x" << std::hex << (int)it.first << " connection check failed with code 0x" << result << std::dec << std::endl; diff --git a/src/fsfw/objectmanager/ObjectManagerIF.h b/src/fsfw/objectmanager/ObjectManagerIF.h index 32a0942f..58ee9ab4 100644 --- a/src/fsfw/objectmanager/ObjectManagerIF.h +++ b/src/fsfw/objectmanager/ObjectManagerIF.h @@ -16,7 +16,7 @@ * @author Bastian Baetz * @ingroup system_objects */ -class ObjectManagerIF : public HasReturnvaluesIF { +class ObjectManagerIF { public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::OBJECT_MANAGER_IF; static constexpr ReturnValue_t INSERTION_FAILED = MAKE_RETURN_CODE(1); diff --git a/src/fsfw/objectmanager/SystemObject.cpp b/src/fsfw/objectmanager/SystemObject.cpp index 7f8acfd8..90839013 100644 --- a/src/fsfw/objectmanager/SystemObject.cpp +++ b/src/fsfw/objectmanager/SystemObject.cpp @@ -22,9 +22,9 @@ void SystemObject::triggerEvent(Event event, uint32_t parameter1, uint32_t param EventManagerIF::triggerEvent(objectId, event, parameter1, parameter2); } -ReturnValue_t SystemObject::initialize() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SystemObject::initialize() { return returnvalue::OK; } -ReturnValue_t SystemObject::checkObjectConnections() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SystemObject::checkObjectConnections() { return returnvalue::OK; } void SystemObject::forwardEvent(Event event, uint32_t parameter1, uint32_t parameter2) const { EventManagerIF::triggerEvent(objectId, event, parameter1, parameter2); diff --git a/src/fsfw/objectmanager/SystemObjectIF.h b/src/fsfw/objectmanager/SystemObjectIF.h index 72fe9044..660bf9e8 100644 --- a/src/fsfw/objectmanager/SystemObjectIF.h +++ b/src/fsfw/objectmanager/SystemObjectIF.h @@ -46,7 +46,7 @@ class SystemObjectIF : public EventReportingProxyIF { * Therefore, a two-step initialization resolves this problem and prevents * circular dependencies of not-fully initialized objects on start up. * @return - @c RETURN_OK in case the initialization was successful - * - @c RETURN_FAILED otherwise + * - @c returnvalue::FAILED otherwise */ virtual ReturnValue_t initialize() = 0; /** diff --git a/src/fsfw/osal/common/TcpIpBase.cpp b/src/fsfw/osal/common/TcpIpBase.cpp index 67e71053..7e989c36 100644 --- a/src/fsfw/osal/common/TcpIpBase.cpp +++ b/src/fsfw/osal/common/TcpIpBase.cpp @@ -21,10 +21,10 @@ ReturnValue_t TcpIpBase::initialize() { sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: WSAStartup failed with error: " << err << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } TcpIpBase::~TcpIpBase() { diff --git a/src/fsfw/osal/common/TcpTmTcBridge.cpp b/src/fsfw/osal/common/TcpTmTcBridge.cpp index 4b2bea73..b57e48c0 100644 --- a/src/fsfw/osal/common/TcpTmTcBridge.cpp +++ b/src/fsfw/osal/common/TcpTmTcBridge.cpp @@ -26,7 +26,7 @@ TcpTmTcBridge::TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination, ob ReturnValue_t TcpTmTcBridge::initialize() { ReturnValue_t result = TmTcBridge::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcpTmTcBridge::initialize: TmTcBridge initialization failed!" << std::endl; #else @@ -35,7 +35,7 @@ ReturnValue_t TcpTmTcBridge::initialize() { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } TcpTmTcBridge::~TcpTmTcBridge() { @@ -48,21 +48,21 @@ ReturnValue_t TcpTmTcBridge::handleTm() { // Simply store the telemetry in the FIFO, the server will use it to access the TM MutexGuard guard(mutex, timeoutType, mutexTimeoutMs); TmTcMessage message; - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; for (ReturnValue_t result = tmTcReceptionQueue->receiveMessage(&message); - result == HasReturnvaluesIF::RETURN_OK; + result == returnvalue::OK; result = tmTcReceptionQueue->receiveMessage(&message)) { status = storeDownlinkData(&message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { break; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TcpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) { // Not used. The Server uses the FIFO to access and send the telemetry. - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TcpTmTcBridge::setMutexProperties(MutexIF::TimeoutType timeoutType, dur_millis_t timeoutMs) { diff --git a/src/fsfw/osal/common/TcpTmTcServer.cpp b/src/fsfw/osal/common/TcpTmTcServer.cpp index a8890006..f9cb923e 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.cpp +++ b/src/fsfw/osal/common/TcpTmTcServer.cpp @@ -39,7 +39,7 @@ ReturnValue_t TcpTmTcServer::initialize() { using namespace tcpip; ReturnValue_t result = TcpIpBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -47,7 +47,7 @@ ReturnValue_t TcpTmTcServer::initialize() { case (ReceptionModes::SPACE_PACKETS): { spacePacketParser = new SpacePacketParser(validPacketIds); if (spacePacketParser == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #if defined PLATFORM_UNIX tcpConfig.tcpFlags |= MSG_DONTWAIT; @@ -79,7 +79,7 @@ ReturnValue_t TcpTmTcServer::initialize() { retval = getaddrinfo(nullptr, tcpConfig.tcpPort.c_str(), &hints, &addrResult); if (retval != 0) { handleError(Protocol::TCP, ErrorSources::GETADDRINFO_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // Open TCP (stream) socket @@ -88,7 +88,7 @@ ReturnValue_t TcpTmTcServer::initialize() { if (listenerTcpSocket == INVALID_SOCKET) { freeaddrinfo(addrResult); handleError(Protocol::TCP, ErrorSources::SOCKET_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // Bind to the address found by getaddrinfo @@ -96,11 +96,11 @@ ReturnValue_t TcpTmTcServer::initialize() { if (retval == SOCKET_ERROR) { freeaddrinfo(addrResult); handleError(Protocol::TCP, ErrorSources::BIND_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } freeaddrinfo(addrResult); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } TcpTmTcServer::~TcpTmTcServer() { closeSocket(listenerTcpSocket); } @@ -151,7 +151,7 @@ ReturnValue_t TcpTmTcServer::initializeAfterTaskCreation() { targetTcDestination = tmtcBridge->getRequestQueue(); tcStore = tmtcBridge->tcStore; tmStore = tmtcBridge->tmStore; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TcpTmTcServer::handleServerOperation(socket_t& connSocket) { @@ -214,11 +214,11 @@ ReturnValue_t TcpTmTcServer::handleTcReception(uint8_t* spacePacket, size_t pack } if (spacePacket == nullptr or packetSize == 0) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } store_address_t storeId; ReturnValue_t result = tcStore->addData(&storeId, spacePacket, packetSize); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TcpTmTcServer::handleServerOperation: Data storage with packet size" @@ -236,7 +236,7 @@ ReturnValue_t TcpTmTcServer::handleTcReception(uint8_t* spacePacket, size_t pack TmTcMessage message(storeId); result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TcpTmTcServer::handleServerOperation: " @@ -273,7 +273,7 @@ ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket, bool& tmSent) // Using the store accessor will take care of deleting TM from the store automatically ConstStorageAccessor storeAccessor(storeId); ReturnValue_t result = tmStore->getData(storeId, storeAccessor); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (wiretappingEnabled) { @@ -297,12 +297,12 @@ ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket, bool& tmSent) return CONN_BROKEN; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; + ReturnValue_t result = returnvalue::OK; size_t readAmount = availableReadData; lastRingBufferSize = availableReadData; if (readAmount >= ringBuffer.getMaxSize()) { @@ -341,7 +341,7 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { size_t readLen = 0; while (readLen < readAmount) { if (spacePacketParser == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } result = spacePacketParser->parseSpacePackets(bufPtrPtr, readAmount, startIdx, foundSize, readLen); @@ -350,9 +350,9 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { case (SpacePacketParser::SPLIT_PACKET): { break; } - case (HasReturnvaluesIF::RETURN_OK): { + case (returnvalue::OK): { result = handleTcReception(receptionBuffer.data() + startIdx, foundSize); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } } diff --git a/src/fsfw/osal/common/TcpTmTcServer.h b/src/fsfw/osal/common/TcpTmTcServer.h index 1181ff10..0e2182a5 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.h +++ b/src/fsfw/osal/common/TcpTmTcServer.h @@ -108,7 +108,7 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb StorageManagerIF* tmStore = nullptr; private: - static constexpr ReturnValue_t CONN_BROKEN = result::makeCode(1, 0); + static constexpr ReturnValue_t CONN_BROKEN = returnvalue::makeCode(1, 0); //! TMTC bridge is cached. object_id_t tmtcBridgeId = objects::NO_OBJECT; TcpTmTcBridge* tmtcBridge = nullptr; diff --git a/src/fsfw/osal/common/UdpTcPollingTask.cpp b/src/fsfw/osal/common/UdpTcPollingTask.cpp index bcc8e9e3..4304fdd2 100644 --- a/src/fsfw/osal/common/UdpTcPollingTask.cpp +++ b/src/fsfw/osal/common/UdpTcPollingTask.cpp @@ -66,7 +66,7 @@ UdpTcPollingTask::UdpTcPollingTask(object_id_t objectId, object_id_t tmtcUdpBrid #endif /* FSFW_UDP_RCV_WIRETAPPING_ENABLED == 1 */ ReturnValue_t result = handleSuccessfullTcRead(bytesReceived); - if (result != HasReturnvaluesIF::RETURN_FAILED) { + if (result != returnvalue::FAILED) { } tmtcBridge->checkAndSetClientAddress(senderAddress); } @@ -80,20 +80,20 @@ ReturnValue_t UdpTcPollingTask::handleSuccessfullTcRead(size_t bytesRead) { #endif ReturnValue_t result = tcStore->addData(&storeId, receptionBuffer.data(), bytesRead); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UdpTcPollingTask::transferPusToSoftwareBus: Data storage failed." << std::endl; sif::warning << "Packet size: " << bytesRead << std::endl; #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } TmTcMessage message(storeId); result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UdpTcPollingTask::handleSuccessfullTcRead: " @@ -124,11 +124,11 @@ ReturnValue_t UdpTcPollingTask::initialize() { } ReturnValue_t result = TcpIpBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t UdpTcPollingTask::initializeAfterTaskCreation() { @@ -138,7 +138,7 @@ ReturnValue_t UdpTcPollingTask::initializeAfterTaskCreation() { /* The server socket is set up in the bridge intialization. Calling this function here ensures that it is set up regardless of which class was initialized first */ this->serverSocket = tmtcBridge->serverSocket; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void UdpTcPollingTask::setTimeout(double timeoutSeconds) { diff --git a/src/fsfw/osal/common/UdpTmTcBridge.cpp b/src/fsfw/osal/common/UdpTmTcBridge.cpp index e3cad58f..0a847271 100644 --- a/src/fsfw/osal/common/UdpTmTcBridge.cpp +++ b/src/fsfw/osal/common/UdpTmTcBridge.cpp @@ -35,7 +35,7 @@ UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, ReturnValue_t UdpTmTcBridge::initialize() { ReturnValue_t result = TmTcBridge::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "UdpTmTcBridge::initialize: TmTcBridge initialization failed!" << std::endl; #endif @@ -56,7 +56,7 @@ ReturnValue_t UdpTmTcBridge::initialize() { #else sif::printError("UdpTmTcBridge::UdpTmTcBridge: WSAStartup failed with error: %d\n", err); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #endif @@ -75,14 +75,14 @@ ReturnValue_t UdpTmTcBridge::initialize() { int retval = getaddrinfo(nullptr, udpServerPort.c_str(), &hints, &addrResult); if (retval != 0) { tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::GETADDRINFO_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } serverSocket = socket(addrResult->ai_family, addrResult->ai_socktype, addrResult->ai_protocol); if (serverSocket == INVALID_SOCKET) { freeaddrinfo(addrResult); tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::SOCKET_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #if FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1 @@ -93,10 +93,10 @@ ReturnValue_t UdpTmTcBridge::initialize() { if (retval != 0) { freeaddrinfo(addrResult); tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::BIND_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } freeaddrinfo(addrResult); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } UdpTmTcBridge::~UdpTmTcBridge() { @@ -131,7 +131,7 @@ ReturnValue_t UdpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) { " sent." << std::endl; #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void UdpTmTcBridge::checkAndSetClientAddress(sockaddr &newAddress) { diff --git a/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp b/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp index 7ffd61d3..54226e18 100644 --- a/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp +++ b/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp @@ -42,7 +42,7 @@ ReturnValue_t BinarySemaphoreUsingTask::acquireWithTickTimeout(TimeoutType timeo TickType_t timeoutTicks) { BaseType_t returncode = ulTaskNotifyTake(pdTRUE, timeoutTicks); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SemaphoreIF::SEMAPHORE_TIMEOUT; } @@ -56,10 +56,10 @@ ReturnValue_t BinarySemaphoreUsingTask::release(TaskHandle_t taskHandle) { } BaseType_t returncode = xTaskNotifyGive(taskHandle); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { // This should never happen. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -82,7 +82,7 @@ ReturnValue_t BinarySemaphoreUsingTask::releaseFromISR(TaskHandle_t taskHandle, return SemaphoreIF::SEMAPHORE_NOT_OWNED; } vTaskNotifyGiveFromISR(taskHandle, higherPriorityTaskWoken); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint8_t BinarySemaphoreUsingTask::getSemaphoreCounterFromISR(TaskHandle_t taskHandle, diff --git a/src/fsfw/osal/freertos/BinSemaphUsingTask.h b/src/fsfw/osal/freertos/BinSemaphUsingTask.h index 34b0d031..a88863c9 100644 --- a/src/fsfw/osal/freertos/BinSemaphUsingTask.h +++ b/src/fsfw/osal/freertos/BinSemaphUsingTask.h @@ -51,7 +51,7 @@ class BinarySemaphoreUsingTask : public SemaphoreIF, public HasReturnvaluesIF { * Same as acquire() with timeout in FreeRTOS ticks. * @param timeoutTicks * @return - @c RETURN_OK on success - * - @c RETURN_FAILED on failure + * - @c returnvalue::FAILED on failure */ ReturnValue_t acquireWithTickTimeout(TimeoutType timeoutType = TimeoutType::BLOCKING, TickType_t timeoutTicks = portMAX_DELAY); @@ -66,7 +66,7 @@ class BinarySemaphoreUsingTask : public SemaphoreIF, public HasReturnvaluesIF { * Wrapper function to give back semaphore from handle * @param semaphore * @return - @c RETURN_OK on success - * - @c RETURN_FAILED on failure + * - @c returnvalue::FAILED on failure */ static ReturnValue_t release(TaskHandle_t taskToNotify); @@ -77,7 +77,7 @@ class BinarySemaphoreUsingTask : public SemaphoreIF, public HasReturnvaluesIF { * a higher priority was unblocked. A context switch should be requested * from an ISR if this is the case (see TaskManagement functions) * @return - @c RETURN_OK on success - * - @c RETURN_FAILED on failure + * - @c returnvalue::FAILED on failure */ static ReturnValue_t releaseFromISR(TaskHandle_t taskToNotify, BaseType_t* higherPriorityTaskWoken); diff --git a/src/fsfw/osal/freertos/BinarySemaphore.cpp b/src/fsfw/osal/freertos/BinarySemaphore.cpp index 6e53380c..0ab621bc 100644 --- a/src/fsfw/osal/freertos/BinarySemaphore.cpp +++ b/src/fsfw/osal/freertos/BinarySemaphore.cpp @@ -59,7 +59,7 @@ ReturnValue_t BinarySemaphore::acquireWithTickTimeout(TimeoutType timeoutType, BaseType_t returncode = xSemaphoreTake(handle, timeoutTicks); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SemaphoreIF::SEMAPHORE_TIMEOUT; } @@ -73,7 +73,7 @@ ReturnValue_t BinarySemaphore::release(SemaphoreHandle_t semaphore) { } BaseType_t returncode = xSemaphoreGive(semaphore); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SemaphoreIF::SEMAPHORE_NOT_OWNED; } @@ -91,7 +91,7 @@ ReturnValue_t BinarySemaphore::releaseFromISR(SemaphoreHandle_t semaphore, } BaseType_t returncode = xSemaphoreGiveFromISR(semaphore, higherPriorityTaskWoken); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SemaphoreIF::SEMAPHORE_NOT_OWNED; } diff --git a/src/fsfw/osal/freertos/Clock.cpp b/src/fsfw/osal/freertos/Clock.cpp index cabf7d81..dc00ac7e 100644 --- a/src/fsfw/osal/freertos/Clock.cpp +++ b/src/fsfw/osal/freertos/Clock.cpp @@ -17,7 +17,7 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { timeval time_timeval; ReturnValue_t result = convertTimeOfDayToTimeval(time, &time_timeval); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -31,7 +31,7 @@ ReturnValue_t Clock::setClock(const timeval* time) { Timekeeper::instance()->setOffset(offset); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getClock_timeval(timeval* time) { @@ -41,13 +41,13 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { *time = offset + uptime; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getUptime(timeval* uptime) { *uptime = getUptime(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } timeval Clock::getUptime() { @@ -58,7 +58,7 @@ timeval Clock::getUptime() { ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { timeval uptime = getUptime(); *uptimeMs = uptime.tv_sec * 1000 + uptime.tv_usec / 1000; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // uint32_t Clock::getUptimeSeconds() { @@ -69,17 +69,17 @@ ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { ReturnValue_t Clock::getClock_usecs(uint64_t* time) { timeval time_timeval; ReturnValue_t result = getClock_timeval(&time_timeval); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *time = time_timeval.tv_sec * 1000000 + time_timeval.tv_usec; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { timeval time_timeval; ReturnValue_t result = getClock_timeval(&time_timeval); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } struct tm time_tm; @@ -96,7 +96,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { time->usecond = time_timeval.tv_usec; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) { @@ -115,10 +115,10 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to->tv_sec = seconds; to->tv_usec = from->usecond; // Fails in 2038.. - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) { *JD2000 = (time.tv_sec - 946728000. + time.tv_usec / 1000000.) / 24. / 3600.; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp b/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp index 0e4d967d..f58e1be9 100644 --- a/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp +++ b/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp @@ -65,7 +65,7 @@ ReturnValue_t CountingSemaphoreUsingTask::acquireWithTickTimeout(TimeoutType tim // Decrement notfication value without resetting it. BaseType_t oldCount = ulTaskNotifyTake(pdFALSE, timeoutTicks); if (getSemaphoreCounter() == oldCount - 1) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SemaphoreIF::SEMAPHORE_TIMEOUT; } @@ -81,10 +81,10 @@ ReturnValue_t CountingSemaphoreUsingTask::release() { ReturnValue_t CountingSemaphoreUsingTask::release(TaskHandle_t taskToNotify) { BaseType_t returncode = xTaskNotifyGive(taskToNotify); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { // This should never happen. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -99,7 +99,7 @@ TaskHandle_t CountingSemaphoreUsingTask::getTaskHandle() { return handle; } ReturnValue_t CountingSemaphoreUsingTask::releaseFromISR(TaskHandle_t taskToNotify, BaseType_t* higherPriorityTaskWoken) { vTaskNotifyGiveFromISR(taskToNotify, higherPriorityTaskWoken); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint8_t CountingSemaphoreUsingTask::getSemaphoreCounterFromISR( diff --git a/src/fsfw/osal/freertos/FixedTimeslotTask.cpp b/src/fsfw/osal/freertos/FixedTimeslotTask.cpp index e86636ab..a0a4ecee 100644 --- a/src/fsfw/osal/freertos/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/freertos/FixedTimeslotTask.cpp @@ -48,7 +48,7 @@ ReturnValue_t FixedTimeslotTask::startTask() { vTaskResume(handle); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } [[noreturn]] void FixedTimeslotTask::taskFunctionality() { @@ -108,7 +108,7 @@ void FixedTimeslotTask::handleMissedDeadline() { ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) { vTaskDelay(pdMS_TO_TICKS(ms)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } TaskHandle_t FixedTimeslotTask::getTaskHandle() { return handle; } diff --git a/src/fsfw/osal/freertos/MessageQueue.cpp b/src/fsfw/osal/freertos/MessageQueue.cpp index d1a7f691..e449ef1e 100644 --- a/src/fsfw/osal/freertos/MessageQueue.cpp +++ b/src/fsfw/osal/freertos/MessageQueue.cpp @@ -48,14 +48,14 @@ ReturnValue_t MessageQueue::handleSendResult(BaseType_t result, bool ignoreFault } return MessageQueueIF::FULL; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { BaseType_t result = xQueueReceive(handle, reinterpret_cast(message->getBuffer()), 0); if (result == pdPASS) { this->last = message->getSender(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return MessageQueueIF::EMPTY; } @@ -65,7 +65,7 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) { // TODO FreeRTOS does not support flushing partially // Is always successful xQueueReset(handle); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // static core function to send messages. diff --git a/src/fsfw/osal/freertos/Mutex.cpp b/src/fsfw/osal/freertos/Mutex.cpp index 1995e1ea..6c264dd6 100644 --- a/src/fsfw/osal/freertos/Mutex.cpp +++ b/src/fsfw/osal/freertos/Mutex.cpp @@ -31,7 +31,7 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { BaseType_t returncode = xSemaphoreTake(handle, timeout); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return MutexIF::MUTEX_TIMEOUT; } @@ -43,7 +43,7 @@ ReturnValue_t Mutex::unlockMutex() { } BaseType_t returncode = xSemaphoreGive(handle); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return MutexIF::CURR_THREAD_DOES_NOT_OWN_MUTEX; } diff --git a/src/fsfw/osal/freertos/PeriodicTask.cpp b/src/fsfw/osal/freertos/PeriodicTask.cpp index 665be06c..2b6a94db 100644 --- a/src/fsfw/osal/freertos/PeriodicTask.cpp +++ b/src/fsfw/osal/freertos/PeriodicTask.cpp @@ -55,12 +55,12 @@ ReturnValue_t PeriodicTask::startTask() { vTaskResume(handle); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) { vTaskDelay(pdMS_TO_TICKS(ms)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } [[noreturn]] void PeriodicTask::taskFunctionality() { diff --git a/src/fsfw/osal/freertos/QueueMapManager.cpp b/src/fsfw/osal/freertos/QueueMapManager.cpp index cb3afb1c..172d9dff 100644 --- a/src/fsfw/osal/freertos/QueueMapManager.cpp +++ b/src/fsfw/osal/freertos/QueueMapManager.cpp @@ -34,12 +34,12 @@ ReturnValue_t QueueMapManager::addMessageQueue(QueueHandle_t queue, MessageQueue "QueueMapManager::addMessageQueue This ID is already " "inside the map!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (id != nullptr) { *id = currentId; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } QueueHandle_t QueueMapManager::getMessageQueue(MessageQueueId_t messageQueueId) const { diff --git a/src/fsfw/osal/freertos/TaskFactory.cpp b/src/fsfw/osal/freertos/TaskFactory.cpp index 7acd812f..c79a6cf1 100644 --- a/src/fsfw/osal/freertos/TaskFactory.cpp +++ b/src/fsfw/osal/freertos/TaskFactory.cpp @@ -31,16 +31,16 @@ ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) { if (task == nullptr) { // delete self vTaskDelete(nullptr); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { // TODO not implemented - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) { vTaskDelay(pdMS_TO_TICKS(delayMs)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TaskFactory::printMissedDeadline() { diff --git a/src/fsfw/osal/host/Clock.cpp b/src/fsfw/osal/host/Clock.cpp index 19e120b3..8b6fc904 100644 --- a/src/fsfw/osal/host/Clock.cpp +++ b/src/fsfw/osal/host/Clock.cpp @@ -32,7 +32,7 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { #else sif::printWarning("Clock::setClock: Not implemented for host OSAL\n"); #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::setClock(const timeval* time) { @@ -43,7 +43,7 @@ ReturnValue_t Clock::setClock(const timeval* time) { #else sif::printWarning("Clock::setClock: Not implemented for host OSAL\n"); #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getClock_timeval(timeval* time) { @@ -54,33 +54,33 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { time->tv_sec = std::chrono::duration_cast(epoch).count(); auto fraction = now - secondsChrono; time->tv_usec = std::chrono::duration_cast(fraction).count(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; #elif defined(PLATFORM_UNIX) timespec timeUnix; int status = clock_gettime(CLOCK_REALTIME, &timeUnix); if (status != 0) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } time->tv_sec = timeUnix.tv_sec; time->tv_usec = timeUnix.tv_nsec / 1000.0; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; #else #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::getUptime: Not implemented for found OS!" << std::endl; #else sif::printWarning("Clock::getUptime: Not implemented for found OS!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; #endif } ReturnValue_t Clock::getClock_usecs(uint64_t* time) { if (time == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } using namespace std::chrono; *time = duration_cast(system_clock::now().time_since_epoch()).count(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } timeval Clock::getUptime() { @@ -108,13 +108,13 @@ timeval Clock::getUptime() { ReturnValue_t Clock::getUptime(timeval* uptime) { *uptime = getUptime(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { timeval uptime = getUptime(); *uptimeMs = uptime.tv_sec * 1000 + uptime.tv_usec / 1000; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { @@ -126,7 +126,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { auto fraction = now - seconds; time_t tt = SystemClock::to_time_t(now); ReturnValue_t result = checkOrCreateClockMutex(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } MutexGuard helper(timeMutex); @@ -142,7 +142,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { time->second = timeInfo->tm_sec; auto usecond = std::chrono::duration_cast(fraction); time->usecond = usecond.count(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) { @@ -162,10 +162,10 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to->tv_sec = seconds; to->tv_usec = from->usecond; // Fails in 2038.. - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) { *JD2000 = (time.tv_sec - 946728000. + time.tv_usec / 1000000.) / 24. / 3600.; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/host/FixedTimeslotTask.cpp b/src/fsfw/osal/host/FixedTimeslotTask.cpp index 1d10b8d8..edb2d52d 100644 --- a/src/fsfw/osal/host/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/host/FixedTimeslotTask.cpp @@ -66,12 +66,12 @@ ReturnValue_t FixedTimeslotTask::startTask() { std::lock_guard lock(initMutex); initCondition.notify_one(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) { std::this_thread::sleep_for(std::chrono::milliseconds(ms)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FixedTimeslotTask::taskFunctionality() { diff --git a/src/fsfw/osal/host/MessageQueue.cpp b/src/fsfw/osal/host/MessageQueue.cpp index d0a12850..ced30f09 100644 --- a/src/fsfw/osal/host/MessageQueue.cpp +++ b/src/fsfw/osal/host/MessageQueue.cpp @@ -14,7 +14,7 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, MqArgs* a messageDepth(messageDepth) { queueLock = MutexFactory::instance()->createMutex(); auto result = QueueMapManager::instance()->addMessageQueue(this, &id); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::MessageQueue: Could not be created" << std::endl; #else @@ -40,14 +40,14 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { messageQueue.pop(); // The last partner is the first uint32_t field in the message this->last = message->getSender(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueue::flush(uint32_t* count) { *count = messageQueue.size(); // Clears the queue. messageQueue = std::queue>(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // static core function to send messages. @@ -56,14 +56,14 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, MessageQueueId_t sentFrom, bool ignoreFault) { if (message == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } message->setSender(sentFrom); if (message->getMessageSize() > message->getMaximumMessageSize()) { // Actually, this should never happen or an error will be emitted // in MessageQueueMessage. // But I will still return a failure here. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } MessageQueue* targetQueue = dynamic_cast(QueueMapManager::instance()->getMessageQueue(sendTo)); @@ -92,7 +92,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, } return MessageQueueIF::FULL; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueue::lockQueue(MutexIF::TimeoutType timeoutType, dur_millis_t lockTimeout) { diff --git a/src/fsfw/osal/host/Mutex.cpp b/src/fsfw/osal/host/Mutex.cpp index 4b7a9582..2b67c7b5 100644 --- a/src/fsfw/osal/host/Mutex.cpp +++ b/src/fsfw/osal/host/Mutex.cpp @@ -7,15 +7,15 @@ Mutex::Mutex() {} ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { if (timeoutType == TimeoutType::BLOCKING) { mutex.lock(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else if (timeoutType == TimeoutType::POLLING) { if (mutex.try_lock()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } else if (timeoutType == TimeoutType::WAITING) { auto chronoMs = std::chrono::milliseconds(timeoutMs); if (mutex.try_lock_for(chronoMs)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } return MutexIF::MUTEX_TIMEOUT; @@ -23,7 +23,7 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { ReturnValue_t Mutex::unlockMutex() { mutex.unlock(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } std::timed_mutex* Mutex::getMutexHandle() { return &mutex; } diff --git a/src/fsfw/osal/host/PeriodicTask.cpp b/src/fsfw/osal/host/PeriodicTask.cpp index 1f18d335..e16aead0 100644 --- a/src/fsfw/osal/host/PeriodicTask.cpp +++ b/src/fsfw/osal/host/PeriodicTask.cpp @@ -63,12 +63,12 @@ ReturnValue_t PeriodicTask::startTask() { std::lock_guard lock(initMutex); initCondition.notify_one(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) { std::this_thread::sleep_for(std::chrono::milliseconds(ms)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void PeriodicTask::taskFunctionality() { diff --git a/src/fsfw/osal/host/QueueFactory.cpp b/src/fsfw/osal/host/QueueFactory.cpp index 732892ca..c6605656 100644 --- a/src/fsfw/osal/host/QueueFactory.cpp +++ b/src/fsfw/osal/host/QueueFactory.cpp @@ -13,7 +13,7 @@ ReturnValue_t MessageQueueSenderIF::sendMessage(MessageQueueId_t sendTo, MessageQueueMessageIF* message, MessageQueueId_t sentFrom, bool ignoreFault) { return MessageQueue::sendMessageFromMessageQueue(sendTo, message, sentFrom, ignoreFault); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } QueueFactory* QueueFactory::instance() { diff --git a/src/fsfw/osal/host/QueueMapManager.cpp b/src/fsfw/osal/host/QueueMapManager.cpp index 72c70baa..dc4eb1de 100644 --- a/src/fsfw/osal/host/QueueMapManager.cpp +++ b/src/fsfw/osal/host/QueueMapManager.cpp @@ -39,12 +39,12 @@ ReturnValue_t QueueMapManager::addMessageQueue(MessageQueueIF* queueToInsert, "QueueMapManager::addMessageQueue This ID is already " "inside the map!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (id != nullptr) { *id = currentId; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MessageQueueIF* QueueMapManager::getMessageQueue(MessageQueueId_t messageQueueId) const { diff --git a/src/fsfw/osal/host/TaskFactory.cpp b/src/fsfw/osal/host/TaskFactory.cpp index ec4c1554..e9415f5a 100644 --- a/src/fsfw/osal/host/TaskFactory.cpp +++ b/src/fsfw/osal/host/TaskFactory.cpp @@ -37,12 +37,12 @@ FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask( ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) { // This might block for some time! delete task; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) { std::this_thread::sleep_for(std::chrono::milliseconds(delayMs)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TaskFactory::printMissedDeadline() { diff --git a/src/fsfw/osal/host/taskHelpers.cpp b/src/fsfw/osal/host/taskHelpers.cpp index 432cf30c..e5a931ed 100644 --- a/src/fsfw/osal/host/taskHelpers.cpp +++ b/src/fsfw/osal/host/taskHelpers.cpp @@ -10,9 +10,9 @@ ReturnValue_t tasks::insertTaskName(std::thread::id threadId, const std::string& std::lock_guard lg(nameMapLock); auto returnPair = taskNameMap.emplace(threadId, taskName); if (not returnPair.second) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } std::string tasks::getTaskName(std::thread::id threadId) { diff --git a/src/fsfw/osal/linux/BinarySemaphore.cpp b/src/fsfw/osal/linux/BinarySemaphore.cpp index 4fb67f15..9b954d6c 100644 --- a/src/fsfw/osal/linux/BinarySemaphore.cpp +++ b/src/fsfw/osal/linux/BinarySemaphore.cpp @@ -43,7 +43,7 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType, uint32_t timeout } } if (result == 0) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } switch (errno) { @@ -62,10 +62,10 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType, uint32_t timeout case (EINTR): { // Call was interrupted by signal handler utility::printUnixErrorGeneric(CLASS_NAME, "acquire", "EINTR"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -73,13 +73,13 @@ ReturnValue_t BinarySemaphore::release() { return BinarySemaphore::release(&this ReturnValue_t BinarySemaphore::release(sem_t* handle) { ReturnValue_t countResult = checkCount(handle, 1); - if (countResult != HasReturnvaluesIF::RETURN_OK) { + if (countResult != returnvalue::OK) { return countResult; } int result = sem_post(handle); if (result == 0) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } switch (errno) { @@ -91,10 +91,10 @@ ReturnValue_t BinarySemaphore::release(sem_t* handle) { case (EOVERFLOW): { // SEM_MAX_VALUE overflow. This should never happen utility::printUnixErrorGeneric(CLASS_NAME, "release", "EOVERFLOW"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -145,9 +145,9 @@ ReturnValue_t BinarySemaphore::checkCount(sem_t* handle, uint8_t maxCount) { // This is a config error use lightweight printf is this is called // from an interrupt printf("BinarySemaphore::release: Value of binary semaphore greater than 1!\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return SemaphoreIF::SEMAPHORE_NOT_OWNED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/linux/Clock.cpp b/src/fsfw/osal/linux/Clock.cpp index 534e7e22..2b914f75 100644 --- a/src/fsfw/osal/linux/Clock.cpp +++ b/src/fsfw/osal/linux/Clock.cpp @@ -26,9 +26,9 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { int status = clock_settime(CLOCK_REALTIME, &timeUnix); if (status != 0) { // TODO errno - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::setClock(const timeval* time) { @@ -38,37 +38,37 @@ ReturnValue_t Clock::setClock(const timeval* time) { int status = clock_settime(CLOCK_REALTIME, &timeUnix); if (status != 0) { // TODO errno - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getClock_timeval(timeval* time) { timespec timeUnix; int status = clock_gettime(CLOCK_REALTIME, &timeUnix); if (status != 0) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } time->tv_sec = timeUnix.tv_sec; time->tv_usec = timeUnix.tv_nsec / 1000.0; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getClock_usecs(uint64_t* time) { timeval timeVal; ReturnValue_t result = getClock_timeval(&timeVal); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *time = (uint64_t)timeVal.tv_sec * 1e6 + timeVal.tv_usec; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } timeval Clock::getUptime() { timeval uptime; auto result = getUptime(&uptime); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Clock::getUptime: Error getting uptime" << std::endl; #endif @@ -84,7 +84,7 @@ ReturnValue_t Clock::getUptime(timeval* uptime) { uptime->tv_sec = uptimeSeconds; uptime->tv_usec = uptimeSeconds * (double)1e6 - (uptime->tv_sec * 1e6); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // Wait for new FSFW Clock function delivering seconds uptime. @@ -93,7 +93,7 @@ ReturnValue_t Clock::getUptime(timeval* uptime) { // struct sysinfo sysInfo; // int result = sysinfo(&sysInfo); // if(result != 0){ -// return HasReturnvaluesIF::RETURN_FAILED; +// return HasReturnvaluesIF::returnvalue::FAILED; // } // return sysInfo.uptime; //} @@ -101,11 +101,11 @@ ReturnValue_t Clock::getUptime(timeval* uptime) { ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { timeval uptime; ReturnValue_t result = getUptime(&uptime); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *uptimeMs = uptime.tv_sec * 1e3 + uptime.tv_usec / 1e3; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { @@ -113,10 +113,10 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { int status = clock_gettime(CLOCK_REALTIME, &timeUnix); if (status != 0) { // TODO errno - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t result = checkOrCreateClockMutex(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } MutexGuard helper(timeMutex); @@ -132,7 +132,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { time->second = timeInfo->tm_sec; time->usecond = timeUnix.tv_nsec / 1000.0; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) { @@ -148,10 +148,10 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to->tv_sec = timegm(&fromTm); to->tv_usec = from->usecond; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) { *JD2000 = (time.tv_sec - 946728000. + time.tv_usec / 1000000.) / 24. / 3600.; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/linux/CountingSemaphore.cpp b/src/fsfw/osal/linux/CountingSemaphore.cpp index 78210996..e2b006d9 100644 --- a/src/fsfw/osal/linux/CountingSemaphore.cpp +++ b/src/fsfw/osal/linux/CountingSemaphore.cpp @@ -35,7 +35,7 @@ CountingSemaphore& CountingSemaphore::operator=(CountingSemaphore&& other) { ReturnValue_t CountingSemaphore::release() { ReturnValue_t result = checkCount(&handle, maxCount); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return CountingSemaphore::release(&this->handle); @@ -44,7 +44,7 @@ ReturnValue_t CountingSemaphore::release() { ReturnValue_t CountingSemaphore::release(sem_t* handle) { int result = sem_post(handle); if (result == 0) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } switch (errno) { @@ -61,7 +61,7 @@ ReturnValue_t CountingSemaphore::release(sem_t* handle) { } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/linux/FixedTimeslotTask.cpp b/src/fsfw/osal/linux/FixedTimeslotTask.cpp index 156413ea..34729c22 100644 --- a/src/fsfw/osal/linux/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/linux/FixedTimeslotTask.cpp @@ -23,7 +23,7 @@ void* FixedTimeslotTask::taskEntryPoint(void* arg) { ReturnValue_t FixedTimeslotTask::startTask() { started = true; posixThread.createTask(&taskEntryPoint, this); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) { diff --git a/src/fsfw/osal/linux/InternalErrorCodes.cpp b/src/fsfw/osal/linux/InternalErrorCodes.cpp index 11913906..41472b0c 100644 --- a/src/fsfw/osal/linux/InternalErrorCodes.cpp +++ b/src/fsfw/osal/linux/InternalErrorCodes.cpp @@ -2,7 +2,7 @@ ReturnValue_t InternalErrorCodes::translate(uint8_t code) { // TODO This class can be removed - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } InternalErrorCodes::InternalErrorCodes() {} diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index ec212165..b2cca3f1 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -54,7 +54,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { "nullptr!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (message->getMaximumMessageSize() < maxMessageSize) { @@ -62,7 +62,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { sif::error << "MessageQueue::receiveMessage: Message size " << message->getMaximumMessageSize() << " too small to receive data!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } unsigned int messagePriority = 0; @@ -72,9 +72,9 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { this->last = message->getSender(); // Check size of incoming message. if (message->getMessageSize() < message->getMinimumMessageSize()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else if (status == 0) { // Success but no message received return MessageQueueIF::EMPTY; @@ -131,9 +131,9 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -152,9 +152,9 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) { utility::printUnixErrorGeneric(CLASS_NAME, "flush", "EINVAL"); break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *count = attrib.mq_curmsgs; attrib.mq_curmsgs = 0; @@ -176,11 +176,11 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) { utility::printUnixErrorGeneric(CLASS_NAME, "flush", "EINVAL"); break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, @@ -200,7 +200,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, #else sif::printError("MessageQueue::sendMessageFromMessageQueue: Message is nullptr\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } message->setSender(sentFrom); @@ -257,11 +257,11 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, utility::printUnixErrorGeneric(CLASS_NAME, "sendMessageFromMessageQueue", "EMSGSIZE"); break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messageDepth) { @@ -320,7 +320,7 @@ ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messag if (tempId != -1) { // Successful mq_open this->id = tempId; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } break; @@ -331,5 +331,5 @@ ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messag utility::printUnixErrorGeneric(CLASS_NAME, "MessageQueue", "Unknown"); } } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } diff --git a/src/fsfw/osal/linux/Mutex.cpp b/src/fsfw/osal/linux/Mutex.cpp index 2698fb54..be7a0a85 100644 --- a/src/fsfw/osal/linux/Mutex.cpp +++ b/src/fsfw/osal/linux/Mutex.cpp @@ -82,9 +82,9 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { return CURR_THREAD_ALREADY_OWNS_MUTEX; case 0: // Success - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; }; } @@ -103,8 +103,8 @@ ReturnValue_t Mutex::unlockMutex() { return CURR_THREAD_DOES_NOT_OWN_MUTEX; case 0: // Success - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; }; } diff --git a/src/fsfw/osal/linux/PeriodicPosixTask.cpp b/src/fsfw/osal/linux/PeriodicPosixTask.cpp index 09b106ed..556a0367 100644 --- a/src/fsfw/osal/linux/PeriodicPosixTask.cpp +++ b/src/fsfw/osal/linux/PeriodicPosixTask.cpp @@ -23,11 +23,11 @@ ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) { ReturnValue_t PeriodicPosixTask::startTask() { if (isEmpty()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } started = true; posixThread.createTask(&taskEntryPoint, this); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } [[noreturn]] void PeriodicPosixTask::taskFunctionality() { diff --git a/src/fsfw/osal/linux/PosixThread.cpp b/src/fsfw/osal/linux/PosixThread.cpp index 9fc088ae..811d58e2 100644 --- a/src/fsfw/osal/linux/PosixThread.cpp +++ b/src/fsfw/osal/linux/PosixThread.cpp @@ -29,16 +29,16 @@ ReturnValue_t PosixThread::sleep(uint64_t ns) { switch (errno) { case EINTR: // The nanosleep() function was interrupted by a signal. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case EINVAL: // The rqtp argument specified a nanosecond value less than zero or // greater than or equal to 1000 million. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void PosixThread::suspend() { diff --git a/src/fsfw/osal/linux/TaskFactory.cpp b/src/fsfw/osal/linux/TaskFactory.cpp index a28e685d..2cd4fd67 100644 --- a/src/fsfw/osal/linux/TaskFactory.cpp +++ b/src/fsfw/osal/linux/TaskFactory.cpp @@ -28,7 +28,7 @@ FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask( ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) { // TODO not implemented - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) { diff --git a/src/fsfw/osal/rtems/BinarySemaphore.cpp b/src/fsfw/osal/rtems/BinarySemaphore.cpp index 06b0bf77..3677dd22 100644 --- a/src/fsfw/osal/rtems/BinarySemaphore.cpp +++ b/src/fsfw/osal/rtems/BinarySemaphore.cpp @@ -7,9 +7,9 @@ BinarySemaphore::BinarySemaphore() {} BinarySemaphore::~BinarySemaphore() {} ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType, uint32_t timeoutMs) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } -ReturnValue_t BinarySemaphore::release() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t BinarySemaphore::release() { return returnvalue::OK; } uint8_t BinarySemaphore::getSemaphoreCounter() const { return 0; } diff --git a/src/fsfw/osal/rtems/Clock.cpp b/src/fsfw/osal/rtems/Clock.cpp index 831c67d4..cb7bd042 100644 --- a/src/fsfw/osal/rtems/Clock.cpp +++ b/src/fsfw/osal/rtems/Clock.cpp @@ -23,13 +23,13 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { rtems_status_code status = rtems_clock_set(&timeRtems); switch (status) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_INVALID_ADDRESS: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_CLOCK: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -38,7 +38,7 @@ ReturnValue_t Clock::setClock(const timeval* time) { newTime.tv_sec = time->tv_sec; if (time->tv_usec < 0) { // better returnvalue. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } newTime.tv_nsec = time->tv_usec * TOD_NANOSECONDS_PER_MICROSECOND; @@ -48,10 +48,10 @@ ReturnValue_t Clock::setClock(const timeval* time) { Status_Control status = _TOD_Set(&newTime, &context); _TOD_Unlock(); if (status == STATUS_SUCCESSFUL) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // better returnvalue - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t Clock::getClock_timeval(timeval* time) { @@ -59,11 +59,11 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { rtems_status_code status = rtems_clock_get_tod_timeval(time); switch (status) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_NOT_DEFINED: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -77,16 +77,16 @@ ReturnValue_t Clock::getUptime(timeval* uptime) { uptime->tv_usec = time.tv_nsec; switch (status) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { // This counter overflows after 50 days *uptimeMs = rtems_clock_get_ticks_since_boot(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getClock_usecs(uint64_t* time) { @@ -95,9 +95,9 @@ ReturnValue_t Clock::getClock_usecs(uint64_t* time) { *time = ((uint64_t)temp_time.tv_sec * 1000000) + temp_time.tv_usec; switch (returnValue) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -118,16 +118,16 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { time->usecond = static_cast(timeRtems.ticks) / rtems_clock_get_ticks_per_second() * 1e6; time->year = timeRtems.year; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case RTEMS_NOT_DEFINED: /* System date and time is not set */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_ADDRESS: /* time_buffer is NULL */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -143,10 +143,10 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* timeRtems.ticks = from->usecond * getTicksPerSecond() / 1e6; to->tv_sec = _TOD_To_seconds(&timeRtems); to->tv_usec = from->usecond; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) { *JD2000 = (time.tv_sec - 946728000. + time.tv_usec / 1000000.) / 24. / 3600.; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/rtems/CpuUsage.cpp b/src/fsfw/osal/rtems/CpuUsage.cpp index 2613a698..4ffc2271 100644 --- a/src/fsfw/osal/rtems/CpuUsage.cpp +++ b/src/fsfw/osal/rtems/CpuUsage.cpp @@ -86,7 +86,7 @@ ReturnValue_t CpuUsage::serialize(uint8_t** buffer, size_t* size, size_t maxSize Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&timeSinceLastReset, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerialArrayListAdapter::serialize(&threadData, buffer, size, maxSize, @@ -106,7 +106,7 @@ ReturnValue_t CpuUsage::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&timeSinceLastReset, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerialArrayListAdapter::deSerialize(&threadData, buffer, size, @@ -116,7 +116,7 @@ ReturnValue_t CpuUsage::deSerialize(const uint8_t** buffer, size_t* size, ReturnValue_t CpuUsage::ThreadData::serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&id, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + MAX_LENGTH_OF_THREAD_NAME > maxSize) { @@ -126,14 +126,14 @@ ReturnValue_t CpuUsage::ThreadData::serialize(uint8_t** buffer, size_t* size, si *size += MAX_LENGTH_OF_THREAD_NAME; *buffer += MAX_LENGTH_OF_THREAD_NAME; result = SerializeAdapter::serialize(&timeRunning, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&percentUsage, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint32_t CpuUsage::ThreadData::getSerializedSize() const { @@ -150,7 +150,7 @@ uint32_t CpuUsage::ThreadData::getSerializedSize() const { ReturnValue_t CpuUsage::ThreadData::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&id, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size < MAX_LENGTH_OF_THREAD_NAME) { @@ -159,12 +159,12 @@ ReturnValue_t CpuUsage::ThreadData::deSerialize(const uint8_t** buffer, size_t* memcpy(name, *buffer, MAX_LENGTH_OF_THREAD_NAME); *buffer -= MAX_LENGTH_OF_THREAD_NAME; result = SerializeAdapter::deSerialize(&timeRunning, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&percentUsage, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/rtems/FixedTimeslotTask.cpp b/src/fsfw/osal/rtems/FixedTimeslotTask.cpp index f400c213..77582d75 100644 --- a/src/fsfw/osal/rtems/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/rtems/FixedTimeslotTask.cpp @@ -48,14 +48,14 @@ ReturnValue_t FixedTimeslotTask::startTask() { switch (status) { case RTEMS_SUCCESSFUL: // ask started successfully - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: /* RTEMS_INVALID_ADDRESS - invalid task entry point RTEMS_INVALID_ID - invalid task id RTEMS_INCORRECT_STATE - task not in the dormant state RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/InternalErrorCodes.cpp b/src/fsfw/osal/rtems/InternalErrorCodes.cpp index 4d78186c..9e0c1ae7 100644 --- a/src/fsfw/osal/rtems/InternalErrorCodes.cpp +++ b/src/fsfw/osal/rtems/InternalErrorCodes.cpp @@ -50,7 +50,7 @@ ReturnValue_t InternalErrorCodes::translate(uint8_t code) { // case INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0: // return UNLIMITED_AND_MAXIMUM_IS_0; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/MessageQueue.cpp b/src/fsfw/osal/rtems/MessageQueue.cpp index 534015dc..bae3b5e0 100644 --- a/src/fsfw/osal/rtems/MessageQueue.cpp +++ b/src/fsfw/osal/rtems/MessageQueue.cpp @@ -32,7 +32,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { this->last = message->getSender(); // Check size of incoming message. if (message->getMessageSize() < message->getMinimumMessageSize()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } else { // No message was received. Keep lastPartner anyway, I might send something later. @@ -66,7 +66,7 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo, MessageQueu ReturnValue_t returnCode = convertReturnCode(result); if (returnCode == MessageQueueIF::EMPTY) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return returnCode; @@ -75,23 +75,23 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo, MessageQueu ReturnValue_t MessageQueue::convertReturnCode(rtems_status_code inValue) { switch (inValue) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_INVALID_ID: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_TIMEOUT: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_OBJECT_WAS_DELETED: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_ADDRESS: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_SIZE: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_TOO_MANY: return MessageQueueIF::FULL; case RTEMS_UNSATISFIED: return MessageQueueIF::EMPTY; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/Mutex.cpp b/src/fsfw/osal/rtems/Mutex.cpp index 94f0041e..eb1a3718 100644 --- a/src/fsfw/osal/rtems/Mutex.cpp +++ b/src/fsfw/osal/rtems/Mutex.cpp @@ -43,7 +43,7 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType = TimeoutType::BLOCKING, switch (status) { case RTEMS_SUCCESSFUL: // semaphore obtained successfully - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_UNSATISFIED: // semaphore not available return MUTEX_NOT_FOUND; @@ -57,7 +57,7 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType = TimeoutType::BLOCKING, // invalid semaphore id return MUTEX_INVALID_ID; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -66,7 +66,7 @@ ReturnValue_t Mutex::unlockMutex() { switch (status) { case RTEMS_SUCCESSFUL: // semaphore obtained successfully - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_NOT_OWNER_OF_RESOURCE: // semaphore not available return CURR_THREAD_DOES_NOT_OWN_MUTEX; @@ -74,6 +74,6 @@ ReturnValue_t Mutex::unlockMutex() { // invalid semaphore id return MUTEX_INVALID_ID; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/PeriodicTask.cpp b/src/fsfw/osal/rtems/PeriodicTask.cpp index cccf937f..5c397815 100644 --- a/src/fsfw/osal/rtems/PeriodicTask.cpp +++ b/src/fsfw/osal/rtems/PeriodicTask.cpp @@ -37,13 +37,13 @@ ReturnValue_t PeriodicTask::startTask() { switch (status) { case RTEMS_SUCCESSFUL: /* Task started successfully */ - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: /* RTEMS_INVALID_ADDRESS - invalid task entry point RTEMS_INVALID_ID - invalid task id RTEMS_INCORRECT_STATE - task not in the dormant state RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/QueueFactory.cpp b/src/fsfw/osal/rtems/QueueFactory.cpp index 074ce273..1918f7bc 100644 --- a/src/fsfw/osal/rtems/QueueFactory.cpp +++ b/src/fsfw/osal/rtems/QueueFactory.cpp @@ -16,25 +16,25 @@ ReturnValue_t MessageQueueSenderIF::sendMessage(MessageQueueId_t sendTo, switch (result) { case RTEMS_SUCCESSFUL: // message sent successfully - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_INVALID_ID: // invalid queue id - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_SIZE: // invalid message size - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_ADDRESS: // buffer is NULL - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_UNSATISFIED: // out of message buffers - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_TOO_MANY: // queue's limit has been reached return MessageQueueIF::FULL; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/RTEMSTaskBase.cpp b/src/fsfw/osal/rtems/RTEMSTaskBase.cpp index a306b9e2..b235f6a0 100644 --- a/src/fsfw/osal/rtems/RTEMSTaskBase.cpp +++ b/src/fsfw/osal/rtems/RTEMSTaskBase.cpp @@ -21,7 +21,7 @@ RTEMSTaskBase::RTEMSTaskBase(rtems_task_priority set_priority, size_t stack_size RTEMS_FLOATING_POINT, &id); } ReturnValue_t result = convertReturnCode(status); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TaskBase::TaskBase: createTask with name " << std::hex << osalName << std::dec << " failed with return code " << (uint32_t)status << std::endl; @@ -42,21 +42,21 @@ ReturnValue_t RTEMSTaskBase::sleepFor(uint32_t ms) { ReturnValue_t RTEMSTaskBase::convertReturnCode(rtems_status_code inValue) { switch (inValue) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_MP_NOT_CONFIGURED: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_NAME: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_TOO_MANY: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_ADDRESS: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_UNSATISFIED: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_PRIORITY: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/TaskFactory.cpp b/src/fsfw/osal/rtems/TaskFactory.cpp index fb52eb0e..f10e5cf3 100644 --- a/src/fsfw/osal/rtems/TaskFactory.cpp +++ b/src/fsfw/osal/rtems/TaskFactory.cpp @@ -31,13 +31,13 @@ FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask( ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) { // This should call the OS specific destructor delete (dynamic_cast(task)); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) { rtems_task_wake_after(RtemsBasic::convertMsToTicks(delayMs)); // Only return value is "RTEMS_SUCCESSFUL - always successful" so it has been neglected - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TaskFactory::printMissedDeadline() { diff --git a/src/fsfw/osal/windows/winTaskHelpers.cpp b/src/fsfw/osal/windows/winTaskHelpers.cpp index c863c4ca..206ee7a7 100644 --- a/src/fsfw/osal/windows/winTaskHelpers.cpp +++ b/src/fsfw/osal/windows/winTaskHelpers.cpp @@ -89,7 +89,7 @@ ReturnValue_t tasks::setTaskPriority(HANDLE nativeHandle, TaskPriority priority) #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; #endif } result = SetThreadPriority(reinterpret_cast(nativeHandle), nPriorityNumber); @@ -97,8 +97,8 @@ ReturnValue_t tasks::setTaskPriority(HANDLE nativeHandle, TaskPriority priority) #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; #endif } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/parameters/ParameterHelper.cpp b/src/fsfw/parameters/ParameterHelper.cpp index 58356af5..ba0e70a4 100644 --- a/src/fsfw/parameters/ParameterHelper.cpp +++ b/src/fsfw/parameters/ParameterHelper.cpp @@ -10,10 +10,10 @@ ParameterHelper::~ParameterHelper() {} ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { if (storage == nullptr) { // ParameterHelper was not initialized - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; switch (message->getCommand()) { case ParameterMessage::CMD_PARAMETER_DUMP: { ParameterWrapper description; @@ -21,7 +21,7 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { uint8_t uniqueIdentifier = HasParametersIF::getUniqueIdentifierId(ParameterMessage::getParameterId(message)); result = owner->getParameter(domain, uniqueIdentifier, &description, &description, 0); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { result = sendParameter(message->getSender(), ParameterMessage::getParameterId(message), &description); } @@ -42,7 +42,7 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { ConstStorageAccessor accessor(storeId); result = storage->getData(storeId, accessor); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ParameterHelper::handleParameterMessage: Getting" << " store data failed for load command." << std::endl; @@ -52,19 +52,19 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { ParameterWrapper streamWrapper; result = streamWrapper.set(type, rows, columns, accessor.data(), accessor.size()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } ParameterWrapper ownerWrapper; result = owner->getParameter(domain, uniqueIdentifier, &ownerWrapper, &streamWrapper, linearIndex); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = ownerWrapper.copyFrom(&streamWrapper, linearIndex); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -73,14 +73,14 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { break; } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { rejectCommand(message->getSender(), result, message->getCommand()); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id, @@ -91,7 +91,7 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id, store_address_t address; ReturnValue_t result = storage->getFreeElement(&address, serializedSize, &storeElement); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -100,7 +100,7 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id, result = description->serialize(&storeElement, &storeElementSize, serializedSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { storage->deleteData(address); return result; } @@ -111,7 +111,7 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id, MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ParameterHelper::initialize() { @@ -121,7 +121,7 @@ ReturnValue_t ParameterHelper::initialize() { if (storage == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason, diff --git a/src/fsfw/parameters/ParameterWrapper.cpp b/src/fsfw/parameters/ParameterWrapper.cpp index 27552290..522a68b1 100644 --- a/src/fsfw/parameters/ParameterWrapper.cpp +++ b/src/fsfw/parameters/ParameterWrapper.cpp @@ -28,16 +28,16 @@ ReturnValue_t ParameterWrapper::serialize(uint8_t **buffer, size_t *size, size_t ReturnValue_t result; result = SerializeAdapter::serialize(&type, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&columns, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&rows, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -91,11 +91,11 @@ template ReturnValue_t ParameterWrapper::serializeData(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { const T *element = (const T *)readonlyData; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; uint16_t dataSize = columns * rows; while (dataSize != 0) { result = SerializeAdapter::serialize(element, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } element++; @@ -112,7 +112,7 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow, uint8_t sta const uint8_t *fromAsStream = reinterpret_cast(from); size_t streamSize = fromRows * fromColumns * sizeof(T); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; for (uint8_t fromRow = 0; fromRow < fromRows; fromRow++) { // get the start element of this row in data @@ -122,7 +122,7 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow, uint8_t sta for (uint8_t fromColumn = 0; fromColumn < fromColumns; fromColumn++) { result = SerializeAdapter::deSerialize(dataWithDataType + fromColumn, &fromAsStream, &streamSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -142,7 +142,7 @@ ReturnValue_t ParameterWrapper::deSerialize(const uint8_t **buffer, size_t *size ParameterWrapper streamDescription; ReturnValue_t result = streamDescription.set(*buffer, *size, buffer, size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -163,24 +163,24 @@ ReturnValue_t ParameterWrapper::set(Type type, uint8_t rows, uint8_t columns, co this->data = nullptr; this->readonlyData = data; pointsToStream = true; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize, const uint8_t **remainingStream, size_t *remainingSize) { ReturnValue_t result = SerializeAdapter::deSerialize(&type, &stream, &streamSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&columns, &stream, &streamSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&rows, &stream, &streamSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -203,7 +203,7 @@ ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize, *remainingSize = streamSize; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from, @@ -265,7 +265,7 @@ ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from, uint8_t typeSize = type.getSize(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; // copy data if (from->pointsToStream) { switch (type) { diff --git a/src/fsfw/parameters/ParameterWrapper.h b/src/fsfw/parameters/ParameterWrapper.h index 873db7b2..3b04199a 100644 --- a/src/fsfw/parameters/ParameterWrapper.h +++ b/src/fsfw/parameters/ParameterWrapper.h @@ -185,7 +185,7 @@ inline ReturnValue_t ParameterWrapper::getElement(T *value, uint8_t row, uint8_t } else { const T *dataWithType = static_cast(readonlyData); *value = dataWithType[row * columns + column]; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } diff --git a/src/fsfw/power/DummyPowerSwitcher.cpp b/src/fsfw/power/DummyPowerSwitcher.cpp index 48ab22c6..952a5a57 100644 --- a/src/fsfw/power/DummyPowerSwitcher.cpp +++ b/src/fsfw/power/DummyPowerSwitcher.cpp @@ -20,28 +20,28 @@ ReturnValue_t DummyPowerSwitcher::sendSwitchCommand(power::Switch_t switchNr, Re if (switchNr < switcherList.size()) { switcherList[switchNr] = onOff; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t DummyPowerSwitcher::sendFuseOnCommand(uint8_t fuseNr) { if (fuseNr < fuseList.size()) { fuseList[fuseNr] = FUSE_ON; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t DummyPowerSwitcher::getSwitchState(power::Switch_t switchNr) const { if (switchNr < switcherList.size()) { return switcherList[switchNr]; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t DummyPowerSwitcher::getFuseState(uint8_t fuseNr) const { if (fuseNr < fuseList.size()) { return fuseList[fuseNr]; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint32_t DummyPowerSwitcher::getSwitchDelayMs(void) const { return switchDelayMs; } diff --git a/src/fsfw/power/Fuse.cpp b/src/fsfw/power/Fuse.cpp index 81b51c89..73b29452 100644 --- a/src/fsfw/power/Fuse.cpp +++ b/src/fsfw/power/Fuse.cpp @@ -32,22 +32,22 @@ void Fuse::addDevice(PowerComponentIF* switchSet) { devices.push_back(switchSet) ReturnValue_t Fuse::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = parameterHelper.initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } powerIF = ObjectManager::instance()->get(powerSwitchId); if (powerIF == NULL) { - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } void Fuse::calculatePowerLimits(float* low, float* high) { @@ -66,7 +66,7 @@ ReturnValue_t Fuse::check() { set.setValidity(false, true); return set.commit(); } - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; checkFuseState(); calculateFusePower(); // Check if power is valid and if fuse state is off or invalid. @@ -89,14 +89,14 @@ ReturnValue_t Fuse::check() { ReturnValue_t Fuse::serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (DeviceList::const_iterator iter = devices.begin(); iter != devices.end(); iter++) { result = (*iter)->serialize(buffer, size, maxSize, streamEndianness); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } } - return RETURN_OK; + return returnvalue::OK; } size_t Fuse::getSerializedSize() const { @@ -108,21 +108,21 @@ size_t Fuse::getSerializedSize() const { } ReturnValue_t Fuse::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (DeviceList::iterator iter = devices.begin(); iter != devices.end(); iter++) { result = (*iter)->deSerialize(buffer, size, streamEndianness); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } } - return RETURN_OK; + return returnvalue::OK; } uint8_t Fuse::getFuseId() const { return fuseId; } void Fuse::calculateFusePower() { ReturnValue_t result1 = currentLimit.check(); - if (result1 != HasReturnvaluesIF::RETURN_OK || !(voltage.isValid())) { + if (result1 != returnvalue::OK || !(voltage.isValid())) { power.setValid(PoolVariableIF::INVALID); return; } @@ -133,7 +133,7 @@ void Fuse::calculateFusePower() { ReturnValue_t Fuse::performOperation(uint8_t opCode) { checkCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void Fuse::reportEvents(Event event) { @@ -157,15 +157,15 @@ void Fuse::setAllMonitorsToUnchecked() { void Fuse::checkCommandQueue() { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } result = healthHelper.handleHealthCommand(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } result = parameterHelper.handleParameterMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } command.setToUnknownCommand(); @@ -227,7 +227,7 @@ bool Fuse::isPowerValid() { return power.isValid(); } ReturnValue_t Fuse::setHealth(HealthState health) { healthHelper.setHealth(health); - return RETURN_OK; + return returnvalue::OK; } HasHealthIF::HealthState Fuse::getHealth() { return healthHelper.getHealth(); } @@ -238,6 +238,6 @@ ReturnValue_t Fuse::PowerMonitor::checkPower(float sample, float lowerLimit, flo } else if (sample < lowerLimit) { return this->monitorStateIs(MonitoringIF::BELOW_LOW_LIMIT, sample, lowerLimit); } else { - return this->monitorStateIs(RETURN_OK, sample, 0.0); // Within limits. + return this->monitorStateIs(returnvalue::OK, sample, 0.0); // Within limits. } } diff --git a/src/fsfw/power/Fuse.h b/src/fsfw/power/Fuse.h index 43896f75..1f880f3a 100644 --- a/src/fsfw/power/Fuse.h +++ b/src/fsfw/power/Fuse.h @@ -16,7 +16,6 @@ void setStaticFrameworkObjectIds(); class Fuse : public SystemObject, public HasHealthIF, - public HasReturnvaluesIF, public ReceivesParameterMessagesIF, public SerializeIF { friend void(Factory::setStaticFrameworkObjectIds)(); diff --git a/src/fsfw/power/PowerComponent.cpp b/src/fsfw/power/PowerComponent.cpp index e4c336c7..fd780841 100644 --- a/src/fsfw/power/PowerComponent.cpp +++ b/src/fsfw/power/PowerComponent.cpp @@ -18,7 +18,7 @@ ReturnValue_t PowerComponent::serialize(uint8_t** buffer, size_t* size, size_t m Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&minPower, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::serialize(&maxPower, buffer, size, maxSize, streamEndianness); @@ -41,7 +41,7 @@ float PowerComponent::getMax() { return maxPower; } ReturnValue_t PowerComponent::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&minPower, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::deSerialize(&maxPower, buffer, size, streamEndianness); @@ -64,5 +64,5 @@ ReturnValue_t PowerComponent::getParameter(uint8_t domainId, uint8_t uniqueId, default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/power/PowerSensor.cpp b/src/fsfw/power/PowerSensor.cpp index 08ff4724..69c9e272 100644 --- a/src/fsfw/power/PowerSensor.cpp +++ b/src/fsfw/power/PowerSensor.cpp @@ -22,8 +22,8 @@ PowerSensor::~PowerSensor() { QueueFactory::instance()->deleteMessageQueue(comma ReturnValue_t PowerSensor::calculatePower() { powerSensorSet.read(); - ReturnValue_t result1 = HasReturnvaluesIF::RETURN_FAILED; - ReturnValue_t result2 = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result1 = returnvalue::FAILED; + ReturnValue_t result2 = returnvalue::FAILED; if (healthHelper.healthTable->isHealthy(getObjectId()) && voltage.isValid() && current.isValid()) { result1 = voltageLimit.doCheck(voltage.value); @@ -33,7 +33,7 @@ ReturnValue_t PowerSensor::calculatePower() { currentLimit.setToInvalid(); result1 = OBJECT_NOT_HEALTHY; } - if (result1 != HasReturnvaluesIF::RETURN_OK || result2 != HasReturnvaluesIF::RETURN_OK) { + if (result1 != returnvalue::OK || result2 != returnvalue::OK) { result1 = MonitoringIF::INVALID; power.setValid(PoolVariableIF::INVALID); } else { @@ -46,22 +46,22 @@ ReturnValue_t PowerSensor::calculatePower() { ReturnValue_t PowerSensor::performOperation(uint8_t opCode) { checkCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MessageQueueId_t PowerSensor::getCommandQueue() const { return commandQueue->getId(); } ReturnValue_t PowerSensor::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = parameterHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return result; @@ -75,15 +75,15 @@ void PowerSensor::setAllMonitorsToUnchecked() { void PowerSensor::checkCommandQueue() { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } result = healthHelper.handleHealthCommand(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } result = parameterHelper.handleParameterMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } command.setToUnknownCommand(); @@ -106,7 +106,7 @@ float PowerSensor::getPower() { ReturnValue_t PowerSensor::setHealth(HealthState health) { healthHelper.setHealth(health); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } HasHealthIF::HealthState PowerSensor::getHealth() { return healthHelper.getHealth(); } diff --git a/src/fsfw/power/PowerSwitchIF.h b/src/fsfw/power/PowerSwitchIF.h index bc883fbc..054923f4 100644 --- a/src/fsfw/power/PowerSwitchIF.h +++ b/src/fsfw/power/PowerSwitchIF.h @@ -13,7 +13,7 @@ * because they can be called asynchronosuly (const ending). * @ingroup interfaces */ -class PowerSwitchIF : public HasReturnvaluesIF { +class PowerSwitchIF { public: /** * Empty dtor. @@ -50,7 +50,7 @@ class PowerSwitchIF : public HasReturnvaluesIF { * @return * - @c SWITCH_ON if the specified switch is on. * - @c SWITCH_OFF if the specified switch is off. - * - @c RETURN_FAILED if an error occured + * - @c returnvalue::FAILED if an error occured */ virtual ReturnValue_t getSwitchState(power::Switch_t switchNr) const = 0; /** @@ -59,7 +59,7 @@ class PowerSwitchIF : public HasReturnvaluesIF { * @return * - @c FUSE_ON if the specified fuse is on. * - @c FUSE_OFF if the specified fuse is off. - * - @c RETURN_FAILED if an error occured + * - @c returnvalue::FAILED if an error occured */ virtual ReturnValue_t getFuseState(uint8_t fuseNr) const = 0; /** diff --git a/src/fsfw/power/PowerSwitcher.cpp b/src/fsfw/power/PowerSwitcher.cpp index 7608c6e7..77733884 100644 --- a/src/fsfw/power/PowerSwitcher.cpp +++ b/src/fsfw/power/PowerSwitcher.cpp @@ -24,11 +24,11 @@ ReturnValue_t PowerSwitcher::getStateOfSwitches() { (secondSwitchState == PowerSwitchIF::SWITCH_OFF)) { return PowerSwitchIF::SWITCH_OFF; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -111,18 +111,18 @@ ReturnValue_t PowerSwitcher::checkSwitchState() { return IN_POWER_TRANSITION; case SWITCH_IS_OFF: if (getStateOfSwitches() == PowerSwitchIF::SWITCH_OFF) { - return RETURN_OK; + return returnvalue::OK; } else { return SWITCH_STATE_MISMATCH; } case SWITCH_IS_ON: if (getStateOfSwitches() == PowerSwitchIF::SWITCH_ON) { - return RETURN_OK; + return returnvalue::OK; } else { return SWITCH_STATE_MISMATCH; } } - return RETURN_FAILED; + return returnvalue::FAILED; } PowerSwitcher::State_t PowerSwitcher::getState() { return state; } diff --git a/src/fsfw/power/PowerSwitcher.h b/src/fsfw/power/PowerSwitcher.h index 279ffacf..7aa60494 100644 --- a/src/fsfw/power/PowerSwitcher.h +++ b/src/fsfw/power/PowerSwitcher.h @@ -6,7 +6,7 @@ #include "../timemanager/Countdown.h" #include "PowerSwitchIF.h" -class PowerSwitcher : public HasReturnvaluesIF { +class PowerSwitcher { public: enum State_t { WAIT_OFF, diff --git a/src/fsfw/power/PowerSwitcherComponent.cpp b/src/fsfw/power/PowerSwitcherComponent.cpp index 9c1ed4cf..b6b67a83 100644 --- a/src/fsfw/power/PowerSwitcherComponent.cpp +++ b/src/fsfw/power/PowerSwitcherComponent.cpp @@ -16,15 +16,15 @@ ReturnValue_t PowerSwitcherComponent::performOperation(uint8_t opCode) { ReturnValue_t result; CommandMessage command; - for (result = queue->receiveMessage(&command); result == RETURN_OK; + for (result = queue->receiveMessage(&command); result == returnvalue::OK; result = queue->receiveMessage(&command)) { result = healthHelper.handleHealthCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = modeHelper.handleModeCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } } @@ -37,16 +37,16 @@ ReturnValue_t PowerSwitcherComponent::performOperation(uint8_t opCode) { setMode(MODE_ON, 0); } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t PowerSwitcherComponent::initialize() { ReturnValue_t result = modeHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SystemObject::initialize(); @@ -61,7 +61,7 @@ void PowerSwitcherComponent::getMode(Mode_t *mode, Submode_t *submode) { ReturnValue_t PowerSwitcherComponent::setHealth(HealthState health) { healthHelper.setHealth(health); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t PowerSwitcherComponent::checkModeCommand(Mode_t mode, Submode_t submode, @@ -70,7 +70,7 @@ ReturnValue_t PowerSwitcherComponent::checkModeCommand(Mode_t mode, Submode_t su if (mode != MODE_ON and mode != MODE_OFF) { return TRANS_NOT_ALLOWED; } - return RETURN_OK; + return returnvalue::OK; } void PowerSwitcherComponent::startTransition(Mode_t mode, Submode_t submode) { diff --git a/src/fsfw/power/PowerSwitcherComponent.h b/src/fsfw/power/PowerSwitcherComponent.h index a3ed640e..01689bef 100644 --- a/src/fsfw/power/PowerSwitcherComponent.h +++ b/src/fsfw/power/PowerSwitcherComponent.h @@ -23,7 +23,6 @@ class PowerSwitchIF; * commanding in to MODE_ON will cause the switcher to turn the switch on. */ class PowerSwitcherComponent : public SystemObject, - public HasReturnvaluesIF, public ExecutableObjectIF, public HasModesIF, public HasHealthIF { diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index 41be3d13..fedc4760 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -20,7 +20,7 @@ ReturnValue_t CService200ModeCommanding::isValidSubservice(uint8_t subservice) { case (Subservice::COMMAND_MODE_COMMAND): case (Subservice::COMMAND_MODE_READ): case (Subservice::COMMAND_MODE_ANNCOUNCE): - return RETURN_OK; + return returnvalue::OK; default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } @@ -47,7 +47,7 @@ ReturnValue_t CService200ModeCommanding::checkInterfaceAndAcquireMessageQueue( } *messageQueueToSet = destination->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CService200ModeCommanding::prepareCommand(CommandMessage *message, uint8_t subservice, @@ -56,7 +56,7 @@ ReturnValue_t CService200ModeCommanding::prepareCommand(CommandMessage *message, ModePacket modeCommandPacket; ReturnValue_t result = modeCommandPacket.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -70,7 +70,7 @@ ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply CommandMessage *optionalNextCommand, object_id_t objectId, bool *isStep) { Command_t replyId = reply->getCommand(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; switch (replyId) { case (ModeMessage::REPLY_MODE_REPLY): { result = prepareModeReply(reply, objectId); @@ -88,7 +88,7 @@ ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply result = INVALID_REPLY; break; default: - result = RETURN_FAILED; + result = returnvalue::FAILED; } return result; } @@ -103,9 +103,9 @@ ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMess object_id_t objectId) { ModePacket wrongModeReply(objectId, ModeMessage::getMode(reply), ModeMessage::getSubmode(reply)); ReturnValue_t result = sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, &wrongModeReply); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { // We want to produce an error here in any case because the mode was not correct - return RETURN_FAILED; + return returnvalue::FAILED; } return result; } @@ -114,9 +114,9 @@ ReturnValue_t CService200ModeCommanding::prepareCantReachModeReply(const Command object_id_t objectId) { CantReachModePacket cantReachModePacket(objectId, ModeMessage::getCantReachModeReason(reply)); ReturnValue_t result = sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, &cantReachModePacket); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { // We want to produce an error here in any case because the mode was not reached - return RETURN_FAILED; + return returnvalue::FAILED; } return result; } diff --git a/src/fsfw/pus/CService201HealthCommanding.cpp b/src/fsfw/pus/CService201HealthCommanding.cpp index 644e0d7c..45473581 100644 --- a/src/fsfw/pus/CService201HealthCommanding.cpp +++ b/src/fsfw/pus/CService201HealthCommanding.cpp @@ -18,7 +18,7 @@ ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) case (Subservice::COMMAND_SET_HEALTH): case (Subservice::COMMAND_ANNOUNCE_HEALTH): case (Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): - return RETURN_OK; + return returnvalue::OK; default: #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Invalid Subservice" << std::endl; @@ -48,19 +48,19 @@ ReturnValue_t CService201HealthCommanding::checkInterfaceAndAcquireMessageQueue( } *messageQueueToSet = destination->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CService201HealthCommanding::prepareCommand(CommandMessage *message, uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, uint32_t *state, object_id_t objectId) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (subservice) { case (Subservice::COMMAND_SET_HEALTH): { HealthSetCommand healthCommand; result = healthCommand.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { break; } HealthMessage::setHealthMessage(message, HealthMessage::HEALTH_SET, @@ -77,7 +77,7 @@ ReturnValue_t CService201HealthCommanding::prepareCommand(CommandMessage *messag } default: { // Should never happen, subservice was already checked - result = RETURN_FAILED; + result = returnvalue::FAILED; } } return result; diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 968a59ff..7b9ba7c0 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -62,13 +62,13 @@ inline ReturnValue_t Service11TelecommandScheduling::handleRequest( default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } - return RETURN_OK; + return returnvalue::OK; } template inline ReturnValue_t Service11TelecommandScheduling::performService() { if (not schedulingEnabled) { - return RETURN_OK; + return returnvalue::OK; } // get current time as UNIX timestamp timeval tNow = {}; @@ -84,7 +84,7 @@ inline ReturnValue_t Service11TelecommandScheduling::performService TmTcMessage releaseMsg(it->second.storeAddr); auto sendRet = this->requestQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false); - if (sendRet != HasReturnvaluesIF::RETURN_OK) { + if (sendRet != returnvalue::OK) { return sendRet; } if (debugMode) { @@ -103,13 +103,13 @@ inline ReturnValue_t Service11TelecommandScheduling::performService it++; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template inline ReturnValue_t Service11TelecommandScheduling::initialize() { ReturnValue_t res = PusServiceBase::initialize(); - if (res != HasReturnvaluesIF::RETURN_OK) { + if (res != returnvalue::OK) { return res; } @@ -130,7 +130,7 @@ template inline ReturnValue_t Service11TelecommandScheduling::handleResetCommand() { for (auto it = telecommandMap.begin(); it != telecommandMap.end(); it++) { ReturnValue_t result = tcStore->deleteData(it->second.storeAddr); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 // This should not happen sif::warning << "Service11TelecommandScheduling::handleRequestDeleting: Deletion failed" @@ -143,7 +143,7 @@ inline ReturnValue_t Service11TelecommandScheduling::handleResetCom } } telecommandMap.clear(); - return RETURN_OK; + return returnvalue::OK; } template @@ -151,7 +151,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi const uint8_t *data, size_t size) { uint32_t timestamp = 0; ReturnValue_t result = SerializeAdapter::deSerialize(×tamp, &data, &size, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -169,12 +169,12 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi "Service11TelecommandScheduling::doInsertActivity: Release time too close to current " "time\n"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } // store currentPacket and receive the store address store_address_t addr{}; - if (tcStore->addData(&addr, data, size) != RETURN_OK || + if (tcStore->addData(&addr, data, size) != returnvalue::OK || addr.raw == storeId::INVALID_STORE_ADDRESS) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed" @@ -183,7 +183,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi sif::printError( "Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed\n"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } // insert into multimap with new store address @@ -195,7 +195,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi auto it = telecommandMap.insert(std::pair(timestamp, tc)); if (it == telecommandMap.end()) { - return RETURN_FAILED; + return returnvalue::FAILED; } if (debugMode) { @@ -206,7 +206,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi #endif debugPrintMultimapContent(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template @@ -215,7 +215,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doDeleteActivi // Get request ID uint64_t requestId; ReturnValue_t result = getRequestIdFromData(data, size, requestId); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -249,11 +249,11 @@ inline ReturnValue_t Service11TelecommandScheduling::doDeleteActivi "Service11TelecommandScheduling::doDeleteActivity: No or more than 1 TC found. " "Cannot explicitly delete TC"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } // delete packet from store - if (tcStore->deleteData(tcToDelete->second.storeAddr) != RETURN_OK) { + if (tcStore->deleteData(tcToDelete->second.storeAddr) != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service11TelecommandScheduling::doDeleteActivity: Could not delete TC from Store" << std::endl; @@ -261,7 +261,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doDeleteActivi sif::printError( "Service11TelecommandScheduling::doDeleteActivity: Could not delete TC from Store\n"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } telecommandMap.erase(tcToDelete); @@ -273,7 +273,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doDeleteActivi #endif } - return RETURN_OK; + return returnvalue::OK; } template @@ -284,14 +284,14 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterDelete ReturnValue_t result = getMapFilterFromData(data, size, itBegin, itEnd); // get the filter window as map range via dedicated method - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } int deletedTCs = 0; for (TcMapIter it = itBegin; it != itEnd; it++) { // delete packet from store - if (tcStore->deleteData(it->second.storeAddr) != RETURN_OK) { + if (tcStore->deleteData(it->second.storeAddr) != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service11TelecommandScheduling::doFilterDeleteActivity: Could not delete TC " "from Store" @@ -322,7 +322,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterDelete sif::printInfo("PUS11::doFilterDeleteActivity: Deleted %d TCs\n", deletedTCs); #endif } - return RETURN_OK; + return returnvalue::OK; } template @@ -331,7 +331,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doTimeshiftAct // Get relative time uint32_t relativeTime = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&relativeTime, &data, &size, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (relativeTime == 0) { @@ -342,7 +342,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doTimeshiftAct // Get request ID uint64_t requestId; result = getRequestIdFromData(data, size, requestId); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -400,7 +400,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doTimeshiftAct debugPrintMultimapContent(); } - return RETURN_OK; + return returnvalue::OK; } template @@ -409,7 +409,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterTimesh // Get relative time uint32_t relativeTime = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&relativeTime, &data, &size, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (relativeTime == 0) { @@ -420,7 +420,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterTimesh TcMapIter itBegin; TcMapIter itEnd; result = getMapFilterFromData(data, size, itBegin, itEnd); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -449,9 +449,9 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterTimesh } if (shiftedItemsCount > 0) { - return RETURN_OK; + return returnvalue::OK; } - return RETURN_FAILED; + return returnvalue::FAILED; } template @@ -474,20 +474,20 @@ inline ReturnValue_t Service11TelecommandScheduling::getRequestIdFr uint16_t ssc = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&srcId, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&apid, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&ssc, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } requestId = buildRequestId(srcId, apid, ssc); - return RETURN_OK; + return returnvalue::OK; } template @@ -507,7 +507,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr // get filter type first uint32_t typeRaw = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&typeRaw, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -530,7 +530,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr case TypeOfTimeWindow::FROM_TIMETAG: { uint32_t fromTimestamp = 0; result = SerializeAdapter::deSerialize(&fromTimestamp, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -546,7 +546,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr case TypeOfTimeWindow::TO_TIMETAG: { uint32_t toTimestamp; result = SerializeAdapter::deSerialize(&toTimestamp, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } itBegin = telecommandMap.begin(); @@ -563,12 +563,12 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr result = SerializeAdapter::deSerialize(&fromTimestamp, &data, &dataSize, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&toTimestamp, &data, &dataSize, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } itBegin = telecommandMap.begin(); @@ -584,7 +584,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr } default: - return RETURN_FAILED; + return returnvalue::FAILED; } // additional security check, this should never be true @@ -593,11 +593,11 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr #else sif::printError("11::GetMapFilterFromData: itBegin > itEnd\n"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } // the map range should now be set according to the sent filter. - return RETURN_OK; + return returnvalue::OK; } template @@ -610,7 +610,7 @@ inline ReturnValue_t Service11TelecommandScheduling::handleInvalidD sif::printWarning("Service11TelecommandScheduling::%s: Invalid buffer\n", ctx); #endif #endif - return RETURN_FAILED; + return returnvalue::FAILED; } template diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index f784acf4..acc48819 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -21,7 +21,7 @@ ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { packetSubCounter++); #endif connectionPacket.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case Subservice::EVENT_TRIGGER_TEST: { #if FSFW_USE_PUS_C_TELEMETRY == 0 @@ -33,11 +33,11 @@ ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { #endif connectionPacket.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); triggerEvent(TEST, 1234, 5678); - return RETURN_OK; + return returnvalue::OK; } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } } -ReturnValue_t Service17Test::performService() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t Service17Test::performService() { return returnvalue::OK; } diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 13d6a1c4..2e96a33a 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -30,15 +30,15 @@ MessageQueueId_t Service1TelecommandVerification::getVerificationQueue() { ReturnValue_t Service1TelecommandVerification::performOperation(uint8_t operationCode) { PusVerificationMessage message; ReturnValue_t status = tmQueue->receiveMessage(&message); - while (status == HasReturnvaluesIF::RETURN_OK) { + while (status == returnvalue::OK) { status = sendVerificationReport(&message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { return status; } status = tmQueue->receiveMessage(&message); } if (status == MessageQueueIF::EMPTY) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return status; } @@ -52,7 +52,7 @@ ReturnValue_t Service1TelecommandVerification::sendVerificationReport( } else { result = generateSuccessReport(message); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service1TelecommandVerification::sendVerificationReport: " "Sending verification packet failed !" diff --git a/src/fsfw/pus/Service1TelecommandVerification.h b/src/fsfw/pus/Service1TelecommandVerification.h index 10d2da0e..02a5e513 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.h +++ b/src/fsfw/pus/Service1TelecommandVerification.h @@ -38,8 +38,7 @@ */ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, public SystemObject, - public ExecutableObjectIF, - public HasReturnvaluesIF { + public ExecutableObjectIF { public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_1; diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index 61e29412..382aea00 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -20,7 +20,7 @@ ReturnValue_t Service20ParameterManagement::isValidSubservice(uint8_t subservice switch (static_cast(subservice)) { case Subservice::PARAMETER_LOAD: case Subservice::PARAMETER_DUMP: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Invalid Subservice for Service 20" << std::endl; @@ -37,7 +37,7 @@ ReturnValue_t Service20ParameterManagement::getMessageQueueAndObject(uint8_t sub MessageQueueId_t* id, object_id_t* objectId) { ReturnValue_t result = checkAndAcquireTargetID(objectId, tcData, tcDataLen); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } return checkInterfaceAndAcquireMessageQueue(id, objectId); @@ -47,7 +47,7 @@ ReturnValue_t Service20ParameterManagement::checkAndAcquireTargetID(object_id_t* const uint8_t* tcData, size_t tcDataLen) { if (SerializeAdapter::deSerialize(objectIdToSet, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG) != HasReturnvaluesIF::RETURN_OK) { + SerializeIF::Endianness::BIG) != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service20ParameterManagement::checkAndAcquireTargetID: " << "Invalid data." << std::endl; @@ -58,7 +58,7 @@ ReturnValue_t Service20ParameterManagement::checkAndAcquireTargetID(object_id_t* #endif return CommandingServiceBase::INVALID_TC; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue( @@ -83,7 +83,7 @@ ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue return CommandingServiceBase::INVALID_OBJECT; } *messageQueueToSet = possibleTarget->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service20ParameterManagement::prepareCommand(CommandMessage* message, @@ -98,7 +98,7 @@ ReturnValue_t Service20ParameterManagement::prepareCommand(CommandMessage* messa return prepareLoadCommand(message, tcData, tcDataLen); } break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -111,7 +111,7 @@ ReturnValue_t Service20ParameterManagement::prepareDumpCommand(CommandMessage* m tcDataLen -= sizeof(object_id_t); ParameterId_t parameterId; if (SerializeAdapter::deSerialize(¶meterId, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG) != HasReturnvaluesIF::RETURN_OK) { + SerializeIF::Endianness::BIG) != returnvalue::OK) { return CommandingServiceBase::INVALID_TC; } /* The length should have been decremented to 0 by this point */ @@ -120,7 +120,7 @@ ReturnValue_t Service20ParameterManagement::prepareDumpCommand(CommandMessage* m } ParameterMessage::setParameterDumpCommand(message, parameterId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service20ParameterManagement::prepareLoadCommand(CommandMessage* message, @@ -138,7 +138,7 @@ ReturnValue_t Service20ParameterManagement::prepareLoadCommand(CommandMessage* m return CommandingServiceBase::INVALID_TC; } ReturnValue_t result = IPCStore->getFreeElement(&storeAddress, parameterDataLen, &storePointer); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -151,14 +151,14 @@ ReturnValue_t Service20ParameterManagement::prepareLoadCommand(CommandMessage* m 4. Number of columns */ ParameterLoadCommand command(storePointer, parameterDataLen); result = command.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } ParameterMessage::setParameterLoadCommand(message, command.getParameterId(), storeAddress, command.getPtc(), command.getPfc(), command.getRows(), command.getColumns()); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service20ParameterManagement::handleReply(const CommandMessage* reply, @@ -170,15 +170,15 @@ ReturnValue_t Service20ParameterManagement::handleReply(const CommandMessage* re switch (replyId) { case ParameterMessage::REPLY_PARAMETER_DUMP: { ConstAccessorPair parameterData = IPCStore->getData(ParameterMessage::getStoreId(reply)); - if (parameterData.first != HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_FAILED; + if (parameterData.first != returnvalue::OK) { + return returnvalue::FAILED; } ParameterId_t parameterId = ParameterMessage::getParameterId(reply); ParameterDumpReply parameterReply(objectId, parameterId, parameterData.second.data(), parameterData.second.size()); sendTmPacket(static_cast(Subservice::PARAMETER_DUMP_REPLY), ¶meterReply); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } default: return CommandingServiceBase::INVALID_REPLY; diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index 3430271e..a1bf8121 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -23,7 +23,7 @@ ReturnValue_t Service2DeviceAccess::isValidSubservice(uint8_t subservice) { switch (static_cast(subservice)) { case Subservice::COMMAND_RAW_COMMANDING: case Subservice::COMMAND_TOGGLE_WIRETAPPING: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Invalid Subservice" << std::endl; @@ -51,7 +51,7 @@ ReturnValue_t Service2DeviceAccess::checkInterfaceAndAcquireMessageQueue( return CommandingServiceBase::INVALID_OBJECT; } *messageQueueToSet = possibleTarget->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service2DeviceAccess::prepareCommand(CommandMessage* message, uint8_t subservice, @@ -65,7 +65,7 @@ ReturnValue_t Service2DeviceAccess::prepareCommand(CommandMessage* message, uint return prepareWiretappingCommand(message, tcData, tcDataLen); } break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -99,7 +99,7 @@ ReturnValue_t Service2DeviceAccess::handleReply(const CommandMessage* reply, object_id_t objectId, bool* isStep) { switch (reply->getCommand()) { case CommandMessage::REPLY_COMMAND_OK: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case CommandMessage::REPLY_REJECTED: return reply->getReplyRejectedReason(); default: @@ -136,7 +136,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs const uint8_t* data = nullptr; size_t size = 0; ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in " "handleUnrequestedReply with failure ID " diff --git a/src/fsfw/pus/Service3Housekeeping.cpp b/src/fsfw/pus/Service3Housekeeping.cpp index 07574783..1a1c87ff 100644 --- a/src/fsfw/pus/Service3Housekeeping.cpp +++ b/src/fsfw/pus/Service3Housekeeping.cpp @@ -22,7 +22,7 @@ ReturnValue_t Service3Housekeeping::isValidSubservice(uint8_t subservice) { case Subservice::GENERATE_ONE_DIAGNOSTICS_REPORT: case Subservice::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL: case Subservice::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; // Telemetry or invalid subservice. case Subservice::HK_DEFINITIONS_REPORT: case Subservice::DIAGNOSTICS_DEFINITION_REPORT: @@ -38,7 +38,7 @@ ReturnValue_t Service3Housekeeping::getMessageQueueAndObject(uint8_t subservice, size_t tcDataLen, MessageQueueId_t* id, object_id_t* objectId) { ReturnValue_t result = checkAndAcquireTargetID(objectId, tcData, tcDataLen); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } return checkInterfaceAndAcquireMessageQueue(id, objectId); @@ -48,10 +48,10 @@ ReturnValue_t Service3Housekeeping::checkAndAcquireTargetID(object_id_t* objectI const uint8_t* tcData, size_t tcDataLen) { if (SerializeAdapter::deSerialize(objectIdToSet, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG) != HasReturnvaluesIF::RETURN_OK) { + SerializeIF::Endianness::BIG) != returnvalue::OK) { return CommandingServiceBase::INVALID_TC; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::checkInterfaceAndAcquireMessageQueue( @@ -63,7 +63,7 @@ ReturnValue_t Service3Housekeeping::checkInterfaceAndAcquireMessageQueue( return CommandingServiceBase::INVALID_OBJECT; } *messageQueueToSet = possibleTarget->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::prepareCommand(CommandMessage* message, uint8_t subservice, @@ -100,9 +100,9 @@ ReturnValue_t Service3Housekeeping::prepareCommand(CommandMessage* message, uint return CommandingServiceBase::INVALID_TC; default: // should never happen, subservice was already checked. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand( @@ -116,7 +116,7 @@ ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand( sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen); HousekeepingMessage::setToggleReportingCommand(command, targetSid, enableReporting, isDiagnostics); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::prepareStructureReportingCommand(CommandMessage* command, @@ -131,7 +131,7 @@ ReturnValue_t Service3Housekeeping::prepareStructureReportingCommand(CommandMess sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen); HousekeepingMessage::setStructureReportingCommand(command, targetSid, isDiagnostics); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::prepareOneShotReportCommand(CommandMessage* command, @@ -146,7 +146,7 @@ ReturnValue_t Service3Housekeeping::prepareOneShotReportCommand(CommandMessage* sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen); HousekeepingMessage::setOneShotReportCommand(command, targetSid, isDiagnostics); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand( @@ -163,7 +163,7 @@ ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand SerializeIF::Endianness::BIG); HousekeepingMessage::setCollectionIntervalModificationCommand( command, targetSid, newCollectionInterval, isDiagnostics); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, @@ -174,7 +174,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, switch (command) { case (HousekeepingMessage::HK_REPORT): { ReturnValue_t result = generateHkReply(reply, static_cast(Subservice::HK_REPORT)); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return CommandingServiceBase::EXECUTION_COMPLETE; @@ -183,7 +183,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, case (HousekeepingMessage::DIAGNOSTICS_REPORT): { ReturnValue_t result = generateHkReply(reply, static_cast(Subservice::DIAGNOSTICS_REPORT)); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return CommandingServiceBase::EXECUTION_COMPLETE; @@ -205,7 +205,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, case (HousekeepingMessage::HK_REQUEST_FAILURE): { failureParameter1 = objectId; - ReturnValue_t error = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t error = returnvalue::FAILED; HousekeepingMessage::getHkRequestFailureReply(reply, &error); failureParameter2 = error; return CommandingServiceBase::EXECUTION_COMPLETE; @@ -223,11 +223,11 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, #endif return CommandingServiceBase::INVALID_REPLY; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void Service3Housekeeping::handleUnrequestedReply(CommandMessage* reply) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; Command_t command = reply->getCommand(); switch (command) { @@ -264,7 +264,7 @@ void Service3Housekeeping::handleUnrequestedReply(CommandMessage* reply) { } } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { /* Configuration error */ #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service3Housekeeping::handleUnrequestedReply: Could not generate reply!" @@ -285,7 +285,7 @@ ReturnValue_t Service3Housekeeping::generateHkReply(const CommandMessage* hkMess sid_t sid = HousekeepingMessage::getHkDataReply(hkMessage, &storeId); auto resultPair = IPCStore->getData(storeId); - if (resultPair.first != HasReturnvaluesIF::RETURN_OK) { + if (resultPair.first != returnvalue::OK) { return resultPair.first; } diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index 987217dc..d267c803 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -21,17 +21,17 @@ Service5EventReporting::~Service5EventReporting() { ReturnValue_t Service5EventReporting::performService() { EventMessage message; - ReturnValue_t status = RETURN_OK; + ReturnValue_t status = returnvalue::OK; for (uint8_t counter = 0; counter < maxNumberReportsPerCycle; counter++) { // Receive messages even if reporting is disabled for now. status = eventQueue->receiveMessage(&message); if (status == MessageQueueIF::EMPTY) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } if (enableEventReport) { status = generateEventReport(message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { return status; } } @@ -39,7 +39,7 @@ ReturnValue_t Service5EventReporting::performService() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service5EventReporting::generateEventReport: Too many events" << std::endl; #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) { @@ -54,7 +54,7 @@ ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) #endif ReturnValue_t result = tmPacket.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service5EventReporting::generateEventReport: " "Could not send TM packet" @@ -72,11 +72,11 @@ ReturnValue_t Service5EventReporting::handleRequest(uint8_t subservice) { switch (subservice) { case Subservice::ENABLE: { enableEventReport = true; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case Subservice::DISABLE: { enableEventReport = false; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; @@ -88,11 +88,11 @@ ReturnValue_t Service5EventReporting::handleRequest(uint8_t subservice) { ReturnValue_t Service5EventReporting::initialize() { auto* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (manager == nullptr) { - return RETURN_FAILED; + return returnvalue::FAILED; } // register Service 5 as listener for events ReturnValue_t result = manager->registerListener(eventQueue->getId(), true); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return PusServiceBase::initialize(); diff --git a/src/fsfw/pus/Service8FunctionManagement.cpp b/src/fsfw/pus/Service8FunctionManagement.cpp index be8d9058..4f552ec8 100644 --- a/src/fsfw/pus/Service8FunctionManagement.cpp +++ b/src/fsfw/pus/Service8FunctionManagement.cpp @@ -20,7 +20,7 @@ Service8FunctionManagement::~Service8FunctionManagement() {} ReturnValue_t Service8FunctionManagement::isValidSubservice(uint8_t subservice) { switch (static_cast(subservice)) { case Subservice::COMMAND_DIRECT_COMMANDING: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } @@ -48,7 +48,7 @@ ReturnValue_t Service8FunctionManagement::checkInterfaceAndAcquireMessageQueue( return CommandingServiceBase::INVALID_OBJECT; } *messageQueueToSet = possibleTarget->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service8FunctionManagement::prepareCommand(CommandMessage* message, @@ -62,7 +62,7 @@ ReturnValue_t Service8FunctionManagement::prepareDirectCommand(CommandMessage* m const uint8_t* tcData, size_t tcDataLen) { if (message == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (tcDataLen < sizeof(object_id_t) + sizeof(ActionId_t)) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -91,7 +91,7 @@ ReturnValue_t Service8FunctionManagement::handleReply(const CommandMessage* repl CommandMessage* optionalNextCommand, object_id_t objectId, bool* isStep) { Command_t replyId = reply->getCommand(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; ActionId_t actionId = ActionMessage::getActionId(reply); ReturnValue_t returnCode = ActionMessage::getReturnCode(reply); @@ -103,7 +103,7 @@ ReturnValue_t Service8FunctionManagement::handleReply(const CommandMessage* repl } case ActionMessage::STEP_SUCCESS: { *isStep = true; - result = HasReturnvaluesIF::RETURN_OK; + result = returnvalue::OK; break; } case ActionMessage::DATA_REPLY: { @@ -131,7 +131,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* size_t size = 0; const uint8_t* buffer = nullptr; ReturnValue_t result = IPCStore->getData(storeId, &buffer, &size); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service 8: Could not retrieve data for data reply" << std::endl; #endif @@ -141,7 +141,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* result = sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), &dataReply); auto deletionResult = IPCStore->deleteData(storeId); - if (deletionResult != HasReturnvaluesIF::RETURN_OK) { + if (deletionResult != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service8FunctionManagement::handleReply: Deletion" << " of data in pool failed." << std::endl; diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 86eef93a..ea852f28 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -11,7 +11,7 @@ Service9TimeManagement::Service9TimeManagement(object_id_t objectId, uint16_t ap Service9TimeManagement::~Service9TimeManagement() {} -ReturnValue_t Service9TimeManagement::performService() { return RETURN_OK; } +ReturnValue_t Service9TimeManagement::performService() { return returnvalue::OK; } ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { switch (subservice) { @@ -28,7 +28,7 @@ ReturnValue_t Service9TimeManagement::setTime() { TimePacket timePacket(currentPacket.getApplicationData(), currentPacket.getApplicationDataSize()); ReturnValue_t result = CCSDSTime::convertFromCcsds(&timeToSet, timePacket.getTime(), timePacket.getTimeSize()); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { triggerEvent(CLOCK_SET_FAILURE, result, 0); return result; } @@ -37,13 +37,13 @@ ReturnValue_t Service9TimeManagement::setTime() { Clock::getUptime(&formerUptime); result = Clock::setClock(&timeToSet); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { uint32_t newUptime; Clock::getUptime(&newUptime); triggerEvent(CLOCK_SET, newUptime, formerUptime); - return RETURN_OK; + return returnvalue::OK; } else { triggerEvent(CLOCK_SET_FAILURE, result, 0); - return RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/pus/servicepackets/Service1Packets.h b/src/fsfw/pus/servicepackets/Service1Packets.h index df70f670..1878f722 100644 --- a/src/fsfw/pus/servicepackets/Service1Packets.h +++ b/src/fsfw/pus/servicepackets/Service1Packets.h @@ -42,26 +42,26 @@ class FailureReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6 SerializeIF::Endianness streamEndianness) const override { ReturnValue_t result = SerializeAdapter::serialize(&packetId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&packetSequenceControl, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (failureSubtype == tc_verification::PROGRESS_FAILURE) { result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } result = SerializeAdapter::serialize(&errorCode, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&errorParameter1, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -91,7 +91,7 @@ class FailureReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6 */ ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } private: @@ -122,17 +122,17 @@ class SuccessReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5 SerializeIF::Endianness streamEndianness) const override { ReturnValue_t result = SerializeAdapter::serialize(&packetId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&packetSequenceControl, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (subtype == tc_verification::PROGRESS_SUCCESS) { result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -151,7 +151,7 @@ class SuccessReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5 ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } private: diff --git a/src/fsfw/pus/servicepackets/Service5Packets.h b/src/fsfw/pus/servicepackets/Service5Packets.h index 9ff2e4d4..05d92674 100644 --- a/src/fsfw/pus/servicepackets/Service5Packets.h +++ b/src/fsfw/pus/servicepackets/Service5Packets.h @@ -28,19 +28,19 @@ class EventReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 2, 3, SerializeIF::Endianness streamEndianness) const override { ReturnValue_t result = SerializeAdapter::serialize(&reportId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&objectId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(¶meter1, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(¶meter2, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return result; @@ -57,7 +57,7 @@ class EventReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 2, 3, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } private: diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/HasReturnvaluesIF.h index 20c10e0b..45574056 100644 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ b/src/fsfw/returnvalues/HasReturnvaluesIF.h @@ -8,35 +8,25 @@ #include "FwClassIds.h" #define MAKE_RETURN_CODE(number) ((INTERFACE_ID << 8) + (number)) + typedef uint16_t ReturnValue_t; -namespace result { -static constexpr ReturnValue_t OK = 0; -static constexpr ReturnValue_t FAILED = 1; +namespace returnvalue { + static const ReturnValue_t OK = 0; + static const ReturnValue_t FAILED = 1; -static constexpr ReturnValue_t makeCode(uint8_t classId, uint8_t number) { +/** + * It is discouraged to use the input parameters 0,0 and 0,1 as this + * will generate the RETURN_OK and returnvalue::FAILED returnvalues. + * @param interfaceId + * @param number + * @return + */ +static constexpr ReturnValue_t makeCode( + uint8_t classId, uint8_t number) { return (static_cast(classId) << 8) + number; } -} // namespace result -class HasReturnvaluesIF { - public: - static const ReturnValue_t RETURN_OK = result::OK; - static const ReturnValue_t RETURN_FAILED = result::FAILED; - - virtual ~HasReturnvaluesIF() = default; - - /** - * It is discouraged to use the input parameters 0,0 and 0,1 as this - * will generate the RETURN_OK and RETURN_FAILED returnvalues. - * @param interfaceId - * @param number - * @return - */ - [[deprecated("Use result::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode( - uint8_t classId, uint8_t number) { - return result::makeCode(classId, number); - } -}; +} #endif /* FSFW_RETURNVALUES_HASRETURNVALUESIF_H_ */ diff --git a/src/fsfw/rmap/RmapDeviceCommunicationIF.cpp b/src/fsfw/rmap/RmapDeviceCommunicationIF.cpp index cf5d49ea..70a5e7a6 100644 --- a/src/fsfw/rmap/RmapDeviceCommunicationIF.cpp +++ b/src/fsfw/rmap/RmapDeviceCommunicationIF.cpp @@ -26,7 +26,7 @@ ReturnValue_t RmapDeviceCommunicationIF::readReceivedMessage(CookieIF *cookie, u ReturnValue_t RmapDeviceCommunicationIF::setAddress(CookieIF *cookie, uint32_t address) { ((RMAPCookie *)cookie)->setAddress(address); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint32_t RmapDeviceCommunicationIF::getAddress(CookieIF *cookie) { @@ -35,7 +35,7 @@ uint32_t RmapDeviceCommunicationIF::getAddress(CookieIF *cookie) { ReturnValue_t RmapDeviceCommunicationIF::setParameter(CookieIF *cookie, uint32_t parameter) { // TODO Empty? - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint32_t RmapDeviceCommunicationIF::getParameter(CookieIF *cookie) { return 0; } diff --git a/src/fsfw/serialize/SerialArrayListAdapter.h b/src/fsfw/serialize/SerialArrayListAdapter.h index d7c99aae..fa87ddbe 100644 --- a/src/fsfw/serialize/SerialArrayListAdapter.h +++ b/src/fsfw/serialize/SerialArrayListAdapter.h @@ -26,7 +26,7 @@ class SerialArrayListAdapter : public SerializeIF { ReturnValue_t result = SerializeAdapter::serialize(&list->size, buffer, size, maxSize, streamEndianness); count_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < list->size)) { + while ((result == returnvalue::OK) && (i < list->size)) { result = SerializeAdapter::serialize(&list->entries[i], buffer, size, maxSize, streamEndianness); ++i; @@ -56,7 +56,7 @@ class SerialArrayListAdapter : public SerializeIF { size_t* size, Endianness streamEndianness) { count_t tempSize = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&tempSize, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (tempSize > list->maxSize()) { @@ -65,7 +65,7 @@ class SerialArrayListAdapter : public SerializeIF { list->size = tempSize; count_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < list->size)) { + while ((result == returnvalue::OK) && (i < list->size)) { result = SerializeAdapter::deSerialize(&list->front()[i], buffer, size, streamEndianness); ++i; } diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 83129982..81919f37 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -30,7 +30,7 @@ ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, size_t* if (serializeLength) { ReturnValue_t result = SerializeAdapter::serialize(&bufferLength, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -46,11 +46,11 @@ ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, size_t* // set if non-const buffer is set. std::memcpy(*buffer, this->buffer, bufferLength); } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *size += bufferLength; (*buffer) += bufferLength; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template @@ -66,14 +66,14 @@ template ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { if (this->buffer == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (serializeLength) { count_t lengthField = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&lengthField, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (lengthField > bufferLength) { @@ -86,7 +86,7 @@ ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, *size -= bufferLength; std::memcpy(this->buffer, *buffer, bufferLength); (*buffer) += bufferLength; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return STREAM_TOO_SHORT; } diff --git a/src/fsfw/serialize/SerialLinkedListAdapter.h b/src/fsfw/serialize/SerialLinkedListAdapter.h index 4975c0a5..6c2fb7df 100644 --- a/src/fsfw/serialize/SerialLinkedListAdapter.h +++ b/src/fsfw/serialize/SerialLinkedListAdapter.h @@ -51,7 +51,7 @@ class SerialLinkedListAdapter : public SinglyLinkedList, public SerializeIF { count_t mySize = SinglyLinkedList::getSize(); ReturnValue_t result = SerializeAdapter::serialize(&mySize, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -60,8 +60,8 @@ class SerialLinkedListAdapter : public SinglyLinkedList, public SerializeIF { static ReturnValue_t serialize(const LinkedElement* element, uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while ((result == HasReturnvaluesIF::RETURN_OK) and (element != nullptr)) { + ReturnValue_t result = returnvalue::OK; + while ((result == returnvalue::OK) and (element != nullptr)) { result = element->value->serialize(buffer, size, maxSize, streamEndianness); element = element->getNext(); } @@ -92,8 +92,8 @@ class SerialLinkedListAdapter : public SinglyLinkedList, public SerializeIF { static ReturnValue_t deSerialize(LinkedElement* element, const uint8_t** buffer, size_t* size, Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while ((result == HasReturnvaluesIF::RETURN_OK) and (element != nullptr)) { + ReturnValue_t result = returnvalue::OK; + while ((result == returnvalue::OK) and (element != nullptr)) { result = element->value->deSerialize(buffer, size, streamEndianness); element = element->getNext(); } diff --git a/src/fsfw/serialize/SerializeAdapter.h b/src/fsfw/serialize/SerializeAdapter.h index 5feda889..31259b0f 100644 --- a/src/fsfw/serialize/SerializeAdapter.h +++ b/src/fsfw/serialize/SerializeAdapter.h @@ -39,7 +39,7 @@ class SerializeAdapter { * SerializeIF::Endianness * @return * - @c BUFFER_TOO_SHORT The given buffer in is too short - * - @c RETURN_FAILED Generic Error + * - @c returnvalue::FAILED Generic Error * - @c RETURN_OK Successful serialization */ template @@ -64,14 +64,14 @@ class SerializeAdapter { * SerializeIF::Endianness * @return * - @c BUFFER_TOO_SHORT The given buffer in is too short - * - @c RETURN_FAILED Generic Error + * - @c returnvalue::FAILED Generic Error * - @c RETURN_OK Successful serialization */ template static ReturnValue_t serialize(const T *object, uint8_t *const buffer, size_t *serSize, size_t maxSize, SerializeIF::Endianness streamEndianness) { if (object == nullptr or buffer == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } InternalSerializeAdapter::value> adapter; uint8_t **tempPtr = const_cast(&buffer); @@ -113,7 +113,7 @@ class SerializeAdapter { * @return * - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object * - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected - * - @c RETURN_FAILED Generic Error + * - @c returnvalue::FAILED Generic Error * - @c RETURN_OK Successful deserialization */ template @@ -136,14 +136,14 @@ class SerializeAdapter { * @return * - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object * - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected - * - @c RETURN_FAILED Generic Error + * - @c returnvalue::FAILED Generic Error * - @c RETURN_OK Successful deserialization */ template static ReturnValue_t deSerialize(T *object, const uint8_t *buffer, size_t *deserSize, SerializeIF::Endianness streamEndianness) { if (object == nullptr or buffer == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } InternalSerializeAdapter::value> adapter; const uint8_t **tempPtr = &buffer; @@ -200,7 +200,7 @@ class SerializeAdapter { std::memcpy(*buffer, &tmp, sizeof(T)); *size += sizeof(T); (*buffer) += sizeof(T); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SerializeIF::BUFFER_TOO_SHORT; } @@ -226,7 +226,7 @@ class SerializeAdapter { } *buffer += sizeof(T); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SerializeIF::STREAM_TOO_SHORT; } diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index f20bf21f..a02b5f9e 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -56,7 +56,7 @@ class SerializeIF { * SerializeIF::Endianness * @return * - @c BUFFER_TOO_SHORT The given buffer in is too short - * - @c RETURN_FAILED Generic error + * - @c returnvalue::FAILED Generic error * - @c RETURN_OK Successful serialization */ [[nodiscard]] virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, @@ -92,7 +92,7 @@ class SerializeIF { * @return * - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object * - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected - * - @c RETURN_FAILED Generic Error + * - @c returnvalue::FAILED Generic Error * - @c RETURN_OK Successful deserialization */ virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, diff --git a/src/fsfw/storagemanager/ConstStorageAccessor.cpp b/src/fsfw/storagemanager/ConstStorageAccessor.cpp index df2fc750..f64334f7 100644 --- a/src/fsfw/storagemanager/ConstStorageAccessor.cpp +++ b/src/fsfw/storagemanager/ConstStorageAccessor.cpp @@ -58,16 +58,16 @@ ReturnValue_t ConstStorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (size_ > maxSize) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "StorageAccessor: Supplied buffer not large enough" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } std::copy(constDataPointer, constDataPointer + size_, pointer); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void ConstStorageAccessor::release() { deleteData = false; } diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index cee1d407..b0376d2c 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -34,7 +34,7 @@ LocalPool::~LocalPool(void) {} ReturnValue_t LocalPool::addData(store_address_t* storageId, const uint8_t* data, size_t size, bool ignoreFault) { ReturnValue_t status = reserveSpace(size, storageId, ignoreFault); - if (status == RETURN_OK) { + if (status == returnvalue::OK) { write(*storageId, data, size); } return status; @@ -67,7 +67,7 @@ ConstAccessorPair LocalPool::getData(store_address_t storeId) { ReturnValue_t LocalPool::getFreeElement(store_address_t* storageId, const size_t size, uint8_t** pData, bool ignoreFault) { ReturnValue_t status = reserveSpace(size, storageId, ignoreFault); - if (status == RETURN_OK) { + if (status == returnvalue::OK) { *pData = &store[storageId->poolIndex][getRawPosition(*storageId)]; } else { *pData = nullptr; @@ -90,7 +90,7 @@ ReturnValue_t LocalPool::modifyData(store_address_t storeId, StorageAccessor& st } ReturnValue_t LocalPool::modifyData(store_address_t storeId, uint8_t** packetPtr, size_t* size) { - ReturnValue_t status = RETURN_FAILED; + ReturnValue_t status = returnvalue::FAILED; if (storeId.poolIndex >= NUMBER_OF_SUBPOOLS) { return ILLEGAL_STORAGE_ID; } @@ -102,7 +102,7 @@ ReturnValue_t LocalPool::modifyData(store_address_t storeId, uint8_t** packetPtr size_type packetPosition = getRawPosition(storeId); *packetPtr = &store[storeId.poolIndex][packetPosition]; *size = sizeLists[storeId.poolIndex][storeId.packetIndex]; - status = RETURN_OK; + status = returnvalue::OK; } else { status = DATA_DOES_NOT_EXIST; } @@ -117,7 +117,7 @@ ReturnValue_t LocalPool::deleteData(store_address_t storeId) { #endif #endif - ReturnValue_t status = RETURN_OK; + ReturnValue_t status = returnvalue::OK; size_type pageSize = getSubpoolElementSize(storeId.poolIndex); if ((pageSize != 0) and (storeId.packetIndex < numberOfElements[storeId.poolIndex])) { uint16_t packetPosition = getRawPosition(storeId); @@ -166,7 +166,7 @@ ReturnValue_t LocalPool::deleteData(uint8_t* ptr, size_t size, store_address_t* ReturnValue_t LocalPool::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } internalErrorReporter = @@ -186,7 +186,7 @@ ReturnValue_t LocalPool::initialize() { return StorageManagerIF::POOL_TOO_LARGE; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void LocalPool::clearStore() { @@ -202,7 +202,7 @@ void LocalPool::clearStore() { ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeId, bool ignoreFault) { ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); - if (status != RETURN_OK) { + if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool( " << std::hex << getObjectId() << std::dec << " )::reserveSpace: Packet too large." << std::endl; @@ -210,15 +210,15 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeI return status; } status = findEmpty(storeId->poolIndex, &storeId->packetIndex); - while (status != RETURN_OK && spillsToHigherPools) { + while (status != returnvalue::OK && spillsToHigherPools) { status = getSubPoolIndex(size, &storeId->poolIndex, storeId->poolIndex + 1); - if (status != RETURN_OK) { + if (status != returnvalue::OK) { // We don't find any fitting pool anymore. break; } status = findEmpty(storeId->poolIndex, &storeId->packetIndex); } - if (status == RETURN_OK) { + if (status == returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 2 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Reserve: Pool: " << std::dec << storeId->poolIndex @@ -265,7 +265,7 @@ ReturnValue_t LocalPool::getSubPoolIndex(size_t packetSize, uint16_t* subpoolInd #endif if (elementSizes[n] >= packetSize) { *subpoolIndex = n; - return RETURN_OK; + return returnvalue::OK; } } return DATA_TOO_LARGE; @@ -280,7 +280,7 @@ ReturnValue_t LocalPool::findEmpty(n_pool_elem_t poolIndex, uint16_t* element) { for (uint16_t foundElement = 0; foundElement < numberOfElements[poolIndex]; foundElement++) { if (sizeLists[poolIndex][foundElement] == STORAGE_FREE) { *element = foundElement; - status = RETURN_OK; + status = returnvalue::OK; break; } } diff --git a/src/fsfw/storagemanager/StorageAccessor.cpp b/src/fsfw/storagemanager/StorageAccessor.cpp index b8096c1e..8a96dcec 100644 --- a/src/fsfw/storagemanager/StorageAccessor.cpp +++ b/src/fsfw/storagemanager/StorageAccessor.cpp @@ -26,7 +26,7 @@ ReturnValue_t StorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (size_ > maxSize) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -34,10 +34,10 @@ ReturnValue_t StorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { "enough" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } std::copy(dataPointer, dataPointer + size_, pointer); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint8_t* StorageAccessor::data() { @@ -54,7 +54,7 @@ ReturnValue_t StorageAccessor::write(uint8_t* data, size_t size, uint16_t offset #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (offset + size > size_) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -62,10 +62,10 @@ ReturnValue_t StorageAccessor::write(uint8_t* data, size_t size, uint16_t offset "entry!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } std::copy(data, data + size, dataPointer + offset); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void StorageAccessor::assignConstPointer() { constDataPointer = dataPointer; } diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index 375fc7cc..24ef2e45 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -25,7 +25,7 @@ using ConstAccessorPair = std::pair; * @author Bastian Baetz * @date 18.09.2012 */ -class StorageManagerIF : public HasReturnvaluesIF { +class StorageManagerIF { public: using size_type = size_t; using max_subpools_t = uint8_t; @@ -64,7 +64,7 @@ class StorageManagerIF : public HasReturnvaluesIF { * @param data The data to be stored in the StorageManager. * @param size The amount of data to be stored. * @return Returns @li RETURN_OK if data was added. - * @li RETURN_FAILED if data could not be added. + * @li returnvalue::FAILED if data could not be added. * storageId is unchanged then. */ virtual ReturnValue_t addData(store_address_t* storageId, const uint8_t* data, size_t size, @@ -74,7 +74,7 @@ class StorageManagerIF : public HasReturnvaluesIF { * identified by packet_id. * @param packet_id The identifier of the memory region to be freed. * @return @li RETURN_OK on success. - * @li RETURN_FAILED if deletion did not work + * @li returnvalue::FAILED if deletion did not work * (e.g. an illegal packet_id was passed). */ virtual ReturnValue_t deleteData(store_address_t packet_id) = 0; @@ -117,7 +117,7 @@ class StorageManagerIF : public HasReturnvaluesIF { * position * @param size The exact size of the stored data is returned here. * @return @li RETURN_OK on success. - * @li RETURN_FAILED if fetching data did not work + * @li returnvalue::FAILED if fetching data did not work * (e.g. an illegal packet_id was passed). */ virtual ReturnValue_t getData(store_address_t packet_id, const uint8_t** packet_ptr, @@ -157,7 +157,7 @@ class StorageManagerIF : public HasReturnvaluesIF { * @param size The size of the space to be reserved. * @param p_data A pointer to the element data is returned here. * @return Returns @li RETURN_OK if data was added. - * @li RETURN_FAILED if data could not be added. + * @li returnvalue::FAILED if data could not be added. * storageId is unchanged then. */ virtual ReturnValue_t getFreeElement(store_address_t* storageId, const size_t size, diff --git a/src/fsfw/subsystem/Subsystem.cpp b/src/fsfw/subsystem/Subsystem.cpp index 27e6ae8e..9495323d 100644 --- a/src/fsfw/subsystem/Subsystem.cpp +++ b/src/fsfw/subsystem/Subsystem.cpp @@ -39,12 +39,12 @@ ReturnValue_t Subsystem::checkSequence(HybridIterator iter, return TABLE_DOES_NOT_EXIST; } else { ReturnValue_t result = checkTable(getTable(iter->getTableId())); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t Subsystem::checkSequence(Mode_t sequence) { @@ -55,9 +55,9 @@ ReturnValue_t Subsystem::checkSequence(Mode_t sequence) { return checkSequence(iter, getFallbackSequence(sequence)); } -bool Subsystem::existsModeSequence(Mode_t id) { return modeSequences.exists(id) == RETURN_OK; } +bool Subsystem::existsModeSequence(Mode_t id) { return modeSequences.exists(id) == returnvalue::OK; } -bool Subsystem::existsModeTable(Mode_t id) { return modeTables.exists(id) == RETURN_OK; } +bool Subsystem::existsModeTable(Mode_t id) { return modeTables.exists(id) == returnvalue::OK; } HybridIterator Subsystem::getCurrentTable() { return getTable(currentSequenceIterator->getTableId()); @@ -67,7 +67,7 @@ void Subsystem::performChildOperation() { if (isInTransition) { if (commandsOutstanding <= 0) { // all children of the current table were commanded and replied if (currentSequenceIterator.value == nullptr) { // we're through with this sequence - if (checkStateAgainstTable(currentTargetTable, targetSubmode) == RETURN_OK) { + if (checkStateAgainstTable(currentTargetTable, targetSubmode) == returnvalue::OK) { setMode(targetMode, targetSubmode); isInTransition = false; return; @@ -82,7 +82,7 @@ void Subsystem::performChildOperation() { } } if (currentSequenceIterator->checkSuccess()) { - if (checkStateAgainstTable(getCurrentTable(), targetSubmode) != RETURN_OK) { + if (checkStateAgainstTable(getCurrentTable(), targetSubmode) != returnvalue::OK) { transitionFailed(TABLE_CHECK_FAILED, currentSequenceIterator->getTableId()); return; } @@ -111,7 +111,7 @@ void Subsystem::performChildOperation() { childrenChangedHealth = false; startTransition(mode, submode); } else if (childrenChangedMode) { - if (checkStateAgainstTable(currentTargetTable, submode) != RETURN_OK) { + if (checkStateAgainstTable(currentTargetTable, submode) != returnvalue::OK) { triggerEvent(CANT_KEEP_MODE, mode, submode); cantKeepMode(); } @@ -154,15 +154,15 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage *message) { size_t sizeRead; ReturnValue_t result = IPCStore->getData(ModeSequenceMessage::getStoreAddress(message), &pointer, &sizeRead); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { Mode_t fallbackId; size_t size = sizeRead; result = SerializeAdapter::deSerialize(&fallbackId, &pointer, &size, SerializeIF::Endianness::BIG); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { result = SerialArrayListAdapter::deSerialize(&sequence, &pointer, &size, SerializeIF::Endianness::BIG); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { result = addSequence(&sequence, ModeSequenceMessage::getSequenceId(message), fallbackId); } @@ -177,11 +177,11 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage *message) { size_t sizeRead; ReturnValue_t result = IPCStore->getData(ModeSequenceMessage::getStoreAddress(message), &pointer, &sizeRead); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { size_t size = sizeRead; result = SerialArrayListAdapter::deSerialize(&table, &pointer, &size, SerializeIF::Endianness::BIG); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { result = addTable(&table, ModeSequenceMessage::getSequenceId(message)); } IPCStore->deleteData(ModeSequenceMessage::getStoreAddress(message)); @@ -228,7 +228,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage *message) { Mode_t sequence = ModeSequenceMessage::getSequenceId(message); SequenceInfo *sequenceInfo = NULL; result = modeSequences.find(sequence, &sequenceInfo); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { replyToCommand(result, 0); } @@ -255,7 +255,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage *message) { Mode_t table = ModeSequenceMessage::getSequenceId(message); EntryPointer *entry = nullptr; result = modeTables.find(table, &entry); - if (result != RETURN_OK or entry == nullptr) { + if (result != returnvalue::OK or entry == nullptr) { replyToCommand(result, 0); if (entry == nullptr) { return result; @@ -292,13 +292,13 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage *message) { commandQueue->reply(&reply); } break; default: - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } void Subsystem::replyToCommand(ReturnValue_t status, uint32_t parameter) { - if (status == RETURN_OK) { + if (status == returnvalue::OK) { CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, 0); commandQueue->reply(&reply); } else { @@ -322,7 +322,7 @@ ReturnValue_t Subsystem::addSequence(ArrayList *sequence, Mode_t if (!preInit) { result = checkSequence(HybridIterator(sequence->front(), sequence->back()), fallbackSequence); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -336,19 +336,19 @@ ReturnValue_t Subsystem::addSequence(ArrayList *sequence, Mode_t result = modeSequences.insert(id, info); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (inStore) { #if FSFW_USE_MODESTORE == 1 result = modeStore->storeArray(sequence, &(modeSequences.find(id)->entries.firstLinkedElement)); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { modeSequences.erase(id); } #else modeSequences.erase(id); - return RETURN_FAILED; + return returnvalue::FAILED; #endif } @@ -367,7 +367,7 @@ ReturnValue_t Subsystem::addTable(ArrayList *table, Mode_t id, bo // are not added yet. Tables added before are checked by initialize() if (!preInit) { result = checkTable(HybridIterator(table->front(), table->back())); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -379,19 +379,19 @@ ReturnValue_t Subsystem::addTable(ArrayList *table, Mode_t id, bo result = modeTables.insert(id, pointer); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (inStore) { #if FSFW_USE_MODESTORE == 1 result = modeStore->storeArray(table, &(modeTables.find(id)->firstLinkedElement)); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { modeTables.erase(id); } #else modeTables.erase(id); - return RETURN_FAILED; + return returnvalue::FAILED; #endif } return result; @@ -405,7 +405,7 @@ ReturnValue_t Subsystem::deleteSequence(Mode_t id) { SequenceInfo *sequenceInfo; ReturnValue_t result; result = modeSequences.find(id, &sequenceInfo); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (!sequenceInfo->entries.islinked) { @@ -416,7 +416,7 @@ ReturnValue_t Subsystem::deleteSequence(Mode_t id) { modeStore->deleteList(sequenceInfo->entries.firstLinkedElement); #endif modeSequences.erase(id); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t Subsystem::deleteTable(Mode_t id) { @@ -427,7 +427,7 @@ ReturnValue_t Subsystem::deleteTable(Mode_t id) { EntryPointer *pointer; ReturnValue_t result; result = modeTables.find(id, &pointer); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (!pointer->islinked) { @@ -438,26 +438,26 @@ ReturnValue_t Subsystem::deleteTable(Mode_t id) { modeStore->deleteList(pointer->firstLinkedElement); #endif modeSequences.erase(id); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t Subsystem::initialize() { ReturnValue_t result = SubsystemBase::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); if (IPCStore == NULL) { - return RETURN_FAILED; + return returnvalue::FAILED; } #if FSFW_USE_MODESTORE == 1 modeStore = ObjectManager::instance()->get(objects::MODE_STORE); if (modeStore == nullptr) { - return RETURN_FAILED; + return returnvalue::FAILED; } #endif @@ -469,7 +469,7 @@ ReturnValue_t Subsystem::initialize() { mode = initialMode; submode = initSubmode; - return RETURN_OK; + return returnvalue::OK; } MessageQueueId_t Subsystem::getSequenceCommandQueue() const { @@ -553,7 +553,7 @@ void Subsystem::transitionFailed(ReturnValue_t failureCode, uint32_t parameter) // so we come here at the next fail modeHelper.setForced(true); ReturnValue_t result; - if ((result = checkSequence(getFallbackSequence(mode))) != RETURN_OK) { + if ((result = checkSequence(getFallbackSequence(mode))) != returnvalue::OK) { triggerEvent(FALLBACK_FAILED, result, getFallbackSequence(mode)); // keep still and allow arbitrary mode commands to recover isInTransition = false; @@ -579,7 +579,7 @@ void Subsystem::sendSerializablesAsCommandMessage(Command_t command, SerializeIF size_t size = 0; result = IPCStore->getFreeElement(&address, maxSize, &storeBuffer); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { replyToCommand(result, 0); return; } @@ -588,21 +588,21 @@ void Subsystem::sendSerializablesAsCommandMessage(Command_t command, SerializeIF } CommandMessage reply; ModeSequenceMessage::setModeSequenceMessage(&reply, command, address); - if (commandQueue->reply(&reply) != RETURN_OK) { + if (commandQueue->reply(&reply) != returnvalue::OK) { IPCStore->deleteData(address); } } ReturnValue_t Subsystem::checkObjectConnections() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; for (FixedMap::Iterator iter = modeSequences.begin(); iter != modeSequences.end(); iter++) { result = checkSequence(iter.value->first); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } } - return RETURN_OK; + return returnvalue::OK; } void Subsystem::setInitialMode(Mode_t mode, Submode_t submode) { @@ -612,7 +612,7 @@ void Subsystem::setInitialMode(Mode_t mode, Submode_t submode) { void Subsystem::cantKeepMode() { ReturnValue_t result; - if ((result = checkSequence(getFallbackSequence(mode))) != RETURN_OK) { + if ((result = checkSequence(getFallbackSequence(mode))) != returnvalue::OK) { triggerEvent(FALLBACK_FAILED, result, getFallbackSequence(mode)); return; } diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 104db3c3..17bbdf46 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -42,7 +42,7 @@ ReturnValue_t SubsystemBase::registerChild(object_id_t objectId) { if (not resultPair.second) { return COULD_NOT_INSERT_CHILD; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t SubsystemBase::checkStateAgainstTable(HybridIterator tableIter, @@ -53,11 +53,11 @@ ReturnValue_t SubsystemBase::checkStateAgainstTable(HybridIteratorgetObject(); if ((childIter = childrenMap.find(object)) == childrenMap.end()) { - return RETURN_FAILED; + return returnvalue::FAILED; } if (childIter->second.mode != tableIter.value->getMode()) { - return RETURN_FAILED; + return returnvalue::FAILED; } Submode_t submodeToCheckAgainst = tableIter.value->getSubmode(); @@ -66,10 +66,10 @@ ReturnValue_t SubsystemBase::checkStateAgainstTable(HybridIteratorsecond.submode != submodeToCheckAgainst) { - return RETURN_FAILED; + return returnvalue::FAILED; } } - return RETURN_OK; + return returnvalue::OK; } void SubsystemBase::executeTable(HybridIterator tableIter, Submode_t targetSubmode) { @@ -122,7 +122,7 @@ void SubsystemBase::executeTable(HybridIterator tableIter, Submod // mode is forced to reach lower levels } ReturnValue_t result = commandQueue->sendMessage(iter->second.commandQueue, &command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { ++commandsOutstanding; } } @@ -136,7 +136,7 @@ ReturnValue_t SubsystemBase::updateChildMode(MessageQueueId_t queue, Mode_t mode if (iter->second.commandQueue == queue) { iter->second.mode = mode; iter->second.submode = submode; - return RETURN_OK; + return returnvalue::OK; } } return CHILD_NOT_FOUND; @@ -146,7 +146,7 @@ ReturnValue_t SubsystemBase::updateChildChangedHealth(MessageQueueId_t queue, bo for (auto iter = childrenMap.begin(); iter != childrenMap.end(); iter++) { if (iter->second.commandQueue == queue) { iter->second.healthChanged = changedHealth; - return RETURN_OK; + return returnvalue::OK; } } return CHILD_NOT_FOUND; @@ -158,14 +158,14 @@ ReturnValue_t SubsystemBase::initialize() { MessageQueueId_t parentQueue = MessageQueueIF::NO_QUEUE; ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (parentId != objects::NO_OBJECT) { SubsystemBase* parent = ObjectManager::instance()->get(parentId); if (parent == nullptr) { - return RETURN_FAILED; + return returnvalue::FAILED; } parentQueue = parent->getCommandQueue(); @@ -174,17 +174,17 @@ ReturnValue_t SubsystemBase::initialize() { result = healthHelper.initialize(parentQueue); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = modeHelper.initialize(parentQueue); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t SubsystemBase::performOperation(uint8_t opCode) { @@ -194,7 +194,7 @@ ReturnValue_t SubsystemBase::performOperation(uint8_t opCode) { performChildOperation(); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) { @@ -203,14 +203,14 @@ ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) { updateChildMode(message->getSender(), ModeMessage::getMode(message), ModeMessage::getSubmode(message)); childrenChangedMode = true; - return RETURN_OK; + return returnvalue::OK; case ModeMessage::REPLY_MODE_REPLY: case ModeMessage::REPLY_WRONG_MODE_REPLY: updateChildMode(message->getSender(), ModeMessage::getMode(message), ModeMessage::getSubmode(message)); childrenChangedMode = true; commandsOutstanding--; - return RETURN_OK; + return returnvalue::OK; case ModeMessage::REPLY_CANT_REACH_MODE: commandsOutstanding--; { @@ -220,7 +220,7 @@ ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) { } } } - return RETURN_OK; + return returnvalue::OK; // case ModeMessage::CMD_MODE_COMMAND: // handleCommandedMode(message); // return RETURN_OK; @@ -232,7 +232,7 @@ ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) { // commandAllChildren(message); // return RETURN_OK; default: - return RETURN_FAILED; + return returnvalue::FAILED; } } @@ -242,7 +242,7 @@ ReturnValue_t SubsystemBase::checkTable(HybridIterator tableIter) return TABLE_CONTAINS_INVALID_OBJECT_ID; } } - return RETURN_OK; + return returnvalue::OK; } void SubsystemBase::replyToCommand(CommandMessage* message) { commandQueue->reply(message); } @@ -284,25 +284,25 @@ void SubsystemBase::checkCommandQueue() { ReturnValue_t result; CommandMessage command; - for (result = commandQueue->receiveMessage(&command); result == RETURN_OK; + for (result = commandQueue->receiveMessage(&command); result == returnvalue::OK; result = commandQueue->receiveMessage(&command)) { result = healthHelper.handleHealthCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = modeHelper.handleModeCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = handleModeReply(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = handleCommandMessage(&command); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { CommandMessage reply; reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, command.getCommand()); replyToCommand(&reply); @@ -315,7 +315,7 @@ ReturnValue_t SubsystemBase::setHealth(HealthState health) { case HEALTHY: case EXTERNAL_CONTROL: healthHelper.setHealth(health); - return RETURN_OK; + return returnvalue::OK; default: return INVALID_HEALTH_STATE; } diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index 52f9891e..ad341b80 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -20,7 +20,6 @@ class SubsystemBase : public SystemObject, public HasModesIF, public HasHealthIF, - public HasReturnvaluesIF, public ExecutableObjectIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::SUBSYSTEM_BASE; diff --git a/src/fsfw/subsystem/modes/ModeDefinitions.h b/src/fsfw/subsystem/modes/ModeDefinitions.h index 9a6b8e31..d22bcd95 100644 --- a/src/fsfw/subsystem/modes/ModeDefinitions.h +++ b/src/fsfw/subsystem/modes/ModeDefinitions.h @@ -21,17 +21,17 @@ class ModeListEntry : public SerializeIF, public LinkedElement { result = SerializeAdapter::serialize(&value1, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&value2, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&value3, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -50,17 +50,17 @@ class ModeListEntry : public SerializeIF, public LinkedElement { result = SerializeAdapter::deSerialize(&value1, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&value2, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&value3, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&value4, buffer, size, streamEndianness); diff --git a/src/fsfw/subsystem/modes/ModeStore.cpp b/src/fsfw/subsystem/modes/ModeStore.cpp index c70b5e21..2fb16d31 100644 --- a/src/fsfw/subsystem/modes/ModeStore.cpp +++ b/src/fsfw/subsystem/modes/ModeStore.cpp @@ -54,28 +54,28 @@ ReturnValue_t ModeStore::storeArray(ArrayList* sequence, } pointer->setNext(NULL); OSAL::unlockMutex(mutex); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ModeStore::deleteList(ModeListEntry* sequence) { ReturnValue_t result = isValidEntry(sequence); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT); deleteListNoLock(sequence); OSAL::unlockMutex(mutex); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ModeStore::readList(ModeListEntry* sequence, ArrayList* into) { ReturnValue_t result = isValidEntry(sequence); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT); result = into->insert(*sequence->value); - while ((result == HasReturnvaluesIF::RETURN_OK) && (sequence->getNext() != NULL)) { + while ((result == returnvalue::OK) && (sequence->getNext() != NULL)) { result = into->insert(*sequence->value); sequence = sequence->getNext()->value; } @@ -117,7 +117,7 @@ ReturnValue_t ModeStore::isValidEntry(ModeListEntry* sequence) { if ((sequence < store.front()) || (sequence > store.back()) || sequence->getNext() == emptySlot) { return INVALID_ENTRY; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } #endif diff --git a/src/fsfw/tasks/ExecutableObjectIF.h b/src/fsfw/tasks/ExecutableObjectIF.h index 753a124f..60f38259 100644 --- a/src/fsfw/tasks/ExecutableObjectIF.h +++ b/src/fsfw/tasks/ExecutableObjectIF.h @@ -45,7 +45,7 @@ class ExecutableObjectIF { * called so the execution frequency can't be cached in initialize() * @return */ - virtual ReturnValue_t initializeAfterTaskCreation() { return HasReturnvaluesIF::RETURN_OK; } + virtual ReturnValue_t initializeAfterTaskCreation() { return returnvalue::OK; } }; #endif /* FRAMEWORK_TASKS_EXECUTABLEOBJECTIF_H_ */ diff --git a/src/fsfw/tasks/FixedSlotSequence.cpp b/src/fsfw/tasks/FixedSlotSequence.cpp index 9305b441..e538c9fc 100644 --- a/src/fsfw/tasks/FixedSlotSequence.cpp +++ b/src/fsfw/tasks/FixedSlotSequence.cpp @@ -98,7 +98,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { if (customChecker != nullptr) { ReturnValue_t result = customChecker(slotList, customCheckArgs); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { // Continue for now but print error output. #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FixedSlotSequence::checkSequence:" @@ -132,9 +132,9 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { // << slotList.size() << std::endl; #endif if (errorCount > 0) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { @@ -144,7 +144,7 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { // Ensure that each unique object is initialized once. if (uniqueObjects.find(slot.executableObject) == uniqueObjects.end()) { ReturnValue_t result = slot.executableObject->initializeAfterTaskCreation(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { count++; } uniqueObjects.emplace(slot.executableObject); @@ -156,9 +156,9 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { "Counted " << count << " failed initializations!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FixedSlotSequence::addCustomCheck(CustomCheckFunc customChecker_, void* checkerArgs_) { diff --git a/src/fsfw/tasks/FixedTimeslotTaskBase.cpp b/src/fsfw/tasks/FixedTimeslotTaskBase.cpp index 5d12d565..3327deae 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskBase.cpp +++ b/src/fsfw/tasks/FixedTimeslotTaskBase.cpp @@ -20,8 +20,8 @@ ReturnValue_t FixedTimeslotTaskBase::addSlot(object_id_t execId, ExecutableObjec #else sif::printError("Component 0x%08x not found, not adding it to PST\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } pollingSeqTable.addSlot(execId, slotTimeMs, executionStep, execObj, this); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tasks/FixedTimeslotTaskIF.h b/src/fsfw/tasks/FixedTimeslotTaskIF.h index c7b90ec3..916af639 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskIF.h +++ b/src/fsfw/tasks/FixedTimeslotTaskIF.h @@ -15,7 +15,7 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF { ~FixedTimeslotTaskIF() override = default; static constexpr ReturnValue_t SLOT_LIST_EMPTY = - result::makeCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0); + returnvalue::makeCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0); /** * Add an object with a slot time and the execution step to the task. @@ -51,11 +51,11 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF { virtual ReturnValue_t checkSequence() = 0; ReturnValue_t addComponent(object_id_t object, uint8_t opCode) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t addComponent(ExecutableObjectIF* object, uint8_t opCode) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } }; diff --git a/src/fsfw/tasks/PeriodicTaskBase.cpp b/src/fsfw/tasks/PeriodicTaskBase.cpp index ce925a45..3ae8afe7 100644 --- a/src/fsfw/tasks/PeriodicTaskBase.cpp +++ b/src/fsfw/tasks/PeriodicTaskBase.cpp @@ -29,13 +29,13 @@ ReturnValue_t PeriodicTaskBase::addComponent(ExecutableObjectIF* object) { ReturnValue_t PeriodicTaskBase::initObjsAfterTaskCreation() { std::set uniqueObjects; - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; uint32_t count = 0; for (const auto& obj : objectList) { // Ensure that each unique object is initialized once. if (uniqueObjects.find(obj.first) == uniqueObjects.end()) { ReturnValue_t result = obj.first->initializeAfterTaskCreation(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { count++; status = result; } @@ -62,10 +62,10 @@ ReturnValue_t PeriodicTaskBase::addComponent(ExecutableObjectIF* object, uint8_t "PeriodicTask::addComponent: Invalid object. Make sure it " "implements ExecutableObjectIF!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } objectList.push_back({object, opCode}); object->setTaskIF(this); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tasks/PeriodicTaskIF.h b/src/fsfw/tasks/PeriodicTaskIF.h index 03b709ab..04415533 100644 --- a/src/fsfw/tasks/PeriodicTaskIF.h +++ b/src/fsfw/tasks/PeriodicTaskIF.h @@ -29,7 +29,7 @@ class PeriodicTaskIF { * The objects are executed in the order added. The object needs to implement * ExecutableObjectIF * @param object Id of the object to add. - * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. + * @return RETURN_OK on success, returnvalue::FAILED if the object could not be added. */ virtual ReturnValue_t addComponent(object_id_t object, uint8_t opCode) = 0; virtual ReturnValue_t addComponent(object_id_t object) { return addComponent(object, 0); }; @@ -38,7 +38,7 @@ class PeriodicTaskIF { * Adds an object to the list of objects to be executed. * The objects are executed in the order added. * @param object pointer to the object to add. - * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. + * @return RETURN_OK on success, returnvalue::FAILED if the object could not be added. */ virtual ReturnValue_t addComponent(ExecutableObjectIF* object, uint8_t opCode) = 0; virtual ReturnValue_t addComponent(ExecutableObjectIF* object) { return addComponent(object, 0); } diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index 628dd8d0..6202ca78 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -26,7 +26,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { const uint8_t* packet = nullptr; size_t size = 0; ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(), &packet, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CCSDSDistributor::selectDestination: Getting data from" @@ -59,20 +59,20 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { MessageQueueId_t CCSDSDistributor::getRequestQueue() { return tcQueue->getId(); } ReturnValue_t CCSDSDistributor::registerApplication(AcceptsTelecommandsIF* application) { - ReturnValue_t returnValue = RETURN_OK; + ReturnValue_t returnValue = returnvalue::OK; auto insertPair = this->queueMap.emplace(application->getIdentifier(), application->getRequestQueue()); if (not insertPair.second) { - returnValue = RETURN_FAILED; + returnValue = returnvalue::FAILED; } return returnValue; } ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid, MessageQueueId_t id) { - ReturnValue_t returnValue = RETURN_OK; + ReturnValue_t returnValue = returnvalue::OK; auto insertPair = this->queueMap.emplace(apid, id); if (not insertPair.second) { - returnValue = RETURN_FAILED; + returnValue = returnvalue::FAILED; } return returnValue; } @@ -94,14 +94,14 @@ ReturnValue_t CCSDSDistributor::initialize() { " TC store!\n"); #endif #endif - status = RETURN_FAILED; + status = returnvalue::FAILED; } return status; } ReturnValue_t CCSDSDistributor::callbackAfterSending(ReturnValue_t queueStatus) { - if (queueStatus != RETURN_OK) { + if (queueStatus != returnvalue::OK) { tcStore->deleteData(currentMessage.getStorageId()); } - return RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/CCSDSDistributorIF.h b/src/fsfw/tcdistribution/CCSDSDistributorIF.h index d1c88118..a57379ea 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributorIF.h +++ b/src/fsfw/tcdistribution/CCSDSDistributorIF.h @@ -18,7 +18,7 @@ class CCSDSDistributorIF { * at the distributor. * @param application A pointer to the Application to register. * @return - @c RETURN_OK on success, - * - @c RETURN_FAILED on failure. + * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerApplication(AcceptsTelecommandsIF* application) = 0; /** @@ -28,7 +28,7 @@ class CCSDSDistributorIF { * @param id The MessageQueueId of the message queue to send the * TC Packets to. * @return - @c RETURN_OK on success, - * - @c RETURN_FAILED on failure. + * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerApplication(uint16_t apid, MessageQueueId_t id) = 0; /** diff --git a/src/fsfw/tcdistribution/CFDPDistributor.cpp b/src/fsfw/tcdistribution/CFDPDistributor.cpp index d8be1543..20edc0f4 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.cpp +++ b/src/fsfw/tcdistribution/CFDPDistributor.cpp @@ -13,7 +13,7 @@ CFDPDistributor::CFDPDistributor(uint16_t setApid, object_id_t setObjectId, : TcDistributor(setObjectId), apid(setApid), checker(setApid), - tcStatus(RETURN_FAILED), + tcStatus(returnvalue::FAILED), packetSource(setPacketSource) {} CFDPDistributor::~CFDPDistributor() {} @@ -36,7 +36,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); if (currentPacket->getWholeData() != nullptr) { tcStatus = checker.checkPacket(currentPacket); - if (tcStatus != HasReturnvaluesIF::RETURN_OK) { + if (tcStatus != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "CFDPDistributor::handlePacket: Packet format invalid, code " @@ -63,7 +63,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { #endif } - if (tcStatus != RETURN_OK) { + if (tcStatus != returnvalue::OK) { return this->queueMap.end(); } else { return queueMapIt; @@ -95,7 +95,7 @@ ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) { #endif return SERVICE_ID_ALREADY_EXISTS; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MessageQueueId_t CFDPDistributor::getRequestQueue() { return tcQueue->getId(); } @@ -110,7 +110,7 @@ MessageQueueId_t CFDPDistributor::getRequestQueue() { return tcQueue->getId(); } // // A failed packet is deleted immediately after reporting, // // otherwise it will block memory. // currentPacket->deletePacket(); -// return RETURN_FAILED; +// return returnvalue::FAILED; // } else { // this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, // currentPacket); @@ -137,7 +137,7 @@ ReturnValue_t CFDPDistributor::initialize() { sif::printError("CFDPDistributor::initialize: Packet source invalid\n"); sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } return ccsdsDistributor->registerApplication(this); } diff --git a/src/fsfw/tcdistribution/CFDPDistributorIF.h b/src/fsfw/tcdistribution/CFDPDistributorIF.h index 3c1836f1..57cf9fde 100644 --- a/src/fsfw/tcdistribution/CFDPDistributorIF.h +++ b/src/fsfw/tcdistribution/CFDPDistributorIF.h @@ -18,7 +18,7 @@ class CFDPDistributorIF { * With this method, Handlers can register themselves at the CFDP Distributor. * @param handler A pointer to the registering Handler. * @return - @c RETURN_OK on success, - * - @c RETURN_FAILED on failure. + * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) = 0; }; diff --git a/src/fsfw/tcdistribution/PUSDistributor.cpp b/src/fsfw/tcdistribution/PUSDistributor.cpp index dad002a1..a32a210f 100644 --- a/src/fsfw/tcdistribution/PUSDistributor.cpp +++ b/src/fsfw/tcdistribution/PUSDistributor.cpp @@ -12,7 +12,7 @@ PUSDistributor::PUSDistributor(uint16_t setApid, object_id_t setObjectId, : TcDistributor(setObjectId), checker(setApid), verifyChannel(), - tcStatus(RETURN_FAILED), + tcStatus(returnvalue::FAILED), packetSource(setPacketSource) {} PUSDistributor::~PUSDistributor() = default; @@ -30,7 +30,7 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { this->currentPacket->setStoreAddress(this->currentMessage.getStorageId(), currentPacket); if (currentPacket->getWholeData() != nullptr) { tcStatus = checker.checkPacket(currentPacket); - if (tcStatus != HasReturnvaluesIF::RETURN_OK) { + if (tcStatus != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 const char* keyword = "unnamed error"; if (tcStatus == TcPacketCheckPUS::INCORRECT_CHECKSUM) { @@ -70,7 +70,7 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { #endif } - if (tcStatus != RETURN_OK) { + if (tcStatus != returnvalue::OK) { return this->queueMap.end(); } else { return queueMapIt; @@ -100,25 +100,25 @@ ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) { #endif return SERVICE_ID_ALREADY_EXISTS; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MessageQueueId_t PUSDistributor::getRequestQueue() { return tcQueue->getId(); } ReturnValue_t PUSDistributor::callbackAfterSending(ReturnValue_t queueStatus) { - if (queueStatus != RETURN_OK) { + if (queueStatus != returnvalue::OK) { tcStatus = queueStatus; } - if (tcStatus != RETURN_OK) { + if (tcStatus != returnvalue::OK) { this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, currentPacket, tcStatus); // A failed packet is deleted immediately after reporting, // otherwise it will block memory. currentPacket->deletePacket(); - return RETURN_FAILED; + return returnvalue::FAILED; } else { this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, currentPacket); - return RETURN_OK; + return returnvalue::OK; } } @@ -140,7 +140,7 @@ ReturnValue_t PUSDistributor::initialize() { sif::printError("PUSDistributor::initialize: Packet source invalid\n"); sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } return ccsdsDistributor->registerApplication(this); } diff --git a/src/fsfw/tcdistribution/PUSDistributorIF.h b/src/fsfw/tcdistribution/PUSDistributorIF.h index da6db283..85619fee 100644 --- a/src/fsfw/tcdistribution/PUSDistributorIF.h +++ b/src/fsfw/tcdistribution/PUSDistributorIF.h @@ -18,7 +18,7 @@ class PUSDistributorIF { * With this method, Services can register themselves at the PUS Distributor. * @param service A pointer to the registering Service. * @return - @c RETURN_OK on success, - * - @c RETURN_FAILED on failure. + * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerService(AcceptsTelecommandsIF* service) = 0; }; diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index a650546c..d7fbd0f8 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -11,13 +11,13 @@ TcDistributor::TcDistributor(object_id_t objectId) : SystemObject(objectId) { TcDistributor::~TcDistributor() { QueueFactory::instance()->deleteMessageQueue(tcQueue); } ReturnValue_t TcDistributor::performOperation(uint8_t opCode) { - ReturnValue_t status = RETURN_OK; - for (status = tcQueue->receiveMessage(¤tMessage); status == RETURN_OK; + ReturnValue_t status = returnvalue::OK; + for (status = tcQueue->receiveMessage(¤tMessage); status == returnvalue::OK; status = tcQueue->receiveMessage(¤tMessage)) { status = handlePacket(); } if (status == MessageQueueIF::EMPTY) { - return RETURN_OK; + return returnvalue::OK; } else { return status; } @@ -25,7 +25,7 @@ ReturnValue_t TcDistributor::performOperation(uint8_t opCode) { ReturnValue_t TcDistributor::handlePacket() { TcMqMapIter queueMapIt = this->selectDestination(); - ReturnValue_t returnValue = RETURN_FAILED; + ReturnValue_t returnValue = returnvalue::FAILED; if (queueMapIt != this->queueMap.end()) { returnValue = this->tcQueue->sendMessage(queueMapIt->second, &this->currentMessage); } @@ -43,4 +43,4 @@ void TcDistributor::print() { #endif } -ReturnValue_t TcDistributor::callbackAfterSending(ReturnValue_t queueStatus) { return RETURN_OK; } +ReturnValue_t TcDistributor::callbackAfterSending(ReturnValue_t queueStatus) { return returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/TcDistributor.h b/src/fsfw/tcdistribution/TcDistributor.h index 1b783ff4..7c7e539c 100644 --- a/src/fsfw/tcdistribution/TcDistributor.h +++ b/src/fsfw/tcdistribution/TcDistributor.h @@ -27,7 +27,7 @@ * implementations. * @ingroup tc_distribution */ -class TcDistributor : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { +class TcDistributor : public SystemObject, public ExecutableObjectIF { public: using TcMessageQueueMap = std::map; using TcMqMapIter = std::map::iterator; @@ -93,7 +93,7 @@ class TcDistributor : public SystemObject, public ExecutableObjectIF, public Has /** * The handlePacket method calls the child class's selectDestination method * and forwards the packet to its destination, if found. - * @return The message queue return value or @c RETURN_FAILED, in case no + * @return The message queue return value or @c returnvalue::FAILED, in case no * destination was found. */ ReturnValue_t handlePacket(); @@ -105,7 +105,7 @@ class TcDistributor : public SystemObject, public ExecutableObjectIF, public Has * @param queueStatus The status of the message queue after an attempt * to send the TC. * @return - @c RETURN_OK on success - * - @c RETURN_FAILED on failure + * - @c returnvalue::FAILED on failure */ virtual ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus); diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp index d1eb43bc..012c2d1a 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp @@ -4,6 +4,6 @@ TcPacketCheckCFDP::TcPacketCheckCFDP(uint16_t setApid) : apid(setApid) {} -ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketBase* currentPacket) { return RETURN_OK; } +ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketBase* currentPacket) { return returnvalue::OK; } uint16_t TcPacketCheckCFDP::getApid() const { return apid; } diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.h b/src/fsfw/tcdistribution/TcPacketCheckCFDP.h index 3fe281d1..8946c7a7 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.h +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.h @@ -10,7 +10,7 @@ class CFDPPacketStored; * This class performs a formal packet check for incoming CFDP Packets. * @ingroup tc_distribution */ -class TcPacketCheckCFDP : public TcPacketCheckIF, public HasReturnvaluesIF { +class TcPacketCheckCFDP : public TcPacketCheckIF { protected: /** * The packet id each correct packet should have. diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp index 83844337..8ae29ae1 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp @@ -14,7 +14,7 @@ ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) { TcPacketStoredBase* storedPacket = dynamic_cast(currentPacket); TcPacketPusBase* tcPacketBase = dynamic_cast(currentPacket); if (tcPacketBase == nullptr or storedPacket == nullptr) { - return RETURN_FAILED; + return returnvalue::FAILED; } uint16_t calculated_crc = CRC::crc16ccitt(tcPacketBase->getWholeData(), tcPacketBase->getFullSize()); @@ -38,7 +38,7 @@ ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) { if (condition) { return INCORRECT_SECONDARY_HEADER; } - return RETURN_OK; + return returnvalue::OK; } uint16_t TcPacketCheckPUS::getApid() const { return apid; } diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.h b/src/fsfw/tcdistribution/TcPacketCheckPUS.h index e3eca1a4..5b02bbc0 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.h +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.h @@ -13,7 +13,7 @@ class TcPacketStoredBase; * Currently, it only checks if the APID and CRC are correct. * @ingroup tc_distribution */ -class TcPacketCheckPUS : public TcPacketCheckIF, public HasReturnvaluesIF { +class TcPacketCheckPUS : public TcPacketCheckIF { protected: /** * Describes the version number a packet must have to pass. diff --git a/src/fsfw/thermal/AbstractTemperatureSensor.cpp b/src/fsfw/thermal/AbstractTemperatureSensor.cpp index 68cd3aca..fc182bf1 100644 --- a/src/fsfw/thermal/AbstractTemperatureSensor.cpp +++ b/src/fsfw/thermal/AbstractTemperatureSensor.cpp @@ -24,11 +24,11 @@ MessageQueueId_t AbstractTemperatureSensor::getCommandQueue() const { ReturnValue_t AbstractTemperatureSensor::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = parameterHelper.initialize(); @@ -38,24 +38,24 @@ ReturnValue_t AbstractTemperatureSensor::initialize() { ReturnValue_t AbstractTemperatureSensor::performOperation(uint8_t opCode) { handleCommandQueue(); doChildOperation(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t AbstractTemperatureSensor::performHealthOp() { handleCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void AbstractTemperatureSensor::handleCommandQueue() { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { result = healthHelper.handleHealthCommand(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } result = parameterHelper.handleParameterMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } command.setToUnknownCommand(); @@ -65,7 +65,7 @@ void AbstractTemperatureSensor::handleCommandQueue() { ReturnValue_t AbstractTemperatureSensor::setHealth(HealthState health) { healthHelper.setHealth(health); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } HasHealthIF::HealthState AbstractTemperatureSensor::getHealth() { return healthHelper.getHealth(); } diff --git a/src/fsfw/thermal/Heater.cpp b/src/fsfw/thermal/Heater.cpp index 4f0f8060..2ad988bd 100644 --- a/src/fsfw/thermal/Heater.cpp +++ b/src/fsfw/thermal/Heater.cpp @@ -21,14 +21,14 @@ ReturnValue_t Heater::set() { passive = false; // wait for clear before doing anything if (internalState == STATE_WAIT) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } if (healthHelper.healthTable->isHealthy(getObjectId())) { doAction(SET); if ((internalState == STATE_OFF) || (internalState == STATE_PASSIVE)) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } else { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } else { if (healthHelper.healthTable->isFaulty(getObjectId())) { @@ -37,7 +37,7 @@ ReturnValue_t Heater::set() { doAction(CLEAR); } } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -186,7 +186,7 @@ ReturnValue_t Heater::performOperation(uint8_t opCode) { wasOn = false; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void Heater::setSwitch(uint8_t number, ReturnValue_t state, uint32_t* uptimeOfSwitching) { @@ -220,54 +220,54 @@ MessageQueueId_t Heater::getCommandQueue() const { return commandQueue->getId(); ReturnValue_t Heater::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (manager == NULL) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } result = manager->registerListener(eventQueue->getId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } ConfirmsFailuresIF* pcdu = ObjectManager::instance()->get( DeviceHandlerFailureIsolation::powerConfirmationId); if (pcdu == NULL) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } pcduQueueId = pcdu->getEventReceptionQueue(); result = manager->subscribeToAllEventsFrom(eventQueue->getId(), getObjectId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = parameterHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void Heater::handleQueue() { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { result = healthHelper.handleHealthCommand(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } result = parameterHelper.handleParameterMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } } @@ -286,13 +286,13 @@ ReturnValue_t Heater::getParameter(uint8_t domainId, uint8_t uniqueId, default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void Heater::handleEventQueue() { EventMessage event; for (ReturnValue_t result = eventQueue->receiveMessage(&event); - result == HasReturnvaluesIF::RETURN_OK; result = eventQueue->receiveMessage(&event)) { + result == returnvalue::OK; result = eventQueue->receiveMessage(&event)) { switch (event.getMessageId()) { case EventMessage::EVENT_MESSAGE: switch (event.getEvent()) { diff --git a/src/fsfw/thermal/RedundantHeater.cpp b/src/fsfw/thermal/RedundantHeater.cpp index 431d9900..24b70c89 100644 --- a/src/fsfw/thermal/RedundantHeater.cpp +++ b/src/fsfw/thermal/RedundantHeater.cpp @@ -14,7 +14,7 @@ void RedundantHeater::performOperation(uint8_t opCode) { void RedundantHeater::set(bool on, bool both, bool passive) { if (on) { ReturnValue_t result = heater0.set(); - if (result != HasReturnvaluesIF::RETURN_OK || both) { + if (result != returnvalue::OK || both) { heater1.set(); } else { heater1.clear(passive); diff --git a/src/fsfw/thermal/TemperatureSensor.h b/src/fsfw/thermal/TemperatureSensor.h index 591fd7d9..4cb2a083 100644 --- a/src/fsfw/thermal/TemperatureSensor.h +++ b/src/fsfw/thermal/TemperatureSensor.h @@ -117,7 +117,7 @@ class TemperatureSensor : public AbstractTemperatureSensor { void doChildOperation() { ReturnValue_t result = inputTemperature->read(MutexIF::TimeoutType::WAITING, 20); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } @@ -209,7 +209,7 @@ class TemperatureSensor : public AbstractTemperatureSensor { default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } virtual void resetOldState() { sensorMonitor.setToUnchecked(); } diff --git a/src/fsfw/thermal/ThermalComponent.cpp b/src/fsfw/thermal/ThermalComponent.cpp index 000f2e19..e0077af2 100644 --- a/src/fsfw/thermal/ThermalComponent.cpp +++ b/src/fsfw/thermal/ThermalComponent.cpp @@ -21,18 +21,18 @@ ReturnValue_t ThermalComponent::setTargetState(int8_t newState) { targetState.setReadWriteMode(pool_rwm_t::VAR_READ_WRITE); targetState.read(); if ((targetState == STATE_REQUEST_OPERATIONAL) and (newState != STATE_REQUEST_IGNORE)) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } switch (newState) { case STATE_REQUEST_NON_OPERATIONAL: targetState = newState; targetState.setValid(true); targetState.commit(PoolVariableIF::VALID); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: return ThermalComponentCore::setTargetState(newState); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ThermalComponent::setLimits(const uint8_t* data, size_t size) { @@ -48,7 +48,7 @@ ReturnValue_t ThermalComponent::setLimits(const uint8_t* data, size_t size) { SerializeIF::Endianness::BIG); SerializeAdapter::deSerialize(&nopParameters.upperNopLimit, &data, &readSize, SerializeIF::Endianness::BIG); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ThermalComponentIF::State ThermalComponent::getState(float temperature, @@ -155,5 +155,5 @@ ReturnValue_t ThermalComponent::getParameter(uint8_t domainId, uint8_t uniqueId, default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/thermal/ThermalComponentCore.cpp b/src/fsfw/thermal/ThermalComponentCore.cpp index 887c30f2..ef47f49f 100644 --- a/src/fsfw/thermal/ThermalComponentCore.cpp +++ b/src/fsfw/thermal/ThermalComponentCore.cpp @@ -18,7 +18,7 @@ ThermalComponentCore::ThermalComponentCore(object_id_t reportingObjectId, uint8_ // Set thermal state once, then leave to operator. targetState.setReadWriteMode(PoolVariableIF::VAR_WRITE); ReturnValue_t result = targetState.read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { targetState = initialTargetState; targetState.setValid(true); targetState.commit(); @@ -91,7 +91,7 @@ ReturnValue_t ThermalComponentCore::setTargetState(int8_t newState) { targetState.setReadWriteMode(pool_rwm_t::VAR_READ_WRITE); targetState.read(); if ((targetState == STATE_REQUEST_OPERATIONAL) and (newState != STATE_REQUEST_IGNORE)) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } switch (newState) { @@ -106,7 +106,7 @@ ReturnValue_t ThermalComponentCore::setTargetState(int8_t newState) { } targetState.setValid(true); targetState.commit(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void ThermalComponentCore::setOutputInvalid() { @@ -267,5 +267,5 @@ ReturnValue_t ThermalComponentCore::getParameter(uint8_t domainId, uint8_t uniqu default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/thermal/ThermalModule.cpp b/src/fsfw/thermal/ThermalModule.cpp index 976bbe45..6f62a02b 100644 --- a/src/fsfw/thermal/ThermalModule.cpp +++ b/src/fsfw/thermal/ThermalModule.cpp @@ -233,7 +233,7 @@ bool ThermalModule::calculateModuleHeaterRequestAndSetModuleStatus(Strategy stra void ThermalModule::setHeating(bool on) { ReturnValue_t result = targetState.read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { if (on) { targetState.value = STATE_REQUEST_HEATING; } else { diff --git a/src/fsfw/thermal/ThermalMonitorReporter.cpp b/src/fsfw/thermal/ThermalMonitorReporter.cpp index dc64280e..2e6796a6 100644 --- a/src/fsfw/thermal/ThermalMonitorReporter.cpp +++ b/src/fsfw/thermal/ThermalMonitorReporter.cpp @@ -46,20 +46,20 @@ ReturnValue_t ThermalMonitorReporter::translateState(ThermalComponentIF::State s if (componentIsOperational) { return monitorStateIs(ThermalComponentIF::BELOW_OPERATIONAL_LIMIT, sample, lowerLimit); } else { - return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0); + return monitorStateIs(returnvalue::OK, sample, 0.0); } case ThermalComponentIF::OPERATIONAL: - return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0); + return monitorStateIs(returnvalue::OK, sample, 0.0); case ThermalComponentIF::NON_OPERATIONAL_HIGH: if (componentIsOperational) { return monitorStateIs(ThermalComponentIF::ABOVE_OPERATIONAL_LIMIT, sample, upperLimit); } else { - return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0); + return monitorStateIs(returnvalue::OK, sample, 0.0); } case ThermalComponentIF::OUT_OF_RANGE_HIGH: return monitorStateIs(MonitoringIF::ABOVE_HIGH_LIMIT, sample, upperLimit); default: // Never reached, all states covered. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/timemanager/CCSDSTime.cpp b/src/fsfw/timemanager/CCSDSTime.cpp index 1f84dd03..5e035d67 100644 --- a/src/fsfw/timemanager/CCSDSTime.cpp +++ b/src/fsfw/timemanager/CCSDSTime.cpp @@ -8,7 +8,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(Ccs_seconds* to, const Clock::TimeOfDay_t* from) { ReturnValue_t result = checkTimeOfDay(from); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -22,12 +22,12 @@ ReturnValue_t CCSDSTime::convertToCcsds(Ccs_seconds* to, const Clock::TimeOfDay_ to->minute = from->minute; to->second = from->second; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertToCcsds(Ccs_mseconds* to, const Clock::TimeOfDay_t* from) { ReturnValue_t result = checkTimeOfDay(from); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -43,7 +43,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(Ccs_mseconds* to, const Clock::TimeOfDay to->secondEminus2 = from->usecond / 10000; to->secondEminus4 = (from->usecond % 10000) / 100; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, const uint8_t* from, @@ -53,8 +53,8 @@ ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, const uint8_t* return LENGTH_MISMATCH; } result = convertFromASCII(to, from, length); // Try to parse it as ASCII - if (result == RETURN_OK) { - return RETURN_OK; + if (result == returnvalue::OK) { + return returnvalue::OK; } // Seems to be no ascii, try the other formats @@ -84,7 +84,7 @@ ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to, const uint8_t* f uint8_t length) { timeval time; ReturnValue_t result = convertFromCDS(&time, from, NULL, length); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return Clock::convertTimevalToTimeOfDay(&time, to); @@ -102,7 +102,7 @@ ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* f ReturnValue_t result = checkCcs(from, maxLength); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } // At this point we made sure that this is a valid ccs time @@ -118,7 +118,7 @@ ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* f uint8_t tempDay = 0; uint8_t tempMonth = 0; result = convertDaysOfYear(tempDayOfYear, to->year, &tempMonth, &tempDay); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } to->month = tempMonth; @@ -144,13 +144,13 @@ ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* f to->usecond += temp->secondEminus4 * 100; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* from, uint8_t length) { if (length < 19) { - return RETURN_FAILED; + return returnvalue::FAILED; } // Newlib nano can't parse uint8, see SCNu8 documentation and https://sourceware.org/newlib/README // Suggestion: use uint16 all the time. This should work on all systems. @@ -174,7 +174,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* to->minute = minute; to->second = second; to->usecond = (second - floor(second)) * 1000000; - return RETURN_OK; + return returnvalue::OK; } // try Code B (yyyy-ddd) @@ -187,8 +187,8 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* uint8_t tempDay; ReturnValue_t result = CCSDSTime::convertDaysOfYear( day, year, reinterpret_cast(&month), reinterpret_cast(&tempDay)); - if (result != RETURN_OK) { - return RETURN_FAILED; + if (result != returnvalue::OK) { + return returnvalue::FAILED; } to->year = year; to->month = month; @@ -197,7 +197,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* to->minute = minute; to->second = second; to->usecond = (second - floor(second)) * 1000000; - return RETURN_OK; + return returnvalue::OK; } // Warning: Compiler/Linker fails ambiguously if library does not implement // C99 I/O @@ -220,7 +220,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* to->minute = minute; to->second = second; to->usecond = (second - floor(second)) * 1000000; - return RETURN_OK; + return returnvalue::OK; } // try Code B (yyyy-ddd) @@ -229,8 +229,8 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* if (count == 5) { uint8_t tempDay; ReturnValue_t result = CCSDSTime::convertDaysOfYear(day, year, &month, &tempDay); - if (result != RETURN_OK) { - return RETURN_FAILED; + if (result != returnvalue::OK) { + return returnvalue::FAILED; } to->year = year; to->month = month; @@ -239,7 +239,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* to->minute = minute; to->second = second; to->usecond = (second - floor(second)) * 1000000; - return RETURN_OK; + return returnvalue::OK; } #endif @@ -284,7 +284,7 @@ ReturnValue_t CCSDSTime::checkCcs(const uint8_t* time, uint8_t length) { return INVALID_TIME_FORMAT; } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertDaysOfYear(uint16_t dayofYear, uint16_t year, uint8_t* month, @@ -301,21 +301,21 @@ ReturnValue_t CCSDSTime::convertDaysOfYear(uint16_t dayofYear, uint16_t year, ui *month = 1; if (dayofYear <= 31) { *day = dayofYear; - return RETURN_OK; + return returnvalue::OK; } *month += 1; dayofYear -= 31; if (isLeapYear(year)) { if (dayofYear <= 29) { *day = dayofYear; - return RETURN_OK; + return returnvalue::OK; } *month += 1; dayofYear -= 29; } else { if (dayofYear <= 28) { *day = dayofYear; - return RETURN_OK; + return returnvalue::OK; } *month += 1; dayofYear -= 28; @@ -323,7 +323,7 @@ ReturnValue_t CCSDSTime::convertDaysOfYear(uint16_t dayofYear, uint16_t year, ui while (*month <= 12) { if (dayofYear <= 31) { *day = dayofYear; - return RETURN_OK; + return returnvalue::OK; } *month += 1; dayofYear -= 31; @@ -334,7 +334,7 @@ ReturnValue_t CCSDSTime::convertDaysOfYear(uint16_t dayofYear, uint16_t year, ui if (dayofYear <= 30) { *day = dayofYear; - return RETURN_OK; + return returnvalue::OK; } *month += 1; dayofYear -= 30; @@ -369,7 +369,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(CDS_short* to, const timeval* from) { to->msDay_h = (msDay & 0xFF0000) >> 16; to->msDay_l = (msDay & 0xFF00) >> 8; to->msDay_ll = (msDay & 0xFF); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertToCcsds(OBT_FLP* to, const timeval* from) { @@ -387,7 +387,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(OBT_FLP* to, const timeval* from) { to->subsecondsMSB = (temp >> 8) & 0xff; to->subsecondsLSB = temp & 0xff; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from, size_t* foundLength, @@ -396,7 +396,7 @@ ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from, size Clock::TimeOfDay_t timeOfDay; /* Try to parse it as ASCII */ ReturnValue_t result = convertFromASCII(&timeOfDay, from, maxLength); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return Clock::convertTimeOfDayToTimeval(&timeOfDay, to); } } @@ -423,7 +423,7 @@ ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, const uint8_t* from, size_t uint8_t pField = *from; from++; ReturnValue_t result = convertFromCUC(to, pField, from, foundLength, maxLength - 1); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { if (foundLength != nullptr) { *foundLength += 1; } @@ -482,7 +482,7 @@ ReturnValue_t CCSDSTime::checkTimeOfDay(const Clock::TimeOfDay_t* time) { return INVALID_TIME_FORMAT; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from, size_t* foundLength, @@ -545,12 +545,12 @@ ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from, size_t // Not very useful. to->tv_usec += (picosecs / 1000); } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const CCSDSTime::CDS_short* from) { if (to == nullptr or from == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint16_t days = (from->dayMSB << 8) + from->dayLSB; if (days <= DAYS_CCSDS_TO_UNIX_EPOCH) { @@ -562,16 +562,16 @@ ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const CCSDSTime::CDS_short* (from->msDay_hh << 24) + (from->msDay_h << 16) + (from->msDay_l << 8) + from->msDay_ll; to->tv_sec += (msDay / 1000); to->tv_usec = (msDay % 1000) * 1000; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to, const CCSDSTime::CDS_short* from) { if (to == nullptr or from == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } timeval tempTimeval; ReturnValue_t result = convertFromCDS(&tempTimeval, from); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return Clock::convertTimevalToTimeOfDay(&tempTimeval, to); @@ -605,7 +605,7 @@ ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, uint8_t pField, const uint8 to->tv_sec -= (DAYS_CCSDS_TO_UNIX_EPOCH * SECONDS_PER_DAY); } to->tv_usec = subsecondsToMicroseconds(subSeconds); - return RETURN_OK; + return returnvalue::OK; } uint32_t CCSDSTime::subsecondsToMicroseconds(uint16_t subseconds) { @@ -617,7 +617,7 @@ ReturnValue_t CCSDSTime::convertFromCCS(timeval* to, const uint8_t* from, size_t size_t maxLength) { Clock::TimeOfDay_t tempTime; ReturnValue_t result = convertFromCCS(&tempTime, from, foundLength, maxLength); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index 2a2316af..c0db1d6e 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -20,7 +20,7 @@ bool operator==(const timeval &lhs, const timeval &rhs); * * Still work in progress */ -class CCSDSTime : public HasReturnvaluesIF { +class CCSDSTime { public: /** * The Time code identifications, bits 4-6 in the P-Field diff --git a/src/fsfw/timemanager/Clock.h b/src/fsfw/timemanager/Clock.h index 75c898e5..6df6e12b 100644 --- a/src/fsfw/timemanager/Clock.h +++ b/src/fsfw/timemanager/Clock.h @@ -137,7 +137,7 @@ class Clock { * @param[out] tt timeval, corresponding to Terrestial Time * @return * - @c RETURN_OK on success - * - @c RETURN_FAILED if leapSeconds are not set + * - @c returnvalue::FAILED if leapSeconds are not set */ static ReturnValue_t convertUTCToTT(timeval utc, timeval *tt); @@ -158,7 +158,7 @@ class Clock { * @param[out] leapSeconds_ * @return * - @c RETURN_OK on success. - * - @c RETURN_FAILED on error + * - @c returnvalue::FAILED on error */ static ReturnValue_t getLeapSeconds(uint16_t *leapSeconds_); @@ -167,7 +167,7 @@ class Clock { * Function to check and create the Mutex for the clock * @return * - @c RETURN_OK on success. - * - Otherwise @c RETURN_FAILED if not able to create one + * - Otherwise @c returnvalue::FAILED if not able to create one */ static ReturnValue_t checkOrCreateClockMutex(); diff --git a/src/fsfw/timemanager/ClockCommon.cpp b/src/fsfw/timemanager/ClockCommon.cpp index ca8b12a4..45755f35 100644 --- a/src/fsfw/timemanager/ClockCommon.cpp +++ b/src/fsfw/timemanager/ClockCommon.cpp @@ -10,7 +10,7 @@ bool Clock::leapSecondsSet = false; ReturnValue_t Clock::convertUTCToTT(timeval utc, timeval* tt) { uint16_t leapSeconds; ReturnValue_t result = getLeapSeconds(&leapSeconds); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } timeval leapSeconds_timeval = {0, 0}; @@ -23,33 +23,33 @@ ReturnValue_t Clock::convertUTCToTT(timeval utc, timeval* tt) { *tt = utc + leapSeconds_timeval + UTCtoTAI1972 + TAItoTT; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) { - if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_FAILED; + if (checkOrCreateClockMutex() != returnvalue::OK) { + return returnvalue::FAILED; } MutexGuard helper(timeMutex); leapSeconds = leapSeconds_; leapSecondsSet = true; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) { if (not leapSecondsSet) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_FAILED; + if (checkOrCreateClockMutex() != returnvalue::OK) { + return returnvalue::FAILED; } MutexGuard helper(timeMutex); *leapSeconds_ = leapSeconds; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimevalToTimeOfDay(const timeval* from, TimeOfDay_t* to) { @@ -58,7 +58,7 @@ ReturnValue_t Clock::convertTimevalToTimeOfDay(const timeval* from, TimeOfDay_t* // in the Windows CRT is incompatible with the C standard but this should not be an issue for // this implementation ReturnValue_t result = checkOrCreateClockMutex(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } MutexGuard helper(timeMutex); @@ -72,19 +72,19 @@ ReturnValue_t Clock::convertTimevalToTimeOfDay(const timeval* from, TimeOfDay_t* to->minute = timeInfo->tm_min; to->second = timeInfo->tm_sec; to->usecond = from->tv_usec; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::checkOrCreateClockMutex() { if (timeMutex == nullptr) { MutexFactory* mutexFactory = MutexFactory::instance(); if (mutexFactory == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } timeMutex = mutexFactory->createMutex(); if (timeMutex == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/timemanager/TimeStamper.cpp b/src/fsfw/timemanager/TimeStamper.cpp index 9b4ad3d3..99cbdd70 100644 --- a/src/fsfw/timemanager/TimeStamper.cpp +++ b/src/fsfw/timemanager/TimeStamper.cpp @@ -8,14 +8,14 @@ TimeStamper::TimeStamper(object_id_t objectId) : SystemObject(objectId) {} ReturnValue_t TimeStamper::addTimeStamp(uint8_t* buffer, const uint8_t maxSize) { if (maxSize < TimeStamperIF::MISSION_TIMESTAMP_SIZE) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } timeval now; Clock::getClock_timeval(&now); CCSDSTime::CDS_short cds; ReturnValue_t result = CCSDSTime::convertToCcsds(&cds, &now); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } std::memcpy(buffer, &cds, sizeof(cds)); diff --git a/src/fsfw/tmstorage/TmStoreMessage.cpp b/src/fsfw/tmstorage/TmStoreMessage.cpp index a6bab6c5..6165df6d 100644 --- a/src/fsfw/tmstorage/TmStoreMessage.cpp +++ b/src/fsfw/tmstorage/TmStoreMessage.cpp @@ -9,13 +9,13 @@ TmStoreMessage::TmStoreMessage() {} ReturnValue_t TmStoreMessage::setEnableStoringMessage(CommandMessage* cmd, bool setEnabled) { cmd->setCommand(ENABLE_STORING); cmd->setParameter(setEnabled); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmStoreMessage::setDeleteContentMessage(CommandMessage* cmd, ApidSsc upTo) { cmd->setCommand(DELETE_STORE_CONTENT); cmd->setParameter((upTo.apid << 16) + upTo.ssc); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmStoreMessage::setDownlinkContentMessage(CommandMessage* cmd, ApidSsc fromPacket, @@ -23,7 +23,7 @@ ReturnValue_t TmStoreMessage::setDownlinkContentMessage(CommandMessage* cmd, Api cmd->setCommand(DOWNLINK_STORE_CONTENT); cmd->setParameter((fromPacket.apid << 16) + fromPacket.ssc); cmd->setParameter2((toPacket.apid << 16) + toPacket.ssc); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ApidSsc TmStoreMessage::getPacketId1(CommandMessage* cmd) { @@ -86,7 +86,7 @@ bool TmStoreMessage::getAddToSelection(CommandMessage* cmd) { return (bool)cmd-> ReturnValue_t TmStoreMessage::setReportSelectionDefinitionMessage(CommandMessage* cmd) { cmd->setCommand(REPORT_SELECTION_DEFINITION); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TmStoreMessage::setSelectionDefinitionReportMessage(CommandMessage* cmd, @@ -97,7 +97,7 @@ void TmStoreMessage::setSelectionDefinitionReportMessage(CommandMessage* cmd, ReturnValue_t TmStoreMessage::setReportStoreCatalogueMessage(CommandMessage* cmd) { cmd->setCommand(REPORT_STORE_CATALOGUE); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TmStoreMessage::setStoreCatalogueReportMessage(CommandMessage* cmd, object_id_t objectId, @@ -127,18 +127,18 @@ ReturnValue_t TmStoreMessage::setDeleteBlocksMessage(CommandMessage* cmd, uint32 cmd->setCommand(DELETE_STORE_CONTENT_BLOCKS); cmd->setParameter(addressLow); cmd->setParameter2(addressHigh); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmStoreMessage::setDownlinkBlocksMessage(CommandMessage* cmd, uint32_t addressLow, uint32_t addressHigh) { cmd->setCommand(DOWNLINK_STORE_CONTENT_BLOCKS); cmd->setParameter(addressLow); cmd->setParameter2(addressHigh); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmStoreMessage::setIndexRequestMessage(CommandMessage* cmd) { cmd->setCommand(REPORT_INDEX_REQUEST); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TmStoreMessage::setIndexReportMessage(CommandMessage* cmd, store_address_t storeId) { diff --git a/src/fsfw/tmstorage/TmStorePackets.h b/src/fsfw/tmstorage/TmStorePackets.h index d54b7b52..8a2dfaf3 100644 --- a/src/fsfw/tmstorage/TmStorePackets.h +++ b/src/fsfw/tmstorage/TmStorePackets.h @@ -32,7 +32,7 @@ class ApidSsc : public SerializeIF { Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::serialize(&ssc, buffer, size, maxSize, streamEndianness); @@ -42,7 +42,7 @@ class ApidSsc : public SerializeIF { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::deSerialize(&ssc, buffer, size, streamEndianness); @@ -87,7 +87,7 @@ class TmPacketInformation : public SerializeIF { const uint8_t* pField = NULL; uint32_t size = 0; ReturnValue_t result = packet->getPacketTimeRaw(&pField, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } if (*pField == CCSDSTime::P_FIELD_CDS_SHORT && size <= TimeStamperIF::MISSION_TIMESTAMP_SIZE) { @@ -97,13 +97,13 @@ class TmPacketInformation : public SerializeIF { } timeval time = {0, 0}; result = packet->getPacketTime(&time); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } CCSDSTime::CDS_short cdsFormat; result = CCSDSTime::convertToCcsds(&cdsFormat, &time); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } memcpy(rawTimestamp, &cdsFormat, sizeof(cdsFormat)); @@ -196,24 +196,24 @@ class TmPacketInformation : public SerializeIF { Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&sourceSequenceCount, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&serviceType, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&serviceSubtype, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&subCounter, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } SerialBufferAdapter adapter(rawTimestamp, sizeof(rawTimestamp)); @@ -234,23 +234,23 @@ class TmPacketInformation : public SerializeIF { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&sourceSequenceCount, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&serviceType, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&serviceSubtype, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&subCounter, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } SerialBufferAdapter adapter(rawTimestamp, sizeof(rawTimestamp)); diff --git a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h index 364feb4e..a1fc77e8 100644 --- a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h +++ b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h @@ -23,7 +23,7 @@ class RedirectableDataPointerIF { * @param args Any additional user arguments required to set the data pointer * @return * - RETURN_OK if the pointer was set successfully - * - RETURN_FAILED on general error of if the maximum size is too small + * - returnvalue::FAILED on general error of if the maximum size is too small */ virtual ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) = 0; diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.cpp b/src/fsfw/tmtcpacket/SpacePacketBase.cpp index 756d7e50..e02417d8 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketBase.cpp @@ -25,7 +25,7 @@ ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool ha sif::printWarning("SpacePacketBase::initSpacePacketHeader: Data pointer is invalid!\n"); #endif #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // reset header to zero: memset(data, 0, sizeof(this->data->header)); @@ -37,7 +37,7 @@ ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool ha // Always initialize as standalone packets. data->header.sequence_control_h = 0b11000000; setPacketSequenceCount(sequenceCount); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool SpacePacketBase::isTelecommand(void) { @@ -111,8 +111,8 @@ uint8_t* SpacePacketBase::getPacketData() { return &(data->packet_data); } ReturnValue_t SpacePacketBase::setData(uint8_t* pData, size_t maxSize, void* args) { if (maxSize < 6) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->data = reinterpret_cast(const_cast(pData)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp index 9a410b40..6e0f7b22 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp @@ -16,7 +16,7 @@ CFDPPacketStored::CFDPPacketStored(const uint8_t* data, size_t size) : CFDPPacke } if (this->checkAndSetStore()) { ReturnValue_t status = store->addData(&storeAddress, data, size); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { this->setData(nullptr, -1); } const uint8_t* storePtr = nullptr; @@ -41,11 +41,11 @@ void CFDPPacketStored::setStoreAddress(store_address_t setAddress) { this->storeAddress = setAddress; const uint8_t* tempData = nullptr; size_t tempSize; - ReturnValue_t status = StorageManagerIF::RETURN_FAILED; + ReturnValue_t status = returnvalue::FAILED; if (this->checkAndSetStore()) { status = this->store->getData(this->storeAddress, &tempData, &tempSize); } - if (status == StorageManagerIF::RETURN_OK) { + if (status == returnvalue::OK) { this->setData(const_cast(tempData), tempSize); } else { // To circumvent size checks @@ -59,11 +59,11 @@ store_address_t CFDPPacketStored::getStoreAddress() { return this->storeAddress; CFDPPacketStored::~CFDPPacketStored() {} ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSize) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // ReturnValue_t CFDPPacketStored::setData(const uint8_t *data) { -// return HasReturnvaluesIF::RETURN_OK; +// return returnvalue::OK; // } bool CFDPPacketStored::checkAndSetStore() { @@ -82,8 +82,8 @@ bool CFDPPacketStored::checkAndSetStore() { bool CFDPPacketStored::isSizeCorrect() { const uint8_t* temp_data = nullptr; size_t temp_size; - ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data, &temp_size); - if (status == StorageManagerIF::RETURN_OK) { + ReturnValue_t status = store->getData(this->storeAddress, &temp_data, &temp_size); + if (status == returnvalue::OK) { if (this->getFullSize() == temp_size) { return true; } diff --git a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp index 6b900030..e4688590 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp +++ b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp @@ -41,7 +41,7 @@ ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t sub findOrInsertMatch(this->begin(), &testPacket, &lastTest); if (result == NEW_NODE_CREATED) { rollback = lastTest; - } else if (result != RETURN_OK) { + } else if (result != returnvalue::OK) { return result; } if (type == 0) { @@ -50,7 +50,7 @@ ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t sub if (lastTest.left() != this->end()) { removeElementAndAllChildren(lastTest.left()); } - return RETURN_OK; + return returnvalue::OK; } // Type insertion required. result = @@ -59,7 +59,7 @@ ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t sub if (rollback == this->end()) { rollback = lastTest; } - } else if (result != RETURN_OK) { + } else if (result != returnvalue::OK) { if (rollback != this->end()) { removeElementAndAllChildren(rollback); } @@ -70,20 +70,20 @@ ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t sub // See above removeElementAndAllChildren(lastTest.left()); } - return RETURN_OK; + return returnvalue::OK; } // Subtype insertion required. result = findOrInsertMatch(lastTest.left(), &testPacket, &lastTest); if (result == NEW_NODE_CREATED) { - return RETURN_OK; - } else if (result != RETURN_OK) { + return returnvalue::OK; + } else if (result != returnvalue::OK) { if (rollback != this->end()) { removeElementAndAllChildren(rollback); } return result; } - return RETURN_OK; + return returnvalue::OK; } template @@ -96,7 +96,7 @@ ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test, attachToBranch = OR; *lastTest = iter; if (isMatch) { - return RETURN_OK; + return returnvalue::OK; } else { // Go down OR branch. iter = iter.right(); @@ -116,7 +116,7 @@ ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test, *lastTest = insert(attachToBranch, *lastTest, newNode); if (*lastTest == end()) { // This actaully never fails, so creating a dedicated returncode seems an overshoot. - return RETURN_FAILED; + return returnvalue::FAILED; } return NEW_NODE_CREATED; } diff --git a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h index 0cbd4494..e8727d71 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h +++ b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h @@ -6,7 +6,7 @@ #include "fsfw/storagemanager/LocalPool.h" #include "fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h" -class PacketMatchTree : public MatchTree, public HasReturnvaluesIF { +class PacketMatchTree : public MatchTree { public: PacketMatchTree(Node* root); PacketMatchTree(iterator root); diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp index f5ebe38c..7120e62f 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp @@ -86,14 +86,14 @@ size_t TcPacketPus::calculateFullPacketLength(size_t appDataLen) const { ReturnValue_t TcPacketPus::setData(uint8_t *dataPtr, size_t maxSize, void *args) { ReturnValue_t result = SpacePacketBase::setData(dataPtr, maxSize); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (maxSize < sizeof(TcPacketPointer)) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // This function is const-correct, but it was decided to keep the pointer non-const // for convenience. Therefore, cast away constness here and then cast to packet type. tcData = reinterpret_cast(const_cast(dataPtr)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp index 22918526..b7443b01 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.cpp @@ -17,7 +17,7 @@ TcPacketStoredBase::~TcPacketStoredBase() = default; ReturnValue_t TcPacketStoredBase::getData(const uint8_t** dataPtr, size_t* dataSize) { auto result = TcPacketStoredBase::STORE->getData(storeAddress, dataPtr, dataSize); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TcPacketStoredBase: Could not get data" << std::endl; #else @@ -47,12 +47,12 @@ void TcPacketStoredBase::setStoreAddress(store_address_t setAddress, this->storeAddress = setAddress; const uint8_t* tempData = nullptr; size_t tempSize; - ReturnValue_t status = StorageManagerIF::RETURN_FAILED; + ReturnValue_t status = returnvalue::FAILED; if (this->checkAndSetStore()) { status = TcPacketStoredBase::STORE->getData(this->storeAddress, &tempData, &tempSize); } - if (status == StorageManagerIF::RETURN_OK) { + if (status == returnvalue::OK) { packet->setData(const_cast(tempData), tempSize); } else { packet->setData(nullptr, -1); diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp index 643c2ecc..d25486e5 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp @@ -15,7 +15,7 @@ TcPacketStoredPus::TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t sub uint8_t* pData = nullptr; ReturnValue_t returnValue = this->STORE->getFreeElement(&this->storeAddress, (TC_PACKET_MIN_SIZE + size), &pData); - if (returnValue != this->STORE->RETURN_OK) { + if (returnValue != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TcPacketStoredBase: Could not get free element from store!" << std::endl; #endif @@ -45,7 +45,7 @@ TcPacketStoredPus::TcPacketStoredPus(const uint8_t* data, size_t size) : TcPacke } if (this->checkAndSetStore()) { ReturnValue_t status = STORE->addData(&storeAddress, data, size); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { this->setData(nullptr, size); } const uint8_t* storePtr = nullptr; @@ -69,7 +69,7 @@ bool TcPacketStoredPus::isSizeCorrect() { const uint8_t* temp_data = nullptr; size_t temp_size; ReturnValue_t status = this->STORE->getData(this->storeAddress, &temp_data, &temp_size); - if (status == StorageManagerIF::RETURN_OK) { + if (status == returnvalue::OK) { if (this->getFullSize() == temp_size) { return true; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp index 388a4098..80f28878 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp @@ -19,14 +19,14 @@ uint8_t TmPacketMinimal::getPacketSubcounter() { return tm_data->data_field.subc ReturnValue_t TmPacketMinimal::getPacketTime(timeval* timestamp) { if (timestampInterpreter == NULL) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return timestampInterpreter->getPacketTime(this, timestamp); } ReturnValue_t TmPacketMinimal::getPacketTimeRaw(const uint8_t** timePtr, uint32_t* size) { if (timestampInterpreter == NULL) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return timestampInterpreter->getPacketTimeRaw(this, timePtr, size); } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp index e8f71717..be9cc39d 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp @@ -30,11 +30,11 @@ uint16_t TmPacketPusA::getSourceDataSize() { ReturnValue_t TmPacketPusA::setData(uint8_t* p_Data, size_t maxSize, void* args) { ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } tmData = reinterpret_cast(const_cast(p_Data)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t TmPacketPusA::getPacketMinimumSize() const { return TM_PACKET_MIN_SIZE; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp index ab690414..00c889e3 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp @@ -30,14 +30,14 @@ uint16_t TmPacketPusC::getSourceDataSize() { ReturnValue_t TmPacketPusC::setData(uint8_t* p_Data, size_t maxSize, void* args) { ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (maxSize < sizeof(TmPacketPointerPusC)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } tmData = reinterpret_cast(const_cast(p_Data)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t TmPacketPusC::getPacketMinimumSize() const { return TM_PACKET_MIN_SIZE; } @@ -51,7 +51,7 @@ ReturnValue_t TmPacketPusC::initializeTmPacket(uint16_t apid, uint8_t service, u uint8_t timeRefField) { // Set primary header: ReturnValue_t result = initSpacePacketHeader(false, true, apid); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } // Set data Field Header: @@ -72,7 +72,7 @@ ReturnValue_t TmPacketPusC::initializeTmPacket(uint16_t apid, uint8_t service, u if (TmPacketBase::checkAndSetStamper()) { timeStamper->addTimeStamp(tmData->dataField.time, sizeof(tmData->dataField.time)); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TmPacketPusC::setSourceDataSize(uint16_t size) { diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp index 4d37bf46..44e25e16 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.cpp @@ -33,7 +33,7 @@ void TmPacketStoredBase::setStoreAddress(store_address_t setAddress) { return; } ReturnValue_t status = store->getData(storeAddress, &tempData, &tempSize); - if (status == StorageManagerIF::RETURN_OK) { + if (status == returnvalue::OK) { setData(const_cast(tempData), tempSize); } else { setData(nullptr, -1); @@ -58,11 +58,11 @@ ReturnValue_t TmPacketStoredBase::sendPacket(MessageQueueId_t destination, MessageQueueId_t sentFrom, bool doErrorReporting) { if (getAllTmData() == nullptr) { // SHOULDDO: More decent code. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } TmTcMessage tmMessage(getStoreAddress()); ReturnValue_t result = MessageQueueSenderIF::sendMessage(destination, &tmMessage, sentFrom); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { deletePacket(); if (doErrorReporting) { checkAndReportLostTm(); @@ -71,7 +71,7 @@ ReturnValue_t TmPacketStoredBase::sendPacket(MessageQueueId_t destination, } // SHOULDDO: In many cases, some counter is incremented for successfully sent packets. The check // is often not done, but just incremented. - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TmPacketStoredBase::checkAndReportLostTm() { diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp index 37ba63f3..4d9da5a9 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusA.cpp @@ -20,7 +20,7 @@ TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service, uint8_t s size_t sizeToReserve = getPacketMinimumSize() + size + headerSize; ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData); - if (returnValue != store->RETURN_OK) { + if (returnValue != returnvalue::OK) { handleStoreFailure("A", returnValue, sizeToReserve); return; } @@ -49,7 +49,7 @@ TmPacketStoredPusA::TmPacketStoredPusA(uint16_t apid, uint8_t service, uint8_t s uint8_t *pData = nullptr; size_t sizeToReserve = getPacketMinimumSize() + sourceDataSize; ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData); - if (returnValue != store->RETURN_OK) { + if (returnValue != returnvalue::OK) { handleStoreFailure("A", returnValue, sizeToReserve); return; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp index 9c170aa3..55a5637a 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp @@ -22,7 +22,7 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t s size_t sizeToReserve = getPacketMinimumSize() + size + headerSize; ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData); - if (returnValue != store->RETURN_OK) { + if (returnValue != returnvalue::OK) { handleStoreFailure("C", returnValue, sizeToReserve); return; } @@ -52,7 +52,7 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t s uint8_t *pData = nullptr; size_t sizeToReserve = getPacketMinimumSize() + sourceDataSize; ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData); - if (returnValue != store->RETURN_OK) { + if (returnValue != returnvalue::OK) { handleStoreFailure("C", returnValue, sizeToReserve); return; } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index bbdf8d2a..4cecf53b 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -42,7 +42,7 @@ ReturnValue_t CommandingServiceBase::performOperation(uint8_t opCode) { handleRequestQueue(); checkTimeout(); doPeriodicOperation(); - return RETURN_OK; + return returnvalue::OK; } uint16_t CommandingServiceBase::getIdentifier() { return service; } @@ -51,7 +51,7 @@ MessageQueueId_t CommandingServiceBase::getRequestQueue() { return requestQueue- ReturnValue_t CommandingServiceBase::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -90,15 +90,15 @@ ReturnValue_t CommandingServiceBase::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - return RETURN_OK; + return returnvalue::OK; } void CommandingServiceBase::handleCommandQueue() { CommandMessage reply; - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; while (true) { result = commandQueue->receiveMessage(&reply); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { handleCommandMessage(&reply); continue; } else if (result == MessageQueueIF::EMPTY) { @@ -138,18 +138,18 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) { iter->second.objectId, &isStep); /* If the child implementation does not implement special handling for - * rejected replies (RETURN_FAILED or INVALID_REPLY is returned), a + * rejected replies (returnvalue::FAILED or INVALID_REPLY is returned), a * failure verification will be generated with the reason as the * return code and the initial command as failure parameter 1 */ if ((reply->getCommand() == CommandMessage::REPLY_REJECTED) and - (result == RETURN_FAILED or result == INVALID_REPLY)) { + (result == returnvalue::FAILED or result == INVALID_REPLY)) { result = reply->getReplyRejectedReason(); failureParameter1 = iter->second.command; } switch (result) { case EXECUTION_COMPLETE: - case RETURN_OK: + case returnvalue::OK: case NO_STEP_MESSAGE: // handle result of reply handler implemented by developer. handleReplyHandlerResult(result, iter, &nextCommand, reply, isStep); @@ -185,12 +185,12 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, Comma // In case a new command is to be sent immediately, this is performed here. // If no new command is sent, only analyse reply result by initializing // sendResult as RETURN_OK - ReturnValue_t sendResult = RETURN_OK; + ReturnValue_t sendResult = returnvalue::OK; if (nextCommand->getCommand() != CommandMessage::CMD_NONE) { sendResult = commandQueue->sendMessage(reply->getSender(), nextCommand); } - if (sendResult == RETURN_OK) { + if (sendResult == returnvalue::OK) { if (isStep and result != NO_STEP_MESSAGE) { verificationReporter.sendSuccessReport( tc_verification::PROGRESS_SUCCESS, iter->second.tcInfo.ackFlags, @@ -229,19 +229,19 @@ void CommandingServiceBase::handleRequestQueue() { TcPacketStoredPus packet; MessageQueueId_t queue; object_id_t objectId; - for (result = requestQueue->receiveMessage(&message); result == RETURN_OK; + for (result = requestQueue->receiveMessage(&message); result == returnvalue::OK; result = requestQueue->receiveMessage(&message)) { address = message.getStorageId(); packet.setStoreAddress(address, &packet); - if ((packet.getSubService() == 0) or (isValidSubservice(packet.getSubService()) != RETURN_OK)) { + if ((packet.getSubService() == 0) or (isValidSubservice(packet.getSubService()) != returnvalue::OK)) { rejectPacket(tc_verification::START_FAILURE, &packet, INVALID_SUBSERVICE); continue; } result = getMessageQueueAndObject(packet.getSubService(), packet.getApplicationData(), packet.getApplicationDataSize(), &queue, &objectId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { rejectPacket(tc_verification::START_FAILURE, &packet, result); continue; } @@ -252,14 +252,14 @@ void CommandingServiceBase::handleRequestQueue() { if (iter != commandMap.end()) { result = iter->second.fifo.insert(address); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { rejectPacket(tc_verification::START_FAILURE, &packet, OBJECT_BUSY); } } else { CommandInfo newInfo; // Info will be set by startExecution if neccessary newInfo.objectId = objectId; result = commandMap.insert(queue, newInfo, &iter); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { rejectPacket(tc_verification::START_FAILURE, &packet, BUSY); } else { startExecution(&packet, iter); @@ -280,7 +280,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, const uint #endif ReturnValue_t result = tmPacketStored.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { this->tmPacketCounter++; } return result; @@ -302,7 +302,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_ #endif ReturnValue_t result = tmPacketStored.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { this->tmPacketCounter++; } return result; @@ -319,14 +319,14 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeI #endif ReturnValue_t result = tmPacketStored.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId()); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { this->tmPacketCounter++; } return result; } void CommandingServiceBase::startExecution(TcPacketStoredPus* storedPacket, CommandMapIter iter) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; CommandMessage command; // TcPacketPusBase* tcPacketBase = storedPacket->getPacketBase(); if (storedPacket == nullptr) { @@ -337,13 +337,13 @@ void CommandingServiceBase::startExecution(TcPacketStoredPus* storedPacket, Comm storedPacket->getApplicationDataSize(), &iter->second.state, iter->second.objectId); - ReturnValue_t sendResult = RETURN_OK; + ReturnValue_t sendResult = returnvalue::OK; switch (result) { - case RETURN_OK: + case returnvalue::OK: if (command.getCommand() != CommandMessage::CMD_NONE) { sendResult = commandQueue->sendMessage(iter.value->first, &command); } - if (sendResult == RETURN_OK) { + if (sendResult == returnvalue::OK) { Clock::getUptime(&iter->second.uptimeOfStart); iter->second.step = 0; iter->second.subservice = storedPacket->getSubService(); @@ -363,7 +363,7 @@ void CommandingServiceBase::startExecution(TcPacketStoredPus* storedPacket, Comm // Fire-and-forget command. sendResult = commandQueue->sendMessage(iter.value->first, &command); } - if (sendResult == RETURN_OK) { + if (sendResult == returnvalue::OK) { verificationReporter.sendSuccessReport(tc_verification::START_SUCCESS, storedPacket->getPacketBase()); acceptPacket(tc_verification::COMPLETION_SUCCESS, storedPacket); @@ -395,7 +395,7 @@ void CommandingServiceBase::acceptPacket(uint8_t reportId, TcPacketStoredPus* pa void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) { store_address_t address; - if (iter->second.fifo.retrieve(&address) != RETURN_OK) { + if (iter->second.fifo.retrieve(&address) != returnvalue::OK) { commandMap.erase(&iter); } else { TcPacketStoredPus newPacket(address); diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 4dcad024..73b42259 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -36,8 +36,7 @@ void setStaticFrameworkObjectIds(); */ class CommandingServiceBase : public SystemObject, public AcceptsTelecommandsIF, - public ExecutableObjectIF, - public HasReturnvaluesIF { + public ExecutableObjectIF { friend void(Factory::setStaticFrameworkObjectIds)(); public: @@ -145,7 +144,7 @@ class CommandingServiceBase : public SystemObject, * @param objectId Object ID is extracted and stored here * @return * - @c RETURN_OK Cotinue message handling - * - @c RETURN_FAILED Reject the packet and generates a start failure + * - @c returnvalue::FAILED Reject the packet and generates a start failure * verification */ virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice, const uint8_t* tcData, @@ -193,7 +192,7 @@ class CommandingServiceBase : public SystemObject, * - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to * generate TC verification success * - @c INVALID_REPLY Calls handleUnrequestedReply - * - Anything else triggers a TC verification failure. If RETURN_FAILED or + * - Anything else triggers a TC verification failure. If returnvalue::FAILED or * INVALID_REPLY is returned and the command ID is * CommandMessage::REPLY_REJECTED, a failure verification message with * the reason as the error parameter and the initial command as @@ -232,14 +231,14 @@ class CommandingServiceBase : public SystemObject, virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; }; virtual size_t getSerializedSize() const override { return 0; }; virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; }; }; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 3af2b82c..0ee358b0 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -21,21 +21,21 @@ PusServiceBase::~PusServiceBase() { QueueFactory::instance()->deleteMessageQueue ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { handleRequestQueue(); ReturnValue_t result = this->performService(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PusService " << (uint16_t)this->serviceId << ": performService returned with " << (int16_t)result << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } void PusServiceBase::setTaskIF(PeriodicTaskIF* taskHandle) { this->taskHandle = taskHandle; } void PusServiceBase::handleRequestQueue() { TmTcMessage message; - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) { ReturnValue_t status = this->requestQueue->receiveMessage(&message); // if(status != MessageQueueIF::EMPTY) { @@ -48,7 +48,7 @@ void PusServiceBase::handleRequestQueue() { #endif // } - if (status == RETURN_OK) { + if (status == returnvalue::OK) { this->currentPacket.setStoreAddress(message.getStorageId(), ¤tPacket); // info << "Service " << (uint16_t) this->serviceId << // ": new packet!" << std::endl; @@ -57,7 +57,7 @@ void PusServiceBase::handleRequestQueue() { // debug << "Service " << (uint16_t)this->serviceId << // ": handleRequest returned: " << (int)return_code << std::endl; - if (result == RETURN_OK) { + if (result == returnvalue::OK) { this->verifyReporter.sendSuccessReport(tc_verification::COMPLETION_SUCCESS, &this->currentPacket); } else { @@ -69,7 +69,7 @@ void PusServiceBase::handleRequestQueue() { errorParameter1 = 0; errorParameter2 = 0; } else if (status == MessageQueueIF::EMPTY) { - status = RETURN_OK; + status = returnvalue::OK; // debug << "PusService " << (uint16_t)this->serviceId << // ": no new packet." << std::endl; break; @@ -89,7 +89,7 @@ MessageQueueId_t PusServiceBase::getRequestQueue() { return this->requestQueue-> ReturnValue_t PusServiceBase::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } AcceptsTelemetryIF* destService = @@ -105,12 +105,12 @@ ReturnValue_t PusServiceBase::initialize() { } this->requestQueue->setDefaultDestination(destService->getReportReceptionQueue()); distributor->registerService(this); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t PusServiceBase::initializeAfterTaskCreation() { // If task parameters, for example task frequency are required, this // function should be overriden and the system object task IF can // be used to get those parameters. - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 9db1bef0..6271f267 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -35,8 +35,7 @@ void setStaticFrameworkObjectIds(); */ class PusServiceBase : public ExecutableObjectIF, public AcceptsTelecommandsIF, - public SystemObject, - public HasReturnvaluesIF { + public SystemObject { friend void(Factory::setStaticFrameworkObjectIds)(); public: @@ -94,7 +93,7 @@ class PusServiceBase : public ExecutableObjectIF, * the TC requests afterwards. * performService is always executed afterwards. * @return @c RETURN_OK if the periodic performService was successful. - * @c RETURN_FAILED else. + * @c returnvalue::FAILED else. */ ReturnValue_t performOperation(uint8_t opCode) override; virtual uint16_t getIdentifier() override; diff --git a/src/fsfw/tmtcservices/SpacePacketParser.cpp b/src/fsfw/tmtcservices/SpacePacketParser.cpp index 4c10ae9e..b8364138 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.cpp +++ b/src/fsfw/tmtcservices/SpacePacketParser.cpp @@ -22,7 +22,7 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const #else sif::printWarning("SpacePacketParser::parseSpacePackets: Frame invalid\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } const uint8_t* bufPtr = *buffer; @@ -30,7 +30,7 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const uint16_t lengthField = bufPtr[idx + 4] << 8 | bufPtr[idx + 5]; size_t packetSize = lengthField + 7; startIndex = idx; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (lengthField == 0) { // Skip whole header for now foundSize = 6; diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index 8ea67119..0d50ebe2 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -23,28 +23,28 @@ TmTcBridge::~TmTcBridge() { QueueFactory::instance()->deleteMessageQueue(tmTcRec ReturnValue_t TmTcBridge::setNumberOfSentPacketsPerCycle(uint8_t sentPacketsPerCycle) { if (sentPacketsPerCycle <= LIMIT_STORED_DATA_SENT_PER_CYCLE) { this->sentPacketsPerCycle = sentPacketsPerCycle; - return RETURN_OK; + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TmTcBridge::setNumberOfSentPacketsPerCycle: Number of " << "packets sent per cycle exceeds limits. " << "Keeping default value." << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored) { if (maxNumberOfPacketsStored <= LIMIT_DOWNLINK_PACKETS_STORED) { this->maxNumberOfPacketsStored = maxNumberOfPacketsStored; - return RETURN_OK; + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TmTcBridge::setMaxNumberOfPacketsStored: Number of " << "packets stored exceeds limits. " << "Keeping default value." << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } } @@ -79,20 +79,20 @@ ReturnValue_t TmTcBridge::initialize() { tmFifo = new DynamicFIFO(maxNumberOfPacketsStored); tmTcReceptionQueue->setDefaultDestination(tcDistributor->getRequestQueue()); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmTcBridge::performOperation(uint8_t operationCode) { ReturnValue_t result; result = handleTc(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "TmTcBridge::performOperation: " << "Error handling TCs" << std::endl; #endif } result = handleTm(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "TmTcBridge::performOperation: " << "Error handling TMs" << std::endl; @@ -101,12 +101,12 @@ ReturnValue_t TmTcBridge::performOperation(uint8_t operationCode) { return result; } -ReturnValue_t TmTcBridge::handleTc() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t TmTcBridge::handleTc() { return returnvalue::OK; } ReturnValue_t TmTcBridge::handleTm() { - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; ReturnValue_t result = handleTmQueue(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::handleTm: Error handling TM queue with error code 0x" << std::hex << result << std::dec << "!" << std::endl; @@ -116,7 +116,7 @@ ReturnValue_t TmTcBridge::handleTm() { if (tmStored and communicationLinkUp and (packetSentCounter < sentPacketsPerCycle)) { result = handleStoredTm(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::handleTm: Error handling stored TMs!" << std::endl; #endif @@ -131,9 +131,9 @@ ReturnValue_t TmTcBridge::handleTmQueue() { TmTcMessage message; const uint8_t* data = nullptr; size_t size = 0; - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; for (ReturnValue_t result = tmTcReceptionQueue->receiveMessage(&message); - result == HasReturnvaluesIF::RETURN_OK; + result == returnvalue::OK; result = tmTcReceptionQueue->receiveMessage(&message)) { #if FSFW_VERBOSE_LEVEL >= 3 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -149,13 +149,13 @@ ReturnValue_t TmTcBridge::handleTmQueue() { } result = tmStore->getData(message.getStorageId(), &data, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; continue; } result = sendTm(data, size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } else { tmStore->deleteData(message.getStorageId()); @@ -168,7 +168,7 @@ ReturnValue_t TmTcBridge::handleTmQueue() { ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage* message) { store_address_t storeId = 0; if (tmFifo == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (tmFifo->full()) { @@ -185,18 +185,18 @@ ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage* message) { tmFifo->retrieve(&storeId); tmStore->deleteData(storeId); } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } storeId = message->getStorageId(); tmFifo->insert(storeId); tmStored = true; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmTcBridge::handleStoredTm() { - ReturnValue_t status = RETURN_OK; + ReturnValue_t status = returnvalue::OK; while (not tmFifo->empty() and packetSentCounter < sentPacketsPerCycle) { #if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::info << "TMTC Bridge: Sending stored TM data. There are " @@ -208,12 +208,12 @@ ReturnValue_t TmTcBridge::handleStoredTm() { size_t size = 0; tmFifo->retrieve(&storeId); ReturnValue_t result = tmStore->getData(storeId, &data, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } result = sendTm(data, size); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TMTC Bridge: Could not send stored downlink data" << std::endl; #endif diff --git a/src/fsfw/tmtcservices/TmTcBridge.h b/src/fsfw/tmtcservices/TmTcBridge.h index 237f1f3e..3ebdac95 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.h +++ b/src/fsfw/tmtcservices/TmTcBridge.h @@ -13,7 +13,6 @@ class TmTcBridge : public AcceptsTelemetryIF, public AcceptsTelecommandsIF, public ExecutableObjectIF, - public HasReturnvaluesIF, public SystemObject { public: static constexpr uint8_t TMTC_RECEPTION_QUEUE_DEPTH = 20; @@ -32,7 +31,7 @@ class TmTcBridge : public AcceptsTelemetryIF, * value must be smaller than MAX_STORED_DATA_SENT_PER_CYCLE * @param sentPacketsPerCycle * @return -@c RETURN_OK if value was set successfully - * -@c RETURN_FAILED otherwise, stored value stays the same + * -@c returnvalue::FAILED otherwise, stored value stays the same */ ReturnValue_t setNumberOfSentPacketsPerCycle(uint8_t sentPacketsPerCycle); @@ -41,7 +40,7 @@ class TmTcBridge : public AcceptsTelemetryIF, * value must be smaller than MAX_DOWNLINK_PACKETS_STORED * @param sentPacketsPerCycle * @return -@c RETURN_OK if value was set successfully - * -@c RETURN_FAILED otherwise, stored value stays the same + * -@c returnvalue::FAILED otherwise, stored value stays the same */ ReturnValue_t setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored); diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 9d06adc4..f833b445 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -25,7 +25,7 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, TcPacketPusB currentPacket->getPacketId(), currentPacket->getPacketSequenceControl(), 0, set_step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendSuccessReport: Error writing " << "to queue. Code: " << std::hex << status << std::dec << std::endl; @@ -42,7 +42,7 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, uint8_t ackF PusVerificationMessage message(set_report_id, ackFlags, tcPacketId, tcSequenceControl, 0, set_step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendSuccessReport: Error writing " << "to queue. Code: " << std::hex << status << std::dec << std::endl; @@ -63,7 +63,7 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, TcPacketPusBase* report_id, currentPacket->getAcknowledgeFlags(), currentPacket->getPacketId(), currentPacket->getPacketSequenceControl(), error_code, step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendFailureReport: Error writing " << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; @@ -81,7 +81,7 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, uint8_t ackFlags PusVerificationMessage message(report_id, ackFlags, tcPacketId, tcSequenceControl, error_code, step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendFailureReport: Error writing " << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; diff --git a/src/fsfw_hal/common/gpio/GpioCookie.cpp b/src/fsfw_hal/common/gpio/GpioCookie.cpp index 4c4b4d14..f75ba4e8 100644 --- a/src/fsfw_hal/common/gpio/GpioCookie.cpp +++ b/src/fsfw_hal/common/gpio/GpioCookie.cpp @@ -11,7 +11,7 @@ ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) { #else sif::printWarning("GpioCookie::addGpio: gpioConfig is nullpointer\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } auto gpioMapIter = gpioMap.find(gpioId); if (gpioMapIter == gpioMap.end()) { @@ -25,9 +25,9 @@ ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) { sif::printWarning("GpioCookie::addGpio: Failed to add GPIO %d to GPIO map\n", gpioId); #endif #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -36,7 +36,7 @@ ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) { sif::printWarning("GpioCookie::addGpio: GPIO already exists in GPIO map\n"); #endif #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } GpioMap GpioCookie::getGpioMap() const { return gpioMap; } diff --git a/src/fsfw_hal/common/gpio/GpioIF.h b/src/fsfw_hal/common/gpio/GpioIF.h index 5cca1481..feb356f4 100644 --- a/src/fsfw_hal/common/gpio/GpioIF.h +++ b/src/fsfw_hal/common/gpio/GpioIF.h @@ -13,7 +13,7 @@ class GpioCookie; * over GPIOs. * @author J. Meier */ -class GpioIF : public HasReturnvaluesIF { +class GpioIF { public: virtual ~GpioIF(){}; @@ -29,7 +29,7 @@ class GpioIF : public HasReturnvaluesIF { * functionality to pull a certain GPIO to high logic level. * * @param gpioId A unique number which specifies the GPIO to drive. - * @return Returns RETURN_OK for success. This should never return RETURN_FAILED. + * @return Returns RETURN_OK for success. This should never return returnvalue::FAILED. */ virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0; diff --git a/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp b/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp index 94e1331c..1ffc60f1 100644 --- a/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp +++ b/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp @@ -70,9 +70,9 @@ ReturnValue_t GyroHandlerL3GD20H::buildTransitionDeviceCommand(DeviceCommandId_t "GyroL3GD20Handler::buildTransitionDeviceCommand: " "Unknown internal state!\n"); #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroHandlerL3GD20H::buildNormalDeviceCommand(DeviceCommandId_t *id) { @@ -135,7 +135,7 @@ ReturnValue_t GyroHandlerL3GD20H::buildCommandFromCommand(DeviceCommandId_t devi default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroHandlerL3GD20H::scanForReply(const uint8_t *start, size_t len, @@ -144,12 +144,12 @@ ReturnValue_t GyroHandlerL3GD20H::scanForReply(const uint8_t *start, size_t len, *foundId = this->getPendingCommand(); *foundLen = this->rawPacketLen; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (id) { case (L3GD20H::CONFIGURE_CTRL_REGS): { commandExecuted = true; @@ -207,7 +207,7 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id, } PoolReadGuard readSet(&dataset); - if (readSet.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + if (readSet.getReadResult() == returnvalue::OK) { if (std::abs(angVelocX) < this->absLimitX) { dataset.angVelocX = angVelocX; dataset.angVelocX.setValid(true); @@ -252,7 +252,7 @@ ReturnValue_t GyroHandlerL3GD20H::initializeLocalDataPool(localpool::DataPool &l localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Y, new PoolEntry({0.0})); localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Z, new PoolEntry({0.0})); localDataPoolMap.emplace(L3GD20H::TEMPERATURE, new PoolEntry({0.0})); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void GyroHandlerL3GD20H::fillCommandAndReplyMap() { diff --git a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index 5ddc3245..b4d64dbc 100644 --- a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -82,7 +82,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildTransitionDeviceCommand(DeviceCommandId_t #else sif::printWarning("GyroHandler::buildTransitionDeviceCommand: Unknown internal state!\n"); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } return buildCommandFromCommand(*id, NULL, 0); @@ -137,7 +137,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic rawPacket = commandBuffer; rawPacketLen = MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1; - return RETURN_OK; + return returnvalue::OK; } case (MGMLIS3MDL::READ_TEMPERATURE): { std::memset(commandBuffer, 0, 3); @@ -145,7 +145,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic rawPacket = commandBuffer; rawPacketLen = 3; - return RETURN_OK; + return returnvalue::OK; } case (MGMLIS3MDL::IDENTIFY_DEVICE): { return identifyDevice(); @@ -155,7 +155,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic } case (MGMLIS3MDL::SETUP_MGM): { setupMgm(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (MGMLIS3MDL::ACCURACY_OP_MODE_SET): { return setOperatingMode(commandData, commandDataLen); @@ -163,7 +163,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t MgmLIS3MDLHandler::identifyDevice() { @@ -174,7 +174,7 @@ ReturnValue_t MgmLIS3MDLHandler::identifyDevice() { rawPacket = commandBuffer; rawPacketLen = size; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len, @@ -234,7 +234,7 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len, /* Data with SPI Interface always has this answer */ if (start[0] == 0b11111111) { - return RETURN_OK; + return returnvalue::OK; } else { return DeviceHandlerIF::INVALID_DATA; } @@ -285,7 +285,7 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons } PoolReadGuard readHelper(&dataset); - if (readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + if (readHelper.getReadResult() == returnvalue::OK) { if (std::abs(mgmX) > absLimitX or std::abs(mgmY) > absLimitY or std::abs(mgmZ) > absLimitZ) { dataset.fieldStrengths.setValid(false); @@ -320,7 +320,7 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons } ReturnValue_t result = dataset.read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { dataset.temperature = tempValue; dataset.commit(); } @@ -331,7 +331,7 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } } - return RETURN_OK; + return returnvalue::OK; } MGMLIS3MDL::Sensitivies MgmLIS3MDLHandler::getSensitivity(uint8_t ctrlRegister2) { @@ -394,7 +394,7 @@ ReturnValue_t MgmLIS3MDLHandler::enableTemperatureSensor(const uint8_t *commandD rawPacket = commandBuffer; rawPacketLen = size; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmLIS3MDLHandler::setOperatingMode(const uint8_t *commandData, @@ -451,7 +451,7 @@ ReturnValue_t MgmLIS3MDLHandler::prepareCtrlRegisterWrite() { rawPacketLen = MGMLIS3MDL::NR_OF_CTRL_REGISTERS + 1; // We dont have to check if this is working because we just did i - return RETURN_OK; + return returnvalue::OK; } void MgmLIS3MDLHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { @@ -467,7 +467,7 @@ ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(localpool::DataPool &lo localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTHS, &mgmXYZ); localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, &temperature); poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 10.0, false); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void MgmLIS3MDLHandler::setAbsoluteLimits(float xLimit, float yLimit, float zLimit) { diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index c329f5a6..24e90c9f 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -93,7 +93,7 @@ ReturnValue_t MgmRM3100Handler::buildTransitionDeviceCommand(DeviceCommandId_t * "Unknown internal state\n"); #endif #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return buildCommandFromCommand(*id, commandBuffer, commandLen); @@ -146,7 +146,7 @@ ReturnValue_t MgmRM3100Handler::buildCommandFromCommand(DeviceCommandId_t device default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmRM3100Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { @@ -159,11 +159,11 @@ ReturnValue_t MgmRM3100Handler::scanForReply(const uint8_t *start, size_t len, // For SPI, ID will always be the one of the last sent command *foundId = this->getPendingCommand(); *foundLen = len; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (id) { case (RM3100::CONFIGURE_CMM): case (RM3100::CONFIGURE_CYCLE_COUNT): @@ -250,7 +250,7 @@ ReturnValue_t MgmRM3100Handler::handleCycleCountConfigCommand(DeviceCommandId_t std::memcpy(commandBuffer + 5, &cycleCountRegValueZ, 2); rawPacketLen = 7; rawPacket = commandBuffer; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmRM3100Handler::handleCycleCommand(bool oneCycleValue, const uint8_t *commandData, @@ -258,7 +258,7 @@ ReturnValue_t MgmRM3100Handler::handleCycleCommand(bool oneCycleValue, const uin RM3100::CycleCountCommand command(oneCycleValue); ReturnValue_t result = command.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -274,7 +274,7 @@ ReturnValue_t MgmRM3100Handler::handleCycleCommand(bool oneCycleValue, const uin cycleCountRegValueX = command.cycleCountX; cycleCountRegValueY = command.cycleCountY; cycleCountRegValueZ = command.cycleCountZ; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmRM3100Handler::handleTmrcConfigCommand(DeviceCommandId_t deviceCommand, @@ -289,7 +289,7 @@ ReturnValue_t MgmRM3100Handler::handleTmrcConfigCommand(DeviceCommandId_t device tmrcRegValue = commandData[0]; rawPacketLen = 2; rawPacket = commandBuffer; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void MgmRM3100Handler::fillCommandAndReplyMap() { @@ -311,7 +311,7 @@ ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(localpool::DataPool &loc LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(RM3100::FIELD_STRENGTHS, &mgmXYZ); poolManager.subscribeForPeriodicPacket(primaryDataset.getSid(), false, 10.0, false); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint32_t MgmRM3100Handler::getTransitionDelayMs(Mode_t from, Mode_t to) { @@ -352,13 +352,13 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) { // TODO: Sanity check on values? PoolReadGuard readGuard(&primaryDataset); - if (readGuard.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + if (readGuard.getReadResult() == returnvalue::OK) { primaryDataset.fieldStrengths[0] = fieldStrengthX; primaryDataset.fieldStrengths[1] = fieldStrengthY; primaryDataset.fieldStrengths[2] = fieldStrengthZ; primaryDataset.setValidity(true, true); } - return RETURN_OK; + return returnvalue::OK; } void MgmRM3100Handler::enablePeriodicPrintouts(bool enable, uint8_t divider) { diff --git a/src/fsfw_hal/linux/CommandExecutor.cpp b/src/fsfw_hal/linux/CommandExecutor.cpp index 49c44ebf..8b81d94f 100644 --- a/src/fsfw_hal/linux/CommandExecutor.cpp +++ b/src/fsfw_hal/linux/CommandExecutor.cpp @@ -23,7 +23,7 @@ ReturnValue_t CommandExecutor::load(std::string command, bool blocking, bool pri if (state == States::IDLE) { state = States::COMMAND_LOADED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CommandExecutor::execute() { @@ -35,7 +35,7 @@ ReturnValue_t CommandExecutor::execute() { currentCmdFile = popen(currentCmd.c_str(), "r"); if (currentCmdFile == nullptr) { lastError = errno; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (blocking) { ReturnValue_t result = executeBlocking(); @@ -46,7 +46,7 @@ ReturnValue_t CommandExecutor::execute() { waiter.fd = currentFd; } state = States::PENDING; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CommandExecutor::close() { @@ -56,7 +56,7 @@ ReturnValue_t CommandExecutor::close() { pclose(currentCmdFile); } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void CommandExecutor::printLastError(std::string funcName) const { @@ -79,7 +79,7 @@ void CommandExecutor::setRingBuffer(SimpleRingBuffer* ringBuffer, ReturnValue_t CommandExecutor::check(bool& replyReceived) { if (blocking) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } switch (state) { case (States::IDLE): @@ -94,7 +94,7 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) { int result = poll(&waiter, 1, 0); switch (result) { case (0): { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; break; } case (1): { @@ -151,7 +151,7 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) { ReturnValue_t retval = EXECUTION_FINISHED; if (result != 0) { lastError = result; - retval = HasReturnvaluesIF::RETURN_FAILED; + retval = returnvalue::FAILED; } state = States::IDLE; currentCmdFile = nullptr; @@ -161,7 +161,7 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) { break; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void CommandExecutor::reset() { @@ -201,7 +201,7 @@ ReturnValue_t CommandExecutor::executeBlocking() { int result = pclose(currentCmdFile); if (result != 0) { lastError = result; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h index 90662c0f..f817b0c2 100644 --- a/src/fsfw_hal/linux/CommandExecutor.h +++ b/src/fsfw_hal/linux/CommandExecutor.h @@ -32,19 +32,19 @@ class CommandExecutor { //! [EXPORT] : [COMMENT] Execution of the current command has finished static constexpr ReturnValue_t EXECUTION_FINISHED = - HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0); + returnvalue::makeCode(CLASS_ID, 0); //! [EXPORT] : [COMMENT] Command is pending. This will also be returned if the user tries //! to load another command but a command is still pending - static constexpr ReturnValue_t COMMAND_PENDING = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); + static constexpr ReturnValue_t COMMAND_PENDING = returnvalue::makeCode(CLASS_ID, 1); //! [EXPORT] : [COMMENT] Some bytes have been read from the executing process - static constexpr ReturnValue_t BYTES_READ = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); + static constexpr ReturnValue_t BYTES_READ = returnvalue::makeCode(CLASS_ID, 2); //! [EXPORT] : [COMMENT] Command execution failed - static constexpr ReturnValue_t COMMAND_ERROR = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); + static constexpr ReturnValue_t COMMAND_ERROR = returnvalue::makeCode(CLASS_ID, 3); //! [EXPORT] : [COMMENT] static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = - HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4); - static constexpr ReturnValue_t PCLOSE_CALL_ERROR = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 6); + returnvalue::makeCode(CLASS_ID, 4); + static constexpr ReturnValue_t PCLOSE_CALL_ERROR = returnvalue::makeCode(CLASS_ID, 6); /** * Constructor. Is initialized with maximum size of internal buffer to read data from the @@ -64,7 +64,7 @@ class CommandExecutor { /** * Execute the loaded command. * @return - * - In blocking mode, it will return RETURN_FAILED if + * - In blocking mode, it will return returnvalue::FAILED if * the result of the system call was not 0. The error value can be accessed using * getLastError * - In non-blocking mode, this call will start @@ -78,7 +78,7 @@ class CommandExecutor { * - BYTES_READ if bytes have been read from the executing process. It is recommended to call * check again after this * - RETURN_OK execution is pending, but no bytes have been read from the executing process - * - RETURN_FAILED if execution has failed, error value can be accessed using getLastError + * - returnvalue::FAILED if execution has failed, error value can be accessed using getLastError * - EXECUTION_FINISHED if the process was executed successfully * - NO_COMMAND_LOADED_OR_PENDING self-explanatory * - COMMAND_ERROR internal poll error diff --git a/src/fsfw_hal/linux/UnixFileGuard.h b/src/fsfw_hal/linux/UnixFileGuard.h index d94234b6..1fe47116 100644 --- a/src/fsfw_hal/linux/UnixFileGuard.h +++ b/src/fsfw_hal/linux/UnixFileGuard.h @@ -24,7 +24,7 @@ class UnixFileGuard { private: int* fileDescriptor = nullptr; - ReturnValue_t openStatus = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t openStatus = returnvalue::OK; }; #endif /* LINUX_UTILITY_UNIXFILEGUARD_H_ */ diff --git a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp index 15061d14..cecc1f3f 100644 --- a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp +++ b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp @@ -23,30 +23,30 @@ ReturnValue_t LinuxLibgpioIF::addGpios(GpioCookie* gpioCookie) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LinuxLibgpioIF::addGpios: Invalid cookie" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } GpioMap mapToAdd = gpioCookie->getGpioMap(); /* Check whether this ID already exists in the map and remove duplicates */ result = checkForConflicts(mapToAdd); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = configureGpios(mapToAdd); - if (result != RETURN_OK) { - return RETURN_FAILED; + if (result != returnvalue::OK) { + return returnvalue::FAILED; } /* Register new GPIOs in gpioMap */ gpioMap.insert(mapToAdd.begin(), mapToAdd.end()); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; for (auto& gpioConfig : mapToAdd) { auto& gpioType = gpioConfig.second->gpioType; switch (gpioType) { @@ -86,7 +86,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) { gpioCallback->initValue, gpioCallback->callbackArgs); } } - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return GPIO_INIT_FAILED; } } @@ -102,7 +102,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByLabel(gpioId_t gpioId, sif::warning << "LinuxLibgpioIF::configureGpioByLabel: Failed to open gpio from gpio " << "group with label " << label << ". Gpio ID: " << gpioId << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } std::string failOutput = "label: " + label; return configureRegularGpio(gpioId, chip, gpioByLabel, failOutput); @@ -116,7 +116,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByChip(gpioId_t gpioId, GpiodRegularB sif::warning << "LinuxLibgpioIF::configureGpioByChip: Failed to open chip " << chipname << ". Gpio ID: " << gpioId << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } std::string failOutput = "chipname: " + chipname; return configureRegularGpio(gpioId, chip, gpioByChip, failOutput); @@ -132,7 +132,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByLineName(gpioId_t gpioId, gpiod_ctxless_find_line(lineName.c_str(), chipname, MAX_CHIPNAME_LENGTH, &lineOffset); if (result != LINE_FOUND) { parseFindeLineResult(result, lineName); - return RETURN_FAILED; + return returnvalue::FAILED; } gpioByLineName.lineNum = static_cast(lineOffset); @@ -143,7 +143,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByLineName(gpioId_t gpioId, sif::warning << "LinuxLibgpioIF::configureGpioByLineName: Failed to open chip " << chipname << ". callback(gpioMapIter->first, gpio::GpioOperation::WRITE, gpio::Levels::HIGH, gpioCallback->callbackArgs); - return RETURN_OK; + return returnvalue::OK; } return GPIO_TYPE_FAILURE; } @@ -270,7 +270,7 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) { } gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, gpio::Levels::LOW, gpioCallback->callbackArgs); - return RETURN_OK; + return returnvalue::OK; } return GPIO_TYPE_FAILURE; } @@ -291,7 +291,7 @@ ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, GpiodRegularBase& regul return DRIVE_GPIO_FAILURE; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) { @@ -321,14 +321,14 @@ ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) { } gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::READ, gpio::Levels::NONE, gpioCallback->callbackArgs); - return RETURN_OK; + return returnvalue::OK; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) { - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; + ReturnValue_t result = returnvalue::OK; for (auto& gpioConfig : mapToAdd) { switch (gpioConfig.second->gpioType) { case (gpio::GpioTypes::GPIO_REGULAR_BY_CHIP): @@ -340,7 +340,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) { } // Check for conflicts and remove duplicates if necessary result = checkForConflictsById(gpioConfig.first, gpioConfig.second->gpioType, mapToAdd); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } break; @@ -352,7 +352,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) { } // Check for conflicts and remove duplicates if necessary result = checkForConflictsById(gpioConfig.first, gpioConfig.second->gpioType, mapToAdd); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } break; @@ -426,7 +426,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsById(gpioId_t gpioIdToCheck, mapToAdd.erase(gpioIdToCheck); return GPIO_DUPLICATE_DETECTED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void LinuxLibgpioIF::parseFindeLineResult(int result, std::string& lineName) { diff --git a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h index fcc9c775..f9ba680b 100644 --- a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h +++ b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h @@ -71,7 +71,7 @@ class LinuxLibgpioIF : public GpioIF, public SystemObject { * * @param mapToAdd The GPIOs which shall be added to the gpioMap. * - * @return RETURN_OK if successful, otherwise RETURN_FAILED + * @return RETURN_OK if successful, otherwise returnvalue::FAILED */ ReturnValue_t checkForConflicts(GpioMap& mapToAdd); diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp index 4f53dc1f..8edeb8ab 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -52,16 +52,16 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { << i2cAddress << "to I2C device " << "map" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::initializeInterface: Device with address " << i2cAddress << "already in use" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { @@ -73,11 +73,11 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::sendMessage: Send Data is nullptr" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (sendLen == 0) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } I2cCookie* i2cCookie = dynamic_cast(cookie); @@ -95,16 +95,16 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not " << "registered in i2cDeviceMap" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } deviceFile = i2cCookie->getDeviceFile(); UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::sendMessage"); - if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + if (fileHelper.getOpenResult() != returnvalue::OK) { return fileHelper.getOpenResult(); } result = openDevice(deviceFile, i2cAddress, &fd); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -114,17 +114,17 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s "device with error code " << errno << ". Error description: " << strerror(errno) << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #if FSFW_HAL_I2C_WIRETAPPING == 1 sif::info << "Sent I2C data to bus " << deviceFile << ":" << std::endl; arrayprinter::print(sendData, sendLen); #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } -ReturnValue_t I2cComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t I2cComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { ReturnValue_t result; @@ -132,7 +132,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe std::string deviceFile; if (requestLen == 0) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } I2cCookie* i2cCookie = dynamic_cast(cookie); @@ -152,16 +152,16 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe << "registered in i2cDeviceMap" << std::endl; #endif i2cDeviceMapIter->second.replyLen = 0; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } deviceFile = i2cCookie->getDeviceFile(); UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::requestReceiveMessage"); - if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + if (fileHelper.getOpenResult() != returnvalue::OK) { return fileHelper.getOpenResult(); } result = openDevice(deviceFile, i2cAddress, &fd); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { i2cDeviceMapIter->second.replyLen = 0; return result; } @@ -182,7 +182,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen << " bytes" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #if FSFW_HAL_I2C_WIRETAPPING == 1 @@ -191,7 +191,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe #endif i2cDeviceMapIter->second.replyLen = requestLen; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { @@ -210,12 +210,12 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not " << "found in i2cDeviceMap" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *buffer = i2cDeviceMapIter->second.replyBuffer.data(); *size = i2cDeviceMapIter->second.replyLen; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress, @@ -231,7 +231,7 @@ ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress, sif::printWarning("Error description: %s\n", strerror(errno)); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.h b/src/fsfw_hal/linux/i2c/I2cComIF.h index cf3bbe49..7101b9b6 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.h +++ b/src/fsfw_hal/linux/i2c/I2cComIF.h @@ -49,7 +49,7 @@ class I2cComIF : public DeviceCommunicationIF, public SystemObject { * @param deviceFile The name of the device file. E.g. i2c-0 * @param i2cAddress The address of the i2c slave device. * @param fileDescriptor Pointer to device descriptor. - * @return RETURN_OK if successful, otherwise RETURN_FAILED. + * @return RETURN_OK if successful, otherwise returnvalue::FAILED. */ ReturnValue_t openDevice(std::string deviceFile, address_t i2cAddress, int *fileDescriptor); }; diff --git a/src/fsfw_hal/linux/rpi/GpioRPi.cpp b/src/fsfw_hal/linux/rpi/GpioRPi.cpp index d3c0a577..a6b097bf 100644 --- a/src/fsfw_hal/linux/rpi/GpioRPi.cpp +++ b/src/fsfw_hal/linux/rpi/GpioRPi.cpp @@ -9,7 +9,7 @@ ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int std::string consumer, gpio::Direction direction, gpio::Levels initValue) { if (cookie == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } auto config = new GpiodRegularByChip(); @@ -30,9 +30,9 @@ ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int sif::printError("createRpiGpioConfig: BCM pin %d invalid!\n", bcmPin); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } config->lineNum = bcmPin; cookie->addGpio(gpioId, config); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_hal/linux/spi/SpiComIF.cpp b/src/fsfw_hal/linux/spi/SpiComIF.cpp index b06def69..cc52b689 100644 --- a/src/fsfw_hal/linux/spi/SpiComIF.cpp +++ b/src/fsfw_hal/linux/spi/SpiComIF.cpp @@ -56,7 +56,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { static_cast(spiAddress)); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } /* Now we emplaced the read buffer in the map, we still need to assign that location to the SPI driver transfer struct */ @@ -69,7 +69,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { sif::printError("SpiComIF::initializeInterface: SPI address already exists!\n"); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } /* Pull CS high in any case to be sure that device is inactive */ @@ -87,7 +87,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { int fileDescriptor = 0; UnixFileGuard fileHelper(spiCookie->getSpiDevice(), &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); - if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + if (fileHelper.getOpenResult() != returnvalue::OK) { return fileHelper.getOpenResult(); } @@ -129,12 +129,12 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { "Could not write bits per word!"); } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { SpiCookie* spiCookie = dynamic_cast(cookie); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (spiCookie == nullptr) { return NULLPOINTER; @@ -178,13 +178,13 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const spiCookie->assignReadBuffer(iter->second.replyBuffer.data()); } - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; int retval = 0; /* Prepare transfer */ int fileDescriptor = 0; std::string device = spiCookie->getSpiDevice(); UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); - if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + if (fileHelper.getOpenResult() != returnvalue::OK) { return OPENING_FILE_FAILED; } spi::SpiModes spiMode = spi::SpiModes::MODE_0; @@ -200,7 +200,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const /* Pull SPI CS low. For now, no support for active high given */ if (gpioId != gpio::NO_GPIO) { result = spiMutex->lockMutex(timeoutType, timeoutMs); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; @@ -211,7 +211,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const return result; } result = gpioComIF->pullLow(gpioId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "SpiComIF::sendMessage: Pulling low CS pin failed" << std::endl; @@ -251,7 +251,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const if (gpioId != gpio::NO_GPIO) { gpioComIF->pullHigh(gpioId); result = spiMutex->unlockMutex(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "SpiComIF::sendMessage: Failed to unlock mutex" << std::endl; #endif @@ -261,7 +261,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const return result; } -ReturnValue_t SpiComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SpiComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { SpiCookie* spiCookie = dynamic_cast(cookie); @@ -270,32 +270,32 @@ ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe } if (spiCookie->isFullDuplex()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return performHalfDuplexReception(spiCookie); } ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::string device = spiCookie->getSpiDevice(); int fileDescriptor = 0; UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::requestReceiveMessage"); - if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + if (fileHelper.getOpenResult() != returnvalue::OK) { return OPENING_FILE_FAILED; } uint8_t* rxBuf = nullptr; size_t readSize = spiCookie->getCurrentTransferSize(); result = getReadBuffer(spiCookie->getSpiAddress(), &rxBuf); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } gpioId_t gpioId = spiCookie->getChipSelectPin(); if (gpioId != gpio::NO_GPIO) { result = spiMutex->lockMutex(timeoutType, timeoutMs); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "SpiComIF::getSendSuccess: Failed to lock mutex" << std::endl; #endif @@ -318,7 +318,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { if (gpioId != gpio::NO_GPIO) { gpioComIF->pullHigh(gpioId); result = spiMutex->unlockMutex(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "SpiComIF::getSendSuccess: Failed to unlock mutex" << std::endl; #endif @@ -332,18 +332,18 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { ReturnValue_t SpiComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { SpiCookie* spiCookie = dynamic_cast(cookie); if (spiCookie == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint8_t* rxBuf = nullptr; ReturnValue_t result = getReadBuffer(spiCookie->getSpiAddress(), &rxBuf); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *buffer = rxBuf; *size = spiCookie->getCurrentTransferSize(); spiCookie->setTransferSize(0); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MutexIF* SpiComIF::getMutex(MutexIF::TimeoutType* timeoutType, uint32_t* timeoutMs) { @@ -377,16 +377,16 @@ void SpiComIF::performSpiWiretapping(SpiCookie* spiCookie) { ReturnValue_t SpiComIF::getReadBuffer(address_t spiAddress, uint8_t** buffer) { if (buffer == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } auto iter = spiDeviceMap.find(spiAddress); if (iter == spiDeviceMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *buffer = iter->second.replyBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } GpioIF* SpiComIF::getGpioInterface() { return gpioComIF; } diff --git a/src/fsfw_hal/linux/uart/UartComIF.cpp b/src/fsfw_hal/linux/uart/UartComIF.cpp index f77bdeae..8947c562 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -37,7 +37,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { if (uartDeviceMapIter == uartDeviceMap.end()) { int fileDescriptor = configureUartPort(uartCookie); if (fileDescriptor < 0) { - return RETURN_FAILED; + return returnvalue::FAILED; } size_t maxReplyLen = uartCookie->getMaxReplyLen(); UartElements uartElements = {fileDescriptor, std::vector(maxReplyLen), 0}; @@ -47,17 +47,17 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { sif::warning << "UartComIF::initializeInterface: Failed to insert device " << deviceFile << "to UART device map" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::initializeInterface: UART device " << deviceFile << " already in use" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } int UartComIF::configureUartPort(UartCookie* uartCookie) { @@ -329,14 +329,14 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, UartDeviceMapIter uartDeviceMapIter; if (sendLen == 0) { - return RETURN_OK; + return returnvalue::OK; } if (sendData == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::sendMessage: Send data is nullptr" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } UartCookie* uartCookie = dynamic_cast(cookie); @@ -354,7 +354,7 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, sif::debug << "UartComIF::sendMessage: Device file " << deviceFile << "not in UART map" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } fd = uartDeviceMapIter->second.fileDescriptor; @@ -364,13 +364,13 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, sif::error << "UartComIF::sendMessage: Failed to send data with error code " << errno << ": Error description: " << strerror(errno) << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } -ReturnValue_t UartComIF::getSendSuccess(CookieIF* cookie) { return RETURN_OK; } +ReturnValue_t UartComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { std::string deviceFile; @@ -389,7 +389,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartMode == UartModes::NON_CANONICAL and requestLen == 0) { - return RETURN_OK; + return returnvalue::OK; } if (uartDeviceMapIter == uartDeviceMap.end()) { @@ -397,7 +397,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL sif::debug << "UartComIF::requestReceiveMessage: Device file " << deviceFile << " not in uart map" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } if (uartMode == UartModes::CANONICAL) { @@ -405,13 +405,13 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL } else if (uartMode == UartModes::NON_CANONICAL) { return handleNoncanonicalRead(*uartCookie, uartDeviceMapIter, requestLen); } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, size_t requestLen) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; uint8_t maxReadCycles = uartCookie.getReadCycles(); uint8_t currentReadCycles = 0; int bytesRead = 0; @@ -454,7 +454,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM strerror(errno)); #endif #endif - return RETURN_FAILED; + return returnvalue::FAILED; } } else if (bytesRead > 0) { @@ -487,18 +487,18 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi } int bytesRead = read(fd, bufferPtr, requestLen); if (bytesRead < 0) { - return RETURN_FAILED; + return returnvalue::FAILED; } else if (bytesRead != static_cast(requestLen)) { if (uartCookie.isReplySizeFixed()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::requestReceiveMessage: Only read " << bytesRead << " of " << requestLen << " bytes" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } } iter->second.replyLen = bytesRead; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { @@ -520,7 +520,7 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, sif::debug << "UartComIF::readReceivedMessage: Device file " << deviceFile << " not in uart map" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } *buffer = uartDeviceMapIter->second.replyBuffer.data(); @@ -529,7 +529,7 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, /* Length is reset to 0 to prevent reading the same data twice */ uartDeviceMapIter->second.replyLen = 0; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { @@ -547,9 +547,9 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCIFLUSH); - return RETURN_OK; + return returnvalue::OK; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { @@ -567,9 +567,9 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCOFLUSH); - return RETURN_OK; + return returnvalue::OK; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { @@ -587,9 +587,9 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCIOFLUSH); - return RETURN_OK; + return returnvalue::OK; } - return RETURN_FAILED; + return returnvalue::FAILED; } void UartComIF::setUartMode(struct termios* options, UartCookie& uartCookie) { diff --git a/src/fsfw_hal/linux/uio/UioMapper.cpp b/src/fsfw_hal/linux/uio/UioMapper.cpp index 43ca2727..3d7e5987 100644 --- a/src/fsfw_hal/linux/uio/UioMapper.cpp +++ b/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -18,17 +18,17 @@ UioMapper::UioMapper(std::string uioFile, int mapNum) : uioFile(uioFile), mapNum UioMapper::~UioMapper() {} ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permissions) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; 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; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } size_t size = 0; result = getMapSize(&size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *address = static_cast( @@ -39,9 +39,9 @@ ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permiss sif::error << "UioMapper::getMappedAdress: Failed to map physical address of uio device " << uioFile.c_str() << " and map" << static_cast(mapNum) << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t UioMapper::getMapSize(size_t* size) { @@ -54,7 +54,7 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "UioMapper::getMapSize: Failed to open file " << namestream.str() << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } char hexstring[SIZE_HEX_STRING] = ""; int items = fscanf(fp, "%s", hexstring); @@ -66,7 +66,7 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) { << namestream.str() << std::endl; #endif fclose(fp); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint32_t sizeTmp = 0; items = sscanf(hexstring, "%x", &sizeTmp); @@ -79,8 +79,8 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) { << "size of map" << mapNum << " to integer" << std::endl; #endif fclose(fp); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } fclose(fp); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp b/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp index cbf8def5..624696c8 100644 --- a/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp +++ b/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp @@ -84,7 +84,7 @@ ReturnValue_t GyroL3GD20H::initialize() { spiHandle->Init.Mode = SPI_MODE_MASTER; if (HAL_SPI_Init(spiHandle) != HAL_OK) { sif::printWarning("Error initializing SPI\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } delete mspCfg; @@ -106,11 +106,11 @@ ReturnValue_t GyroL3GD20H::initialize() { return handlePollingTransferInit(); } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::performOperation() { @@ -125,10 +125,10 @@ ReturnValue_t GyroL3GD20H::performOperation() { return handleInterruptSensorRead(); } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::handleDmaTransferInit() { @@ -162,10 +162,10 @@ ReturnValue_t GyroL3GD20H::handleDmaTransferInit() { case (TransferStates::FAILURE): { sif::printWarning("Transfer failure\n"); transferState = TransferStates::FAILURE; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -194,10 +194,10 @@ ReturnValue_t GyroL3GD20H::handleDmaTransferInit() { case (TransferStates::FAILURE): { sif::printWarning("GyroL3GD20H::initialize: Configuration transfer failure\n"); transferState = TransferStates::FAILURE; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -228,13 +228,13 @@ ReturnValue_t GyroL3GD20H::handleDmaTransferInit() { case (TransferStates::FAILURE): { sif::printWarning("GyroL3GD20H::initialize: Configuration transfer failure\n"); transferState = TransferStates::FAILURE; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::handleDmaSensorRead() { @@ -259,13 +259,13 @@ ReturnValue_t GyroL3GD20H::handleDmaSensorRead() { case (TransferStates::FAILURE): { sif::printWarning("GyroL3GD20H::handleDmaSensorRead: Sensor read failure\n"); transferState = TransferStates::FAILURE; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } HAL_StatusTypeDef GyroL3GD20H::performDmaTransfer(size_t sendSize) { @@ -298,14 +298,14 @@ ReturnValue_t GyroL3GD20H::handlePollingTransferInit() { } case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } case (HAL_ERROR): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -323,14 +323,14 @@ ReturnValue_t GyroL3GD20H::handlePollingTransferInit() { } case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } case (HAL_ERROR): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -353,17 +353,17 @@ ReturnValue_t GyroL3GD20H::handlePollingTransferInit() { } case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } case (HAL_ERROR): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::handlePollingSensorRead() { @@ -380,17 +380,17 @@ ReturnValue_t GyroL3GD20H::handlePollingSensorRead() { } case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } case (HAL_ERROR): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() { @@ -416,7 +416,7 @@ ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() { case (HAL_ERROR): case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Initialization failure using interrupts\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -438,7 +438,7 @@ ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() { case (HAL_ERROR): case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Initialization failure using interrupts\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -465,10 +465,10 @@ ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() { case (HAL_ERROR): case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Initialization failure using interrupts\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::handleInterruptSensorRead() { @@ -489,10 +489,10 @@ ReturnValue_t GyroL3GD20H::handleInterruptSensorRead() { case (HAL_ERROR): case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Sensor read failure using interrupts\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void GyroL3GD20H::prepareConfigRegs(uint8_t *configRegs) { diff --git a/src/fsfw_hal/stm32h7/spi/SpiComIF.cpp b/src/fsfw_hal/stm32h7/spi/SpiComIF.cpp index 49e4670d..724917bd 100644 --- a/src/fsfw_hal/stm32h7/spi/SpiComIF.cpp +++ b/src/fsfw_hal/stm32h7/spi/SpiComIF.cpp @@ -35,7 +35,7 @@ void SpiComIF::addDmaHandles(DMA_HandleTypeDef *txHandle, DMA_HandleTypeDef *rxH spi::setDmaHandles(txHandle, rxHandle); } -ReturnValue_t SpiComIF::initialize() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SpiComIF::initialize() { return returnvalue::OK; } ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { SpiCookie *spiCookie = dynamic_cast(cookie); @@ -55,7 +55,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { spi::getDmaHandles(&txHandle, &rxHandle); if (txHandle == nullptr or rxHandle == nullptr) { sif::printError("SpiComIF::initialize: DMA handles not set!\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } // This semaphore ensures thread-safety for a given bus @@ -79,7 +79,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { static_cast(spiAddress)); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } auto gpioPin = spiCookie->getChipSelectGpioPin(); @@ -98,7 +98,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { #endif } else { printCfgError("SPI Bus Index"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } auto mspCfg = spiCookie->getMspCfg(); @@ -107,21 +107,21 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { auto typedCfg = dynamic_cast(mspCfg); if (typedCfg == nullptr) { printCfgError("Polling MSP"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } spi::setSpiPollingMspFunctions(typedCfg); } else if (transferMode == spi::TransferModes::INTERRUPT) { auto typedCfg = dynamic_cast(mspCfg); if (typedCfg == nullptr) { printCfgError("IRQ MSP"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } spi::setSpiIrqMspFunctions(typedCfg); } else if (transferMode == spi::TransferModes::DMA) { auto typedCfg = dynamic_cast(mspCfg); if (typedCfg == nullptr) { printCfgError("DMA MSP"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // Check DMA handles DMA_HandleTypeDef *txHandle = nullptr; @@ -129,7 +129,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { spi::getDmaHandles(&txHandle, &rxHandle); if (txHandle == nullptr or rxHandle == nullptr) { printCfgError("DMA Handle"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } spi::setSpiDmaMspFunctions(typedCfg); } @@ -145,12 +145,12 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { if (HAL_SPI_Init(&spiHandle) != HAL_OK) { sif::printWarning("SpiComIF::initialize: Error initializing SPI\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // The MSP configuration struct is not required anymore spiCookie->deleteMspCfg(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) { @@ -163,7 +163,7 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s auto iter = spiDeviceMap.find(spiCookie->getDeviceAddress()); if (iter == spiDeviceMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } iter->second.currentTransferLen = sendLen; @@ -176,7 +176,7 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s case (spi::TransferStates::FAILURE): case (spi::TransferStates::SUCCESS): default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -194,13 +194,13 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s sendData, sendLen); } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } -ReturnValue_t SpiComIF::getSendSuccess(CookieIF *cookie) { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SpiComIF::getSendSuccess(CookieIF *cookie) { return returnvalue::OK; } ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { @@ -212,7 +212,7 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, case (spi::TransferStates::SUCCESS): { auto iter = spiDeviceMap.find(spiCookie->getDeviceAddress()); if (iter == spiDeviceMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *buffer = iter->second.replyBuffer.data(); *size = iter->second.currentTransferLen; @@ -228,18 +228,18 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, #endif #endif spiCookie->setTransferState(spi::TransferStates::IDLE); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } case (spi::TransferStates::WAIT): case (spi::TransferStates::IDLE): { break; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void SpiComIF::setDefaultPollingTimeout(dur_millis_t timeout) { @@ -252,7 +252,7 @@ ReturnValue_t SpiComIF::handlePollingSendOperation(uint8_t *recvPtr, SPI_HandleT auto gpioPort = spiCookie.getChipSelectGpioPort(); auto gpioPin = spiCookie.getChipSelectGpioPin(); auto returnval = spiSemaphore->acquire(timeoutType, timeoutMs); - if (returnval != HasReturnvaluesIF::RETURN_OK) { + if (returnval != returnvalue::OK) { return returnval; } spiCookie.setTransferState(spi::TransferStates::WAIT); @@ -299,7 +299,7 @@ ReturnValue_t SpiComIF::handlePollingSendOperation(uint8_t *recvPtr, SPI_HandleT return spi::HAL_ERROR_RETVAL; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t SpiComIF::handleInterruptSendOperation(uint8_t *recvPtr, SPI_HandleTypeDef &spiHandle, @@ -318,7 +318,7 @@ ReturnValue_t SpiComIF::handleIrqSendOperation(uint8_t *recvPtr, SPI_HandleTypeD SpiCookie &spiCookie, const uint8_t *sendData, size_t sendLen) { ReturnValue_t result = genericIrqSendSetup(recvPtr, spiHandle, spiCookie, sendData, sendLen); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } // yet another HAL driver which is not const-correct.. @@ -366,7 +366,7 @@ ReturnValue_t SpiComIF::halErrorHandler(HAL_StatusTypeDef status, spi::TransferM return spi::HAL_TIMEOUT_RETVAL; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } } @@ -379,7 +379,7 @@ ReturnValue_t SpiComIF::genericIrqSendSetup(uint8_t *recvPtr, SPI_HandleTypeDef // Take the semaphore which will be released by a callback when the transfer is complete ReturnValue_t result = spiSemaphore->acquire(SemaphoreIF::TimeoutType::WAITING, timeoutMs); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { // Configuration error sif::printWarning( "SpiComIF::handleInterruptSendOperation: Semaphore " @@ -399,7 +399,7 @@ ReturnValue_t SpiComIF::genericIrqSendSetup(uint8_t *recvPtr, SPI_HandleTypeDef HAL_GPIO_WritePin(spiCookie.getChipSelectGpioPort(), spiCookie.getChipSelectGpioPin(), GPIO_PIN_RESET); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void SpiComIF::spiTransferTxCompleteCallback(SPI_HandleTypeDef *hspi, void *args) { @@ -445,7 +445,7 @@ void SpiComIF::genericIrqHandler(void *irqArgsVoid, spi::TransferStates targetSt #elif defined FSFW_OSAL_RTEMS ReturnValue_t result = comIF->spiSemaphore->release(); #endif - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { // Configuration error printf("SpiComIF::genericIrqHandler: Failure releasing Semaphore!\n"); } diff --git a/src/fsfw_tests/integration/assemblies/TestAssembly.cpp b/src/fsfw_tests/integration/assemblies/TestAssembly.cpp index a0313f96..668120c6 100644 --- a/src/fsfw_tests/integration/assemblies/TestAssembly.cpp +++ b/src/fsfw_tests/integration/assemblies/TestAssembly.cpp @@ -30,7 +30,7 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) { #else sif::printInfo("TestAssembly: Received command to go to mode %d submode %d\n", mode, submode); #endif - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (mode == MODE_OFF) { commandTable[0].setMode(MODE_OFF); commandTable[0].setSubmode(SUBMODE_NONE); @@ -113,14 +113,14 @@ ReturnValue_t TestAssembly::isModeCombinationValid(Mode_t mode, Submode_t submod switch (mode) { case MODE_OFF: if (submode == SUBMODE_NONE) { - return RETURN_OK; + return returnvalue::OK; } else { return INVALID_SUBMODE; } case DeviceHandlerIF::MODE_NORMAL: case MODE_ON: if (submode < 3) { - return RETURN_OK; + return returnvalue::OK; } else { return INVALID_SUBMODE; } @@ -130,24 +130,24 @@ ReturnValue_t TestAssembly::isModeCombinationValid(Mode_t mode, Submode_t submod ReturnValue_t TestAssembly::initialize() { ReturnValue_t result = AssemblyBase::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } handler0 = ObjectManager::instance()->get(deviceHandler0Id); handler1 = ObjectManager::instance()->get(deviceHandler1Id); if ((handler0 == nullptr) or (handler1 == nullptr)) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } handler0->setParentQueue(this->getCommandQueue()); handler1->setParentQueue(this->getCommandQueue()); result = registerChild(deviceHandler0Id); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = registerChild(deviceHandler1Id); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return result; @@ -160,11 +160,11 @@ ReturnValue_t TestAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wa return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE; } } - return RETURN_OK; + return returnvalue::OK; } else if (submode == submodes::SINGLE) { for (const auto& info : childrenMap) { if (info.second.mode == wantedMode and info.second.mode != wantedSubmode) { - return RETURN_OK; + return returnvalue::OK; } } } diff --git a/src/fsfw_tests/integration/controller/TestController.cpp b/src/fsfw_tests/integration/controller/TestController.cpp index 03f24311..2ee4d5fe 100644 --- a/src/fsfw_tests/integration/controller/TestController.cpp +++ b/src/fsfw_tests/integration/controller/TestController.cpp @@ -10,7 +10,7 @@ TestController::TestController(object_id_t objectId, object_id_t parentId, size_ TestController::~TestController() {} ReturnValue_t TestController::handleCommandMessage(CommandMessage *message) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TestController::performControlOperation() {} @@ -24,7 +24,7 @@ LocalPoolDataSetBase *TestController::getDataSetHandle(sid_t sid) { return nullp ReturnValue_t TestController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestController::initializeAfterTaskCreation() { @@ -33,5 +33,5 @@ ReturnValue_t TestController::initializeAfterTaskCreation() { ReturnValue_t TestController::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp index 36f1ea8c..e2df55c3 100644 --- a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp +++ b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp @@ -139,7 +139,7 @@ ReturnValue_t TestDevice::buildCommandFromCommand(DeviceCommandId_t deviceComman const uint8_t* commandData, size_t commandDataLen) { using namespace testdevice; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (deviceCommand) { case (TEST_NORMAL_MODE_CMD): { commandSent = true; @@ -222,7 +222,7 @@ ReturnValue_t TestDevice::buildNormalModeCommand(DeviceCommandId_t deviceCommand } /* The command is passed on in the command buffer as it is */ passOnCommand(deviceCommand, commandData, commandDataLen); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::buildTestCommand0(DeviceCommandId_t deviceCommand, @@ -248,7 +248,7 @@ ReturnValue_t TestDevice::buildTestCommand0(DeviceCommandId_t deviceCommand, /* The command is passed on in the command buffer as it is */ passOnCommand(deviceCommand, commandData, commandDataLen); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::buildTestCommand1(DeviceCommandId_t deviceCommand, @@ -277,7 +277,7 @@ ReturnValue_t TestDevice::buildTestCommand1(DeviceCommandId_t deviceCommand, size_t size = commandDataLen; ReturnValue_t result = SerializeAdapter::deSerialize(¶meter1, &commandData, &size, SerializeIF::Endianness::BIG); - if (result == HasReturnvaluesIF::RETURN_FAILED) { + if (result == returnvalue::FAILED) { return result; } @@ -299,7 +299,7 @@ ReturnValue_t TestDevice::buildTestCommand1(DeviceCommandId_t deviceCommand, memcpy(commandBuffer + 6, ¶meter2, sizeof(parameter2)); rawPacket = commandBuffer; rawPacketLen = sizeof(deviceCommand) + sizeof(parameter1) + sizeof(parameter2); - return RETURN_OK; + return returnvalue::OK; } void TestDevice::passOnCommand(DeviceCommandId_t command, const uint8_t* commandData, @@ -342,7 +342,7 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC size_t size = len; ReturnValue_t result = SerializeAdapter::deSerialize(foundId, &start, &size, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -366,7 +366,7 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC *foundLen = len; *foundId = pendingCmd; - return RETURN_OK; + return returnvalue::OK; } case (TEST_COMMAND_0): { @@ -389,7 +389,7 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC *foundLen = TEST_COMMAND_0_SIZE; *foundId = pendingCmd; - return RETURN_OK; + return returnvalue::OK; } case (TEST_COMMAND_1): { @@ -409,7 +409,7 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC *foundLen = len; *foundId = pendingCmd; - return RETURN_OK; + return returnvalue::OK; } default: @@ -418,7 +418,7 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC } ReturnValue_t TestDevice::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (id) { /* Periodic replies */ case testdevice::TEST_NORMAL_MODE_CMD: { @@ -460,7 +460,7 @@ ReturnValue_t TestDevice::interpretingNormalModeReply() { dataset.testFloat3Vec.value[2] = 0.0; dataset.setValidity(false, true); } - return RETURN_OK; + return returnvalue::OK; } PoolReadGuard readHelper(&dataset); @@ -570,7 +570,7 @@ ReturnValue_t TestDevice::interpretingNormalModeReply() { } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::interpretingTestReply0(DeviceCommandId_t id, const uint8_t* packet) { @@ -589,7 +589,7 @@ ReturnValue_t TestDevice::interpretingTestReply0(DeviceCommandId_t id, const uin actionHelper.step(1, commander, id); actionHelper.finish(true, commander, id); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::interpretingTestReply1(DeviceCommandId_t id, const uint8_t* packet) { @@ -608,7 +608,7 @@ ReturnValue_t TestDevice::interpretingTestReply1(DeviceCommandId_t id, const uin ReturnValue_t result = actionHelper.reportData(commander, id, packet, testdevice::TEST_COMMAND_1_SIZE, false); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TestDevice" << deviceIdx << "::interpretingReply1: Sending data " @@ -620,7 +620,7 @@ ReturnValue_t TestDevice::interpretingTestReply1(DeviceCommandId_t id, const uin return result; } - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { /* Finish reply */ actionHelper.finish(true, commander, id); } else { @@ -628,7 +628,7 @@ ReturnValue_t TestDevice::interpretingTestReply1(DeviceCommandId_t id, const uin actionHelper.finish(false, commander, id, result); } - return RETURN_OK; + return returnvalue::OK; } uint32_t TestDevice::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } @@ -646,7 +646,7 @@ ReturnValue_t TestDevice::initializeLocalDataPool(localpool::DataPool& localData /* Subscribe for periodic HK packets but do not enable reporting for now. Non-diangostic with a period of one second */ poolManager.subscribeForPeriodicPacket(sid, false, 1.0, false); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, @@ -658,7 +658,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, if (fullInfoPrintout) { uint32_t newValue = 0; ReturnValue_t result = newValues->getElement(&newValue, 0, 0); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx << "::getParameter: Setting parameter 0 to " @@ -677,7 +677,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, if (fullInfoPrintout) { int32_t newValue = 0; ReturnValue_t result = newValues->getElement(&newValue, 0, 0); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx << "::getParameter: Setting parameter 1 to " @@ -695,10 +695,10 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, case ParameterUniqueIds::TEST_FLOAT_VEC3_2: { if (fullInfoPrintout) { float newVector[3]; - if (newValues->getElement(newVector, 0, 0) != RETURN_OK or - newValues->getElement(newVector + 1, 0, 1) != RETURN_OK or - newValues->getElement(newVector + 2, 0, 2) != RETURN_OK) { - return HasReturnvaluesIF::RETURN_FAILED; + if (newValues->getElement(newVector, 0, 0) != returnvalue::OK or + newValues->getElement(newVector + 1, 0, 1) != returnvalue::OK or + newValues->getElement(newVector + 2, 0, 2) != returnvalue::OK) { + return returnvalue::FAILED; } #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx @@ -720,7 +720,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, if (fullInfoPrintout) { uint8_t enabled = 0; ReturnValue_t result = newValues->getElement(&enabled, 0, 0); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } char const* printout = nullptr; @@ -743,7 +743,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, case (ParameterUniqueIds::CHANGING_DATASETS): { uint8_t enabled = 0; ReturnValue_t result = newValues->getElement(&enabled, 0, 0); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (not enabled) { @@ -776,7 +776,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } LocalPoolObjectBase* TestDevice::getPoolObjectHandle(lp_id_t localPoolId) { diff --git a/src/fsfw_tests/integration/devices/TestEchoComIF.cpp b/src/fsfw_tests/integration/devices/TestEchoComIF.cpp index 727381a2..c0aa64a4 100644 --- a/src/fsfw_tests/integration/devices/TestEchoComIF.cpp +++ b/src/fsfw_tests/integration/devices/TestEchoComIF.cpp @@ -25,9 +25,9 @@ ReturnValue_t TestEchoComIF::initializeInterface(CookieIF *cookie) { auto resultPair = replyMap.emplace(dummyCookie->getAddress(), ReplyBuffer(dummyCookie->getReplyMaxLen())); if (not resultPair.second) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestEchoComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, @@ -50,17 +50,17 @@ ReturnValue_t TestEchoComIF::sendMessage(CookieIF *cookie, const uint8_t *sendDa "reply buffer length!\n", sendLen); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } replyBuffer.resize(sendLen); memcpy(replyBuffer.data(), sendData, sendLen); - return RETURN_OK; + return returnvalue::OK; } -ReturnValue_t TestEchoComIF::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } +ReturnValue_t TestEchoComIF::getSendSuccess(CookieIF *cookie) { return returnvalue::OK; } ReturnValue_t TestEchoComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestEchoComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { @@ -78,5 +78,5 @@ ReturnValue_t TestEchoComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buf // add anything that needs to be read periodically by dummy handler dummyReplyCounter = 0; } - return RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_tests/integration/task/TestTask.cpp b/src/fsfw_tests/integration/task/TestTask.cpp index a6a4a30b..a09644d2 100644 --- a/src/fsfw_tests/integration/task/TestTask.cpp +++ b/src/fsfw_tests/integration/task/TestTask.cpp @@ -15,7 +15,7 @@ TestTask::TestTask(object_id_t objectId) : SystemObject(objectId), testMode(test TestTask::~TestTask() = default; ReturnValue_t TestTask::performOperation(uint8_t operationCode) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; testLock->lockMutex(MutexIF::TimeoutType::WAITING, 20); if (oneShotAction) { // Add code here which should only be run once @@ -40,23 +40,23 @@ ReturnValue_t TestTask::performOperation(uint8_t operationCode) { ReturnValue_t TestTask::performOneShotAction() { /* Everything here will only be performed once. */ - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestTask::performPeriodicAction() { /* This is performed each task cycle */ - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; return result; } ReturnValue_t TestTask::performActionA() { /* This is performed each alternating task cycle */ - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; return result; } ReturnValue_t TestTask::performActionB() { /* This is performed each alternating task cycle */ - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; return result; } diff --git a/src/fsfw_tests/internal/InternalUnitTester.cpp b/src/fsfw_tests/internal/InternalUnitTester.cpp index 4e45d25b..a135359c 100644 --- a/src/fsfw_tests/internal/InternalUnitTester.cpp +++ b/src/fsfw_tests/internal/InternalUnitTester.cpp @@ -37,5 +37,5 @@ ReturnValue_t InternalUnitTester::performTests( #else sif::printInfo("Internal unit tests finished.\n"); #endif - return RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_tests/internal/InternalUnitTester.h b/src/fsfw_tests/internal/InternalUnitTester.h index d6d7ca36..07744825 100644 --- a/src/fsfw_tests/internal/InternalUnitTester.h +++ b/src/fsfw_tests/internal/InternalUnitTester.h @@ -13,7 +13,7 @@ * which simply calls all other tests from other files manually. * Maybe there is a better way.. */ -class InternalUnitTester : public HasReturnvaluesIF { +class InternalUnitTester { public: struct TestConfig { bool testArrayPrinter = false; diff --git a/src/fsfw_tests/internal/UnittDefinitions.cpp b/src/fsfw_tests/internal/UnittDefinitions.cpp index 3322b1ad..ea562591 100644 --- a/src/fsfw_tests/internal/UnittDefinitions.cpp +++ b/src/fsfw_tests/internal/UnittDefinitions.cpp @@ -6,5 +6,5 @@ ReturnValue_t unitt::put_error(std::string errorId) { #else sif::printError("Unit Tester error: Failed at test ID %s\n", errorId.c_str()); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } diff --git a/src/fsfw_tests/internal/osal/testMq.cpp b/src/fsfw_tests/internal/osal/testMq.cpp index 3d8e1034..88082b0a 100644 --- a/src/fsfw_tests/internal/osal/testMq.cpp +++ b/src/fsfw_tests/internal/osal/testMq.cpp @@ -20,22 +20,22 @@ void testmq::testMq() { testSenderMq->setDefaultDestination(testReceiverMqId); auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - if (result != result::OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - if (result != result::OK or recvMessage.getData()[0] != 42) { + if (result != returnvalue::OK or recvMessage.getData()[0] != 42) { unitt::put_error(id); } result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - if (result != result::OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } MessageQueueId_t senderId = 0; result = testReceiverMq->receiveMessage(&recvMessage, &senderId); - if (result != result::OK or recvMessage.getData()[0] != 42) { + if (result != returnvalue::OK or recvMessage.getData()[0] != 42) { unitt::put_error(id); } if (senderId != testSenderMqId) { diff --git a/src/fsfw_tests/internal/osal/testMutex.cpp b/src/fsfw_tests/internal/osal/testMutex.cpp index 6206c31d..98c471cb 100644 --- a/src/fsfw_tests/internal/osal/testMutex.cpp +++ b/src/fsfw_tests/internal/osal/testMutex.cpp @@ -16,7 +16,7 @@ void testmutex::testMutex() { std::string id = "[testMutex]"; MutexIF* mutex = MutexFactory::instance()->createMutex(); auto result = mutex->lockMutex(MutexIF::TimeoutType::POLLING); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } // timed_mutex from the C++ library specifies undefined behaviour if @@ -35,7 +35,7 @@ void testmutex::testMutex() { } result = mutex->unlockMutex(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } diff --git a/src/fsfw_tests/internal/osal/testSemaphore.cpp b/src/fsfw_tests/internal/osal/testSemaphore.cpp index a3e4c277..df88b4ed 100644 --- a/src/fsfw_tests/internal/osal/testSemaphore.cpp +++ b/src/fsfw_tests/internal/osal/testSemaphore.cpp @@ -54,7 +54,7 @@ void testsemaph::testCountingSemaph() { // release 3 times in a row for (int i = 0; i < 3; i++) { auto result = countingSemaph->release(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } } @@ -75,7 +75,7 @@ void testsemaph::testBinSemaphoreImplementation(SemaphoreIF* binSemaph, std::str unitt::put_error(id); } result = binSemaph->acquire(SemaphoreIF::BLOCKING); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } @@ -104,7 +104,7 @@ void testsemaph::testBinSemaphoreImplementation(SemaphoreIF* binSemaph, std::str } result = binSemaph->release(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } } @@ -122,7 +122,7 @@ void testsemaph::testCountingSemaphImplementation(SemaphoreIF* countingSemaph, s // acquire 3 times in a row for (int i = 0; i < 3; i++) { result = countingSemaph->acquire(SemaphoreIF::BLOCKING); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } } @@ -144,7 +144,7 @@ void testsemaph::testCountingSemaphImplementation(SemaphoreIF* countingSemaph, s // release 3 times in a row for (int i = 0; i < 3; i++) { result = countingSemaph->release(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } } diff --git a/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp b/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp index 5865f8fc..58ab05c1 100644 --- a/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp +++ b/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp @@ -13,18 +13,18 @@ std::array testserialize::test_array = {0}; ReturnValue_t testserialize::test_serialization() { // Here, we test all serialization tools. First test basic cases. ReturnValue_t result = test_endianness_tools(); - if (result != result::OK) { + if (result != returnvalue::OK) { return result; } result = test_autoserialization(); - if (result != result::OK) { + if (result != returnvalue::OK) { return result; } result = test_serial_buffer_adapter(); - if (result != result::OK) { + if (result != returnvalue::OK) { return result; } - return result::OK; + return returnvalue::OK; } ReturnValue_t testserialize::test_endianness_tools() { @@ -48,7 +48,7 @@ ReturnValue_t testserialize::test_endianness_tools() { if (test_array[0] != 0 and test_array[1] != 1) { return unitt::put_error(id); } - return result::OK; + return returnvalue::OK; } ReturnValue_t testserialize::test_autoserialization() { @@ -152,7 +152,7 @@ ReturnValue_t testserialize::test_autoserialization() { } // Check overflow - return result::OK; + return returnvalue::OK; } // TODO: Also test for constant buffers. @@ -205,5 +205,5 @@ ReturnValue_t testserialize::test_serial_buffer_adapter() { if (testUint16 != 16) { return unitt::put_error(id); } - return result::OK; + return returnvalue::OK; } diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index 0d160c6f..fdb8aad6 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -19,12 +19,12 @@ TEST_CASE("Action Helper", "[ActionHelper]") { StorageManagerIF* ipcStore = tglob::getIpcStoreHandle(); REQUIRE(ipcStore != nullptr); ipcStore->addData(¶mAddress, testParams.data(), 3); - REQUIRE(actionHelper.initialize() == result::OK); + REQUIRE(actionHelper.initialize() == returnvalue::OK); SECTION("Simple tests") { ActionMessage::setCommand(&actionMessage, testActionId, paramAddress); CHECK(not testDhMock.executeActionCalled); - REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == returnvalue::OK); CHECK(testDhMock.executeActionCalled); // No message is sent if everything is alright. CHECK(not testMqMock.wasMessageSent()); @@ -58,7 +58,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { CHECK(testMqMock.wasMessageSent()); CommandMessage testMessage; REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(testMessage.getParameter() == static_cast(testActionId)); uint32_t parameter2 = ((uint32_t)step << 16) | (uint32_t)status; @@ -73,7 +73,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { CHECK(testMqMock.wasMessageSent()); CommandMessage testMessage; REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::COMPLETION_FAILED)); REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId); REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(status)); @@ -82,15 +82,15 @@ TEST_CASE("Action Helper", "[ActionHelper]") { SECTION("Handle failed") { store_address_t toLongParamAddress = StorageManagerIF::INVALID_ADDRESS; std::array toLongData = {5, 4, 3, 2, 1}; - REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == result::OK); + REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == returnvalue::OK); ActionMessage::setCommand(&actionMessage, testActionId, toLongParamAddress); CHECK(not testDhMock.executeActionCalled); - REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == returnvalue::OK); REQUIRE(ipcStore->getData(toLongParamAddress).first == static_cast(StorageManagerIF::DATA_DOES_NOT_EXIST)); CommandMessage testMessage; REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(ActionMessage::getReturnCode(&testMessage) == 0xAFFE); REQUIRE(ActionMessage::getStep(&testMessage) == 0); @@ -100,10 +100,10 @@ TEST_CASE("Action Helper", "[ActionHelper]") { SECTION("Missing IPC Data") { ActionMessage::setCommand(&actionMessage, testActionId, StorageManagerIF::INVALID_ADDRESS); CHECK(not testDhMock.executeActionCalled); - REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == returnvalue::OK); CommandMessage testMessage; REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(StorageManagerIF::ILLEGAL_STORAGE_ID)); diff --git a/unittests/action/TestActionHelper.h b/unittests/action/TestActionHelper.h index 75a9f3fe..bd88df80 100644 --- a/unittests/action/TestActionHelper.h +++ b/unittests/action/TestActionHelper.h @@ -26,7 +26,7 @@ class ActionHelperOwnerMockBase : public HasActionsIF { } this->size = size; memcpy(buffer, data, size); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void clearBuffer() { diff --git a/unittests/cfdp/testAckPdu.cpp b/unittests/cfdp/testAckPdu.cpp index e5668799..93d484db 100644 --- a/unittests/cfdp/testAckPdu.cpp +++ b/unittests/cfdp/testAckPdu.cpp @@ -7,7 +7,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array buf = {}; uint8_t* bufptr = buf.data(); size_t maxsz = buf.size(); @@ -20,7 +20,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { AckTransactionStatus::ACTIVE); auto ackSerializer = AckPduSerializer(ackInfo, pduConf); result = ackSerializer.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); SECTION("Serialize") { REQUIRE(buf.data()[sz - 3] == cfdp::FileDirectives::ACK); @@ -34,7 +34,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { bufptr = buf.data(); sz = 0; result = ackSerializer2.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(buf.data()[sz - 3] == cfdp::FileDirectives::ACK); REQUIRE((buf.data()[sz - 2] >> 4) == FileDirectives::FINISH); REQUIRE((buf.data()[sz - 2] & 0x0f) == 0b0001); @@ -47,7 +47,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { auto ackSerializer3 = AckPduSerializer(ackInfo, pduConf); result = ackSerializer3.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); // Invalid file directive - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); ackInfo.setAckedDirective(FileDirectives::FINISH); // buffer too small @@ -59,7 +59,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { AckInfo ackInfo; auto reader = AckPduDeserializer(buf.data(), sz, ackInfo); result = reader.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(ackInfo.getAckedDirective() == FileDirectives::EOF_DIRECTIVE); REQUIRE(ackInfo.getAckedConditionCode() == ConditionCode::NO_ERROR); REQUIRE(ackInfo.getDirectiveSubtypeCode() == 0); @@ -71,11 +71,11 @@ TEST_CASE("ACK PDU", "[AckPdu]") { bufptr = buf.data(); sz = 0; result = ackSerializer2.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); auto reader2 = AckPduDeserializer(buf.data(), sz, ackInfo); result = reader2.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(ackInfo.getAckedDirective() == FileDirectives::FINISH); REQUIRE(ackInfo.getAckedConditionCode() == ConditionCode::FILESTORE_REJECTION); REQUIRE(ackInfo.getDirectiveSubtypeCode() == 0b0001); diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index e7acab01..b18ef9a3 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -14,7 +14,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { using namespace cfdp; std::array serBuf; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; cfdp::TransactionSeqNum seqNum = TransactionSeqNum(cfdp::WidthInBytes::ONE_BYTE, 2); cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0); cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1); @@ -29,10 +29,10 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { const uint8_t** dummyPtr = nullptr; ReturnValue_t deserResult = headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK); - REQUIRE(deserResult == result::FAILED); + REQUIRE(deserResult == returnvalue::FAILED); deserResult = headerSerializer.serialize(nullptr, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(deserResult == result::FAILED); + REQUIRE(deserResult == returnvalue::FAILED); REQUIRE(seqNum.getSerializedSize() == 1); REQUIRE(headerSerializer.getPduDataFieldLen() == 0); @@ -62,7 +62,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serSize == 7); // Only version bits are set REQUIRE(serBuf[0] == 0b00100000); @@ -155,11 +155,11 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { REQUIRE(entityId == 0x00ff00ff); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); uint8_t oneByteSourceId = 32; serTarget = &oneByteSourceId; size_t deserLen = 1; @@ -197,7 +197,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); ReturnValue_t result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serBuf[1] == 0); REQUIRE(serBuf[2] == 0); // Entity and Transaction Sequence number are 1 byte large @@ -207,7 +207,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { auto headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); ReturnValue_t serResult = headerDeser.parseData(); - REQUIRE(serResult == result::OK); + REQUIRE(serResult == returnvalue::OK); REQUIRE(headerDeser.getPduDataFieldLen() == 0); REQUIRE(headerDeser.getHeaderSize() == 7); REQUIRE(headerDeser.getWholePduSize() == 7); @@ -230,11 +230,11 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { headerSerializer.setPduType(cfdp::PduType::FILE_DATA); headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); serTarget = serBuf.data(); serSize = 0; result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), @@ -242,7 +242,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); result = headerDeser.parseData(); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Everything except version bit flipped to one now REQUIRE(serBuf[0] == 0x3f); REQUIRE(serBuf[3] == 0b11001010); @@ -274,7 +274,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { serTarget = serBuf.data(); const uint8_t** serTargetConst = const_cast(&serTarget); result = headerDeser.parseData(); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); headerDeser.setData(nullptr, -1); REQUIRE(headerDeser.getHeaderSize() == 0); @@ -286,7 +286,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48); result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(headerDeser.getWholePduSize() == 8); headerDeser.setData(serBuf.data(), serBuf.size()); @@ -301,7 +301,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { serTarget = serBuf.data(); serSize = 0; result = fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Only version bits are set REQUIRE(serBuf[0] == 0b00100000); // PDU data field length is 5 (4 + Directive code octet) @@ -321,9 +321,9 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { size_t deserSize = 20; serSize = 0; REQUIRE(fdSer.deSerialize(&deserTarget, &deserSize, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); REQUIRE(fdSer.serialize(nullptr, nullptr, 85, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); for (uint8_t idx = 0; idx < 8; idx++) { serTarget = serBuf.data(); serSize = 0; @@ -338,7 +338,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); fdDeser.setEndianness(SerializeIF::Endianness::NETWORK); - REQUIRE(fdDeser.parseData() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(fdDeser.parseData() == returnvalue::OK); REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK); REQUIRE(fdDeser.getPduDataFieldLen() == 5); REQUIRE(fdDeser.getHeaderSize() == 8); @@ -358,11 +358,11 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { fss.setFileSize(0x20, false); ReturnValue_t result = fss.serialize(&buffer, &size, fssBuf.size(), SerializeIF::Endianness::MACHINE); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); uint32_t fileSize = 0; result = SerializeAdapter::deSerialize(&fileSize, fssBuf.data(), nullptr, SerializeIF::Endianness::MACHINE); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(fileSize == 0x20); } } diff --git a/unittests/cfdp/testEofPdu.cpp b/unittests/cfdp/testEofPdu.cpp index d400af5a..b5cd801c 100644 --- a/unittests/cfdp/testEofPdu.cpp +++ b/unittests/cfdp/testEofPdu.cpp @@ -8,7 +8,7 @@ TEST_CASE("EOF PDU", "[EofPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array buf = {}; uint8_t* bufPtr = buf.data(); size_t sz = 0; @@ -25,17 +25,17 @@ TEST_CASE("EOF PDU", "[EofPdu]") { auto eofSerializer = EofPduSerializer(pduConf, eofInfo); SECTION("Serialize") { result = eofSerializer.serialize(&bufPtr, &sz, buf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(((buf[1] << 8) | buf[2]) == 10); uint32_t checksum = 0; result = SerializeAdapter::deSerialize(&checksum, buf.data() + sz - 8, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(checksum == 5); uint32_t fileSizeVal = 0; result = SerializeAdapter::deSerialize(&fileSizeVal, buf.data() + sz - 4, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(fileSizeVal == 12); REQUIRE(buf[sz - 10] == cfdp::FileDirectives::EOF_DIRECTIVE); REQUIRE(buf[sz - 9] == 0x00); @@ -50,7 +50,7 @@ TEST_CASE("EOF PDU", "[EofPdu]") { sz = 0; result = serializeWithFaultLocation.serialize(&bufPtr, &sz, buf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(sz == 28); REQUIRE(buf[10] == cfdp::FileDirectives::EOF_DIRECTIVE); REQUIRE(buf[11] >> 4 == cfdp::ConditionCode::FILESTORE_REJECTION); @@ -80,12 +80,12 @@ TEST_CASE("EOF PDU", "[EofPdu]") { SECTION("Deserialize") { result = eofSerializer.serialize(&bufPtr, &sz, buf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); EntityIdTlv tlv(destId); EofInfo emptyInfo(&tlv); auto deserializer = EofPduDeserializer(buf.data(), buf.size(), emptyInfo); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::NO_ERROR); REQUIRE(emptyInfo.getChecksum() == 5); REQUIRE(emptyInfo.getFileSize().getSize() == 12); @@ -101,7 +101,7 @@ TEST_CASE("EOF PDU", "[EofPdu]") { SerializeIF::Endianness::NETWORK); auto deserializer2 = EofPduDeserializer(buf.data(), buf.size(), emptyInfo); result = deserializer2.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::FILESTORE_REJECTION); REQUIRE(emptyInfo.getChecksum() == 5); REQUIRE(emptyInfo.getFileSize().getSize() == 0x10ffffff10); @@ -112,7 +112,7 @@ TEST_CASE("EOF PDU", "[EofPdu]") { for (size_t maxSz = 0; maxSz < deserializer2.getWholePduSize() - 1; maxSz++) { auto invalidDeser = EofPduDeserializer(buf.data(), maxSz, emptyInfo); result = invalidDeser.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } } diff --git a/unittests/cfdp/testFileData.cpp b/unittests/cfdp/testFileData.cpp index 1f6a09e9..dd8654d6 100644 --- a/unittests/cfdp/testFileData.cpp +++ b/unittests/cfdp/testFileData.cpp @@ -9,7 +9,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array fileBuffer = {}; std::array fileDataBuffer = {}; uint8_t* buffer = fileDataBuffer.data(); @@ -29,7 +29,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { FileDataSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(sz == 24); // 10 file bytes plus 4 byte offset REQUIRE(((fileDataBuffer[1] << 8) | fileDataBuffer[2]) == 14); @@ -39,7 +39,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { buffer = fileDataBuffer.data(); result = SerializeAdapter::deSerialize(&offsetRaw, buffer + 10, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(offsetRaw == 50); buffer = fileDataBuffer.data() + 14; for (size_t idx = 0; idx < 10; idx++) { @@ -62,7 +62,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { result = serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(((fileDataBuffer[1] << 8) | fileDataBuffer[2]) == 25); // First bit: Seg Ctrl is set // Bits 1 to 3 length of enitity IDs is 2 @@ -88,7 +88,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { buffer = fileDataBuffer.data(); sz = 0; result = serializer.serialize(&buffer, &invalidStartSz, sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } info.setSegmentMetadataFlag(true); @@ -105,13 +105,13 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { FileDataSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); FileSize emptyOffset; FileDataInfo emptyInfo(emptyOffset); FileDataDeserializer deserializer(fileDataBuffer.data(), fileDataBuffer.size(), emptyInfo); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserializer.getWholePduSize() == 24); REQUIRE(deserializer.getPduDataFieldLen() == 14); REQUIRE(deserializer.getSegmentationControl() == @@ -136,10 +136,10 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { sz = 0; result = serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getOffset().getSize() == 50); REQUIRE(emptyInfo.hasSegmentMetadata() == true); @@ -164,7 +164,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { // Starting at 15, the file data is parsed. There is not leading file data length // field to the parser can't check whether the remaining length is valid if (invalidPduField < 15) { - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } } diff --git a/unittests/cfdp/testFinishedPdu.cpp b/unittests/cfdp/testFinishedPdu.cpp index 143eaf2a..dd04144c 100644 --- a/unittests/cfdp/testFinishedPdu.cpp +++ b/unittests/cfdp/testFinishedPdu.cpp @@ -7,7 +7,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array fnBuffer = {}; uint8_t* buffer = fnBuffer.data(); size_t sz = 0; @@ -24,7 +24,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { SECTION("Serialize") { FinishPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getSerializedSize() == 12); REQUIRE(((fnBuffer[1] << 8) | fnBuffer[2]) == 2); REQUIRE(fnBuffer[10] == cfdp::FileDirectives::FINISH); @@ -47,7 +47,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { sz = 0; buffer = fnBuffer.data(); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getSerializedSize() == 12 + 14); REQUIRE(serializer.getPduDataFieldLen() == 16); @@ -69,7 +69,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { sz = 0; buffer = fnBuffer.data(); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); info.setConditionCode(cfdp::ConditionCode::FILESTORE_REJECTION); REQUIRE(serializer.getSerializedSize() == 12 + 14 + 15 + 4); REQUIRE(sz == 12 + 14 + 15 + 4); @@ -81,7 +81,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { sz = 0; buffer = fnBuffer.data(); result = serializer.serialize(&buffer, &sz, maxSz, SerializeIF::Endianness::NETWORK); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } @@ -89,10 +89,10 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { FinishedInfo emptyInfo; FinishPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); FinishPduDeserializer deserializer(fnBuffer.data(), fnBuffer.size(), emptyInfo); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getFileStatus() == cfdp::FinishedFileStatus::DISCARDED_DELIBERATELY); REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::INACTIVITY_DETECTED); REQUIRE(emptyInfo.getDeliveryCode() == cfdp::FinishedDeliveryCode::DATA_INCOMPLETE); @@ -110,13 +110,13 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { serializer.updateDirectiveFieldLen(); REQUIRE(serializer.getPduDataFieldLen() == 16); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); FilestoreResponseTlv emptyResponse(firstNameLv, nullptr); responsePtr = &emptyResponse; emptyInfo.setFilestoreResponsesArray(&responsePtr, nullptr, &len); FinishPduDeserializer deserializer2(fnBuffer.data(), fnBuffer.size(), emptyInfo); result = deserializer2.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getFsResponsesLen() == 1); FilestoreResponseTlv** responseArray = nullptr; emptyInfo.getFilestoreResonses(&responseArray, nullptr, nullptr); @@ -145,7 +145,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { sz = 0; buffer = fnBuffer.data(); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); EntityId emptyId; EntityIdTlv emptyFaultLoc(emptyId); emptyInfo.setFaultLocation(&emptyFaultLoc); @@ -154,7 +154,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { response2.setFilestoreMessage(&emptyFsMsg); FinishPduDeserializer deserializer3(fnBuffer.data(), fnBuffer.size(), emptyInfo); result = deserializer3.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); auto& infoRef = deserializer3.getInfo(); REQUIRE(deserializer3.getWholePduSize() == 45); @@ -183,7 +183,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { for (size_t maxSz = 0; maxSz < 45; maxSz++) { FinishPduDeserializer faultyDeser(fnBuffer.data(), maxSz, emptyInfo); result = faultyDeser.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } } diff --git a/unittests/cfdp/testKeepAlivePdu.cpp b/unittests/cfdp/testKeepAlivePdu.cpp index 8ec8c66c..4b52a084 100644 --- a/unittests/cfdp/testKeepAlivePdu.cpp +++ b/unittests/cfdp/testKeepAlivePdu.cpp @@ -7,7 +7,7 @@ TEST_CASE("Keep Alive PDU", "[KeepAlivePdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array kaBuffer = {}; uint8_t* buffer = kaBuffer.data(); size_t sz = 0; @@ -21,12 +21,12 @@ TEST_CASE("Keep Alive PDU", "[KeepAlivePdu]") { SECTION("Serialize") { KeepAlivePduSerializer serializer(pduConf, progress); result = serializer.serialize(&buffer, &sz, kaBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(kaBuffer[10] == cfdp::FileDirectives::KEEP_ALIVE); uint32_t fsRaw = 0; result = SerializeAdapter::deSerialize(&fsRaw, kaBuffer.data() + 11, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(fsRaw == 0x50); REQUIRE(sz == 15); REQUIRE(serializer.getWholePduSize() == 15); @@ -37,33 +37,33 @@ TEST_CASE("Keep Alive PDU", "[KeepAlivePdu]") { buffer = kaBuffer.data(); sz = 0; result = serializer.serialize(&buffer, &sz, kaBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getWholePduSize() == 19); REQUIRE(serializer.getPduDataFieldLen() == 9); uint64_t fsRawLarge = 0; result = SerializeAdapter::deSerialize(&fsRawLarge, kaBuffer.data() + 11, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(fsRawLarge == 0x50); for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { buffer = kaBuffer.data(); sz = 0; result = serializer.serialize(&buffer, &sz, invalidMaxSz, SerializeIF::Endianness::NETWORK); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } SECTION("Deserialize") { KeepAlivePduSerializer serializer(pduConf, progress); result = serializer.serialize(&buffer, &sz, kaBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Set another file size progress.setFileSize(200, false); KeepAlivePduDeserializer deserializer(kaBuffer.data(), kaBuffer.size(), progress); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); auto& progRef = deserializer.getProgress(); // Should have been overwritten REQUIRE(progRef.getSize() == 0x50); @@ -73,7 +73,7 @@ TEST_CASE("Keep Alive PDU", "[KeepAlivePdu]") { for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { deserializer.setData(kaBuffer.data(), invalidMaxSz); result = deserializer.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } } diff --git a/unittests/cfdp/testMetadataPdu.cpp b/unittests/cfdp/testMetadataPdu.cpp index 331d64a9..7e90e8d3 100644 --- a/unittests/cfdp/testMetadataPdu.cpp +++ b/unittests/cfdp/testMetadataPdu.cpp @@ -10,7 +10,7 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array mdBuffer = {}; uint8_t* buffer = mdBuffer.data(); size_t sz = 0; @@ -41,7 +41,7 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { SECTION("Serialize") { MetadataPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getWholePduSize() == 27); REQUIRE(info.getSourceFileName().getSerializedSize() == 10); REQUIRE(info.getDestFileName().getSerializedSize() == 1); @@ -53,7 +53,7 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { uint32_t fileSizeRaw = 0; result = SerializeAdapter::deSerialize(&fileSizeRaw, mdBuffer.data() + 12, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(fileSizeRaw == 35); REQUIRE(mdBuffer[16] == 9); REQUIRE(mdBuffer[17] == 'h'); @@ -83,7 +83,7 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { serializer.updateDirectiveFieldLen(); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE((mdBuffer[1] << 8 | mdBuffer[2]) == 37); auto checksumType = static_cast(mdBuffer[11] & 0x0f); REQUIRE(checksumType == cfdp::ChecksumType::CRC_32C); @@ -117,16 +117,16 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { SECTION("Deserialize") { MetadataPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); MetadataPduDeserializer deserializer(mdBuffer.data(), mdBuffer.size(), info); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); size_t fullSize = deserializer.getWholePduSize(); for (size_t maxSz = 0; maxSz < fullSize; maxSz++) { MetadataPduDeserializer invalidSzDeser(mdBuffer.data(), maxSz, info); result = invalidSzDeser.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } size_t sizeOfOptions = options.size(); size_t maxSize = 4; @@ -140,11 +140,11 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { info.setSourceFileName(sourceFileName); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); MetadataPduDeserializer deserializer2(mdBuffer.data(), mdBuffer.size(), info); result = deserializer2.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(options[0]->getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); REQUIRE(options[0]->getSerializedSize() == 14); REQUIRE(options[1]->getType() == cfdp::TlvTypes::MSG_TO_USER); @@ -162,7 +162,7 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { } // This is the precise length where there are no options or one option if (invalidFieldLen != 17 and invalidFieldLen != 31) { - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } mdBuffer[1] = (36 >> 8) & 0xff; diff --git a/unittests/cfdp/testNakPdu.cpp b/unittests/cfdp/testNakPdu.cpp index 38b45300..0fc74c89 100644 --- a/unittests/cfdp/testNakPdu.cpp +++ b/unittests/cfdp/testNakPdu.cpp @@ -8,7 +8,7 @@ TEST_CASE("NAK PDU", "[NakPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array nakBuffer = {}; uint8_t* buffer = nakBuffer.data(); size_t sz = 0; @@ -23,7 +23,7 @@ TEST_CASE("NAK PDU", "[NakPdu]") { SECTION("Serializer") { NakPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getSerializedSize() == 19); REQUIRE(serializer.FileDirectiveSerializer::getSerializedSize() == 11); REQUIRE(sz == 19); @@ -33,11 +33,11 @@ TEST_CASE("NAK PDU", "[NakPdu]") { uint32_t scope = 0; result = SerializeAdapter::deSerialize(&scope, nakBuffer.data() + 11, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(scope == 50); result = SerializeAdapter::deSerialize(&scope, nakBuffer.data() + 15, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(scope == 1050); NakInfo::SegmentRequest segReq0(cfdp::FileSize(2020), cfdp::FileSize(2520)); @@ -50,26 +50,26 @@ TEST_CASE("NAK PDU", "[NakPdu]") { size_t sz = 0; serializer.updateDirectiveFieldLen(); result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getSerializedSize() == 35); REQUIRE(serializer.getPduDataFieldLen() == 25); REQUIRE(((nakBuffer[1] << 8) | nakBuffer[2]) == 25); uint32_t segReqScopes = 0; result = SerializeAdapter::deSerialize(&segReqScopes, nakBuffer.data() + 19, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(segReqScopes == 2020); result = SerializeAdapter::deSerialize(&segReqScopes, nakBuffer.data() + 23, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(segReqScopes == 2520); result = SerializeAdapter::deSerialize(&segReqScopes, nakBuffer.data() + 27, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(segReqScopes == 2932); result = SerializeAdapter::deSerialize(&segReqScopes, nakBuffer.data() + 31, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(segReqScopes == 3021); for (size_t maxSz = 0; maxSz < 35; maxSz++) { @@ -89,13 +89,13 @@ TEST_CASE("NAK PDU", "[NakPdu]") { SECTION("Deserializer") { NakPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); info.getStartOfScope().setFileSize(0, false); info.getEndOfScope().setFileSize(0, false); NakPduDeserializer deserializer(nakBuffer.data(), nakBuffer.size(), info); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserializer.getWholePduSize() == 19); REQUIRE(info.getStartOfScope().getSize() == 50); REQUIRE(info.getEndOfScope().getSize() == 1050); @@ -110,11 +110,11 @@ TEST_CASE("NAK PDU", "[NakPdu]") { size_t sz = 0; serializer.updateDirectiveFieldLen(); result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); NakPduDeserializer deserializeWithSegReqs(nakBuffer.data(), nakBuffer.size(), info); result = deserializeWithSegReqs.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); NakInfo::SegmentRequest* segReqsPtr = nullptr; size_t readSegReqs = 0; info.getSegmentRequests(&segReqsPtr, &readSegReqs, nullptr); @@ -128,7 +128,7 @@ TEST_CASE("NAK PDU", "[NakPdu]") { for (size_t idx = 0; idx < 34; idx++) { NakPduDeserializer faultyDeserializer(nakBuffer.data(), idx, info); result = faultyDeserializer.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } for (size_t pduFieldLen = 0; pduFieldLen < 25; pduFieldLen++) { nakBuffer[1] = (pduFieldLen >> 8) & 0xff; @@ -143,7 +143,7 @@ TEST_CASE("NAK PDU", "[NakPdu]") { REQUIRE(info.getSegmentRequestsLen() == 2); } if (pduFieldLen != 9 and pduFieldLen != 17 and pduFieldLen != 25) { - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } info.setMaxSegmentRequestLen(5); diff --git a/unittests/cfdp/testPromptPdu.cpp b/unittests/cfdp/testPromptPdu.cpp index 9f406aec..80363983 100644 --- a/unittests/cfdp/testPromptPdu.cpp +++ b/unittests/cfdp/testPromptPdu.cpp @@ -7,7 +7,7 @@ TEST_CASE("Prompt PDU", "[PromptPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array rawBuf = {}; uint8_t* buffer = rawBuf.data(); size_t sz = 0; @@ -19,7 +19,7 @@ TEST_CASE("Prompt PDU", "[PromptPdu]") { SECTION("Serialize") { PromptPduSerializer serializer(pduConf, cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); result = serializer.serialize(&buffer, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getWholePduSize() == 12); REQUIRE(sz == 12); REQUIRE(serializer.getPduDataFieldLen() == 2); @@ -30,24 +30,24 @@ TEST_CASE("Prompt PDU", "[PromptPdu]") { uint8_t* buffer = rawBuf.data(); size_t sz = 0; result = serializer.serialize(&buffer, &sz, invalidMaxSz, SerializeIF::Endianness::NETWORK); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } for (size_t invalidSz = 1; invalidSz < sz; invalidSz++) { size_t locSz = invalidSz; uint8_t* buffer = rawBuf.data(); result = serializer.serialize(&buffer, &locSz, sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } SECTION("Deserialize") { PromptPduSerializer serializer(pduConf, cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); result = serializer.serialize(&buffer, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); PromptPduDeserializer deserializer(rawBuf.data(), rawBuf.size()); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserializer.getPromptResponseRequired() == cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); sz = deserializer.getWholePduSize(); @@ -59,7 +59,7 @@ TEST_CASE("Prompt PDU", "[PromptPdu]") { for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { deserializer.setData(rawBuf.data(), invalidMaxSz); result = deserializer.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } } diff --git a/unittests/cfdp/testTlvsLvs.cpp b/unittests/cfdp/testTlvsLvs.cpp index c251fd15..3bfd3a6b 100644 --- a/unittests/cfdp/testTlvsLvs.cpp +++ b/unittests/cfdp/testTlvsLvs.cpp @@ -16,7 +16,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { using namespace cfdp; - int result = HasReturnvaluesIF::RETURN_OK; + int result = returnvalue::OK; std::array rawBuf; uint8_t* serPtr = rawBuf.data(); const uint8_t* deserPtr = rawBuf.data(); @@ -28,7 +28,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = tlvRawBuf.data(); result = sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 2); auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvRawBuf.data(), deserSize); REQUIRE(tlv.getSerializedSize() == 4); @@ -36,7 +36,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); deserSize = 0; result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 4); REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); REQUIRE(rawBuf[1] == 2); @@ -55,25 +55,25 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); deserSize = 0; result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); REQUIRE(rawBuf[1] == 4); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); serPtr = rawBuf.data(); deserSize = 0; auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, tlvRawBuf.data(), 0); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) != returnvalue::OK); tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) != returnvalue::OK); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); REQUIRE(tlvInvalid.getSerializedSize() == 0); REQUIRE(tlvInvalid.serialize(nullptr, nullptr, 0, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); REQUIRE(zeroLenField.getSerializedSize() == 2); @@ -81,7 +81,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { deserSize = 0; REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER); REQUIRE(rawBuf[1] == 0); } @@ -100,7 +100,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { Tlv tlv; deserPtr = rawBuf.data(); result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(tlv.getSerializedSize() == 4); REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID); deserPtr = tlv.getValue(); @@ -111,7 +111,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { REQUIRE(entityId == 0x0ff0); REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); deserPtr = rawBuf.data(); deserSize = 0; REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) == @@ -120,17 +120,17 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { rawBuf[0] = TlvTypes::INVALID_TLV; deserSize = 4; REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); serPtr = rawBuf.data(); deserSize = 0; REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); deserPtr = rawBuf.data(); result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(zeroLenField.getSerializedSize() == 2); REQUIRE(deserSize == 0); } @@ -140,7 +140,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = lvRawBuf.data(); result = sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 2); auto lv = cfdp::Lv(lvRawBuf.data(), 2); auto lvCopy = cfdp::Lv(lv); @@ -150,7 +150,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); deserSize = 0; result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 3); REQUIRE(rawBuf[0] == 2); uint16_t sourceId = 0; @@ -164,7 +164,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { deserSize = 0; result = lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 1); } @@ -177,13 +177,13 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); deserSize = 0; result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); Lv uninitLv; deserPtr = rawBuf.data(); deserSize = 3; result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(uninitLv.getSerializedSize() == 3); const uint8_t* storedValue = uninitLv.getValue(nullptr); uint16_t sourceId = 0; @@ -197,15 +197,15 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { deserSize = 0; result = lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 1); deserPtr = rawBuf.data(); result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(uninitLv.getSerializedSize() == 1); REQUIRE(uninitLv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); serPtr = rawBuf.data(); deserSize = 0; REQUIRE(uninitLv.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::BIG) == @@ -233,14 +233,14 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { std::array serBuf = {}; result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); cfdp::Lv emptyMsg; cfdp::Lv emptySecondName; FilestoreResponseTlv emptyTlv(firstName, &emptyMsg); emptyTlv.setSecondFileName(&emptySecondName); result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyTlv.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); REQUIRE(emptyTlv.getStatusCode() == cfdp::FSR_SUCCESS); size_t firstNameLen = 0; @@ -274,26 +274,26 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { REQUIRE(expectedSz == 10 + 11 + 1); REQUIRE(request.getSerializedSize() == expectedSz + 2); result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(sz == expectedSz + 2); FilestoreRequestTlv emptyRequest(firstName); emptyRequest.setSecondFileName(&secondName); const uint8_t* constptr = serBuf.data(); result = emptyRequest.deSerialize(&constptr, &sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); cfdp::Tlv rawRequest; ptr = serBuf.data(); sz = 0; result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE); result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); } @@ -310,11 +310,11 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); REQUIRE(faultOverrideTlv.getSerializedSize() == 3); REQUIRE(sz == 3); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); FaultHandlerOverrideTlv emptyOverrideTlv; result = emptyOverrideTlv.deSerialize(&deserPtr, &sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); EntityId entId(cfdp::WidthInBytes::TWO_BYTES, 0x42); EntityId emptyId; @@ -322,9 +322,9 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); deserPtr = rawBuf.data(); result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); } } diff --git a/unittests/container/RingBufferTest.cpp b/unittests/container/RingBufferTest.cpp index edabfd55..efc571b4 100644 --- a/unittests/container/RingBufferTest.cpp +++ b/unittests/container/RingBufferTest.cpp @@ -12,42 +12,42 @@ TEST_CASE("Ring Buffer Test", "[RingBufferTest]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.writeData(testData, 3) == result::FAILED); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == returnvalue::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 4) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == returnvalue::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == returnvalue::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 1024) == result::FAILED); - REQUIRE(ringBuffer.writeData(nullptr, 5) == result::FAILED); + REQUIRE(ringBuffer.writeData(testData, 1024) == returnvalue::FAILED); + REQUIRE(ringBuffer.writeData(nullptr, 5) == returnvalue::FAILED); } SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 8) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == returnvalue::FAILED); REQUIRE(ringBuffer.writeTillWrap() == 2); // too many excess bytes. - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == returnvalue::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == returnvalue::OK); REQUIRE(ringBuffer.getExcessBytes() == 3); std::memcpy(testPtr, testData, 5); ringBuffer.confirmBytesWritten(5); @@ -59,19 +59,19 @@ TEST_CASE("Ring Buffer Test", "[RingBufferTest]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == returnvalue::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == returnvalue::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); } } @@ -84,21 +84,21 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == returnvalue::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 4) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == returnvalue::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == returnvalue::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } @@ -106,17 +106,17 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 8) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == returnvalue::FAILED); REQUIRE(ringBuffer.writeTillWrap() == 2); // too many excess bytes. - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == returnvalue::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == returnvalue::OK); REQUIRE(ringBuffer.getExcessBytes() == 3); std::memcpy(testPtr, testData, 5); ringBuffer.confirmBytesWritten(5); @@ -128,19 +128,19 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == returnvalue::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == returnvalue::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); } @@ -148,17 +148,17 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { REQUIRE(ringBuffer.availableWriteSpace() == 9); // We don't allow writing of Data that is larger than the ring buffer in total REQUIRE(ringBuffer.getMaxSize() == 9); - REQUIRE(ringBuffer.writeData(testData, 13) == result::FAILED); + REQUIRE(ringBuffer.writeData(testData, 13) == returnvalue::FAILED); REQUIRE(ringBuffer.getAvailableReadData() == 0); ringBuffer.clear(); uint8_t *ptr = nullptr; // With excess Bytes 13 Bytes can be written to this Buffer - REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == returnvalue::OK); REQUIRE(ptr != nullptr); memcpy(ptr, testData, 13); ringBuffer.confirmBytesWritten(13); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 3, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 3, true) == returnvalue::OK); for (auto i = 0; i < 3; i++) { REQUIRE(readBuffer[i] == testData[i + 10]); } @@ -173,21 +173,21 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == returnvalue::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 4) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == returnvalue::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == returnvalue::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } @@ -195,19 +195,19 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 8) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == returnvalue::OK); REQUIRE(ringBuffer.getExcessBytes() == 8); REQUIRE(ringBuffer.writeTillWrap() == 2); // too many excess bytes. - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == returnvalue::FAILED); // Less Execss bytes overwrites before - REQUIRE(ringBuffer.getFreeElement(&testPtr, 3) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 3) == returnvalue::OK); REQUIRE(ringBuffer.getExcessBytes() == 1); std::memcpy(testPtr, testData, 3); ringBuffer.confirmBytesWritten(3); @@ -219,19 +219,19 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == returnvalue::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == returnvalue::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); } @@ -239,18 +239,18 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { REQUIRE(ringBuffer.availableWriteSpace() == 9); // Writing more than the buffer is large. // This write will be rejected and is seen as a configuration mistake - REQUIRE(ringBuffer.writeData(testData, 13) == result::FAILED); + REQUIRE(ringBuffer.writeData(testData, 13) == returnvalue::FAILED); REQUIRE(ringBuffer.getAvailableReadData() == 0); ringBuffer.clear(); // Using FreeElement allows the usage of excessBytes but // should be used with caution uint8_t *ptr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == returnvalue::OK); REQUIRE(ptr != nullptr); memcpy(ptr, testData, 13); ringBuffer.confirmBytesWritten(13); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 3, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 3, true) == returnvalue::OK); for (auto i = 0; i < 3; i++) { REQUIRE(readBuffer[i] == testData[i + 10]); } @@ -264,22 +264,22 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.writeData(testData, 3) == result::FAILED); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == returnvalue::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 4) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == returnvalue::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == returnvalue::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } @@ -287,16 +287,16 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") { SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 8) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == returnvalue::FAILED); REQUIRE(ringBuffer.writeTillWrap() == 2); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::OK); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == returnvalue::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == returnvalue::OK); REQUIRE(ringBuffer.getExcessBytes() == 3); std::memcpy(testPtr, testData, 5); ringBuffer.confirmBytesWritten(5); @@ -308,19 +308,19 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == returnvalue::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == returnvalue::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); } } diff --git a/unittests/container/TestArrayList.cpp b/unittests/container/TestArrayList.cpp index 4daf59d4..e2f14e47 100644 --- a/unittests/container/TestArrayList.cpp +++ b/unittests/container/TestArrayList.cpp @@ -25,7 +25,7 @@ TEST_CASE("Array List", "[ArrayListTest]") { SECTION("SimpleTest") { REQUIRE(list.maxSize() == 20); REQUIRE(list.size == 0); - REQUIRE(list.insert(10) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(list.insert(10) == static_cast(returnvalue::OK)); REQUIRE(list[0] == 10); REQUIRE(list.front() != nullptr); REQUIRE((*list.front()) == 10); @@ -41,7 +41,7 @@ TEST_CASE("Array List", "[ArrayListTest]") { // This is an invalid element but its not a nullptr REQUIRE(list.back() != nullptr); for (auto i = 0; i < 20; i++) { - REQUIRE(list.insert(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(list.insert(i) == static_cast(returnvalue::OK)); } REQUIRE(list.insert(20) == static_cast(ArrayList::FULL)); ArrayList::Iterator it = list.begin(); @@ -64,7 +64,7 @@ TEST_CASE("Array List", "[ArrayListTest]") { SECTION("Const Iterator") { ArrayList::Iterator it = list.begin(); for (auto i = 0; i < 10; i++) { - REQUIRE(list.insert(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(list.insert(i) == static_cast(returnvalue::OK)); } it++; const uint16_t* number = it.value; @@ -75,7 +75,7 @@ TEST_CASE("Array List", "[ArrayListTest]") { ArrayList::Iterator it = complexList.begin(); for (auto i = 0; i < 10; i++) { REQUIRE(complexList.insert(TestClass(i, i + 1)) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); } it++; const TestClass* secondTest = it.value; diff --git a/unittests/container/TestDynamicFifo.cpp b/unittests/container/TestDynamicFifo.cpp index 6769c247..1475b0dc 100644 --- a/unittests/container/TestDynamicFifo.cpp +++ b/unittests/container/TestDynamicFifo.cpp @@ -35,13 +35,13 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { REQUIRE(fifo.empty()); REQUIRE(not fifo.full()); - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.insert(structTwo) == static_cast(FIFOBase::FULL)); struct Test testptr; - REQUIRE(fifo.peek(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.peek(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == structOne; REQUIRE(equal); REQUIRE(fifo.size() == 3); @@ -52,7 +52,7 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { testptr.number1 = 0; testptr.number2 = 0; testptr.number3 = 0; - REQUIRE(fifo.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.retrieve(&testptr) == static_cast(returnvalue::OK)); equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo.size() == i); @@ -66,29 +66,29 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { REQUIRE(fifo.empty()); REQUIRE(fifo.pop() == static_cast(FIFOBase::EMPTY)); - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 1); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 2); - REQUIRE(fifo.pop() == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.pop() == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 1); testptr.number1 = 0; testptr.number2 = 0; testptr.number3 = 0; - REQUIRE(fifo.peek(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.peek(&testptr) == static_cast(returnvalue::OK)); equal = testptr == structTwo; REQUIRE(equal); - REQUIRE(fifo.pop() == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.pop() == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 0); REQUIRE(fifo.empty()); // struct Test* ptr = nullptr; - // REQUIRE(fifo.retrieve(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); - // REQUIRE(fifo.peek(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); + // REQUIRE(fifo.retrieve(ptr) == static_cast(HasReturnvaluesIF::returnvalue::FAILED)); + // REQUIRE(fifo.peek(ptr) == static_cast(HasReturnvaluesIF::returnvalue::FAILED)); }; SECTION("Copy Test") { - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 3); REQUIRE(fifo.full()); REQUIRE(not fifo.empty()); @@ -100,9 +100,9 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { }; SECTION("Assignment Test") { - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 3); REQUIRE(fifo.full()); REQUIRE(not fifo.empty()); @@ -114,7 +114,7 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { REQUIRE(not fifo2.empty()); for (size_t i = 2; i < 3; i--) { struct Test testptr = {0, 0, 0}; - REQUIRE(fifo2.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo2.retrieve(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo2.size() == i); @@ -122,9 +122,9 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { }; SECTION("Assignment Test Smaller") { - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 3); REQUIRE(fifo.full()); REQUIRE(not fifo.empty()); @@ -136,7 +136,7 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { REQUIRE(not fifo2.empty()); for (size_t i = 2; i < 3; i--) { struct Test testptr = {0, 0, 0}; - REQUIRE(fifo2.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo2.retrieve(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo2.size() == i); diff --git a/unittests/container/TestFifo.cpp b/unittests/container/TestFifo.cpp index 0b4b41af..1a3c9d8a 100644 --- a/unittests/container/TestFifo.cpp +++ b/unittests/container/TestFifo.cpp @@ -35,13 +35,13 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { REQUIRE(fifo.empty()); REQUIRE(not fifo.full()); - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.insert(structTwo) == static_cast(FIFOBase::FULL)); struct Test testptr; - REQUIRE(fifo.peek(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.peek(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == structOne; REQUIRE(equal); REQUIRE(fifo.size() == 3); @@ -52,7 +52,7 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { testptr.number1 = 0; testptr.number2 = 0; testptr.number3 = 0; - REQUIRE(fifo.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.retrieve(&testptr) == static_cast(returnvalue::OK)); equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo.size() == i); @@ -66,11 +66,11 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { REQUIRE(fifo.empty()); REQUIRE(fifo.pop() == static_cast(FIFOBase::EMPTY)); - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 1); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 2); - REQUIRE(fifo.pop() == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.pop() == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 1); testptr.number1 = 0; testptr.number2 = 0; @@ -78,20 +78,20 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { // Test that retrieve and peek will not cause a nullptr dereference struct Test* ptr = nullptr; - REQUIRE(fifo.retrieve(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); - REQUIRE(fifo.peek(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); + REQUIRE(fifo.retrieve(ptr) == static_cast(returnvalue::FAILED)); + REQUIRE(fifo.peek(ptr) == static_cast(returnvalue::FAILED)); - REQUIRE(fifo.peek(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.peek(&testptr) == static_cast(returnvalue::OK)); equal = testptr == structTwo; REQUIRE(equal); - REQUIRE(fifo.pop() == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.pop() == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 0); REQUIRE(fifo.empty()); }; SECTION("Copy Test") { - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 3); REQUIRE(fifo.full()); REQUIRE(not fifo.empty()); @@ -102,7 +102,7 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { REQUIRE(not fifo2.empty()); for (size_t i = 2; i < 3; i--) { struct Test testptr = {0, 0, 0}; - REQUIRE(fifo2.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo2.retrieve(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo2.size() == i); @@ -110,9 +110,9 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { }; SECTION("Assignment Test") { - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 3); REQUIRE(fifo.full()); REQUIRE(not fifo.empty()); @@ -124,7 +124,7 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { REQUIRE(not fifo2.empty()); for (size_t i = 2; i < 3; i--) { struct Test testptr = {0, 0, 0}; - REQUIRE(fifo2.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo2.retrieve(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo2.size() == i); diff --git a/unittests/container/TestFixedArrayList.cpp b/unittests/container/TestFixedArrayList.cpp index 6beb8d5d..b28c3166 100644 --- a/unittests/container/TestFixedArrayList.cpp +++ b/unittests/container/TestFixedArrayList.cpp @@ -10,7 +10,7 @@ TEST_CASE("FixedArrayList Tests", "[TestFixedArrayList]") { using testList = FixedArrayList; testList list; REQUIRE(list.size == 0); - REQUIRE(list.insert(10) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(list.insert(10) == static_cast(returnvalue::OK)); REQUIRE(list.size == 1); REQUIRE(list.maxSize() == 260); SECTION("Copy Constructor") { @@ -29,7 +29,7 @@ TEST_CASE("FixedArrayList Tests", "[TestFixedArrayList]") { }; SECTION("Fill") { for (auto i = 1; i < 260; i++) { - REQUIRE(list.insert(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(list.insert(i) == static_cast(returnvalue::OK)); } REQUIRE(list.insert(260) == static_cast(ArrayList::FULL)); list.clear(); diff --git a/unittests/container/TestFixedMap.cpp b/unittests/container/TestFixedMap.cpp index d3c65760..d17cc55b 100644 --- a/unittests/container/TestFixedMap.cpp +++ b/unittests/container/TestFixedMap.cpp @@ -20,8 +20,8 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { SECTION("Fill and erase") { for (uint16_t i = 0; i < 30; i++) { REQUIRE(map.insert(std::make_pair(i, i + 1)) == - static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(map.exists(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); + REQUIRE(map.exists(i) == static_cast(returnvalue::OK)); REQUIRE(map.find(i)->second == i + 1); REQUIRE(not map.empty()); } @@ -32,7 +32,7 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { REQUIRE(map.full()); { uint16_t* ptr; - REQUIRE(map.find(5, &ptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.find(5, &ptr) == static_cast(returnvalue::OK)); REQUIRE(*ptr == 6); REQUIRE(*(map.findValue(6)) == 7); REQUIRE(map.find(31, &ptr) == @@ -41,7 +41,7 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { REQUIRE(map.getSerializedSize() == (sizeof(uint32_t) + 30 * (sizeof(uint32_t) + sizeof(uint16_t)))); - REQUIRE(map.erase(2) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(2) == static_cast(returnvalue::OK)); REQUIRE(map.erase(31) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); REQUIRE(map.exists(2) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); REQUIRE(map.size() == 29); @@ -60,7 +60,7 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { } for (FixedMap::Iterator it = map.begin(); it != map.end(); it++) { - REQUIRE(map.erase(&it) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(&it) == static_cast(returnvalue::OK)); } REQUIRE(map.size() == 0); @@ -73,11 +73,11 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { SECTION("Insert variants") { FixedMap::Iterator it = map.end(); - REQUIRE(map.insert(36, 37, &it) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(36, 37, &it) == static_cast(returnvalue::OK)); REQUIRE(it->first == 36); REQUIRE(it->second == 37); REQUIRE(map.size() == 1); - REQUIRE(map.insert(37, 38, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(37, 38, nullptr) == static_cast(returnvalue::OK)); REQUIRE(map.find(37)->second == 38); REQUIRE(map.size() == 2); REQUIRE(map.insert(37, 24, nullptr) == @@ -86,8 +86,8 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { REQUIRE(map.size() == 2); }; SECTION("Serialize and DeSerialize") { - REQUIRE(map.insert(36, 37, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(map.insert(37, 38, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(36, 37, nullptr) == static_cast(returnvalue::OK)); + REQUIRE(map.insert(37, 38, nullptr) == static_cast(returnvalue::OK)); uint8_t buffer[sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t))]; REQUIRE(map.getSerializedSize() == (sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t)))); @@ -99,25 +99,25 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { size = 0; REQUIRE(map.serialize( &loc_ptr, &size, sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t)), - SerializeIF::Endianness::BIG) == static_cast(HasReturnvaluesIF::RETURN_OK)); + SerializeIF::Endianness::BIG) == static_cast(returnvalue::OK)); REQUIRE(size == 16); uint32_t internal_size = 0; const uint8_t* ptr2 = buffer; REQUIRE( SerializeAdapter::deSerialize(&internal_size, &ptr2, &size, SerializeIF::Endianness::BIG) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(internal_size == 2); for (uint8_t i = 36; i < 38; i++) { uint32_t first_element = 0; REQUIRE(SerializeAdapter::deSerialize(&first_element, &ptr2, &size, SerializeIF::Endianness::BIG) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(first_element == i); uint16_t second_element = 0; REQUIRE(SerializeAdapter::deSerialize(&second_element, &ptr2, &size, SerializeIF::Endianness::BIG) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(second_element == i + 1); } REQUIRE(size == 0); @@ -126,7 +126,7 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { size = 16; REQUIRE(map.size() == 0); REQUIRE(map.deSerialize(&constPtr, &size, SerializeIF::Endianness::BIG) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(map.size() == 2); REQUIRE(map.find(36)->second == 37); for (auto& element : map) { @@ -154,12 +154,12 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { size_t size = 0; size_t max_size = sizeof(uint32_t) + 1 * (sizeof(uint32_t) + sizeof(uint16_t)); REQUIRE(map.serialize(&ptr, &size, max_size, SerializeIF::Endianness::LITTLE) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); map.clear(); REQUIRE(map.size() == 0); const uint8_t* ptr2 = newBuffer; REQUIRE(map.deSerialize(&ptr2, &size, SerializeIF::Endianness::LITTLE) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(map.size() == 1); REQUIRE(map.find(10)->second == 20); }; diff --git a/unittests/container/TestFixedOrderedMultimap.cpp b/unittests/container/TestFixedOrderedMultimap.cpp index 88b32694..153144cd 100644 --- a/unittests/container/TestFixedOrderedMultimap.cpp +++ b/unittests/container/TestFixedOrderedMultimap.cpp @@ -15,8 +15,8 @@ TEST_CASE("FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { SECTION("Test insert, find, exists") { for (uint16_t i = 0; i < 30; i++) { REQUIRE(map.insert(std::make_pair(i, i + 1)) == - static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(map.exists(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); + REQUIRE(map.exists(i) == static_cast(returnvalue::OK)); REQUIRE(map.find(i)->second == i + 1); } REQUIRE(map.insert(0, 0) == @@ -26,12 +26,12 @@ TEST_CASE("FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { REQUIRE(map.size() == 30); { uint16_t* ptr; - REQUIRE(map.find(5, &ptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.find(5, &ptr) == static_cast(returnvalue::OK)); REQUIRE(*ptr == 6); REQUIRE(map.find(31, &ptr) == static_cast(FixedOrderedMultimap::KEY_DOES_NOT_EXIST)); } - REQUIRE(map.erase(2) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(2) == static_cast(returnvalue::OK)); REQUIRE(map.erase(31) == static_cast(FixedOrderedMultimap::KEY_DOES_NOT_EXIST)); REQUIRE(map.exists(2) == @@ -55,7 +55,7 @@ TEST_CASE("FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { { FixedOrderedMultimap::Iterator it = map.begin(); while (it != map.end()) { - REQUIRE(map.erase(&it) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(&it) == static_cast(returnvalue::OK)); } REQUIRE(map.size() == 0); } @@ -69,16 +69,16 @@ TEST_CASE("FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { SECTION("Test different insert variants") { FixedOrderedMultimap::Iterator it = map.end(); - REQUIRE(map.insert(36, 37, &it) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(36, 37, &it) == static_cast(returnvalue::OK)); REQUIRE(it->first == 36); REQUIRE(it->second == 37); REQUIRE(map.size() == 1); - REQUIRE(map.insert(37, 38, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(37, 38, nullptr) == static_cast(returnvalue::OK)); REQUIRE(map.find(37)->second == 38); REQUIRE(map.size() == 2); - REQUIRE(map.insert(37, 24, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(37, 24, nullptr) == static_cast(returnvalue::OK)); REQUIRE(map.find(37)->second == 38); - REQUIRE(map.insert(0, 1, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(0, 1, nullptr) == static_cast(returnvalue::OK)); REQUIRE(map.find(0)->second == 1); REQUIRE(map.size() == 4); map.clear(); @@ -128,8 +128,8 @@ TEST_CASE("FixedOrderedMultimap Non Trivial Type", "[TestFixedOrderedMultimapNon SECTION("Test insert, find, exists") { for (uint16_t i = 0; i < 30; i++) { REQUIRE(map.insert(std::make_pair(i, TestClass(i + 1, i))) == - static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(map.exists(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); + REQUIRE(map.exists(i) == static_cast(returnvalue::OK)); bool compare = map.find(i)->second == TestClass(i + 1, i); REQUIRE(compare); } @@ -140,13 +140,13 @@ TEST_CASE("FixedOrderedMultimap Non Trivial Type", "[TestFixedOrderedMultimapNon REQUIRE(map.size() == 30); { TestClass* ptr = nullptr; - REQUIRE(map.find(5, &ptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.find(5, &ptr) == static_cast(returnvalue::OK)); bool compare = *ptr == TestClass(6, 5); REQUIRE(compare); REQUIRE(map.find(31, &ptr) == static_cast(FixedOrderedMultimap::KEY_DOES_NOT_EXIST)); } - REQUIRE(map.erase(2) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(2) == static_cast(returnvalue::OK)); REQUIRE(map.erase(31) == static_cast(FixedOrderedMultimap::KEY_DOES_NOT_EXIST)); REQUIRE(map.exists(2) == @@ -174,7 +174,7 @@ TEST_CASE("FixedOrderedMultimap Non Trivial Type", "[TestFixedOrderedMultimapNon { FixedOrderedMultimap::Iterator it = map.begin(); while (it != map.end()) { - REQUIRE(map.erase(&it) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(&it) == static_cast(returnvalue::OK)); } REQUIRE(map.size() == 0); } @@ -189,22 +189,22 @@ TEST_CASE("FixedOrderedMultimap Non Trivial Type", "[TestFixedOrderedMultimapNon SECTION("Test different insert variants") { FixedOrderedMultimap::Iterator it = map.end(); REQUIRE(map.insert(36, TestClass(37, 36), &it) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(it->first == 36); bool compare = it->second == TestClass(37, 36); REQUIRE(compare); REQUIRE(map.size() == 1); REQUIRE(map.insert(37, TestClass(38, 37), nullptr) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); compare = map.find(37)->second == TestClass(38, 37); REQUIRE(compare); REQUIRE(map.size() == 2); REQUIRE(map.insert(37, TestClass(24, 37), nullptr) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); compare = map.find(37)->second == TestClass(38, 37); REQUIRE(compare); REQUIRE(map.insert(0, TestClass(1, 0), nullptr) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); compare = map.find(0)->second == TestClass(1, 0); REQUIRE(compare); REQUIRE(map.size() == 4); diff --git a/unittests/container/TestPlacementFactory.cpp b/unittests/container/TestPlacementFactory.cpp index 1333567e..142f03d7 100644 --- a/unittests/container/TestPlacementFactory.cpp +++ b/unittests/container/TestPlacementFactory.cpp @@ -36,13 +36,13 @@ TEST_CASE("PlacementFactory Tests", "[TestPlacementFactory]") { static_cast(StorageManagerIF::DATA_TOO_LARGE)); uint64_t* number2 = factory.generate(12345); REQUIRE(number2 == nullptr); - REQUIRE(factory.destroy(number) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(factory.destroy(number) == static_cast(returnvalue::OK)); REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr) == - static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(storagePool.deleteData(address) == static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); + REQUIRE(storagePool.deleteData(address) == static_cast(returnvalue::OK)); // Check that PlacementFactory checks for nullptr ptr = nullptr; - REQUIRE(factory.destroy(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); + REQUIRE(factory.destroy(ptr) == static_cast(returnvalue::FAILED)); } } diff --git a/unittests/datapoollocal/DataSetTest.cpp b/unittests/datapoollocal/DataSetTest.cpp index 45085eaf..5ccae911 100644 --- a/unittests/datapoollocal/DataSetTest.cpp +++ b/unittests/datapoollocal/DataSetTest.cpp @@ -16,8 +16,8 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == result::OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == result::OK); + REQUIRE(poolOwner->initializeHkManager() == returnvalue::OK); + REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == returnvalue::OK); LocalPoolStaticTestDataSet localSet; SECTION("BasicTest") { @@ -36,7 +36,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Test local pool ID serialization */ CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize, - SerializeIF::Endianness::MACHINE) == result::OK); + SerializeIF::Endianness::MACHINE) == returnvalue::OK); CHECK(serSize == maxSize); CHECK(localPoolIdBuff[0] == 3); CHECK(lpIds[0] == localSet.localPoolVarUint8.getDataPoolId()); @@ -48,7 +48,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { serSize = 0; CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE, - false) == result::OK); + false) == returnvalue::OK); CHECK(serSize == maxSize - sizeof(uint8_t)); CHECK(lpIds[0] == localSet.localPoolVarUint8.getDataPoolId()); CHECK(lpIds[1] == localSet.localPoolVarFloat.getDataPoolId()); @@ -57,7 +57,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { { /* Test read operation. Values should be all zeros */ PoolReadGuard readHelper(&localSet); - REQUIRE(readHelper.getReadResult() == result::OK); + REQUIRE(readHelper.getReadResult() == returnvalue::OK); CHECK(not localSet.isValid()); CHECK(localSet.localPoolVarUint8.value == 0); CHECK(not localSet.localPoolVarUint8.isValid()); @@ -90,7 +90,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Now we read again and check whether our zeroed values were overwritten with the values in the pool */ PoolReadGuard readHelper(&localSet); - REQUIRE(readHelper.getReadResult() == result::OK); + REQUIRE(readHelper.getReadResult() == returnvalue::OK); CHECK(localSet.isValid()); CHECK(localSet.localPoolVarUint8.value == 232); CHECK(localSet.localPoolVarUint8.isValid()); @@ -110,7 +110,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { uint8_t buffer[maxSize + 1]; uint8_t* buffPtr = buffer; CHECK(localSet.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); uint8_t rawUint8 = buffer[0]; CHECK(rawUint8 == 232); float rawFloat = 0.0; @@ -128,7 +128,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { std::memset(buffer, 0, sizeof(buffer)); const uint8_t* constBuffPtr = buffer; CHECK(localSet.deSerialize(&constBuffPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == result::OK); + SerializeIF::Endianness::MACHINE) == returnvalue::OK); /* Check whether deserialization was successfull */ CHECK(localSet.localPoolVarUint8.value == 0); CHECK(localSet.localPoolVarFloat.value == Catch::Approx(0.0)); @@ -156,7 +156,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { serSize = 0; buffPtr = buffer; CHECK(localSet.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(rawUint8 == 232); std::memcpy(&rawFloat, buffer + sizeof(uint8_t), sizeof(float)); CHECK(rawFloat == Catch::Approx(-2324.322)); @@ -186,7 +186,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { sizeToDeserialize = maxSize; constBuffPtr = buffer; CHECK(localSet.deSerialize(&constBuffPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == result::OK); + SerializeIF::Endianness::MACHINE) == returnvalue::OK); /* Check whether deserialization was successfull */ CHECK(localSet.localPoolVarUint8.value == 0); CHECK(localSet.localPoolVarFloat.value == Catch::Approx(0.0)); @@ -213,10 +213,10 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Register same variables again to get more than 8 registered variables */ for (uint8_t idx = 0; idx < 8; idx++) { - REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == result::OK); + REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == returnvalue::OK); } - REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == result::OK); - REQUIRE(set.registerVariable(&localSet.localPoolUint16Vec) == result::OK); + REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == returnvalue::OK); + REQUIRE(set.registerVariable(&localSet.localPoolUint16Vec) == returnvalue::OK); set.setValidityBufferGeneration(true); { @@ -233,7 +233,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { uint8_t buffer[maxSize + 1]; uint8_t* buffPtr = buffer; CHECK(set.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); std::array validityBuffer; std::memcpy(validityBuffer.data(), buffer + 9 + sizeof(uint16_t) * 3, 2); /* The first 9 variables should be valid */ @@ -251,7 +251,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { const uint8_t* constBuffPtr = buffer; size_t sizeToDeSerialize = serSize; CHECK(set.deSerialize(&constBuffPtr, &sizeToDeSerialize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(localSet.localPoolVarUint8.isValid() == false); CHECK(localSet.localPoolUint16Vec.isValid() == true); } @@ -261,11 +261,11 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { SharedLocalDataSet sharedSet(sharedSetId, poolOwner, lpool::testSetId, 5); localSet.localPoolVarUint8.setReadWriteMode(pool_rwm_t::VAR_WRITE); localSet.localPoolUint16Vec.setReadWriteMode(pool_rwm_t::VAR_WRITE); - CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == result::OK); - CHECK(sharedSet.registerVariable(&localSet.localPoolUint16Vec) == result::OK); - CHECK(sharedSet.initialize() == result::OK); - CHECK(sharedSet.lockDataset() == result::OK); - CHECK(sharedSet.unlockDataset() == result::OK); + CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == returnvalue::OK); + CHECK(sharedSet.registerVariable(&localSet.localPoolUint16Vec) == returnvalue::OK); + CHECK(sharedSet.initialize() == returnvalue::OK); + CHECK(sharedSet.lockDataset() == returnvalue::OK); + CHECK(sharedSet.unlockDataset() == returnvalue::OK); { // PoolReadGuard rg(&sharedSet); @@ -274,7 +274,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { localSet.localPoolUint16Vec.value[0] = 1; localSet.localPoolUint16Vec.value[1] = 2; localSet.localPoolUint16Vec.value[2] = 3; - CHECK(sharedSet.commit() == result::OK); + CHECK(sharedSet.commit() == returnvalue::OK); } sharedSet.setReadCommitProtectionBehaviour(true); @@ -282,5 +282,5 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* we need to reset the subscription list because the pool owner is a global object. */ - CHECK(poolOwner->reset() == result::OK); + CHECK(poolOwner->reset() == returnvalue::OK); } diff --git a/unittests/datapoollocal/LocalPoolManagerTest.cpp b/unittests/datapoollocal/LocalPoolManagerTest.cpp index 4fc67c97..e72b108f 100644 --- a/unittests/datapoollocal/LocalPoolManagerTest.cpp +++ b/unittests/datapoollocal/LocalPoolManagerTest.cpp @@ -18,8 +18,8 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == result::OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == result::OK); + REQUIRE(poolOwner->initializeHkManager() == returnvalue::OK); + REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == returnvalue::OK); MessageQueueMockBase* poolOwnerMock = poolOwner->getMockQueueHandle(); REQUIRE(poolOwnerMock != nullptr); @@ -38,14 +38,14 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { CHECK(owner->getObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE); /* Subscribe for message generation on update. */ - REQUIRE(poolOwner->subscribeWrapperSetUpdate() == result::OK); + REQUIRE(poolOwner->subscribeWrapperSetUpdate() == returnvalue::OK); /* Subscribe for an update message. */ poolOwner->dataset.setChanged(true); /* Now the update message should be generated. */ - REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == returnvalue::OK); REQUIRE(poolOwnerMock->wasMessageSent() == true); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); @@ -53,27 +53,27 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { CHECK(poolOwner->dataset.hasChanged() == false); /* Set changed again, result should be the same. */ poolOwner->dataset.setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == returnvalue::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); /* Now subscribe for set update HK as well. */ - REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == result::OK); + REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == returnvalue::OK); poolOwner->dataset.setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == returnvalue::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 2); /* first message sent should be the update notification, considering the internal list is a vector checked in insertion order. */ - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); /* Clear message to avoid memory leak, our mock won't do it for us (yet) */ CommandMessageCleaner::clearCommandMessage(&messageSent); @@ -83,7 +83,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { /* Set the variables in the set to certain values. These are checked later. */ { PoolReadGuard readHelper(&poolOwner->dataset); - REQUIRE(readHelper.getReadResult() == result::OK); + REQUIRE(readHelper.getReadResult() == returnvalue::OK); poolOwner->dataset.localPoolVarUint8.value = 5; poolOwner->dataset.localPoolVarFloat.value = -12.242; poolOwner->dataset.localPoolUint16Vec.value[0] = 2; @@ -92,7 +92,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { } /* Subscribe for snapshot generation on update. */ - REQUIRE(poolOwner->subscribeWrapperSetUpdateSnapshot() == result::OK); + REQUIRE(poolOwner->subscribeWrapperSetUpdateSnapshot() == returnvalue::OK); poolOwner->dataset.setChanged(true); /* Store current time, we are going to check the (approximate) time equality later */ @@ -100,10 +100,10 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { Clock::getClock_timeval(&now); /* Trigger generation of snapshot */ - REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == returnvalue::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == returnvalue::OK); /* Check that snapshot was generated */ CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_SET)); /* Now we deserialize the snapshot into a new dataset instance */ @@ -113,7 +113,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { store_address_t storeId; HousekeepingMessage::getUpdateSnapshotSetCommand(&messageSent, &storeId); ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); - REQUIRE(accessorPair.first == result::OK); + REQUIRE(accessorPair.first == returnvalue::OK); const uint8_t* readOnlyPtr = accessorPair.second.data(); size_t sizeToDeserialize = accessorPair.second.size(); CHECK(newSet.localPoolVarFloat.value == 0); @@ -123,7 +123,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { CHECK(newSet.localPoolUint16Vec.value[2] == 0); /* Fill the dataset and timestamp */ REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == result::OK); + SerializeIF::Endianness::MACHINE) == returnvalue::OK); /* Now we check that the snapshot is actually correct */ CHECK(newSet.localPoolVarFloat.value == Catch::Approx(-12.242)); CHECK(newSet.localPoolVarUint8 == 5); @@ -134,7 +134,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { /* Now we check that both times are equal */ timeval timeFromHK; auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); timeval difference = timeFromHK - now; CHECK(timevalOperations::toDouble(difference) < 1.0); } @@ -145,14 +145,14 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { REQUIRE(subscriptionIF != nullptr); /* Subscribe for variable snapshot */ - REQUIRE(poolOwner->subscribeWrapperVariableSnapshot(lpool::uint8VarId) == result::OK); + REQUIRE(poolOwner->subscribeWrapperVariableSnapshot(lpool::uint8VarId) == returnvalue::OK); auto poolVar = dynamic_cast*>(poolOwner->getPoolObjectHandle(lpool::uint8VarId)); REQUIRE(poolVar != nullptr); { PoolReadGuard rg(poolVar); - CHECK(rg.getReadResult() == result::OK); + CHECK(rg.getReadResult() == returnvalue::OK); poolVar->value = 25; } @@ -161,7 +161,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { CCSDSTime::CDS_short timeCdsNow; timeval now; Clock::getClock_timeval(&now); - REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == returnvalue::OK); /* Check update snapshot was sent. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); @@ -169,7 +169,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { /* Should have been reset. */ CHECK(poolVar->hasChanged() == false); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE)); /* Now we deserialize the snapshot into a new dataset instance */ @@ -179,19 +179,19 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { store_address_t storeId; HousekeepingMessage::getUpdateSnapshotVariableCommand(&messageSent, &storeId); ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); - REQUIRE(accessorPair.first == result::OK); + REQUIRE(accessorPair.first == returnvalue::OK); const uint8_t* readOnlyPtr = accessorPair.second.data(); size_t sizeToDeserialize = accessorPair.second.size(); CHECK(varCopy.value == 0); /* Fill the dataset and timestamp */ REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == result::OK); + SerializeIF::Endianness::MACHINE) == returnvalue::OK); CHECK(varCopy.value == 25); /* Now we check that both times are equal */ timeval timeFromHK; auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); timeval difference = timeFromHK - now; CHECK(timevalOperations::toDouble(difference) < 1.0); } @@ -202,30 +202,30 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { REQUIRE(subscriptionIF != nullptr); /* Subscribe for variable update */ - REQUIRE(poolOwner->subscribeWrapperVariableUpdate(lpool::uint8VarId) == result::OK); + REQUIRE(poolOwner->subscribeWrapperVariableUpdate(lpool::uint8VarId) == returnvalue::OK); lp_var_t* poolVar = dynamic_cast*>(poolOwner->getPoolObjectHandle(lpool::uint8VarId)); REQUIRE(poolVar != nullptr); poolVar->setChanged(true); REQUIRE(poolVar->hasChanged() == true); - REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == returnvalue::OK); /* Check update notification was sent. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); /* Should have been reset. */ CHECK(poolVar->hasChanged() == false); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); /* Now subscribe for the dataset update (HK and update) again with subscription interface */ REQUIRE(subscriptionIF->subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT, objects::HK_RECEIVER_MOCK, - false) == result::OK); - REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == result::OK); + false) == returnvalue::OK); + REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == returnvalue::OK); poolOwner->dataset.setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == returnvalue::OK); /* Now two messages should be sent. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 2); @@ -233,17 +233,17 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { poolOwner->dataset.setChanged(true); poolVar->setChanged(true); - REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == returnvalue::OK); /* Now three messages should be sent. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 3); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == result::OK); + REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); CommandMessageCleaner::clearCommandMessage(&messageSent); REQUIRE(poolOwnerMock->receiveMessage(&messageSent) == static_cast(MessageQueueIF::EMPTY)); @@ -254,70 +254,70 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { the temporal behaviour correctly the HK manager should generate a HK packet immediately and the periodic helper depends on HK op function calls anyway instead of using the clock, so we could also just call performHkOperation multiple times */ - REQUIRE(poolOwner->subscribePeriodicHk(true) == result::OK); - REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner->subscribePeriodicHk(true) == returnvalue::OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == returnvalue::OK); /* Now HK packet should be sent as message immediately. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); LocalPoolDataSetBase* setHandle = poolOwner->getDataSetHandle(lpool::testSid); REQUIRE(setHandle != nullptr); CHECK(poolOwner->poolManager.generateHousekeepingPacket(lpool::testSid, setHandle, false) == - result::OK); + returnvalue::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); CHECK(setHandle->getReportingEnabled() == true); CommandMessage hkCmd; HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(setHandle->getReportingEnabled() == false); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(setHandle->getReportingEnabled() == true); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(setHandle->getReportingEnabled() == false); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); /* For non-diagnostics and a specified minimum frequency of 0.2 seconds, the resulting collection interval should be 1.0 second */ CHECK(poolOwner->dataset.getCollectionInterval() == 1.0); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); - REQUIRE(poolOwner->poolManager.performHkOperation() == result::OK); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + REQUIRE(poolOwner->poolManager.performHkOperation() == returnvalue::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); /* Now HK packet should be sent as message. */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid); sid_t sidToCheck; store_address_t storeId; - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(poolOwner->changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); CHECK(sidToCheck == lpool::testSid); @@ -330,7 +330,7 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { /* We still expect a failure message being sent */ REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, false); @@ -338,68 +338,68 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock->wasMessageSent(&messagesSent) == true); CHECK(messagesSent == 1); - CHECK(poolOwnerMock->popMessage() == result::OK); + CHECK(poolOwnerMock->popMessage() == returnvalue::OK); HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid); gp_id_t gpidToCheck; - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(poolOwner->changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); CHECK(gpidToCheck == lpool::uint8VarGpid); HousekeepingMessage::setUpdateSnapshotSetCommand(&hkCmd, lpool::testSid, storeId::INVALID_STORE_ADDRESS); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(poolOwner->changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); CHECK(sidToCheck == lpool::testSid); HousekeepingMessage::setUpdateSnapshotVariableCommand(&hkCmd, lpool::uint8VarGpid, storeId::INVALID_STORE_ADDRESS); - CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner->poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(poolOwner->changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); CHECK(gpidToCheck == lpool::uint8VarGpid); @@ -408,6 +408,6 @@ TEST_CASE("LocalPoolManagerTest", "[LocManTest]") { /* we need to reset the subscription list because the pool owner is a global object. */ - CHECK(poolOwner->reset() == result::OK); + CHECK(poolOwner->reset() == returnvalue::OK); poolOwnerMock->clearMessages(true); } diff --git a/unittests/datapoollocal/LocalPoolOwnerBase.cpp b/unittests/datapoollocal/LocalPoolOwnerBase.cpp index 6f054893..07ede256 100644 --- a/unittests/datapoollocal/LocalPoolOwnerBase.cpp +++ b/unittests/datapoollocal/LocalPoolOwnerBase.cpp @@ -14,7 +14,7 @@ ReturnValue_t LocalPoolOwnerBase::initializeHkManager() { initialized = true; return poolManager.initialize(messageQueue); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalPoolOwnerBase::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, @@ -26,7 +26,7 @@ ReturnValue_t LocalPoolOwnerBase::initializeLocalDataPool(localpool::DataPool &l localDataPoolMap.emplace(lpool::uint16Vec3Id, new PoolEntry({0, 0, 0})); localDataPoolMap.emplace(lpool::int64Vec2Id, new PoolEntry({0, 0})); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } LocalPoolObjectBase *LocalPoolOwnerBase::getPoolObjectHandle(lp_id_t localPoolId) { @@ -47,10 +47,10 @@ LocalPoolObjectBase *LocalPoolOwnerBase::getPoolObjectHandle(lp_id_t localPoolId ReturnValue_t LocalPoolOwnerBase::reset() { resetSubscriptionList(); - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; { PoolReadGuard readHelper(&dataset); - if (readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + if (readHelper.getReadResult() != returnvalue::OK) { status = readHelper.getReadResult(); } dataset.localPoolVarUint8.value = 0; @@ -63,7 +63,7 @@ ReturnValue_t LocalPoolOwnerBase::reset() { { PoolReadGuard readHelper(&testUint32); - if (readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + if (readHelper.getReadResult() != returnvalue::OK) { status = readHelper.getReadResult(); } testUint32.value = 0; @@ -72,7 +72,7 @@ ReturnValue_t LocalPoolOwnerBase::reset() { { PoolReadGuard readHelper(&testInt64Vec); - if (readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + if (readHelper.getReadResult() != returnvalue::OK) { status = readHelper.getReadResult(); } testInt64Vec.value[0] = 0; @@ -117,7 +117,7 @@ ReturnValue_t LocalPoolOwnerBase::initializeHkManagerAfterTaskCreation() { initializedAfterTaskCreation = true; return poolManager.initializeAfterTaskCreation(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void LocalPoolOwnerBase::handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId, diff --git a/unittests/datapoollocal/LocalPoolVariableTest.cpp b/unittests/datapoollocal/LocalPoolVariableTest.cpp index e9bed9ed..ece01ca5 100644 --- a/unittests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittests/datapoollocal/LocalPoolVariableTest.cpp @@ -11,23 +11,23 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { auto* poolOwner = ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == result::OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == result::OK); + REQUIRE(poolOwner->initializeHkManager() == returnvalue::OK); + REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == returnvalue::OK); SECTION("Basic Tests") { /* very basic test. */ lp_var_t testVariable = lp_var_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); - REQUIRE(testVariable.read() == result::OK); + REQUIRE(testVariable.read() == returnvalue::OK); CHECK(testVariable.value == 0); testVariable.value = 5; - REQUIRE(testVariable.commit() == result::OK); - REQUIRE(testVariable.read() == result::OK); + REQUIRE(testVariable.commit() == returnvalue::OK); + REQUIRE(testVariable.read() == returnvalue::OK); REQUIRE(testVariable.value == 5); CHECK(not testVariable.isValid()); testVariable.setValid(true); CHECK(testVariable.isValid()); - CHECK(testVariable.commit(true) == result::OK); + CHECK(testVariable.commit(true) == returnvalue::OK); testVariable.setReadWriteMode(pool_rwm_t::VAR_READ); CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ); @@ -43,7 +43,7 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); lp_var_t testVariable2 = lp_var_t(globPoolId); - REQUIRE(testVariable2.read() == result::OK); + REQUIRE(testVariable2.read() == returnvalue::OK); CHECK(testVariable2 == 5); CHECK(testVariable == testVariable2); testVariable = 10; @@ -55,12 +55,12 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { CHECK(maxSize == 1); size_t serSize = 0; CHECK(testVariable.serialize(&varPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(variableRaw == 10); const uint8_t* varConstPtr = &variableRaw; testVariable = 5; CHECK(testVariable.deSerialize(&varConstPtr, &serSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(testVariable == 10); CHECK(testVariable != testVariable2); CHECK(testVariable2 < testVariable); @@ -107,5 +107,5 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { lp_var_t invalidObjectVar3 = lp_var_t(nullptr, lpool::uint8VarId); } - CHECK(poolOwner->reset() == result::OK); + CHECK(poolOwner->reset() == returnvalue::OK); } diff --git a/unittests/datapoollocal/LocalPoolVectorTest.cpp b/unittests/datapoollocal/LocalPoolVectorTest.cpp index ddf6da9b..fb75846b 100644 --- a/unittests/datapoollocal/LocalPoolVectorTest.cpp +++ b/unittests/datapoollocal/LocalPoolVectorTest.cpp @@ -11,26 +11,26 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { LocalPoolOwnerBase* poolOwner = ObjectManager::instance()->get(objects::TEST_LOCAL_POOL_OWNER_BASE); REQUIRE(poolOwner != nullptr); - REQUIRE(poolOwner->initializeHkManager() == result::OK); - REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == result::OK); + REQUIRE(poolOwner->initializeHkManager() == returnvalue::OK); + REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == returnvalue::OK); SECTION("BasicTest") { // very basic test. lp_vec_t testVector = lp_vec_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id); - REQUIRE(testVector.read() == result::OK); + REQUIRE(testVector.read() == returnvalue::OK); testVector.value[0] = 5; testVector.value[1] = 232; testVector.value[2] = 32023; - REQUIRE(testVector.commit(true) == result::OK); + REQUIRE(testVector.commit(true) == returnvalue::OK); CHECK(testVector.isValid()); testVector.value[0] = 0; testVector.value[1] = 0; testVector.value[2] = 0; - CHECK(testVector.read() == result::OK); + CHECK(testVector.read() == returnvalue::OK); CHECK(testVector.value[0] == 5); CHECK(testVector.value[1] == 232); CHECK(testVector.value[2] == 32023); @@ -41,7 +41,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { (we can't throw exceptions) */ testVector[4] = 12; CHECK(testVector[2] == 12); - CHECK(testVector.commit() == result::OK); + CHECK(testVector.commit() == returnvalue::OK); /* Use read-only reference. */ const lp_vec_t& roTestVec = testVector; @@ -58,7 +58,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { uint8_t* vecPtr = reinterpret_cast(serializedVector); size_t serSize = 0; REQUIRE(testVector.serialize(&vecPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(serSize == 6); CHECK(serializedVector[0] == 5); @@ -75,7 +75,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { const uint8_t* constVecPtr = reinterpret_cast(serializedVector); REQUIRE(testVector.deSerialize(&constVecPtr, &serSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(testVector[0] == 16); CHECK(testVector[1] == 7832); CHECK(testVector[2] == 39232); diff --git a/unittests/devicehandler/ComIFMock.cpp b/unittests/devicehandler/ComIFMock.cpp index 650b74bd..d51339dc 100644 --- a/unittests/devicehandler/ComIFMock.cpp +++ b/unittests/devicehandler/ComIFMock.cpp @@ -6,24 +6,24 @@ ComIFMock::ComIFMock(object_id_t objectId) : SystemObject(objectId) {} ComIFMock::~ComIFMock() {} -ReturnValue_t ComIFMock::initializeInterface(CookieIF *cookie) { return RETURN_OK; } +ReturnValue_t ComIFMock::initializeInterface(CookieIF *cookie) { return returnvalue::OK; } ReturnValue_t ComIFMock::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) { data = *sendData; - return RETURN_OK; + return returnvalue::OK; } -ReturnValue_t ComIFMock::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } +ReturnValue_t ComIFMock::getSendSuccess(CookieIF *cookie) { return returnvalue::OK; } ReturnValue_t ComIFMock::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { switch (testCase) { case TestCase::MISSED_REPLY: { *size = 0; - return RETURN_OK; + return returnvalue::OK; } case TestCase::SIMPLE_COMMAND_NOMINAL: { *size = 1; @@ -40,7 +40,7 @@ ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, default: break; } - return RETURN_OK; + return returnvalue::OK; } void ComIFMock::setTestCase(TestCase testCase_) { testCase = testCase_; } diff --git a/unittests/devicehandler/DeviceHandlerCommander.cpp b/unittests/devicehandler/DeviceHandlerCommander.cpp index d38166ad..03ff992c 100644 --- a/unittests/devicehandler/DeviceHandlerCommander.cpp +++ b/unittests/devicehandler/DeviceHandlerCommander.cpp @@ -13,15 +13,15 @@ DeviceHandlerCommander::~DeviceHandlerCommander() {} ReturnValue_t DeviceHandlerCommander::performOperation(uint8_t operationCode) { readCommandQueue(); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DeviceHandlerCommander::initialize() { ReturnValue_t result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MessageQueueIF* DeviceHandlerCommander::getCommandQueuePtr() { return commandQueue; } @@ -35,7 +35,7 @@ void DeviceHandlerCommander::dataReceived(ActionId_t actionId, const uint8_t* da } void DeviceHandlerCommander::completionSuccessfulReceived(ActionId_t actionId) { - lastReplyReturnCode = RETURN_OK; + lastReplyReturnCode = returnvalue::OK; } void DeviceHandlerCommander::completionFailedReceived(ActionId_t actionId, @@ -45,11 +45,11 @@ void DeviceHandlerCommander::completionFailedReceived(ActionId_t actionId, void DeviceHandlerCommander::readCommandQueue() { CommandMessage message; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; + for (result = commandQueue->receiveMessage(&message); result == returnvalue::OK; result = commandQueue->receiveMessage(&message)) { result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { continue; } } @@ -61,4 +61,4 @@ ReturnValue_t DeviceHandlerCommander::sendCommand(object_id_t target, ActionId_t ReturnValue_t DeviceHandlerCommander::getReplyReturnCode() { return lastReplyReturnCode; } -void DeviceHandlerCommander::resetReplyReturnCode() { lastReplyReturnCode = RETURN_FAILED; } +void DeviceHandlerCommander::resetReplyReturnCode() { lastReplyReturnCode = returnvalue::FAILED; } diff --git a/unittests/devicehandler/DeviceHandlerCommander.h b/unittests/devicehandler/DeviceHandlerCommander.h index 435d0017..e90cbcee 100644 --- a/unittests/devicehandler/DeviceHandlerCommander.h +++ b/unittests/devicehandler/DeviceHandlerCommander.h @@ -9,8 +9,7 @@ class DeviceHandlerCommander : public ExecutableObjectIF, public SystemObject, - public CommandsActionsIF, - public HasReturnvaluesIF { + public CommandsActionsIF { public: DeviceHandlerCommander(object_id_t objectId); virtual ~DeviceHandlerCommander(); @@ -42,7 +41,7 @@ class DeviceHandlerCommander : public ExecutableObjectIF, CommandActionHelper commandActionHelper; - ReturnValue_t lastReplyReturnCode = RETURN_FAILED; + ReturnValue_t lastReplyReturnCode = returnvalue::FAILED; void readCommandQueue(); }; diff --git a/unittests/devicehandler/DeviceHandlerMock.cpp b/unittests/devicehandler/DeviceHandlerMock.cpp index ea30ff6a..3992d09c 100644 --- a/unittests/devicehandler/DeviceHandlerMock.cpp +++ b/unittests/devicehandler/DeviceHandlerMock.cpp @@ -36,7 +36,7 @@ ReturnValue_t DeviceHandlerMock::buildCommandFromCommand(DeviceCommandId_t devic WARN("DeviceHandlerMock::buildCommandFromCommand: Invalid device command"); break; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, @@ -45,19 +45,19 @@ ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, case SIMPLE_COMMAND_DATA: { *foundId = SIMPLE_COMMAND; *foundLen = sizeof(SIMPLE_COMMAND_DATA); - return RETURN_OK; + return returnvalue::OK; break; } case PERIODIC_REPLY_DATA: { *foundId = PERIODIC_REPLY; *foundLen = sizeof(PERIODIC_REPLY_DATA); - return RETURN_OK; + return returnvalue::OK; break; } default: break; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { @@ -70,7 +70,7 @@ ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, cons default: break; } - return RETURN_OK; + return returnvalue::OK; } void DeviceHandlerMock::fillCommandAndReplyMap() { diff --git a/unittests/devicehandler/TestDeviceHandlerBase.cpp b/unittests/devicehandler/TestDeviceHandlerBase.cpp index e8fdd17b..afa9d2ba 100644 --- a/unittests/devicehandler/TestDeviceHandlerBase.cpp +++ b/unittests/devicehandler/TestDeviceHandlerBase.cpp @@ -15,16 +15,16 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK, cookieIFMock, &deviceFdirMock); ReturnValue_t result = deviceHandlerMock.initialize(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER); result = deviceHandlerCommander.initialize(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); SECTION("Commanding nominal") { comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL); result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, DeviceHandlerMock::SIMPLE_COMMAND); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); @@ -34,7 +34,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { result = deviceHandlerCommander.getReplyReturnCode(); uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); REQUIRE(missedReplies == 0); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); } SECTION("Commanding missed reply") { @@ -44,7 +44,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { deviceHandlerMock.changeSimpleCommandReplyCountdown(0); result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, DeviceHandlerMock::SIMPLE_COMMAND); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); diff --git a/unittests/globalfunctions/testDleEncoder.cpp b/unittests/globalfunctions/testDleEncoder.cpp index fc4d79bf..55e27ba4 100644 --- a/unittests/globalfunctions/testDleEncoder.cpp +++ b/unittests/globalfunctions/testDleEncoder.cpp @@ -49,7 +49,7 @@ const std::vector TEST_ARRAY_4_ENCODED_NON_ESCAPED = { TEST_CASE("DleEncoder", "[DleEncoder]") { DleEncoder dleEncoder; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array buffer; size_t encodedLen = 0; @@ -60,7 +60,7 @@ TEST_CASE("DleEncoder", "[DleEncoder]") { const std::vector& expectedVec) { result = encoder.encode(vecToEncode.data(), vecToEncode.size(), buffer.data(), buffer.size(), &encodedLen); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); for (size_t idx = 0; idx < expectedVec.size(); idx++) { REQUIRE(buffer[idx] == expectedVec[idx]); } @@ -71,7 +71,7 @@ TEST_CASE("DleEncoder", "[DleEncoder]") { const std::vector& expectedVec) { result = encoder.decode(testVecEncoded.data(), testVecEncoded.size(), &readLen, buffer.data(), buffer.size(), &decodedLen); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(readLen == testVecEncoded.size()); REQUIRE(decodedLen == expectedVec.size()); for (size_t idx = 0; idx < decodedLen; idx++) { diff --git a/unittests/hal/testCommandExecutor.cpp b/unittests/hal/testCommandExecutor.cpp index d34f67aa..e6f1ae88 100644 --- a/unittests/hal/testCommandExecutor.cpp +++ b/unittests/hal/testCommandExecutor.cpp @@ -22,8 +22,8 @@ TEST_CASE("Command Executor", "[cmd-exec]") { REQUIRE(cmdExecutor.getCurrentState() == CommandExecutor::States::IDLE); ReturnValue_t result = cmdExecutor.load(cmd, true, true); REQUIRE(cmdExecutor.getCurrentState() == CommandExecutor::States::COMMAND_LOADED); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(cmdExecutor.execute() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); + REQUIRE(cmdExecutor.execute() == returnvalue::OK); // Check that file exists with contents std::ifstream file(TEST_FILE_NAME); std::string line; @@ -38,7 +38,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { cmdExecutor.setRingBuffer(&outputBuffer, &sizesFifo); result = cmdExecutor.load("echo \"Hello World\"", false, false); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); cmdExecutor.execute(); bool bytesHaveBeenRead = false; size_t limitIdx = 0; @@ -58,7 +58,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { REQUIRE(readBytes == 12); REQUIRE(outputBuffer.getAvailableReadData() == 12); uint8_t readBuffer[32] = {}; - REQUIRE(outputBuffer.readData(readBuffer, 12) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(outputBuffer.readData(readBuffer, 12) == returnvalue::OK); std::string readString(reinterpret_cast(readBuffer)); std::string cmpString = "Hello World\n"; CHECK(readString == cmpString); @@ -69,7 +69,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { // Test more complex command result = cmdExecutor.load("ping -c 1 localhost", false, false); REQUIRE(cmdExecutor.getCurrentState() == CommandExecutor::States::COMMAND_LOADED); - REQUIRE(cmdExecutor.execute() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(cmdExecutor.execute() == returnvalue::OK); REQUIRE(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING); limitIdx = 0; while (result != CommandExecutor::EXECUTION_FINISHED) { @@ -110,11 +110,11 @@ TEST_CASE("Command Executor", "[cmd-exec]") { // Now check failing command result = cmdExecutor.load("false", false, false); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); result = cmdExecutor.execute(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); while (result != CommandExecutor::EXECUTION_FINISHED and - result != HasReturnvaluesIF::RETURN_FAILED) { + result != returnvalue::FAILED) { limitIdx++; result = cmdExecutor.check(bytesHaveBeenRead); REQUIRE(result != CommandExecutor::COMMAND_ERROR); @@ -122,7 +122,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { usleep(500); REQUIRE(limitIdx < 500); } - REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(result == returnvalue::FAILED); REQUIRE(cmdExecutor.getLastError() == 1); } diff --git a/unittests/internalerror/TestInternalErrorReporter.cpp b/unittests/internalerror/TestInternalErrorReporter.cpp index b61a6203..a23658c0 100644 --- a/unittests/internalerror/TestInternalErrorReporter.cpp +++ b/unittests/internalerror/TestInternalErrorReporter.cpp @@ -38,7 +38,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { CommandMessage message; ActionMessage::setCompletionReply(&message, 10, true); auto result = hkQueue->sendMessage(testQueue->getId(), &message); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); uint32_t queueHits = 0; uint32_t lostTm = 0; uint32_t storeHits = 0; @@ -49,7 +49,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { { CommandMessage hkMessage; result = hkQueue->receiveMessage(&hkMessage); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(hkMessage.getCommand() == HousekeepingMessage::UPDATE_SNAPSHOT_SET); store_address_t storeAddress; gp_id_t gpid = @@ -59,12 +59,12 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { InternalErrorDataset dataset(objects::INTERNAL_ERROR_REPORTER); CCSDSTime::CDS_short time; ConstAccessorPair data = ipcStore->getData(storeAddress); - REQUIRE(data.first == HasReturnvaluesIF::RETURN_OK); + REQUIRE(data.first == returnvalue::OK); HousekeepingSnapshot hkSnapshot(&time, &dataset); const uint8_t* buffer = data.second.data(); size_t size = data.second.size(); result = hkSnapshot.deSerialize(&buffer, &size, SerializeIF::Endianness::MACHINE); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Remember the amount of queueHits before to see the increase queueHits = dataset.queueHits.value; lostTm = dataset.tmHits.value; @@ -78,7 +78,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { internalErrorReporter->performOperation(0); CommandMessage hkMessage; result = hkQueue->receiveMessage(&hkMessage); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(hkMessage.getCommand() == HousekeepingMessage::UPDATE_SNAPSHOT_SET); store_address_t storeAddress; gp_id_t gpid = @@ -86,7 +86,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { REQUIRE(gpid.objectId == objects::INTERNAL_ERROR_REPORTER); ConstAccessorPair data = ipcStore->getData(storeAddress); - REQUIRE(data.first == HasReturnvaluesIF::RETURN_OK); + REQUIRE(data.first == returnvalue::OK); CCSDSTime::CDS_short time; // We need the object ID of the reporter here (NO_OBJECT) InternalErrorDataset dataset(objects::INTERNAL_ERROR_REPORTER); @@ -94,7 +94,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { const uint8_t* buffer = data.second.data(); size_t size = data.second.size(); result = hkSnapshot.deSerialize(&buffer, &size, SerializeIF::Endianness::MACHINE); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Test that we had one more queueHit REQUIRE(dataset.queueHits.value == (queueHits + 1)); REQUIRE(dataset.tmHits.value == (lostTm + 1)); @@ -111,7 +111,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { sid_t sid(objects::INTERNAL_ERROR_REPORTER, InternalErrorDataset::ERROR_SET_ID); HousekeepingMessage::setToggleReportingCommand(&message, sid, true, false); result = hkQueue->sendMessage(id, &message); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); internalErrorReporter->performOperation(0); } } diff --git a/unittests/mocks/MessageQueueMockBase.h b/unittests/mocks/MessageQueueMockBase.h index d3323186..22f66a54 100644 --- a/unittests/mocks/MessageQueueMockBase.h +++ b/unittests/mocks/MessageQueueMockBase.h @@ -48,9 +48,9 @@ class MessageQueueMockBase : public MessageQueueBase { std::memcpy(message->getBuffer(), messagesSentQueue.front().getBuffer(), message->getMessageSize()); messagesSentQueue.pop(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } - virtual ReturnValue_t flush(uint32_t* count) { return HasReturnvaluesIF::RETURN_OK; } + virtual ReturnValue_t flush(uint32_t* count) { return returnvalue::OK; } virtual ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, MessageQueueId_t sentFrom, bool ignoreFault = false) override { @@ -58,7 +58,7 @@ class MessageQueueMockBase : public MessageQueueBase { messageSentCounter++; MessageQueueMessage& messageRef = *(dynamic_cast(message)); messagesSentQueue.push(messageRef); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } virtual ReturnValue_t reply(MessageQueueMessageIF* message) override { diff --git a/unittests/mocks/PeriodicTaskIFMock.h b/unittests/mocks/PeriodicTaskIFMock.h index dc0ccefc..7fbcfee1 100644 --- a/unittests/mocks/PeriodicTaskIFMock.h +++ b/unittests/mocks/PeriodicTaskIFMock.h @@ -16,10 +16,10 @@ class PeriodicTaskMock : public PeriodicTaskBase { */ virtual ReturnValue_t startTask() override { initObjsAfterTaskCreation(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; }; - virtual ReturnValue_t sleepFor(uint32_t ms) override { return HasReturnvaluesIF::RETURN_OK; }; + virtual ReturnValue_t sleepFor(uint32_t ms) override { return returnvalue::OK; }; }; #endif // FSFW_UNITTEST_TESTS_MOCKS_PERIODICTASKMOCK_H_ diff --git a/unittests/mocks/PowerSwitcherMock.cpp b/unittests/mocks/PowerSwitcherMock.cpp index 5c6935e4..b1506f6e 100644 --- a/unittests/mocks/PowerSwitcherMock.cpp +++ b/unittests/mocks/PowerSwitcherMock.cpp @@ -16,7 +16,7 @@ ReturnValue_t PowerSwitcherMock::sendSwitchCommand(power::Switch_t switchNr, Ret info.timesCalledOff++; } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t PowerSwitcherMock::sendFuseOnCommand(uint8_t fuseNr) { @@ -26,7 +26,7 @@ ReturnValue_t PowerSwitcherMock::sendFuseOnCommand(uint8_t fuseNr) { FuseInfo& info = fuseMap.at(fuseNr); info.timesCalled++; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t PowerSwitcherMock::getSwitchState(power::Switch_t switchNr) const { @@ -35,7 +35,7 @@ ReturnValue_t PowerSwitcherMock::getSwitchState(power::Switch_t switchNr) const SWITCH_REQUEST_UPDATE_VALUE++; return info.currentState; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t PowerSwitcherMock::getFuseState(uint8_t fuseNr) const { @@ -44,7 +44,7 @@ ReturnValue_t PowerSwitcherMock::getFuseState(uint8_t fuseNr) const { } else { return FUSE_OFF; } - return RETURN_FAILED; + return returnvalue::FAILED; } uint32_t PowerSwitcherMock::getSwitchDelayMs(void) const { return 5000; } diff --git a/unittests/osal/TestClock.cpp b/unittests/osal/TestClock.cpp index 9979b28c..5d198db1 100644 --- a/unittests/osal/TestClock.cpp +++ b/unittests/osal/TestClock.cpp @@ -11,13 +11,13 @@ TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") { SECTION("Test getClock") { timeval time; ReturnValue_t result = Clock::getClock_timeval(&time); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); Clock::TimeOfDay_t timeOfDay; result = Clock::getDateAndTime(&timeOfDay); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); timeval timeOfDayAsTimeval; result = Clock::convertTimeOfDayToTimeval(&timeOfDay, &timeOfDayAsTimeval); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // We require timeOfDayAsTimeval to be larger than time as it // was request a few ns later double difference = timevalOperations::toDouble(timeOfDayAsTimeval - time); @@ -27,28 +27,28 @@ TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") { // Conversion in the other direction Clock::TimeOfDay_t timevalAsTimeOfDay; result = Clock::convertTimevalToTimeOfDay(&time, &timevalAsTimeOfDay); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); CHECK(timevalAsTimeOfDay.year <= timeOfDay.year); // TODO We should write TimeOfDay operators! } SECTION("Leap seconds") { uint16_t leapSeconds = 0; ReturnValue_t result = Clock::getLeapSeconds(&leapSeconds); - REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(result == returnvalue::FAILED); REQUIRE(leapSeconds == 0); result = Clock::setLeapSeconds(18); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); result = Clock::getLeapSeconds(&leapSeconds); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(leapSeconds == 18); } SECTION("usec Test") { timeval timeAsTimeval; ReturnValue_t result = Clock::getClock_timeval(&timeAsTimeval); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); uint64_t timeAsUsec = 0; result = Clock::getClock_usecs(&timeAsUsec); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); double timeAsUsecDouble = static_cast(timeAsUsec) / 1000000.0; timeval timeAsUsecTimeval = timevalOperations::toTimeval(timeAsUsecDouble); double difference = timevalOperations::toDouble(timeAsUsecTimeval - timeAsTimeval); @@ -66,7 +66,7 @@ TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") { time.tv_sec = 1648208539; time.tv_usec = 0; ReturnValue_t result = Clock::convertTimevalToJD2000(time, &j2000); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); double correctJ2000 = 2459663.98772 - 2451545.0; CHECK(j2000 == Catch::Approx(correctJ2000).margin(1.2 * 1e-8)); } @@ -76,9 +76,9 @@ TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") { utcTime.tv_usec = 999000; timeval tt; ReturnValue_t result = Clock::setLeapSeconds(27); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); result = Clock::convertUTCToTT(utcTime, &tt); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); CHECK(tt.tv_usec == 183000); // The plus 1 is a own forced overflow of usecs CHECK(tt.tv_sec == (1648208539 + 27 + 10 + 32 + 1)); diff --git a/unittests/osal/TestMessageQueue.cpp b/unittests/osal/TestMessageQueue.cpp index b1792a9c..dbab553f 100644 --- a/unittests/osal/TestMessageQueue.cpp +++ b/unittests/osal/TestMessageQueue.cpp @@ -19,17 +19,17 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { SECTION("Simple Tests") { auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(recvMessage.getData()[0] == 42); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); MessageQueueId_t senderId = 0; result = testReceiverMq->receiveMessage(&recvMessage, &senderId); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(recvMessage.getData()[0] == 42); CHECK(senderId == testSenderMqId); senderId = testReceiverMq->getLastPartner(); @@ -37,7 +37,7 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { } SECTION("Test Full") { auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); REQUIRE(result == MessageQueueIF::FULL); // We try another message @@ -45,12 +45,12 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { REQUIRE(result == MessageQueueIF::FULL); MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(recvMessage.getData()[0] == 42); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(recvMessage.getData()[0] == 42); } // We have to clear MQs ourself ATM diff --git a/unittests/power/testPowerSwitcher.cpp b/unittests/power/testPowerSwitcher.cpp index f6a24583..222dccf6 100644 --- a/unittests/power/testPowerSwitcher.cpp +++ b/unittests/power/testPowerSwitcher.cpp @@ -30,7 +30,7 @@ TEST_CASE("Power Switcher", "[power-switcher]") { REQUIRE(switchInfo.timesCalledOn == 1); REQUIRE(not switcher.active()); REQUIRE(mock.getAmountSwitchStatWasRequested() == 2); - REQUIRE(switcher.checkSwitchState() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(switcher.checkSwitchState() == returnvalue::OK); REQUIRE(mock.getAmountSwitchStatWasRequested() == 3); switcher.turnOff(false); REQUIRE(mock.getAmountSwitchStatWasRequested() == 3); diff --git a/unittests/serialize/testSerialBufferAdapter.cpp b/unittests/serialize/testSerialBufferAdapter.cpp index 56b16975..e5ea379e 100644 --- a/unittests/serialize/testSerialBufferAdapter.cpp +++ b/unittests/serialize/testSerialBufferAdapter.cpp @@ -102,7 +102,7 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") { size_t size = 6; auto result = tv_serial_buffer_adapter3.deSerialize(const_cast(&arrayPtr), &size, SerializeIF::Endianness::MACHINE); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(test_recv_array[0] == 1); CHECK(test_recv_array[1] == 1); CHECK(test_recv_array[2] == 1); diff --git a/unittests/serialize/testSerialLinkedPacket.cpp b/unittests/serialize/testSerialLinkedPacket.cpp index 0af5d2a1..30024248 100644 --- a/unittests/serialize/testSerialLinkedPacket.cpp +++ b/unittests/serialize/testSerialLinkedPacket.cpp @@ -40,7 +40,7 @@ TEST_CASE("Serial Linked Packet", "[SerLinkPacket]") { // Deserialize big endian packet by setting bigEndian to true. ReturnValue_t result = testClass.deSerialize(&readOnlyPointer, &packetLen, SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testClass.getHeader() == 42); // Equivalent check. // CHECK(testClass.getBuffer()[0] == 1); @@ -59,7 +59,7 @@ TEST_CASE("Serial Linked Packet", "[SerLinkPacket]") { // serialize for ground: bigEndian = true. ReturnValue_t result = testClass.serialize(&packetPointer, &serializedSize, packetMaxSize, SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Result should be big endian now. CHECK(packet[3] == 42); CHECK(packet[4] == 1); diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index 7aafe98f..99878eb6 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -14,7 +14,7 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { SECTION("Little Endian Normal") { REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::LITTLE) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); @@ -27,7 +27,7 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { size_t serLen = 0xff; REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), SerializeIF::Endianness::LITTLE) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); @@ -37,14 +37,14 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { SECTION("Big Endian Normal") { SECTION("Explicit") { REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 0") { REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 1") { - REQUIRE(simpleSer.serializeBe(&ptr, &len, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.serializeBe(&ptr, &len, buf.size()) == returnvalue::OK); } CHECK(buf[0] == 1); @@ -60,16 +60,16 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { SECTION("Explicit") { REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 0") { REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 1") { REQUIRE(simpleSer.SerializeIF::serializeBe(buf.data(), serLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } CHECK(buf[0] == 1); CHECK(buf[1] == 2); @@ -86,7 +86,7 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { SECTION("Little Endian Normal") { REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); CHECK(ptr == buf.data() + 3); @@ -97,7 +97,7 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { size_t deserLen = 0xff; REQUIRE( simpleSer.SerializeIF::deSerialize(ptr, deserLen, len, SerializeIF::Endianness::LITTLE) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); CHECK(deserLen == 3); @@ -106,14 +106,14 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { SECTION("Big Endian Normal") { SECTION("Explicit") { REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 0") { REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::deSerializeBe(&ptr, &len) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerializeBe(&ptr, &len) == returnvalue::OK); } CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 1); @@ -126,16 +126,16 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { SECTION("Explicit") { REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size(), SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 0") { REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 1") { REQUIRE(simpleSer.SerializeIF::deSerializeBe(buf.data(), deserLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 1); diff --git a/unittests/storagemanager/TestNewAccessor.cpp b/unittests/storagemanager/TestNewAccessor.cpp index 311ba44d..c2c1dafd 100644 --- a/unittests/storagemanager/TestNewAccessor.cpp +++ b/unittests/storagemanager/TestNewAccessor.cpp @@ -12,7 +12,7 @@ TEST_CASE("New Accessor", "[NewAccessor]") { std::array testDataArray; std::array receptionArray; store_address_t testStoreId; - ReturnValue_t result = result::FAILED; + ReturnValue_t result = returnvalue::FAILED; for (size_t i = 0; i < testDataArray.size(); i++) { testDataArray[i] = i; @@ -21,9 +21,9 @@ TEST_CASE("New Accessor", "[NewAccessor]") { SECTION("Simple tests getter functions") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); auto resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); resultPair.second.getDataCopy(receptionArray.data(), 20); CHECK(resultPair.second.getId() == testStoreId); CHECK(resultPair.second.size() == 10); @@ -39,18 +39,18 @@ TEST_CASE("New Accessor", "[NewAccessor]") { { auto resultPairLoc = SimplePool.getData(testStoreId); - REQUIRE(resultPairLoc.first == result::OK); + REQUIRE(resultPairLoc.first == returnvalue::OK); // data should be deleted when accessor goes out of scope. } resultPair = SimplePool.getData(testStoreId); REQUIRE(resultPair.first == (int)StorageManagerIF::DATA_DOES_NOT_EXIST); result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); { ConstStorageAccessor constAccessor(testStoreId); result = SimplePool.getData(testStoreId, constAccessor); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); constAccessor.getDataCopy(receptionArray.data(), 20); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -63,12 +63,12 @@ TEST_CASE("New Accessor", "[NewAccessor]") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); { resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); resultPair.second.release(); // now data should not be deleted anymore } resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); resultPair.second.getDataCopy(receptionArray.data(), 20); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -77,11 +77,11 @@ TEST_CASE("New Accessor", "[NewAccessor]") { SECTION("Simple tests modify functions") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); { StorageAccessor accessor(testStoreId); result = SimplePool.modifyData(testStoreId, accessor); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(accessor.getId() == testStoreId); CHECK(accessor.size() == 10); accessor.getDataCopy(receptionArray.data(), 20); @@ -98,10 +98,10 @@ TEST_CASE("New Accessor", "[NewAccessor]") { REQUIRE(resultPair.first == (int)StorageManagerIF::DATA_DOES_NOT_EXIST); result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); { auto resultPairLoc = SimplePool.modifyData(testStoreId); - REQUIRE(resultPairLoc.first == result::OK); + REQUIRE(resultPairLoc.first == returnvalue::OK); CHECK(resultPairLoc.second.getId() == testStoreId); CHECK(resultPairLoc.second.size() == 10); resultPairLoc.second.getDataCopy(receptionArray.data(), 20); @@ -117,22 +117,22 @@ TEST_CASE("New Accessor", "[NewAccessor]") { // data should not be deleted when accessor goes out of scope } resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); } SECTION("Write tests") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); { auto resultPair = SimplePool.modifyData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); testDataArray[9] = 42; resultPair.second.write(testDataArray.data(), 10, 0); // now data should not be deleted resultPair.second.release(); } auto resultConstPair = SimplePool.getData(testStoreId); - REQUIRE(resultConstPair.first == result::OK); + REQUIRE(resultConstPair.first == returnvalue::OK); resultConstPair.second.getDataCopy(receptionArray.data(), 10); for (size_t i = 0; i < size - 1; i++) { @@ -141,15 +141,15 @@ TEST_CASE("New Accessor", "[NewAccessor]") { CHECK(receptionArray[9] == 42); auto resultPair = SimplePool.modifyData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); result = resultPair.second.write(testDataArray.data(), 20, 0); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); result = resultPair.second.write(testDataArray.data(), 10, 5); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); std::memset(testDataArray.data(), 42, 5); result = resultPair.second.write(testDataArray.data(), 5, 5); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); resultConstPair = SimplePool.getData(testStoreId); resultPair.second.getDataCopy(receptionArray.data(), 20); for (size_t i = 5; i < 10; i++) { @@ -159,7 +159,7 @@ TEST_CASE("New Accessor", "[NewAccessor]") { SECTION("Operators") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); { StorageAccessor accessor(testStoreId); StorageAccessor accessor2(0); @@ -168,19 +168,19 @@ TEST_CASE("New Accessor", "[NewAccessor]") { std::array data; size_t size = 6; result = accessor.write(data.data(), data.size()); - REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(result == returnvalue::FAILED); result = SimplePool.modifyData(testStoreId, accessor2); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); CHECK(accessor2.getId() == testStoreId); CHECK(accessor2.size() == 10); std::array newData; - // Expect data to be invalid so this must return RETURN_FAILED + // Expect data to be invalid so this must return returnvalue::FAILED result = accessor.getDataCopy(newData.data(), newData.size()); - REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(result == returnvalue::FAILED); // Expect data to be too small result = accessor2.getDataCopy(data.data(), data.size()); - REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(result == returnvalue::FAILED); } } } diff --git a/unittests/storagemanager/TestPool.cpp b/unittests/storagemanager/TestPool.cpp index f3c4f330..6bffa5de 100644 --- a/unittests/storagemanager/TestPool.cpp +++ b/unittests/storagemanager/TestPool.cpp @@ -13,7 +13,7 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { std::array testDataArray; std::array receptionArray; store_address_t testStoreId; - ReturnValue_t result = result::FAILED; + ReturnValue_t result = returnvalue::FAILED; uint8_t* pointer = nullptr; const uint8_t* constPointer = nullptr; @@ -24,9 +24,9 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Basic tests") { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -34,12 +34,12 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { memset(receptionArray.data(), 0, size); result = simplePool.modifyData(testStoreId, &pointer, &size); memcpy(receptionArray.data(), pointer, size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); } result = simplePool.deleteData(testStoreId); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), 15); CHECK(result == (int)StorageManagerIF::DATA_TOO_LARGE); } @@ -47,12 +47,12 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Reservation Tests ") { pointer = nullptr; result = simplePool.getFreeElement(&testStoreId, size, &pointer); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); memcpy(pointer, testDataArray.data(), size); constPointer = nullptr; result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -61,21 +61,21 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Add, delete, add, add when full") { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); } result = simplePool.deleteData(testStoreId); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -102,20 +102,20 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Initialize and clear store, delete with pointer") { result = simplePool.initialize(); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); simplePool.clearStore(); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.modifyData(testStoreId, &pointer, &size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); store_address_t newId; result = simplePool.deleteData(pointer, size, &testStoreId); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(testStoreId.raw != (uint32_t)StorageManagerIF::INVALID_ADDRESS); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); } } @@ -141,7 +141,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { std::array testDataArray; std::array receptionArray; store_address_t testStoreId; - ReturnValue_t result = result::FAILED; + ReturnValue_t result = returnvalue::FAILED; for (size_t i = 0; i < testDataArray.size(); i++) { testDataArray[i] = i; } @@ -150,20 +150,20 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { SECTION("Basic tests") { size = 8; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Should be on second page of the pool now for 8 bytes CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == 0); size = 15; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Should be on third page of the pool now for 15 bytes CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == 0); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Should be on third page of the pool now for 15 bytes CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == 1); @@ -174,7 +174,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 8; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Should still work CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == 1); @@ -182,7 +182,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { // fill the rest of the pool for (uint8_t idx = 2; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } @@ -203,21 +203,21 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 5; for (uint8_t idx = 0; idx < 10; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 0); CHECK(testStoreId.packetIndex == idx); } size = 10; for (uint8_t idx = 0; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } size = 20; for (uint8_t idx = 0; idx < 2; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == idx); } @@ -244,7 +244,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 5; for (uint8_t idx = 0; idx < 10; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 0); CHECK(testStoreId.packetIndex == idx); } @@ -261,7 +261,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 10; for (uint8_t idx = 0; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } diff --git a/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp b/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp index 0c44f6a2..9559cca9 100644 --- a/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp +++ b/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp @@ -17,14 +17,14 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) thisSequence->addSlot(objects::TEST_DEVICE, 0.6 * length, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::TEST_DEVICE, 0.8 * length, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() == returnvalue::OK) { + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" << std::endl; #else sif::printError("pst::pollingSequenceInitDefault: Sequence invalid!"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/unittests/timemanager/TestCCSDSTime.cpp b/unittests/timemanager/TestCCSDSTime.cpp index 9c457dda..0b1b602c 100644 --- a/unittests/timemanager/TestCCSDSTime.cpp +++ b/unittests/timemanager/TestCCSDSTime.cpp @@ -20,7 +20,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { time.usecond = 123456; SECTION("Test CCS Time") { auto result = CCSDSTime::convertToCcsds(&cssMilliSecconds, &time); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(cssMilliSecconds.pField == 0x52); // 0b01010010 REQUIRE(cssMilliSecconds.yearMSB == 0x07); REQUIRE(cssMilliSecconds.yearLSB == 0xe4); @@ -36,7 +36,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { const uint8_t* dataPtr = reinterpret_cast(&cssMilliSecconds); size_t length = sizeof(CCSDSTime::Ccs_mseconds); result = CCSDSTime::convertFromCCS(&timeTo, dataPtr, &length, sizeof(CCSDSTime::Ccs_mseconds)); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(cssMilliSecconds.pField == 0x52); // 0b01010010 REQUIRE(cssMilliSecconds.yearMSB == 0x07); REQUIRE(cssMilliSecconds.yearLSB == 0xe4); @@ -59,7 +59,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { size_t length = ccsDayOfYear.size(); auto result = CCSDSTime::convertFromCCS(&timeTo, ccsDayOfYear.data(), &length, ccsDayOfYear.size()); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Check constness REQUIRE(ccsDayOfYear[0] == 0b01011000); REQUIRE(ccsDayOfYear[1] == 0x07); @@ -82,7 +82,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { Clock::TimeOfDay_t timeTo; const uint8_t* timeChar = reinterpret_cast(timeAscii.c_str()); auto result = CCSDSTime::convertFromASCII(&timeTo, timeChar, timeAscii.length()); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(timeTo.year == 2022); REQUIRE(timeTo.month == 12); REQUIRE(timeTo.day == 31); @@ -95,7 +95,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { const uint8_t* timeChar2 = reinterpret_cast(timeAscii2.c_str()); Clock::TimeOfDay_t timeTo2; result = CCSDSTime::convertFromCcsds(&timeTo2, timeChar2, timeAscii2.length()); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(timeTo2.year == 2022); REQUIRE(timeTo2.month == 12); REQUIRE(timeTo2.day == 31); @@ -117,14 +117,14 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { time.usecond = 123456; timeval timeAsTimeval; auto result = Clock::convertTimeOfDayToTimeval(&time, &timeAsTimeval); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); CHECK(timeAsTimeval.tv_sec == 1582982685); CHECK(timeAsTimeval.tv_usec == 123456); // Conversion to CDS Short CCSDSTime::CDS_short cdsTime; result = CCSDSTime::convertToCcsds(&cdsTime, &timeAsTimeval); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); // Days in CCSDS Epoch 22704 (0x58B0) CHECK(cdsTime.dayMSB == 0x58); CHECK(cdsTime.dayLSB == 0xB0); @@ -138,7 +138,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { // Conversion back to timeval timeval timeReturnAsTimeval; result = CCSDSTime::convertFromCDS(&timeReturnAsTimeval, &cdsTime); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); // micro seconds precision is lost timeval difference = timeAsTimeval - timeReturnAsTimeval; CHECK(difference.tv_usec == 456); @@ -146,7 +146,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { Clock::TimeOfDay_t timeReturnAsTimeOfDay; result = CCSDSTime::convertFromCDS(&timeReturnAsTimeOfDay, &cdsTime); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); CHECK(timeReturnAsTimeOfDay.year == 2020); CHECK(timeReturnAsTimeOfDay.month == 2); CHECK(timeReturnAsTimeOfDay.day == 29); @@ -159,7 +159,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { Clock::TimeOfDay_t timeReturnAsTodFromBuffer; const uint8_t* buffer = reinterpret_cast(&cdsTime); result = CCSDSTime::convertFromCDS(&timeReturnAsTodFromBuffer, buffer, sizeof(cdsTime)); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); CHECK(timeReturnAsTodFromBuffer.year == time.year); CHECK(timeReturnAsTodFromBuffer.month == time.month); CHECK(timeReturnAsTodFromBuffer.day == time.day); @@ -170,7 +170,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { Clock::TimeOfDay_t todFromCCSDS; result = CCSDSTime::convertFromCcsds(&todFromCCSDS, buffer, sizeof(cdsTime)); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); CHECK(todFromCCSDS.year == time.year); CHECK(todFromCCSDS.month == time.month); CHECK(todFromCCSDS.day == time.day); @@ -189,7 +189,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { CCSDSTime::P_FIELD_CUC_6B_CCSDS, 0x77, 0x1E, 0x96, 0x0F, 0x91, 0x27}; size_t foundLength = 0; auto result = CCSDSTime::convertFromCUC(&to, cucBuffer.data(), &foundLength, cucBuffer.size()); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(foundLength == 7); REQUIRE(to.tv_sec == 1619801999); // TAI (no leap seconds) REQUIRE(to.tv_usec == 567001); diff --git a/unittests/timemanager/TestCountdown.cpp b/unittests/timemanager/TestCountdown.cpp index d0af659d..67f4ddb2 100644 --- a/unittests/timemanager/TestCountdown.cpp +++ b/unittests/timemanager/TestCountdown.cpp @@ -8,9 +8,9 @@ TEST_CASE("Countdown Tests", "[TestCountdown]") { INFO("Countdown Tests"); Countdown count(20); REQUIRE(count.timeout == 20); - REQUIRE(count.setTimeout(100) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(count.setTimeout(100) == static_cast(returnvalue::OK)); REQUIRE(count.timeout == 100); - REQUIRE(count.setTimeout(150) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(count.setTimeout(150) == static_cast(returnvalue::OK)); REQUIRE(count.isBusy()); REQUIRE(not count.hasTimedOut()); uint32_t number = count.getRemainingMillis(); From 4224c3d00924ad1555e9fa299153c87f88d1c63a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 Aug 2022 20:29:23 +0200 Subject: [PATCH 234/532] bump changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f83c5078..67361a9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +## Changes + +- Removed `HasReturnvaluesIF` class in favor of `returnvalue` namespace with `OK` and `FAILED` + constants. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/659 + # [v5.0.0] 25.07.2022 ## Changes From 7f9269b3871af38bd0eedaf247cbe2336b95d730 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 Aug 2022 20:30:59 +0200 Subject: [PATCH 235/532] fix for def cfg --- .../fsfwconfig/pollingsequence/PollingSequenceFactory.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp index c8baaf34..81b927dd 100644 --- a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp +++ b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp @@ -11,15 +11,15 @@ ReturnValue_t pst::pollingSequenceInitDefault( /* Add polling sequence table here */ - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() == returnvalue::OK) { + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" << std::endl; #endif - return HasReturnvaluesIF::returnvalue::FAILED; + return returnvalue::FAILED; } } From 1037102349b7e0cac6fe56a65856f12ab6ca3cfb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 Aug 2022 01:08:26 +0200 Subject: [PATCH 236/532] merge retval refactoring --- CHANGELOG.md | 7 + .../PollingSequenceFactory.cpp | 6 +- src/fsfw/action/ActionHelper.cpp | 24 +-- src/fsfw/action/ActionHelper.h | 6 +- src/fsfw/action/ActionMessage.cpp | 2 +- src/fsfw/action/ActionMessage.h | 4 +- src/fsfw/action/CommandActionHelper.cpp | 30 ++-- src/fsfw/action/SimpleActionHelper.cpp | 8 +- src/fsfw/action/SimpleActionHelper.h | 4 +- src/fsfw/cfdp/CfdpHandler.cpp | 12 +- src/fsfw/cfdp/CfdpHandler.h | 5 +- src/fsfw/cfdp/FileSize.h | 6 +- src/fsfw/cfdp/definitions.h | 21 ++- src/fsfw/cfdp/pdu/AckPduDeserializer.cpp | 4 +- src/fsfw/cfdp/pdu/AckPduSerializer.cpp | 6 +- src/fsfw/cfdp/pdu/EofPduDeserializer.cpp | 8 +- src/fsfw/cfdp/pdu/EofPduSerializer.cpp | 4 +- src/fsfw/cfdp/pdu/FileDataDeserializer.cpp | 6 +- src/fsfw/cfdp/pdu/FileDataInfo.cpp | 4 +- src/fsfw/cfdp/pdu/FileDataSerializer.cpp | 6 +- .../cfdp/pdu/FileDirectiveDeserializer.cpp | 4 +- src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp | 6 +- src/fsfw/cfdp/pdu/FinishedInfo.cpp | 10 +- src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp | 10 +- src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp | 6 +- src/fsfw/cfdp/pdu/HeaderDeserializer.cpp | 4 +- src/fsfw/cfdp/pdu/HeaderDeserializer.h | 4 +- src/fsfw/cfdp/pdu/HeaderSerializer.cpp | 12 +- .../cfdp/pdu/KeepAlivePduDeserializer.cpp | 2 +- src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp | 2 +- src/fsfw/cfdp/pdu/MetadataInfo.cpp | 4 +- src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp | 10 +- src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp | 10 +- src/fsfw/cfdp/pdu/NakPduDeserializer.cpp | 10 +- src/fsfw/cfdp/pdu/NakPduSerializer.cpp | 10 +- src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp | 4 +- src/fsfw/cfdp/pdu/PromptPduSerializer.cpp | 2 +- src/fsfw/cfdp/pdu/VarLenField.cpp | 18 +- src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp | 6 +- src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp | 12 +- src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp | 12 +- src/fsfw/cfdp/tlv/FilestoreTlvBase.h | 10 +- src/fsfw/cfdp/tlv/Lv.cpp | 10 +- src/fsfw/cfdp/tlv/Tlv.cpp | 12 +- src/fsfw/container/ArrayList.h | 2 +- src/fsfw/container/FIFOBase.tpp | 10 +- src/fsfw/container/FixedMap.h | 20 +-- src/fsfw/container/FixedOrderedMultimap.h | 2 +- src/fsfw/container/FixedOrderedMultimap.tpp | 12 +- src/fsfw/container/IndexedRingMemoryArray.h | 44 ++--- src/fsfw/container/PlacementFactory.h | 4 +- src/fsfw/container/RingBufferBase.h | 8 +- src/fsfw/container/SimpleRingBuffer.cpp | 22 +-- src/fsfw/container/SimpleRingBuffer.h | 4 +- src/fsfw/controller/ControllerBase.cpp | 24 +-- src/fsfw/controller/ControllerBase.h | 3 +- .../controller/ExtendedControllerBase.cpp | 22 +-- src/fsfw/coordinates/Sgp4Propagator.cpp | 4 +- src/fsfw/datalinklayer/DataLinkLayer.cpp | 22 +-- src/fsfw/datalinklayer/DataLinkLayer.h | 2 +- src/fsfw/datalinklayer/Farm1StateOpen.cpp | 2 +- .../datalinklayer/MapPacketExtraction.cpp | 12 +- src/fsfw/datalinklayer/MapPacketExtraction.h | 2 +- .../datalinklayer/VirtualChannelReception.cpp | 18 +- .../datalinklayer/VirtualChannelReception.h | 5 +- src/fsfw/datapool/PoolDataSetBase.cpp | 32 ++-- src/fsfw/datapool/PoolDataSetBase.h | 6 +- src/fsfw/datapool/PoolReadGuard.h | 4 +- src/fsfw/datapool/ReadCommitIFAttorney.h | 4 +- src/fsfw/datapoollocal/HasLocalDataPoolIF.h | 6 +- .../datapoollocal/LocalDataPoolManager.cpp | 102 ++++++----- src/fsfw/datapoollocal/LocalDataPoolManager.h | 6 +- .../datapoollocal/LocalPoolDataSetBase.cpp | 16 +- src/fsfw/datapoollocal/LocalPoolObjectBase.h | 2 +- src/fsfw/datapoollocal/LocalPoolVariable.tpp | 12 +- src/fsfw/datapoollocal/LocalPoolVector.tpp | 16 +- src/fsfw/datapoollocal/SharedLocalDataSet.cpp | 4 +- src/fsfw/devicehandlers/AssemblyBase.cpp | 24 +-- src/fsfw/devicehandlers/AssemblyBase.h | 2 +- src/fsfw/devicehandlers/ChildHandlerBase.cpp | 6 +- .../devicehandlers/DeviceCommunicationIF.h | 2 +- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 162 +++++++++--------- src/fsfw/devicehandlers/DeviceHandlerBase.h | 23 ++- .../DeviceHandlerFailureIsolation.cpp | 16 +- .../DeviceTmReportingWrapper.cpp | 8 +- src/fsfw/devicehandlers/HealthDevice.cpp | 6 +- src/fsfw/events/EventManager.cpp | 12 +- .../events/eventmatching/EventMatchTree.cpp | 10 +- .../events/eventmatching/EventMatchTree.h | 2 +- src/fsfw/fdir/FailureIsolationBase.cpp | 14 +- src/fsfw/fdir/FailureIsolationBase.h | 4 +- src/fsfw/fdir/FaultCounter.cpp | 2 +- src/fsfw/globalfunctions/AsciiConverter.cpp | 10 +- src/fsfw/globalfunctions/AsciiConverter.h | 2 +- src/fsfw/globalfunctions/DleEncoder.cpp | 8 +- src/fsfw/globalfunctions/DleEncoder.h | 2 +- src/fsfw/globalfunctions/Type.cpp | 14 +- src/fsfw/globalfunctions/matching/MatchTree.h | 28 +-- .../globalfunctions/matching/RangeMatcher.h | 8 +- src/fsfw/health/HealthHelper.cpp | 16 +- src/fsfw/health/HealthHelper.h | 4 +- src/fsfw/health/HealthTable.cpp | 18 +- src/fsfw/housekeeping/HousekeepingSetPacket.h | 4 +- src/fsfw/housekeeping/HousekeepingSnapshot.h | 4 +- .../internalerror/InternalErrorReporter.cpp | 8 +- src/fsfw/ipc/MutexGuard.h | 4 +- src/fsfw/memory/GenericFileSystemMessage.cpp | 4 +- src/fsfw/memory/HasMemoryIF.h | 6 +- src/fsfw/memory/MemoryHelper.cpp | 22 +-- src/fsfw/memory/MemoryHelper.h | 2 +- src/fsfw/modes/HasModesIF.h | 2 +- src/fsfw/modes/ModeHelper.cpp | 8 +- src/fsfw/monitoring/AbsLimitMonitor.h | 4 +- src/fsfw/monitoring/LimitMonitor.h | 4 +- .../monitoring/LimitViolationReporter.cpp | 10 +- src/fsfw/monitoring/MonitorBase.h | 6 +- src/fsfw/monitoring/MonitorReporter.h | 6 +- src/fsfw/monitoring/TriplexMonitor.h | 14 +- src/fsfw/monitoring/TwoValueLimitMonitor.h | 2 +- src/fsfw/objectmanager/ObjectManager.cpp | 10 +- src/fsfw/objectmanager/ObjectManagerIF.h | 2 +- src/fsfw/objectmanager/SystemObject.cpp | 4 +- src/fsfw/objectmanager/SystemObjectIF.h | 2 +- src/fsfw/osal/common/TcpIpBase.cpp | 4 +- src/fsfw/osal/common/TcpTmTcBridge.cpp | 15 +- src/fsfw/osal/common/TcpTmTcServer.cpp | 34 ++-- src/fsfw/osal/common/TcpTmTcServer.h | 2 +- src/fsfw/osal/common/UdpTcPollingTask.cpp | 14 +- src/fsfw/osal/common/UdpTmTcBridge.cpp | 14 +- src/fsfw/osal/freertos/BinSemaphUsingTask.cpp | 8 +- src/fsfw/osal/freertos/BinSemaphUsingTask.h | 6 +- src/fsfw/osal/freertos/BinarySemaphore.cpp | 6 +- src/fsfw/osal/freertos/Clock.cpp | 22 +-- .../osal/freertos/CountingSemaphUsingTask.cpp | 8 +- src/fsfw/osal/freertos/FixedTimeslotTask.cpp | 4 +- src/fsfw/osal/freertos/MessageQueue.cpp | 6 +- src/fsfw/osal/freertos/Mutex.cpp | 4 +- src/fsfw/osal/freertos/PeriodicTask.cpp | 4 +- src/fsfw/osal/freertos/QueueMapManager.cpp | 4 +- src/fsfw/osal/freertos/TaskFactory.cpp | 6 +- src/fsfw/osal/host/Clock.cpp | 28 +-- src/fsfw/osal/host/FixedTimeslotTask.cpp | 4 +- src/fsfw/osal/host/MessageQueue.cpp | 12 +- src/fsfw/osal/host/Mutex.cpp | 8 +- src/fsfw/osal/host/PeriodicTask.cpp | 4 +- src/fsfw/osal/host/QueueMapManager.cpp | 4 +- src/fsfw/osal/host/TaskFactory.cpp | 4 +- src/fsfw/osal/host/taskHelpers.cpp | 4 +- src/fsfw/osal/linux/BinarySemaphore.cpp | 18 +- src/fsfw/osal/linux/Clock.cpp | 36 ++-- src/fsfw/osal/linux/CountingSemaphore.cpp | 6 +- src/fsfw/osal/linux/FixedTimeslotTask.cpp | 2 +- src/fsfw/osal/linux/InternalErrorCodes.cpp | 2 +- src/fsfw/osal/linux/MessageQueue.cpp | 34 ++-- src/fsfw/osal/linux/Mutex.cpp | 8 +- src/fsfw/osal/linux/PeriodicPosixTask.cpp | 4 +- src/fsfw/osal/linux/PosixThread.cpp | 8 +- src/fsfw/osal/linux/TaskFactory.cpp | 2 +- src/fsfw/osal/rtems/BinarySemaphore.cpp | 4 +- src/fsfw/osal/rtems/Clock.cpp | 42 ++--- src/fsfw/osal/rtems/CpuUsage.cpp | 20 +-- src/fsfw/osal/rtems/FixedTimeslotTask.cpp | 4 +- src/fsfw/osal/rtems/InternalErrorCodes.cpp | 2 +- src/fsfw/osal/rtems/MessageQueue.cpp | 18 +- src/fsfw/osal/rtems/Mutex.cpp | 8 +- src/fsfw/osal/rtems/PeriodicTask.cpp | 4 +- src/fsfw/osal/rtems/QueueFactory.cpp | 12 +- src/fsfw/osal/rtems/RTEMSTaskBase.cpp | 18 +- src/fsfw/osal/rtems/TaskFactory.cpp | 4 +- src/fsfw/osal/windows/winTaskHelpers.cpp | 6 +- src/fsfw/parameters/ParameterHelper.cpp | 28 +-- src/fsfw/parameters/ParameterWrapper.cpp | 28 +-- src/fsfw/parameters/ParameterWrapper.h | 2 +- src/fsfw/power/DummyPowerSwitcher.cpp | 8 +- src/fsfw/power/Fuse.cpp | 38 ++-- src/fsfw/power/Fuse.h | 1 - src/fsfw/power/PowerComponent.cpp | 6 +- src/fsfw/power/PowerSensor.cpp | 22 +-- src/fsfw/power/PowerSwitchIF.h | 6 +- src/fsfw/power/PowerSwitcher.cpp | 10 +- src/fsfw/power/PowerSwitcher.h | 2 +- src/fsfw/power/PowerSwitcherComponent.cpp | 16 +- src/fsfw/power/PowerSwitcherComponent.h | 1 - src/fsfw/pus/CService200ModeCommanding.cpp | 18 +- src/fsfw/pus/CService201HealthCommanding.cpp | 10 +- .../pus/Service11TelecommandScheduling.tpp | 82 ++++----- src/fsfw/pus/Service17Test.cpp | 8 +- .../pus/Service1TelecommandVerification.cpp | 18 +- .../pus/Service1TelecommandVerification.h | 3 +- src/fsfw/pus/Service20ParameterManagement.cpp | 26 +-- src/fsfw/pus/Service2DeviceAccess.cpp | 12 +- src/fsfw/pus/Service3Housekeeping.cpp | 36 ++-- src/fsfw/pus/Service5EventReporting.cpp | 20 +-- src/fsfw/pus/Service8FunctionManagement.cpp | 14 +- src/fsfw/pus/Service9TimeManagement.cpp | 10 +- src/fsfw/pus/servicepackets/Service1Packets.h | 20 +-- src/fsfw/pus/servicepackets/Service5Packets.h | 10 +- src/fsfw/returnvalues/HasReturnvaluesIF.h | 41 ++--- src/fsfw/rmap/RmapDeviceCommunicationIF.cpp | 4 +- src/fsfw/serialize/SerialArrayListAdapter.h | 6 +- src/fsfw/serialize/SerialBufferAdapter.cpp | 12 +- src/fsfw/serialize/SerialLinkedListAdapter.h | 10 +- src/fsfw/serialize/SerializeAdapter.h | 16 +- src/fsfw/serialize/SerializeIF.h | 4 +- .../storagemanager/ConstStorageAccessor.cpp | 6 +- src/fsfw/storagemanager/LocalPool.cpp | 26 +-- src/fsfw/storagemanager/StorageAccessor.cpp | 12 +- src/fsfw/storagemanager/StorageManagerIF.h | 12 +- src/fsfw/subsystem/Subsystem.cpp | 82 ++++----- src/fsfw/subsystem/SubsystemBase.cpp | 50 +++--- src/fsfw/subsystem/SubsystemBase.h | 1 - src/fsfw/subsystem/modes/ModeDefinitions.h | 12 +- src/fsfw/subsystem/modes/ModeStore.cpp | 12 +- src/fsfw/tasks/ExecutableObjectIF.h | 2 +- src/fsfw/tasks/FixedSlotSequence.cpp | 12 +- src/fsfw/tasks/FixedTimeslotTaskBase.cpp | 4 +- src/fsfw/tasks/FixedTimeslotTaskIF.h | 6 +- src/fsfw/tasks/PeriodicTaskBase.cpp | 8 +- src/fsfw/tasks/PeriodicTaskIF.h | 4 +- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 18 +- src/fsfw/tcdistribution/CCSDSDistributorIF.h | 4 +- src/fsfw/tcdistribution/CFDPDistributor.cpp | 12 +- src/fsfw/tcdistribution/CFDPDistributorIF.h | 2 +- .../tcdistribution/CcsdsPacketChecker.cpp | 2 +- src/fsfw/tcdistribution/CcsdsPacketChecker.h | 2 +- src/fsfw/tcdistribution/CfdpPacketChecker.h | 2 +- src/fsfw/tcdistribution/PUSDistributorIF.h | 2 +- src/fsfw/tcdistribution/PusDistributor.cpp | 23 ++- src/fsfw/tcdistribution/PusPacketChecker.cpp | 2 +- src/fsfw/tcdistribution/TcDistributor.cpp | 10 +- src/fsfw/tcdistribution/TcDistributor.h | 6 +- src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp | 2 +- .../thermal/AbstractTemperatureSensor.cpp | 16 +- src/fsfw/thermal/Heater.cpp | 38 ++-- src/fsfw/thermal/RedundantHeater.cpp | 2 +- src/fsfw/thermal/TemperatureSensor.h | 4 +- src/fsfw/thermal/ThermalComponent.cpp | 10 +- src/fsfw/thermal/ThermalComponentCore.cpp | 8 +- src/fsfw/thermal/ThermalModule.cpp | 2 +- src/fsfw/thermal/ThermalMonitorReporter.cpp | 8 +- src/fsfw/timemanager/CCSDSTime.cpp | 74 ++++---- src/fsfw/timemanager/CCSDSTime.h | 2 +- src/fsfw/timemanager/CdsShortTimeStamper.cpp | 4 +- src/fsfw/timemanager/Clock.h | 6 +- src/fsfw/timemanager/ClockCommon.cpp | 28 +-- src/fsfw/tmstorage/TmStoreMessage.cpp | 16 +- src/fsfw/tmstorage/TmStorePackets.h | 30 ++-- .../tmtcpacket/RedirectableDataPointerIF.h | 2 +- src/fsfw/tmtcpacket/ccsds/PacketId.h | 4 +- src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h | 2 +- .../tmtcpacket/ccsds/SpacePacketCreator.cpp | 8 +- .../tmtcpacket/ccsds/SpacePacketReader.cpp | 4 +- src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp | 25 ++- .../packetmatcher/PacketMatchTree.cpp | 18 +- .../packetmatcher/PacketMatchTree.h | 2 +- src/fsfw/tmtcpacket/pus/PusIF.h | 4 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 12 +- src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp | 6 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 18 +- src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp | 8 +- .../tmtcservices/CommandingServiceBase.cpp | 48 +++--- src/fsfw/tmtcservices/CommandingServiceBase.h | 11 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 22 +-- src/fsfw/tmtcservices/PusServiceBase.h | 5 +- src/fsfw/tmtcservices/SpacePacketParser.cpp | 4 +- src/fsfw/tmtcservices/TmSendHelper.cpp | 4 +- .../tmtcservices/TmStoreAndSendHelper.cpp | 12 +- src/fsfw/tmtcservices/TmStoreHelper.cpp | 6 +- src/fsfw/tmtcservices/TmTcBridge.cpp | 43 +++-- src/fsfw/tmtcservices/TmTcBridge.h | 5 +- .../tmtcservices/VerificationReporter.cpp | 6 +- .../tmtcservices/VerificationReporterIF.h | 4 +- src/fsfw/tmtcservices/tcHelpers.cpp | 4 +- src/fsfw/tmtcservices/tmHelpers.h | 10 +- src/fsfw_hal/common/gpio/GpioCookie.cpp | 8 +- src/fsfw_hal/common/gpio/GpioIF.h | 4 +- .../devicehandlers/GyroL3GD20Handler.cpp | 14 +- .../devicehandlers/MgmLIS3MDLHandler.cpp | 26 +-- .../devicehandlers/MgmRM3100Handler.cpp | 22 +-- src/fsfw_hal/linux/CommandExecutor.cpp | 20 +-- src/fsfw_hal/linux/CommandExecutor.h | 16 +- src/fsfw_hal/linux/UnixFileGuard.h | 2 +- src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp | 48 +++--- src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h | 2 +- src/fsfw_hal/linux/i2c/I2cComIF.cpp | 42 ++--- src/fsfw_hal/linux/i2c/I2cComIF.h | 2 +- src/fsfw_hal/linux/rpi/GpioRPi.cpp | 6 +- src/fsfw_hal/linux/spi/SpiComIF.cpp | 46 ++--- src/fsfw_hal/linux/uart/UartComIF.cpp | 52 +++--- src/fsfw_hal/linux/uio/UioMapper.cpp | 18 +- .../stm32h7/devicetest/GyroL3GD20H.cpp | 70 ++++---- src/fsfw_hal/stm32h7/spi/SpiComIF.cpp | 52 +++--- .../integration/assemblies/TestAssembly.cpp | 18 +- .../integration/controller/TestController.cpp | 6 +- .../integration/devices/TestDeviceHandler.cpp | 55 +++--- .../integration/devices/TestEchoComIF.cpp | 14 +- src/fsfw_tests/integration/task/TestTask.cpp | 10 +- .../internal/InternalUnitTester.cpp | 2 +- src/fsfw_tests/internal/InternalUnitTester.h | 2 +- src/fsfw_tests/internal/UnittDefinitions.cpp | 2 +- src/fsfw_tests/internal/osal/testMq.cpp | 8 +- src/fsfw_tests/internal/osal/testMutex.cpp | 4 +- .../internal/osal/testSemaphore.cpp | 10 +- .../serialize/IntTestSerialization.cpp | 14 +- unittests/action/TestActionHelper.cpp | 18 +- unittests/action/TestActionHelper.h | 2 +- unittests/cfdp/testAckPdu.cpp | 14 +- unittests/cfdp/testCfdp.cpp | 42 ++--- unittests/cfdp/testEofPdu.cpp | 18 +- unittests/cfdp/testFileData.cpp | 20 +-- unittests/cfdp/testFinishedPdu.cpp | 24 +-- unittests/cfdp/testKeepAlivePdu.cpp | 18 +- unittests/cfdp/testMetadataPdu.cpp | 20 +-- unittests/cfdp/testNakPdu.cpp | 30 ++-- unittests/cfdp/testPromptPdu.cpp | 14 +- unittests/cfdp/testTlvsLvs.cpp | 69 ++++---- unittests/container/RingBufferTest.cpp | 148 ++++++++-------- unittests/container/TestArrayList.cpp | 9 +- unittests/container/TestDynamicFifo.cpp | 46 ++--- unittests/container/TestFifo.cpp | 40 ++--- unittests/container/TestFixedArrayList.cpp | 4 +- unittests/container/TestFixedMap.cpp | 37 ++-- .../container/TestFixedOrderedMultimap.cpp | 41 ++--- unittests/container/TestPlacementFactory.cpp | 8 +- unittests/datapoollocal/testDataSet.cpp | 45 ++--- .../datapoollocal/testLocalPoolManager.cpp | 135 ++++++++------- .../datapoollocal/testLocalPoolVariable.cpp | 20 ++- .../datapoollocal/testLocalPoolVector.cpp | 18 +- .../devicehandler/DeviceHandlerCommander.cpp | 16 +- .../devicehandler/DeviceHandlerCommander.h | 5 +- .../devicehandler/TestDeviceHandlerBase.cpp | 10 +- unittests/globalfunctions/testDleEncoder.cpp | 6 +- unittests/hal/testCommandExecutor.cpp | 19 +- .../TestInternalErrorReporter.cpp | 18 +- unittests/mocks/CdsShortTimestamperMock.h | 18 +- unittests/mocks/ComIFMock.cpp | 12 +- unittests/mocks/DeviceHandlerMock.cpp | 10 +- unittests/mocks/LocalPoolOwnerBase.cpp | 14 +- unittests/mocks/MessageQueueMock.cpp | 14 +- unittests/mocks/PeriodicTaskIFMock.h | 4 +- unittests/mocks/PowerSwitcherMock.cpp | 8 +- unittests/mocks/PusDistributorMock.cpp | 2 +- unittests/mocks/PusServiceBaseMock.cpp | 4 +- .../mocks/PusVerificationReporterMock.cpp | 4 +- unittests/osal/TestClock.cpp | 24 +-- unittests/osal/testMq.cpp | 16 +- unittests/power/testPowerSwitcher.cpp | 2 +- .../serialize/testSerialBufferAdapter.cpp | 2 +- .../serialize/testSerialLinkedPacket.cpp | 4 +- unittests/serialize/testSerializeIF.cpp | 40 ++--- unittests/storagemanager/testAccessor.cpp | 52 +++--- unittests/storagemanager/testPool.cpp | 56 +++--- .../PollingSequenceFactory.cpp | 6 +- unittests/timemanager/TestCCSDSTime.cpp | 24 +-- unittests/timemanager/TestCountdown.cpp | 4 +- unittests/tmtcpacket/testCcsds.cpp | 10 +- unittests/tmtcpacket/testCcsdsCreator.cpp | 10 +- unittests/tmtcpacket/testCcsdsReader.cpp | 8 +- unittests/tmtcpacket/testPusTcCreator.cpp | 12 +- unittests/tmtcpacket/testPusTcReader.cpp | 24 +-- unittests/tmtcpacket/testPusTmCreator.cpp | 13 +- unittests/tmtcpacket/testPusTmReader.cpp | 30 ++-- unittests/tmtcpacket/testZcTmWriter.cpp | 6 +- unittests/tmtcservices/testPsb.cpp | 30 ++-- unittests/tmtcservices/testSendHelper.cpp | 26 +-- .../tmtcservices/testStoreAndSendHelper.cpp | 12 +- unittests/tmtcservices/testStoreHelper.cpp | 34 ++-- unittests/util/testUnsignedByteField.cpp | 15 +- 369 files changed, 2661 insertions(+), 2668 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf50b683..22699114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +## Changes + +- Removed `HasReturnvaluesIF` class in favor of `returnvalue` namespace with `OK` and `FAILED` + constants. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/659 + ## Added - Add new `UnsignedByteField` class + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/660 # [v5.0.0] 25.07.2022 diff --git a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp index b7f1fb3e..81b927dd 100644 --- a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp +++ b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp @@ -11,15 +11,15 @@ ReturnValue_t pst::pollingSequenceInitDefault( /* Add polling sequence table here */ - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() == returnvalue::OK) { + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/action/ActionHelper.cpp b/src/fsfw/action/ActionHelper.cpp index bee68b40..fd6c8afb 100644 --- a/src/fsfw/action/ActionHelper.cpp +++ b/src/fsfw/action/ActionHelper.cpp @@ -12,7 +12,7 @@ ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) { if (command->getCommand() == ActionMessage::EXECUTE_ACTION) { ActionId_t currentAction = ActionMessage::getActionId(command); prepareExecution(command->getSender(), currentAction, ActionMessage::getStoreId(command)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return CommandMessage::UNKNOWN_COMMAND; } @@ -21,7 +21,7 @@ ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) { ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) { ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (queueToUse_ != nullptr) { setQueueToUse(queueToUse_); @@ -35,10 +35,10 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) { sif::printWarning("ActionHelper::initialize: No queue set\n"); #endif #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void ActionHelper::step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, @@ -62,7 +62,7 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act const uint8_t* dataPtr = nullptr; size_t size = 0; ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { CommandMessage reply; ActionMessage::setStepReply(&reply, actionId, 0, result); queueToUse->sendMessage(commandedBy, &reply); @@ -75,7 +75,7 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act ActionMessage::setCompletionReply(&reply, actionId, true, result); queueToUse->sendMessage(commandedBy, &reply); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { CommandMessage reply; ActionMessage::setStepReply(&reply, actionId, 0, result); queueToUse->sendMessage(commandedBy, &reply); @@ -91,11 +91,11 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep size_t maxSize = data->getSerializedSize(); if (maxSize == 0) { /* No error, there's simply nothing to report. */ - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t size = 0; ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, maxSize, &dataPtr); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "ActionHelper::reportData: Getting free element from IPC store failed!" << std::endl; @@ -107,7 +107,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep return result; } result = data->serialize(&dataPtr, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeAddress); return result; } @@ -124,7 +124,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep result = queueToUse->sendMessage(reportTo, &reply); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeAddress); } return result; @@ -137,7 +137,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep CommandMessage reply; store_address_t storeAddress; ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "ActionHelper::reportData: Adding data to IPC store failed!" << std::endl; #else @@ -158,7 +158,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep result = queueToUse->sendMessage(reportTo, &reply); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeAddress); } return result; diff --git a/src/fsfw/action/ActionHelper.h b/src/fsfw/action/ActionHelper.h index a9910b05..16abb212 100644 --- a/src/fsfw/action/ActionHelper.h +++ b/src/fsfw/action/ActionHelper.h @@ -36,7 +36,7 @@ class ActionHelper { * send to the sender of the message automatically. * * @param command Pointer to a command message received by the owner - * @return HasReturnvaluesIF::RETURN_OK if the message is a action message, + * @return returnvalue::OK if the message is a action message, * CommandMessage::UNKNOW_COMMAND if this message ID is unkown */ ReturnValue_t handleActionMessage(CommandMessage* command); @@ -58,7 +58,7 @@ class ActionHelper { * @param result Result of the execution */ void step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + ReturnValue_t result = returnvalue::OK); /** * Function to be called by the owner to send a action completion message * @param success Specify whether action was completed successfully or not. @@ -67,7 +67,7 @@ class ActionHelper { * @param result Result of the execution */ void finish(bool success, MessageQueueId_t reportTo, ActionId_t commandId, - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + ReturnValue_t result = returnvalue::OK); /** * Function to be called by the owner if an action does report data. * Takes a SerializeIF* pointer and serializes it into the IPC store. diff --git a/src/fsfw/action/ActionMessage.cpp b/src/fsfw/action/ActionMessage.cpp index 7fc68558..33088055 100644 --- a/src/fsfw/action/ActionMessage.cpp +++ b/src/fsfw/action/ActionMessage.cpp @@ -25,7 +25,7 @@ store_address_t ActionMessage::getStoreId(const CommandMessage* message) { void ActionMessage::setStepReply(CommandMessage* message, ActionId_t fid, uint8_t step, ReturnValue_t result) { - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { message->setCommand(STEP_SUCCESS); } else { message->setCommand(STEP_FAILED); diff --git a/src/fsfw/action/ActionMessage.h b/src/fsfw/action/ActionMessage.h index bd12cc19..38e3aa99 100644 --- a/src/fsfw/action/ActionMessage.h +++ b/src/fsfw/action/ActionMessage.h @@ -33,12 +33,12 @@ class ActionMessage { static store_address_t getStoreId(const CommandMessage* message); static void setStepReply(CommandMessage* message, ActionId_t fid, uint8_t step, - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + ReturnValue_t result = returnvalue::OK); static uint8_t getStep(const CommandMessage* message); static ReturnValue_t getReturnCode(const CommandMessage* message); static void setDataReply(CommandMessage* message, ActionId_t actionId, store_address_t data); static void setCompletionReply(CommandMessage* message, ActionId_t fid, bool success, - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + ReturnValue_t result = returnvalue::OK); static void clear(CommandMessage* message); }; diff --git a/src/fsfw/action/CommandActionHelper.cpp b/src/fsfw/action/CommandActionHelper.cpp index a06bc44c..831cd862 100644 --- a/src/fsfw/action/CommandActionHelper.cpp +++ b/src/fsfw/action/CommandActionHelper.cpp @@ -16,12 +16,12 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId uint8_t *storePointer; size_t maxSize = data->getSerializedSize(); ReturnValue_t result = ipcStore->getFreeElement(&storeId, maxSize, &storePointer); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t size = 0; result = data->serialize(&storePointer, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return sendCommand(receiver->getCommandQueue(), actionId, storeId); @@ -35,7 +35,7 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo, ActionId } store_address_t storeId; ReturnValue_t result = ipcStore->addData(&storeId, data, size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return sendCommand(receiver->getCommandQueue(), actionId, storeId); @@ -46,7 +46,7 @@ ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId, ActionI CommandMessage command; ActionMessage::setCommand(&command, actionId, storeId); ReturnValue_t result = queueToUse->sendMessage(queueId, &command); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeId); } lastTarget = queueId; @@ -57,44 +57,44 @@ ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId, ActionI ReturnValue_t CommandActionHelper::initialize() { ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } queueToUse = owner->getCommandQueuePtr(); if (queueToUse == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CommandActionHelper::handleReply(CommandMessage *reply) { if (reply->getSender() != lastTarget) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } switch (reply->getCommand()) { case ActionMessage::COMPLETION_SUCCESS: commandCount--; owner->completionSuccessfulReceived(ActionMessage::getActionId(reply)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case ActionMessage::COMPLETION_FAILED: commandCount--; owner->completionFailedReceived(ActionMessage::getActionId(reply), ActionMessage::getReturnCode(reply)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case ActionMessage::STEP_SUCCESS: owner->stepSuccessfulReceived(ActionMessage::getActionId(reply), ActionMessage::getStep(reply)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case ActionMessage::STEP_FAILED: commandCount--; owner->stepFailedReceived(ActionMessage::getActionId(reply), ActionMessage::getStep(reply), ActionMessage::getReturnCode(reply)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case ActionMessage::DATA_REPLY: extractDataForOwner(ActionMessage::getActionId(reply), ActionMessage::getStoreId(reply)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -104,7 +104,7 @@ void CommandActionHelper::extractDataForOwner(ActionId_t actionId, store_address const uint8_t *data = nullptr; size_t size = 0; ReturnValue_t result = ipcStore->getData(storeId, &data, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } owner->dataReceived(actionId, data, size); diff --git a/src/fsfw/action/SimpleActionHelper.cpp b/src/fsfw/action/SimpleActionHelper.cpp index fc7e064e..b9b9922e 100644 --- a/src/fsfw/action/SimpleActionHelper.cpp +++ b/src/fsfw/action/SimpleActionHelper.cpp @@ -9,7 +9,7 @@ void SimpleActionHelper::step(ReturnValue_t result) { // STEP_OFFESET is subtracted to compensate for adding offset in base // method, which is not necessary here. ActionHelper::step(stepCount - STEP_OFFSET, lastCommander, lastAction, result); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { resetHelper(); } } @@ -41,7 +41,7 @@ void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId const uint8_t* dataPtr = nullptr; size_t size = 0; ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ActionMessage::setStepReply(&reply, actionId, 0, result); queueToUse->sendMessage(commandedBy, &reply); return; @@ -51,12 +51,12 @@ void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId result = owner->executeAction(actionId, commandedBy, dataPtr, size); ipcStore->deleteData(dataAddress); switch (result) { - case HasReturnvaluesIF::RETURN_OK: + case returnvalue::OK: isExecuting = true; stepCount++; break; case HasActionsIF::EXECUTION_FINISHED: - ActionMessage::setCompletionReply(&reply, actionId, true, HasReturnvaluesIF::RETURN_OK); + ActionMessage::setCompletionReply(&reply, actionId, true, returnvalue::OK); queueToUse->sendMessage(commandedBy, &reply); break; default: diff --git a/src/fsfw/action/SimpleActionHelper.h b/src/fsfw/action/SimpleActionHelper.h index 973c7cf2..cfe05231 100644 --- a/src/fsfw/action/SimpleActionHelper.h +++ b/src/fsfw/action/SimpleActionHelper.h @@ -12,8 +12,8 @@ class SimpleActionHelper : public ActionHelper { public: SimpleActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue); ~SimpleActionHelper() override; - void step(ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); - void finish(ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + void step(ReturnValue_t result = returnvalue::OK); + void finish(ReturnValue_t result = returnvalue::OK); ReturnValue_t reportData(SerializeIF* data); protected: diff --git a/src/fsfw/cfdp/CfdpHandler.cpp b/src/fsfw/cfdp/CfdpHandler.cpp index caa64f56..b9c8b580 100644 --- a/src/fsfw/cfdp/CfdpHandler.cpp +++ b/src/fsfw/cfdp/CfdpHandler.cpp @@ -20,11 +20,11 @@ CfdpHandler::~CfdpHandler() = default; ReturnValue_t CfdpHandler::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } this->distributor->registerHandler(this); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CfdpHandler::handleRequest(store_address_t storeId) { @@ -38,18 +38,18 @@ ReturnValue_t CfdpHandler::handleRequest(store_address_t storeId) { // TODO read out packet from store using storeId - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CfdpHandler::performOperation(uint8_t opCode) { - ReturnValue_t status = RETURN_OK; + ReturnValue_t status = returnvalue::OK; CommandMessage currentMessage; - for (status = this->requestQueue->receiveMessage(¤tMessage); status == RETURN_OK; + for (status = this->requestQueue->receiveMessage(¤tMessage); status == returnvalue::OK; status = this->requestQueue->receiveMessage(¤tMessage)) { store_address_t storeId = CfdpMessage::getStoreId(¤tMessage); this->handleRequest(storeId); } - return RETURN_OK; + return returnvalue::OK; } uint16_t CfdpHandler::getIdentifier() { return 0; } diff --git a/src/fsfw/cfdp/CfdpHandler.h b/src/fsfw/cfdp/CfdpHandler.h index 01399e98..7fe6826c 100644 --- a/src/fsfw/cfdp/CfdpHandler.h +++ b/src/fsfw/cfdp/CfdpHandler.h @@ -12,10 +12,7 @@ namespace Factory { void setStaticFrameworkObjectIds(); } -class CfdpHandler : public ExecutableObjectIF, - public AcceptsTelecommandsIF, - public SystemObject, - public HasReturnvaluesIF { +class CfdpHandler : public ExecutableObjectIF, public AcceptsTelecommandsIF, public SystemObject { friend void(Factory::setStaticFrameworkObjectIds)(); public: diff --git a/src/fsfw/cfdp/FileSize.h b/src/fsfw/cfdp/FileSize.h index 6dae9683..756b0e0a 100644 --- a/src/fsfw/cfdp/FileSize.h +++ b/src/fsfw/cfdp/FileSize.h @@ -43,7 +43,7 @@ struct FileSize : public SerializeIF { uint32_t sizeTmp = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&sizeTmp, buffer, size, streamEndianness); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { fileSize = sizeTmp; } return result; @@ -53,11 +53,11 @@ struct FileSize : public SerializeIF { ReturnValue_t setFileSize(uint64_t fileSize, bool largeFile) { if (not largeFile and fileSize > UINT32_MAX) { // TODO: emit warning here - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->fileSize = fileSize; this->largeFile = largeFile; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool isLargeFile() const { return largeFile; } diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 772b3ae3..9ec9db59 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -15,21 +15,24 @@ static constexpr uint8_t VERSION_BITS = 0b00100000; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; -static constexpr ReturnValue_t INVALID_TLV_TYPE = result::makeCode(CFDP_CLASS_ID, 1); -static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = result::makeCode(CFDP_CLASS_ID, 2); -static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = result::makeCode(CFDP_CLASS_ID, 3); -static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = result::makeCode(CFDP_CLASS_ID, 4); +static constexpr ReturnValue_t INVALID_TLV_TYPE = returnvalue::makeCode(CFDP_CLASS_ID, 1); +static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = returnvalue::makeCode(CFDP_CLASS_ID, 2); +static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = returnvalue::makeCode(CFDP_CLASS_ID, 3); +static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = + returnvalue::makeCode(CFDP_CLASS_ID, 4); //! Can not parse options. This can also occur because there are options //! available but the user did not pass a valid options array -static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = result::makeCode(CFDP_CLASS_ID, 5); -static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = result::makeCode(CFDP_CLASS_ID, 6); +static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = + returnvalue::makeCode(CFDP_CLASS_ID, 5); +static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = returnvalue::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES = - result::makeCode(CFDP_CLASS_ID, 6); -static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = result::makeCode(CFDP_CLASS_ID, 8); + returnvalue::makeCode(CFDP_CLASS_ID, 6); +static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = + returnvalue::makeCode(CFDP_CLASS_ID, 8); //! Can not parse filestore response because user did not pass a valid instance //! or remaining size is invalid static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE = - result::makeCode(CFDP_CLASS_ID, 9); + returnvalue::makeCode(CFDP_CLASS_ID, 9); //! Checksum types according to the SANA Checksum Types registry //! https://sanaregistry.org/r/checksum_identifiers/ diff --git a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp index f5babf4b..24357a38 100644 --- a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp @@ -5,7 +5,7 @@ AckPduDeserializer::AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, Ac ReturnValue_t AckPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); @@ -15,7 +15,7 @@ ReturnValue_t AckPduDeserializer::parseData() { if (not checkAndSetCodes(rawPtr[currentIdx], rawPtr[currentIdx + 1])) { return cfdp::INVALID_ACK_DIRECTIVE_FIELDS; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool AckPduDeserializer::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) { diff --git a/src/fsfw/cfdp/pdu/AckPduSerializer.cpp b/src/fsfw/cfdp/pdu/AckPduSerializer.cpp index d19418f1..b06f4f00 100644 --- a/src/fsfw/cfdp/pdu/AckPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/AckPduSerializer.cpp @@ -11,7 +11,7 @@ ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } cfdp::FileDirectives ackedDirective = ackInfo.getAckedDirective(); @@ -21,7 +21,7 @@ ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t if (ackedDirective != cfdp::FileDirectives::FINISH and ackedDirective != cfdp::FileDirectives::EOF_DIRECTIVE) { // TODO: better returncode - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size + 2 > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; @@ -32,5 +32,5 @@ ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t **buffer = ackedConditionCode << 4 | transactionStatus; *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp index e1ab8dc9..1a70e225 100644 --- a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp @@ -8,7 +8,7 @@ EofPduDeserializer::EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, Eo ReturnValue_t EofPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -31,7 +31,7 @@ ReturnValue_t EofPduDeserializer::parseData() { uint32_t checksum = 0; auto endianness = getEndianness(); result = SerializeAdapter::deSerialize(&checksum, &bufPtr, &deserLen, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } info.setChecksum(checksum); @@ -44,7 +44,7 @@ ReturnValue_t EofPduDeserializer::parseData() { result = SerializeAdapter::deSerialize(&fileSizeValue, &bufPtr, &deserLen, endianness); info.setFileSize(fileSizeValue, false); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) { @@ -61,7 +61,7 @@ ReturnValue_t EofPduDeserializer::parseData() { " given TLV pointer invalid"); #endif #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } result = tlvPtr->deSerialize(&bufPtr, &deserLen, endianness); } diff --git a/src/fsfw/cfdp/pdu/EofPduSerializer.cpp b/src/fsfw/cfdp/pdu/EofPduSerializer.cpp index e9fe0ca0..aafd332e 100644 --- a/src/fsfw/cfdp/pdu/EofPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduSerializer.cpp @@ -16,7 +16,7 @@ ReturnValue_t EofPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + 1 > maxSize) { @@ -27,7 +27,7 @@ ReturnValue_t EofPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t *size += 1; uint32_t checksum = info.getChecksum(); result = SerializeAdapter::serialize(&checksum, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (info.getFileSize().isLargeFile()) { diff --git a/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp b/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp index 240c4188..274f8b8a 100644 --- a/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDataDeserializer.cpp @@ -6,7 +6,7 @@ FileDataDeserializer::FileDataDeserializer(const uint8_t* pduBuf, size_t maxSize ReturnValue_t FileDataDeserializer::parseData() { ReturnValue_t result = HeaderDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = HeaderDeserializer::getHeaderSize(); @@ -32,13 +32,13 @@ ReturnValue_t FileDataDeserializer::parseData() { } } result = info.getOffset().deSerialize(&buf, &remSize, this->getEndianness()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (remSize > 0) { info.setFileData(buf, remSize); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } SerializeIF::Endianness FileDataDeserializer::getEndianness() const { return endianness; } diff --git a/src/fsfw/cfdp/pdu/FileDataInfo.cpp b/src/fsfw/cfdp/pdu/FileDataInfo.cpp index c410adce..39b6472d 100644 --- a/src/fsfw/cfdp/pdu/FileDataInfo.cpp +++ b/src/fsfw/cfdp/pdu/FileDataInfo.cpp @@ -50,11 +50,11 @@ ReturnValue_t FileDataInfo::addSegmentMetadataInfo(cfdp::RecordContinuationState this->segmentMetadataFlag = cfdp::SegmentMetadataFlag::PRESENT; this->recContState = recContState; if (segmentMetadataLen > 63) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->segmentMetadata = segmentMetadata; this->segmentMetadataLen = segmentMetadataLen; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } const uint8_t *FileDataInfo::getFileData(size_t *fileSize) const { diff --git a/src/fsfw/cfdp/pdu/FileDataSerializer.cpp b/src/fsfw/cfdp/pdu/FileDataSerializer.cpp index 837b418b..bdc2d42f 100644 --- a/src/fsfw/cfdp/pdu/FileDataSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDataSerializer.cpp @@ -17,7 +17,7 @@ void FileDataSerializer::update() { ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { ReturnValue_t result = HeaderSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + this->getSerializedSize() > maxSize) { @@ -36,7 +36,7 @@ ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size } cfdp::FileSize& offset = info.getOffset(); result = offset.serialize(this->getLargeFileFlag(), buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t fileSize = 0; @@ -47,7 +47,7 @@ ReturnValue_t FileDataSerializer::serialize(uint8_t** buffer, size_t* size, size std::memcpy(*buffer, readOnlyPtr, fileSize); *buffer += fileSize; *size += fileSize; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t FileDataSerializer::getSerializedSize() const { diff --git a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp b/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp index 3c0552f7..9d2a1e0a 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveDeserializer.cpp @@ -7,7 +7,7 @@ cfdp::FileDirectives FileDirectiveDeserializer::getFileDirective() const { retur ReturnValue_t FileDirectiveDeserializer::parseData() { ReturnValue_t result = HeaderDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (this->getPduDataFieldLen() < 1) { @@ -21,7 +21,7 @@ ReturnValue_t FileDirectiveDeserializer::parseData() { return cfdp::INVALID_DIRECTIVE_FIELDS; } setFileDirective(static_cast(rawPtr[currentIdx])); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t FileDirectiveDeserializer::getHeaderSize() const { diff --git a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp b/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp index 98b2d0a2..5845ba56 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveSerializer.cpp @@ -13,13 +13,13 @@ size_t FileDirectiveSerializer::getSerializedSize() const { ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (FileDirectiveSerializer::getWholePduSize() > maxSize) { return BUFFER_TOO_SHORT; } ReturnValue_t result = HeaderSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -29,7 +29,7 @@ ReturnValue_t FileDirectiveSerializer::serialize(uint8_t **buffer, size_t *size, **buffer = directiveCode; *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FileDirectiveSerializer::setDirectiveDataFieldLen(size_t len) { diff --git a/src/fsfw/cfdp/pdu/FinishedInfo.cpp b/src/fsfw/cfdp/pdu/FinishedInfo.cpp index c32372a1..ea4ffa89 100644 --- a/src/fsfw/cfdp/pdu/FinishedInfo.cpp +++ b/src/fsfw/cfdp/pdu/FinishedInfo.cpp @@ -46,14 +46,14 @@ ReturnValue_t FinishedInfo::setFilestoreResponsesArray(FilestoreResponseTlv** fs if (maxFsResponsesLen != nullptr) { this->fsResponsesMaxLen = *maxFsResponsesLen; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FinishedInfo::getFilestoreResonses(FilestoreResponseTlv*** fsResponses, size_t* fsResponsesLen, size_t* fsResponsesMaxLen) { if (fsResponses == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *fsResponses = this->fsResponses; if (fsResponsesLen != nullptr) { @@ -62,7 +62,7 @@ ReturnValue_t FinishedInfo::getFilestoreResonses(FilestoreResponseTlv*** fsRespo if (fsResponsesMaxLen != nullptr) { *fsResponsesMaxLen = this->fsResponsesMaxLen; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FinishedInfo::setFaultLocation(EntityIdTlv* faultLocation) { @@ -71,10 +71,10 @@ void FinishedInfo::setFaultLocation(EntityIdTlv* faultLocation) { ReturnValue_t FinishedInfo::getFaultLocation(EntityIdTlv** faultLocation) { if (this->faultLocation == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *faultLocation = this->faultLocation; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } cfdp::ConditionCode FinishedInfo::getConditionCode() const { return conditionCode; } diff --git a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp index feeca617..7d16394e 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp @@ -6,7 +6,7 @@ FinishPduDeserializer::FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSi ReturnValue_t FinishPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); @@ -33,7 +33,7 @@ FinishedInfo& FinishPduDeserializer::getInfo() { return finishedInfo; } ReturnValue_t FinishPduDeserializer::parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf, cfdp::ConditionCode conditionCode) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; size_t fsResponsesIdx = 0; auto endianness = getEndianness(); FilestoreResponseTlv** fsResponseArray = nullptr; @@ -60,7 +60,7 @@ ReturnValue_t FinishPduDeserializer::parseTlvs(size_t remLen, size_t currentIdx, return cfdp::FINISHED_CANT_PARSE_FS_RESPONSES; } result = fsResponseArray[fsResponsesIdx]->deSerialize(&buf, &remLen, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } fsResponsesIdx += 1; @@ -72,11 +72,11 @@ ReturnValue_t FinishPduDeserializer::parseTlvs(size_t remLen, size_t currentIdx, return cfdp::INVALID_TLV_TYPE; } result = finishedInfo.getFaultLocation(&faultLocation); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = faultLocation->deSerialize(&buf, &remLen, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } else { diff --git a/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp index 115a2c9c..ccc86908 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp @@ -17,7 +17,7 @@ ReturnValue_t FinishPduSerializer::serialize(uint8_t **buffer, size_t *size, siz Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + 1 >= maxSize) { @@ -34,13 +34,13 @@ ReturnValue_t FinishPduSerializer::serialize(uint8_t **buffer, size_t *size, siz finishInfo.getFilestoreResonses(&fsResponsesArray, &fsResponsesArrayLen, nullptr); for (size_t idx = 0; idx < fsResponsesArrayLen; idx++) { result = fsResponsesArray[idx]->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } } EntityIdTlv *entityId = nullptr; - if (finishInfo.getFaultLocation(&entityId) == HasReturnvaluesIF::RETURN_OK) { + if (finishInfo.getFaultLocation(&entityId) == returnvalue::OK) { result = entityId->serialize(buffer, size, maxSize, streamEndianness); } return result; diff --git a/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp b/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp index 70f397f8..2dbfed27 100644 --- a/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/HeaderDeserializer.cpp @@ -18,7 +18,7 @@ ReturnValue_t HeaderDeserializer::setData(uint8_t *dataPtr, size_t maxSize, void if (dataPtr == nullptr) { // Allowed for now this->fixedHeader = nullptr; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } this->fixedHeader = reinterpret_cast(const_cast(dataPtr)); sourceIdRaw = static_cast(&fixedHeader->variableFieldsStart); @@ -27,7 +27,7 @@ ReturnValue_t HeaderDeserializer::setData(uint8_t *dataPtr, size_t maxSize, void seqNumRaw = static_cast(sourceIdRaw) + static_cast(widthEntityIds); destIdRaw = static_cast(seqNumRaw) + static_cast(widthSeqNum); this->maxSize = maxSize; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t HeaderDeserializer::getHeaderSize() const { diff --git a/src/fsfw/cfdp/pdu/HeaderDeserializer.h b/src/fsfw/cfdp/pdu/HeaderDeserializer.h index ed033697..70a7908c 100644 --- a/src/fsfw/cfdp/pdu/HeaderDeserializer.h +++ b/src/fsfw/cfdp/pdu/HeaderDeserializer.h @@ -37,7 +37,7 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF * This needs to be called before accessing the PDU fields to avoid segmentation faults. * @return * - RETURN_OK on parse success - * - RETURN_FAILED Invalid raw data + * - returnvalue::FAILED Invalid raw data * - SerializeIF::BUFFER_TOO_SHORT if buffer is shorter than expected */ virtual ReturnValue_t parseData(); @@ -61,7 +61,7 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF void getDestId(cfdp::EntityId& destId) const override; void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const override; - ReturnValue_t deserResult = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t deserResult = returnvalue::OK; /** * Can also be used to reset the pointer to a nullptr, but the getter functions will not diff --git a/src/fsfw/cfdp/pdu/HeaderSerializer.cpp b/src/fsfw/cfdp/pdu/HeaderSerializer.cpp index 041fb714..5721ad69 100644 --- a/src/fsfw/cfdp/pdu/HeaderSerializer.cpp +++ b/src/fsfw/cfdp/pdu/HeaderSerializer.cpp @@ -15,7 +15,7 @@ HeaderSerializer::HeaderSerializer(PduConfig &pduConf, cfdp::PduType pduType, ReturnValue_t HeaderSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (maxSize < this->getSerializedSize()) { return BUFFER_TOO_SHORT; @@ -32,19 +32,19 @@ ReturnValue_t HeaderSerializer::serialize(uint8_t **buffer, size_t *size, size_t *buffer += 1; *size += 4; ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t HeaderSerializer::getSerializedSize() const { @@ -55,7 +55,7 @@ size_t HeaderSerializer::getSerializedSize() const { ReturnValue_t HeaderSerializer::deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) { // We could implement this, but I prefer dedicated classes - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } size_t HeaderSerializer::getWholePduSize() const { diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp index 15f80549..79c908cf 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp @@ -6,7 +6,7 @@ KeepAlivePduDeserializer::KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t ReturnValue_t KeepAlivePduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp index e635ce06..5db4664c 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp @@ -19,7 +19,7 @@ ReturnValue_t KeepAlivePduSerializer::serialize(uint8_t **buffer, size_t *size, Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return progress.serialize(this->getLargeFileFlag(), buffer, size, maxSize, streamEndianness); diff --git a/src/fsfw/cfdp/pdu/MetadataInfo.cpp b/src/fsfw/cfdp/pdu/MetadataInfo.cpp index a2ca6972..572460cd 100644 --- a/src/fsfw/cfdp/pdu/MetadataInfo.cpp +++ b/src/fsfw/cfdp/pdu/MetadataInfo.cpp @@ -39,7 +39,7 @@ cfdp::FileSize& MetadataInfo::getFileSize() { return fileSize; } ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray, size_t* optionsLen, size_t* maxOptsLen) { if (optionsArray == nullptr or this->optionsArray == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *optionsArray = this->optionsArray; if (optionsLen != nullptr) { @@ -48,7 +48,7 @@ ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray, size_t* option if (maxOptsLen != nullptr) { *maxOptsLen = this->maxOptionsLen; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool MetadataInfo::hasOptions() const { diff --git a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp b/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp index 161eb63a..be9f4ed7 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduDeserializer.cpp @@ -6,7 +6,7 @@ MetadataPduDeserializer::MetadataPduDeserializer(const uint8_t* pduBuf, size_t m ReturnValue_t MetadataPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); @@ -21,15 +21,15 @@ ReturnValue_t MetadataPduDeserializer::parseData() { buf += 1; auto endianness = getEndianness(); result = info.getFileSize().deSerialize(&buf, &remSize, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = info.getSourceFileName().deSerialize(&buf, &remSize, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = info.getDestFileName().deSerialize(&buf, &remSize, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -47,7 +47,7 @@ ReturnValue_t MetadataPduDeserializer::parseData() { return cfdp::METADATA_CANT_PARSE_OPTIONS; } result = optionsArray[optsIdx]->deSerialize(&buf, &remSize, endianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } optsIdx++; diff --git a/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp b/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp index f5c4de0a..041b9b84 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduSerializer.cpp @@ -17,7 +17,7 @@ ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, s Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + 1 >= maxSize) { @@ -27,15 +27,15 @@ ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, s *buffer += 1; *size += 1; result = info.getFileSize().serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = info.getSourceFileName().serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = info.getDestFileName().serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -45,7 +45,7 @@ ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, s info.getOptions(&optsArray, &optsLen, nullptr); for (size_t idx = 0; idx < optsLen; idx++) { result = optsArray[idx]->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } diff --git a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp b/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp index 9d5f074c..8acc9fc9 100644 --- a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp @@ -5,7 +5,7 @@ NakPduDeserializer::NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, Na ReturnValue_t NakPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); @@ -16,11 +16,11 @@ ReturnValue_t NakPduDeserializer::parseData() { } result = nakInfo.getStartOfScope().deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = nakInfo.getEndOfScope().deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } nakInfo.setSegmentRequestLen(0); @@ -39,12 +39,12 @@ ReturnValue_t NakPduDeserializer::parseData() { } result = segReqs[idx].first.deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = segReqs[idx].second.deSerialize(&buffer, &remSize, SerializeIF::Endianness::NETWORK); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } idx++; diff --git a/src/fsfw/cfdp/pdu/NakPduSerializer.cpp b/src/fsfw/cfdp/pdu/NakPduSerializer.cpp index 95f1bc98..e8634df7 100644 --- a/src/fsfw/cfdp/pdu/NakPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/NakPduSerializer.cpp @@ -17,15 +17,15 @@ ReturnValue_t NakPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = nakInfo.getStartOfScope().serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = nakInfo.getEndOfScope().serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (nakInfo.hasSegmentRequests()) { @@ -34,11 +34,11 @@ ReturnValue_t NakPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t nakInfo.getSegmentRequests(&segmentRequests, &segmentRequestLen, nullptr); for (size_t idx = 0; idx < segmentRequestLen; idx++) { result = segmentRequests[idx].first.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = segmentRequests[idx].second.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } diff --git a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp b/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp index 6a6f5505..7e9e328d 100644 --- a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp @@ -9,7 +9,7 @@ cfdp::PromptResponseRequired PromptPduDeserializer::getPromptResponseRequired() ReturnValue_t PromptPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveDeserializer::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentIdx = FileDirectiveDeserializer::getHeaderSize(); @@ -17,5 +17,5 @@ ReturnValue_t PromptPduDeserializer::parseData() { return SerializeIF::STREAM_TOO_SHORT; } responseRequired = static_cast((rawPtr[currentIdx] >> 7) & 0x01); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp b/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp index a7287563..e5d5bca7 100644 --- a/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp @@ -13,7 +13,7 @@ ReturnValue_t PromptPduSerializer::serialize(uint8_t **buffer, size_t *size, siz Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveSerializer::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + 1 > maxSize) { diff --git a/src/fsfw/cfdp/pdu/VarLenField.cpp b/src/fsfw/cfdp/pdu/VarLenField.cpp index b11c3b09..f0059270 100644 --- a/src/fsfw/cfdp/pdu/VarLenField.cpp +++ b/src/fsfw/cfdp/pdu/VarLenField.cpp @@ -6,7 +6,7 @@ cfdp::VarLenField::VarLenField(cfdp::WidthInBytes width, size_t value) : VarLenField() { ReturnValue_t result = this->setValue(width, value); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_DISABLE_PRINTOUT == 0 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "cfdp::VarLenField: Setting value failed" << std::endl; @@ -25,21 +25,21 @@ ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, size_ switch (widthInBytes) { case (cfdp::WidthInBytes::ONE_BYTE): { if (value > UINT8_MAX) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->value.oneByte = value; break; } case (cfdp::WidthInBytes::TWO_BYTES): { if (value > UINT16_MAX) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->value.twoBytes = value; break; } case (cfdp::WidthInBytes::FOUR_BYTES): { if (value > UINT32_MAX) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->value.fourBytes = value; break; @@ -49,7 +49,7 @@ ReturnValue_t cfdp::VarLenField::setValue(cfdp::WidthInBytes widthInBytes, size_ } } this->width = widthInBytes; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t cfdp::VarLenField::getValue() const { @@ -77,7 +77,7 @@ ReturnValue_t cfdp::VarLenField::serialize(uint8_t **buffer, size_t *size, size_ **buffer = value.oneByte; *size += 1; *buffer += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (cfdp::WidthInBytes::TWO_BYTES): { return SerializeAdapter::serialize(&value.twoBytes, buffer, size, maxSize, streamEndianness); @@ -86,7 +86,7 @@ ReturnValue_t cfdp::VarLenField::serialize(uint8_t **buffer, size_t *size, size_ return SerializeAdapter::serialize(&value.fourBytes, buffer, size, maxSize, streamEndianness); } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } } @@ -105,7 +105,7 @@ ReturnValue_t cfdp::VarLenField::deSerialize(const uint8_t **buffer, size_t *siz case (cfdp::WidthInBytes::ONE_BYTE): { value.oneByte = **buffer; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (cfdp::WidthInBytes::TWO_BYTES): { return SerializeAdapter::deSerialize(&value.twoBytes, buffer, size, streamEndianness); @@ -114,7 +114,7 @@ ReturnValue_t cfdp::VarLenField::deSerialize(const uint8_t **buffer, size_t *siz return SerializeAdapter::deSerialize(&value.fourBytes, buffer, size, streamEndianness); } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } } diff --git a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp index f5f777ea..bbcb61d2 100644 --- a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp +++ b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp @@ -22,7 +22,7 @@ ReturnValue_t FaultHandlerOverrideTlv::serialize(uint8_t **buffer, size_t *size, **buffer = this->conditionCode << 4 | this->handlerCode; *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t FaultHandlerOverrideTlv::getSerializedSize() const { return getLengthField() + 2; } @@ -40,7 +40,7 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_ *size -= 1; size_t detectedSize = **buffer; if (detectedSize != getLengthField()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *buffer += 1; *size += 1; @@ -48,7 +48,7 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_ this->handlerCode = static_cast(**buffer & 0x0f); *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } cfdp::TlvTypes FaultHandlerOverrideTlv::getType() const { return cfdp::TlvTypes::FAULT_HANDLER; } diff --git a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp index 9ad7c645..941e8f5d 100644 --- a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp +++ b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp @@ -16,11 +16,11 @@ void FilestoreRequestTlv::setSecondFileName(cfdp::Lv *secondFileName) { ReturnValue_t FilestoreRequestTlv::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { ReturnValue_t result = commonSerialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = firstFileName.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (requiresSecondFileName()) { @@ -30,13 +30,13 @@ ReturnValue_t FilestoreRequestTlv::serialize(uint8_t **buffer, size_t *size, siz } secondFileName->serialize(buffer, size, maxSize, streamEndianness); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilestoreRequestTlv::deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) { ReturnValue_t result = commonDeserialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return deSerializeFromValue(buffer, size, streamEndianness); @@ -63,13 +63,13 @@ ReturnValue_t FilestoreRequestTlv::deSerializeFromValue(const uint8_t **buffer, *buffer += 1; *size -= 1; ReturnValue_t result = firstFileName.deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (requiresSecondFileName()) { if (secondFileName == nullptr) { secondFileNameMissing(); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } result = secondFileName->deSerialize(buffer, size, streamEndianness); } diff --git a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp index 36945725..53aaaf8f 100644 --- a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp +++ b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp @@ -32,11 +32,11 @@ ReturnValue_t FilestoreResponseTlv::serialize(uint8_t **buffer, size_t *size, si Endianness streamEndianness) const { ReturnValue_t result = commonSerialize(buffer, size, maxSize, streamEndianness, true, this->statusCode); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = firstFileName.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (requiresSecondFileName()) { @@ -61,7 +61,7 @@ ReturnValue_t FilestoreResponseTlv::serialize(uint8_t **buffer, size_t *size, si ReturnValue_t FilestoreResponseTlv::deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) { ReturnValue_t result = commonDeserialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return deSerializeFromValue(buffer, size, streamEndianness); @@ -75,7 +75,7 @@ ReturnValue_t FilestoreResponseTlv::deSerializeFromValue(const uint8_t **buffer, *buffer += 1; *size -= 1; ReturnValue_t result = firstFileName.deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (requiresSecondFileName()) { @@ -83,7 +83,7 @@ ReturnValue_t FilestoreResponseTlv::deSerializeFromValue(const uint8_t **buffer, return cfdp::FILESTORE_REQUIRES_SECOND_FILE; } result = secondFileName->deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -98,7 +98,7 @@ ReturnValue_t FilestoreResponseTlv::deSerializeFromValue(const uint8_t **buffer, *size -= 1; *buffer += 1; // Ignore empty filestore message - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return filestoreMsg->deSerialize(buffer, size, streamEndianness); } diff --git a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h index 04012cda..c37cb0ad 100644 --- a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h +++ b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h @@ -73,7 +73,7 @@ class FilestoreTlvBase : public TlvIF { Endianness streamEndianness, bool isResponse = false, uint8_t responseStatusCode = 0) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (maxSize < 3) { return SerializeIF::BUFFER_TOO_SHORT; @@ -90,13 +90,13 @@ class FilestoreTlvBase : public TlvIF { } *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t commonDeserialize(const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size < 3) { return SerializeIF::STREAM_TOO_SHORT; @@ -114,7 +114,7 @@ class FilestoreTlvBase : public TlvIF { if (remainingLength == 0) { return SerializeIF::STREAM_TOO_SHORT; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool requiresSecondFileName() const { @@ -152,7 +152,7 @@ class FilestoreTlvBase : public TlvIF { size_t serSize = 0; uint8_t* valueStart = buffer + 2; ReturnValue_t result = this->serialize(&buffer, &serSize, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } tlv.setValue(valueStart, serSize - 2); diff --git a/src/fsfw/cfdp/tlv/Lv.cpp b/src/fsfw/cfdp/tlv/Lv.cpp index 1bb16301..9c72b260 100644 --- a/src/fsfw/cfdp/tlv/Lv.cpp +++ b/src/fsfw/cfdp/tlv/Lv.cpp @@ -31,13 +31,13 @@ ReturnValue_t cfdp::Lv::serialize(uint8_t** buffer, size_t* size, size_t maxSize return BUFFER_TOO_SHORT; } if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (zeroLen) { **buffer = 0; *size += 1; *buffer += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return value.serialize(buffer, size, maxSize, streamEndianness); } @@ -54,7 +54,7 @@ size_t cfdp::Lv::getSerializedSize() const { ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size < 1) { return SerializeIF::STREAM_TOO_SHORT; @@ -64,7 +64,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size, zeroLen = true; *buffer += 1; *size -= 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else if (*size < lengthField + 1) { return SerializeIF::STREAM_TOO_SHORT; } @@ -73,7 +73,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size, value.setBuffer(const_cast(*buffer + 1), lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } const uint8_t* cfdp::Lv::getValue(size_t* size) const { diff --git a/src/fsfw/cfdp/tlv/Tlv.cpp b/src/fsfw/cfdp/tlv/Tlv.cpp index f37ff8d5..3a394741 100644 --- a/src/fsfw/cfdp/tlv/Tlv.cpp +++ b/src/fsfw/cfdp/tlv/Tlv.cpp @@ -12,7 +12,7 @@ cfdp::Tlv::Tlv() : value(static_cast(nullptr), 0, true) {} ReturnValue_t cfdp::Tlv::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size + 2 > maxSize) { return BUFFER_TOO_SHORT; @@ -28,10 +28,10 @@ ReturnValue_t cfdp::Tlv::serialize(uint8_t **buffer, size_t *size, size_t maxSiz **buffer = 0; *size += 1; *buffer += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } if (value.getConstBuffer() == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return value.serialize(buffer, size, maxSize, streamEndianness); } @@ -48,7 +48,7 @@ size_t cfdp::Tlv::getSerializedSize() const { ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size < 2) { return STREAM_TOO_SHORT; @@ -68,7 +68,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, zeroLen = true; *buffer += 1; *size -= 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } if (lengthField + 1 > *size) { return SerializeIF::STREAM_TOO_SHORT; @@ -78,7 +78,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, value.setBuffer(const_cast(*buffer + 1), lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } const uint8_t *cfdp::Tlv::getValue() const { return value.getConstBuffer(); } diff --git a/src/fsfw/container/ArrayList.h b/src/fsfw/container/ArrayList.h index 11f40039..522ddf3b 100644 --- a/src/fsfw/container/ArrayList.h +++ b/src/fsfw/container/ArrayList.h @@ -191,7 +191,7 @@ class ArrayList { } entries[size] = entry; ++size; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } /** diff --git a/src/fsfw/container/FIFOBase.tpp b/src/fsfw/container/FIFOBase.tpp index 91804b6c..63727869 100644 --- a/src/fsfw/container/FIFOBase.tpp +++ b/src/fsfw/container/FIFOBase.tpp @@ -17,7 +17,7 @@ inline ReturnValue_t FIFOBase::insert(T value) { values[writeIndex] = value; writeIndex = next(writeIndex); ++currentSize; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } }; @@ -27,12 +27,12 @@ inline ReturnValue_t FIFOBase::retrieve(T* value) { return EMPTY; } else { if (value == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *value = values[readIndex]; readIndex = next(readIndex); --currentSize; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } }; @@ -42,10 +42,10 @@ inline ReturnValue_t FIFOBase::peek(T* value) { return EMPTY; } else { if (value == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *value = values[readIndex]; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } }; diff --git a/src/fsfw/container/FixedMap.h b/src/fsfw/container/FixedMap.h index 48822cd5..c6b2c9b5 100644 --- a/src/fsfw/container/FixedMap.h +++ b/src/fsfw/container/FixedMap.h @@ -75,7 +75,7 @@ class FixedMap : public SerializeIF { uint32_t size() const { return _size; } ReturnValue_t insert(key_t key, T value, Iterator* storedValue = nullptr) { - if (exists(key) == HasReturnvaluesIF::RETURN_OK) { + if (exists(key) == returnvalue::OK) { return KEY_ALREADY_EXISTS; } if (_size == theMap.maxSize()) { @@ -87,7 +87,7 @@ class FixedMap : public SerializeIF { *storedValue = Iterator(&theMap[_size]); } ++_size; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t insert(std::pair pair) { return insert(pair.first, pair.second); } @@ -95,7 +95,7 @@ class FixedMap : public SerializeIF { ReturnValue_t exists(key_t key) const { ReturnValue_t result = KEY_DOES_NOT_EXIST; if (findIndex(key) < _size) { - result = HasReturnvaluesIF::RETURN_OK; + result = returnvalue::OK; } return result; } @@ -108,7 +108,7 @@ class FixedMap : public SerializeIF { theMap[i] = theMap[_size - 1]; --_size; --((*iter).value); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t erase(key_t key) { @@ -118,14 +118,14 @@ class FixedMap : public SerializeIF { } theMap[i] = theMap[_size - 1]; --_size; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } T* findValue(key_t key) const { return &theMap[findIndex(key)].second; } Iterator find(key_t key) const { ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return end(); } return Iterator(&theMap[findIndex(key)]); @@ -133,11 +133,11 @@ class FixedMap : public SerializeIF { ReturnValue_t find(key_t key, T** value) const { ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *value = &theMap[findIndex(key)].second; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool empty() { @@ -165,7 +165,7 @@ class FixedMap : public SerializeIF { ReturnValue_t result = SerializeAdapter::serialize(&this->_size, buffer, size, maxSize, streamEndianness); uint32_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->_size)) { + while ((result == returnvalue::OK) && (i < this->_size)) { result = SerializeAdapter::serialize(&theMap[i].first, buffer, size, maxSize, streamEndianness); result = @@ -195,7 +195,7 @@ class FixedMap : public SerializeIF { return SerializeIF::TOO_MANY_ELEMENTS; } uint32_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->_size)) { + while ((result == returnvalue::OK) && (i < this->_size)) { result = SerializeAdapter::deSerialize(&theMap[i].first, buffer, size, streamEndianness); result = SerializeAdapter::deSerialize(&theMap[i].second, buffer, size, streamEndianness); ++i; diff --git a/src/fsfw/container/FixedOrderedMultimap.h b/src/fsfw/container/FixedOrderedMultimap.h index 3ef8f8f1..f402d622 100644 --- a/src/fsfw/container/FixedOrderedMultimap.h +++ b/src/fsfw/container/FixedOrderedMultimap.h @@ -148,7 +148,7 @@ class FixedOrderedMultimap { */ Iterator find(key_t key) const { ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return end(); } return Iterator(&theMap[findFirstIndex(key)]); diff --git a/src/fsfw/container/FixedOrderedMultimap.tpp b/src/fsfw/container/FixedOrderedMultimap.tpp index fd58bc44..cfdb5331 100644 --- a/src/fsfw/container/FixedOrderedMultimap.tpp +++ b/src/fsfw/container/FixedOrderedMultimap.tpp @@ -16,7 +16,7 @@ inline ReturnValue_t FixedOrderedMultimap::insert(key_t k if (storedValue != nullptr) { *storedValue = Iterator(&theMap[position]); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template inline ReturnValue_t FixedOrderedMultimap::insert(std::pair pair) { @@ -27,7 +27,7 @@ template inline ReturnValue_t FixedOrderedMultimap::exists(key_t key) const { ReturnValue_t result = KEY_DOES_NOT_EXIST; if (findFirstIndex(key) < _size) { - result = HasReturnvaluesIF::RETURN_OK; + result = returnvalue::OK; } return result; } @@ -44,7 +44,7 @@ inline ReturnValue_t FixedOrderedMultimap::erase(Iterator } else { *iter = begin(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template @@ -57,17 +57,17 @@ inline ReturnValue_t FixedOrderedMultimap::erase(key_t ke removeFromPosition(i); i = findFirstIndex(key, i); } while (i < _size); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template inline ReturnValue_t FixedOrderedMultimap::find(key_t key, T **value) const { ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *value = &theMap[findFirstIndex(key)].second; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template diff --git a/src/fsfw/container/IndexedRingMemoryArray.h b/src/fsfw/container/IndexedRingMemoryArray.h index b76e7d56..4ad72592 100644 --- a/src/fsfw/container/IndexedRingMemoryArray.h +++ b/src/fsfw/container/IndexedRingMemoryArray.h @@ -52,15 +52,15 @@ class Index : public SerializeIF { Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&blockStartAddress, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = indexType.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&this->size, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = @@ -71,19 +71,19 @@ class Index : public SerializeIF { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&blockStartAddress, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = indexType.deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&this->size, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&this->storedPackets, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return result; @@ -449,13 +449,13 @@ class IndexedRingMemoryArray : public SerializeIF, public ArrayList, ui // Check Next Block if (!isNextBlockWritable()) { // The Index is full and does not overwrite old - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // Next block can be written, update Metadata currentWriteBlock = getNextWrite(); currentWriteBlock->setSize(0); currentWriteBlock->setStoredPackets(0); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } /** @@ -475,21 +475,21 @@ class IndexedRingMemoryArray : public SerializeIF, public ArrayList, ui additionalInfo->serialize(buffer, size, maxSize, streamEndianness); } ReturnValue_t result = currentWriteBlock->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&this->size, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } uint32_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->size)) { + while ((result == returnvalue::OK) && (i < this->size)) { result = SerializeAdapter::serialize(&this->entries[i], buffer, size, maxSize, streamEndianness); ++i; } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } uint16_t crc = Calculate_CRC(crcBuffer, (*size - oldSize)); @@ -523,44 +523,44 @@ class IndexedRingMemoryArray : public SerializeIF, public ArrayList, ui */ ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (additionalInfo != NULL) { result = additionalInfo->deSerialize(buffer, size, streamEndianness); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } Index tempIndex; result = tempIndex.deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } uint32_t tempSize = 0; result = SerializeAdapter::deSerialize(&tempSize, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (this->size != tempSize) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint32_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->size)) { + while ((result == returnvalue::OK) && (i < this->size)) { result = SerializeAdapter::deSerialize(&this->entries[i], buffer, size, streamEndianness); ++i; } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } typename IndexedRingMemoryArray::Iterator cmp(&tempIndex); for (typename IndexedRingMemoryArray::Iterator it = this->begin(); it != this->end(); ++it) { if (*(cmp.value) == *(it.value)) { currentWriteBlock = it; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } // Reached if current write block iterator is not found - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint32_t getIndexAddress() const { return indexAddress; } diff --git a/src/fsfw/container/PlacementFactory.h b/src/fsfw/container/PlacementFactory.h index 936be59d..e59fc134 100644 --- a/src/fsfw/container/PlacementFactory.h +++ b/src/fsfw/container/PlacementFactory.h @@ -40,7 +40,7 @@ class PlacementFactory { store_address_t tempId; uint8_t* pData = nullptr; ReturnValue_t result = dataBackend->getFreeElement(&tempId, sizeof(T), &pData); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return nullptr; } T* temp = new (pData) T(std::forward(args)...); @@ -56,7 +56,7 @@ class PlacementFactory { template ReturnValue_t destroy(T* thisElement) { if (thisElement == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // Need to call destructor first, in case something was allocated by the object (shouldn't do // that, however). diff --git a/src/fsfw/container/RingBufferBase.h b/src/fsfw/container/RingBufferBase.h index 98207698..77a0583b 100644 --- a/src/fsfw/container/RingBufferBase.h +++ b/src/fsfw/container/RingBufferBase.h @@ -58,18 +58,18 @@ class RingBufferBase { ReturnValue_t readData(uint32_t amount, uint8_t n = 0) { if (getAvailableReadData(n) >= amount) { incrementRead(amount, n); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t writeData(uint32_t amount) { if (availableWriteSpace() >= amount or overwriteOld) { incrementWrite(amount); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/container/SimpleRingBuffer.cpp b/src/fsfw/container/SimpleRingBuffer.cpp index c104ea97..a006df46 100644 --- a/src/fsfw/container/SimpleRingBuffer.cpp +++ b/src/fsfw/container/SimpleRingBuffer.cpp @@ -32,14 +32,14 @@ ReturnValue_t SimpleRingBuffer::getFreeElement(uint8_t** writePointer, size_t am size_t amountTillWrap = writeTillWrap(); if (amountTillWrap < amount) { if ((amount - amountTillWrap + excessBytes) > maxExcessBytes) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } excessBytes = amount - amountTillWrap; } *writePointer = &buffer[write]; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -52,7 +52,7 @@ void SimpleRingBuffer::confirmBytesWritten(size_t amount) { ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) { if (data == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (amount > getMaxSize()) { #if FSFW_VERBOSE_LEVEL >= 1 @@ -62,7 +62,7 @@ ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) { sif::printError("SimpleRingBuffer::writeData: Amount of data too large\n"); #endif #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (availableWriteSpace() >= amount or overwriteOld) { size_t amountTillWrap = writeTillWrap(); @@ -74,9 +74,9 @@ ReturnValue_t SimpleRingBuffer::writeData(const uint8_t* data, size_t amount) { memcpy(buffer, data + amountTillWrap, amount - amountTillWrap); } incrementWrite(amount); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -89,7 +89,7 @@ ReturnValue_t SimpleRingBuffer::readData(uint8_t* data, size_t amount, bool incr // more data available than amount specified. amount = availableData; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } if (trueAmount != nullptr) { @@ -105,7 +105,7 @@ ReturnValue_t SimpleRingBuffer::readData(uint8_t* data, size_t amount, bool incr if (incrementReadPtr) { deleteData(amount, readRemaining); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t SimpleRingBuffer::getExcessBytes() const { return excessBytes; } @@ -124,12 +124,12 @@ ReturnValue_t SimpleRingBuffer::deleteData(size_t amount, bool deleteRemaining, if (deleteRemaining) { amount = availableData; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } if (trueAmount != nullptr) { *trueAmount = amount; } incrementRead(amount, READ_PTR); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/container/SimpleRingBuffer.h b/src/fsfw/container/SimpleRingBuffer.h index b9762451..7495e31c 100644 --- a/src/fsfw/container/SimpleRingBuffer.h +++ b/src/fsfw/container/SimpleRingBuffer.h @@ -48,7 +48,7 @@ class SimpleRingBuffer : public RingBufferBase<> { * @param data * @param amount * @return -@c RETURN_OK if write operation was successful - * -@c RETURN_FAILED if + * -@c returnvalue::FAILED if */ ReturnValue_t writeData(const uint8_t* data, size_t amount); @@ -96,7 +96,7 @@ class SimpleRingBuffer : public RingBufferBase<> { * to the passed value. * @return * - @c RETURN_OK if data was read successfully - * - @c RETURN_FAILED if not enough data was available and readRemaining + * - @c returnvalue::FAILED if not enough data was available and readRemaining * was set to false. */ ReturnValue_t readData(uint8_t* data, size_t amount, bool incrementReadPtr = false, diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp index 7a8b6bc4..a9d19ef2 100644 --- a/src/fsfw/controller/ControllerBase.cpp +++ b/src/fsfw/controller/ControllerBase.cpp @@ -20,7 +20,7 @@ ControllerBase::~ControllerBase() { QueueFactory::instance()->deleteMessageQueue ReturnValue_t ControllerBase::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -28,7 +28,7 @@ ReturnValue_t ControllerBase::initialize() { if (parentId != objects::NO_OBJECT) { auto* parent = ObjectManager::instance()->get(parentId); if (parent == nullptr) { - return RETURN_FAILED; + return returnvalue::FAILED; } parentQueue = parent->getCommandQueue(); @@ -36,16 +36,16 @@ ReturnValue_t ControllerBase::initialize() { } result = healthHelper.initialize(parentQueue); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = modeHelper.initialize(parentQueue); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return RETURN_OK; + return returnvalue::OK; } MessageQueueId_t ControllerBase::getCommandQueue() const { return commandQueue->getId(); } @@ -53,19 +53,19 @@ MessageQueueId_t ControllerBase::getCommandQueue() const { return commandQueue-> void ControllerBase::handleQueue() { CommandMessage command; ReturnValue_t result; - for (result = commandQueue->receiveMessage(&command); result == RETURN_OK; + for (result = commandQueue->receiveMessage(&command); result == returnvalue::OK; result = commandQueue->receiveMessage(&command)) { result = modeHelper.handleModeCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = healthHelper.handleHealthCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = handleCommandMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } command.setToUnknownCommand(); @@ -96,7 +96,7 @@ void ControllerBase::announceMode(bool recursive) { triggerEvent(MODE_INFO, mode ReturnValue_t ControllerBase::performOperation(uint8_t opCode) { handleQueue(); performControlOperation(); - return RETURN_OK; + return returnvalue::OK; } void ControllerBase::modeChanged(Mode_t mode_, Submode_t submode_) {} @@ -106,7 +106,7 @@ ReturnValue_t ControllerBase::setHealth(HealthState health) { case HEALTHY: case EXTERNAL_CONTROL: healthHelper.setHealth(health); - return RETURN_OK; + return returnvalue::OK; default: return INVALID_HEALTH_STATE; } @@ -117,4 +117,4 @@ void ControllerBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; } void ControllerBase::changeHK(Mode_t mode_, Submode_t submode_, bool enable) {} -ReturnValue_t ControllerBase::initializeAfterTaskCreation() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t ControllerBase::initializeAfterTaskCreation() { return returnvalue::OK; } diff --git a/src/fsfw/controller/ControllerBase.h b/src/fsfw/controller/ControllerBase.h index 550659b8..56c28585 100644 --- a/src/fsfw/controller/ControllerBase.h +++ b/src/fsfw/controller/ControllerBase.h @@ -18,8 +18,7 @@ class ControllerBase : public HasModesIF, public HasHealthIF, public ExecutableObjectIF, - public SystemObject, - public HasReturnvaluesIF { + public SystemObject { public: static const Mode_t MODE_NORMAL = 2; diff --git a/src/fsfw/controller/ExtendedControllerBase.cpp b/src/fsfw/controller/ExtendedControllerBase.cpp index 64b39a31..4d5c90c8 100644 --- a/src/fsfw/controller/ExtendedControllerBase.cpp +++ b/src/fsfw/controller/ExtendedControllerBase.cpp @@ -12,7 +12,7 @@ ReturnValue_t ExtendedControllerBase::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t *data, size_t size) { /* Needs to be overriden and implemented by child class. */ - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } object_id_t ExtendedControllerBase::getObjectId() const { return SystemObject::getObjectId(); } @@ -23,7 +23,7 @@ uint32_t ExtendedControllerBase::getPeriodicOperationFrequency() const { ReturnValue_t ExtendedControllerBase::handleCommandMessage(CommandMessage *message) { ReturnValue_t result = actionHelper.handleActionMessage(message); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return result; } return poolManager.handleHousekeepingMessage(message); @@ -32,30 +32,30 @@ ReturnValue_t ExtendedControllerBase::handleCommandMessage(CommandMessage *messa void ExtendedControllerBase::handleQueue() { CommandMessage command; ReturnValue_t result; - for (result = commandQueue->receiveMessage(&command); result == RETURN_OK; + for (result = commandQueue->receiveMessage(&command); result == returnvalue::OK; result = commandQueue->receiveMessage(&command)) { result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = modeHelper.handleModeCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = healthHelper.handleHealthCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = poolManager.handleHousekeepingMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = handleCommandMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } command.setToUnknownCommand(); @@ -65,11 +65,11 @@ void ExtendedControllerBase::handleQueue() { ReturnValue_t ExtendedControllerBase::initialize() { ReturnValue_t result = ControllerBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = actionHelper.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -86,7 +86,7 @@ ReturnValue_t ExtendedControllerBase::performOperation(uint8_t opCode) { /* We do this after performing control operation because variables will be set changed in this function. */ poolManager.performHkOperation(); - return RETURN_OK; + return returnvalue::OK; } MessageQueueId_t ExtendedControllerBase::getCommandQueue() const { return commandQueue->getId(); } diff --git a/src/fsfw/coordinates/Sgp4Propagator.cpp b/src/fsfw/coordinates/Sgp4Propagator.cpp index 4a43842c..e79ffef5 100644 --- a/src/fsfw/coordinates/Sgp4Propagator.cpp +++ b/src/fsfw/coordinates/Sgp4Propagator.cpp @@ -152,7 +152,7 @@ ReturnValue_t Sgp4Propagator::initialize(const uint8_t* line1, const uint8_t* li return MAKE_RETURN_CODE(result); } else { initialized = true; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } @@ -195,6 +195,6 @@ ReturnValue_t Sgp4Propagator::propagate(double* position, double* velocity, time if (result != 0) { return MAKE_RETURN_CODE(result || 0xB0); } else { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } diff --git a/src/fsfw/datalinklayer/DataLinkLayer.cpp b/src/fsfw/datalinklayer/DataLinkLayer.cpp index ca607478..6fe3e664 100644 --- a/src/fsfw/datalinklayer/DataLinkLayer.cpp +++ b/src/fsfw/datalinklayer/DataLinkLayer.cpp @@ -28,7 +28,7 @@ ReturnValue_t DataLinkLayer::frameDelimitingAndFillRemoval() { TcTransferFrame frame_candidate(frameBuffer); this->currentFrame = frame_candidate; // should work with shallow copy. - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DataLinkLayer::frameValidationCheck() { @@ -59,14 +59,14 @@ ReturnValue_t DataLinkLayer::frameValidationCheck() { if (USE_CRC) { return this->frameCheckCRC(); } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DataLinkLayer::frameCheckCRC() { uint16_t checkValue = CRC::crc16ccitt(this->currentFrame.getFullFrame(), this->currentFrame.getFullSize()); if (checkValue == 0) { - return RETURN_OK; + return returnvalue::OK; } else { return CRC_FAILED; } @@ -74,7 +74,7 @@ ReturnValue_t DataLinkLayer::frameCheckCRC() { ReturnValue_t DataLinkLayer::allFramesReception() { ReturnValue_t status = this->frameDelimitingAndFillRemoval(); - if (status != RETURN_OK) { + if (status != returnvalue::OK) { return status; } return this->frameValidationCheck(); @@ -90,7 +90,7 @@ ReturnValue_t DataLinkLayer::virtualChannelDemultiplexing() { virtualChannelIterator iter = virtualChannels.find(vcId); if (iter == virtualChannels.end()) { // Do not report because passive board will get this error all the time. - return RETURN_OK; + return returnvalue::OK; } else { return (iter->second)->frameAcceptanceAndReportingMechanism(¤tFrame, clcw); } @@ -99,7 +99,7 @@ ReturnValue_t DataLinkLayer::virtualChannelDemultiplexing() { ReturnValue_t DataLinkLayer::processFrame(uint16_t length) { receivedDataLength = length; ReturnValue_t status = allFramesReception(); - if (status != RETURN_OK) { + if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DataLinkLayer::processFrame: frame reception failed. " "Error code: " @@ -117,14 +117,14 @@ ReturnValue_t DataLinkLayer::addVirtualChannel(uint8_t virtualChannelId, std::pair returnValue = virtualChannels.insert( std::pair(virtualChannelId, object)); if (returnValue.second == true) { - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t DataLinkLayer::initialize() { - ReturnValue_t returnValue = RETURN_FAILED; + ReturnValue_t returnValue = returnvalue::FAILED; // Set Virtual Channel ID to first virtual channel instance in this DataLinkLayer instance to // avoid faulty information (e.g. 0) in the VCID. if (virtualChannels.begin() != virtualChannels.end()) { @@ -133,13 +133,13 @@ ReturnValue_t DataLinkLayer::initialize() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DataLinkLayer::initialize: No VC assigned to this DLL instance! " << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } for (virtualChannelIterator iterator = virtualChannels.begin(); iterator != virtualChannels.end(); iterator++) { returnValue = iterator->second->initialize(); - if (returnValue != RETURN_OK) break; + if (returnValue != returnvalue::OK) break; } return returnValue; } diff --git a/src/fsfw/datalinklayer/DataLinkLayer.h b/src/fsfw/datalinklayer/DataLinkLayer.h index 8735feb6..64d33016 100644 --- a/src/fsfw/datalinklayer/DataLinkLayer.h +++ b/src/fsfw/datalinklayer/DataLinkLayer.h @@ -61,7 +61,7 @@ class DataLinkLayer : public CCSDSReturnValuesIF { * handle Frames directed to this VC. * @param virtualChannelId Id of the VC. Shall be smaller than 64. * @param object Reference to the object that handles the Frame. - * @return @c RETURN_OK on success, @c RETURN_FAILED otherwise. + * @return @c RETURN_OK on success, @c returnvalue::FAILED otherwise. */ ReturnValue_t addVirtualChannel(uint8_t virtualChannelId, VirtualChannelReceptionIF* object); /** diff --git a/src/fsfw/datalinklayer/Farm1StateOpen.cpp b/src/fsfw/datalinklayer/Farm1StateOpen.cpp index cf3339a7..b27f609c 100644 --- a/src/fsfw/datalinklayer/Farm1StateOpen.cpp +++ b/src/fsfw/datalinklayer/Farm1StateOpen.cpp @@ -11,7 +11,7 @@ ReturnValue_t Farm1StateOpen::handleADFrame(TcTransferFrame* frame, ClcwIF* clcw if (diff == 0) { myVC->vR++; clcw->setRetransmitFlag(false); - return RETURN_OK; + return returnvalue::OK; } else if (diff < myVC->positiveWindow && diff > 0) { clcw->setRetransmitFlag(true); return NS_POSITIVE_W; diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.cpp b/src/fsfw/datalinklayer/MapPacketExtraction.cpp index feb1cc91..c074de73 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.cpp +++ b/src/fsfw/datalinklayer/MapPacketExtraction.cpp @@ -31,7 +31,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) { if (packetLength <= MAX_PACKET_SIZE) { memcpy(packetBuffer, frame->getDataField(), packetLength); bufferPosition = &packetBuffer[packetLength]; - status = RETURN_OK; + status = returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Packet too large! Size: " @@ -52,7 +52,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) { status = sendCompletePacket(packetBuffer, packetLength); clearBuffers(); } - status = RETURN_OK; + status = returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Packet too large! Size: " @@ -95,7 +95,7 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(TcTransferFrame* frame) status = sendCompletePacket(packet.getWholeData(), packet.getFullSize()); totalLength -= packet.getFullSize(); position += packet.getFullSize(); - status = RETURN_OK; + status = returnvalue::OK; } else { status = DATA_CORRUPTED; totalLength = 0; @@ -110,7 +110,7 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(TcTransferFrame* frame) ReturnValue_t MapPacketExtraction::sendCompletePacket(uint8_t* data, uint32_t size) { store_address_t store_id; ReturnValue_t status = this->packetStore->addData(&store_id, data, size); - if (status == RETURN_OK) { + if (status == returnvalue::OK) { TmTcMessage message(store_id); status = MessageQueueSenderIF::sendMessage(tcQueueId, &message); } @@ -130,9 +130,9 @@ ReturnValue_t MapPacketExtraction::initialize() { ObjectManager::instance()->get(packetDestination); if ((packetStore != NULL) && (distributor != NULL)) { tcQueueId = distributor->getRequestQueue(); - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.h b/src/fsfw/datalinklayer/MapPacketExtraction.h index c2673b2e..54faaf04 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.h +++ b/src/fsfw/datalinklayer/MapPacketExtraction.h @@ -63,7 +63,7 @@ class MapPacketExtraction : public MapPacketExtractionIF { ReturnValue_t extractPackets(TcTransferFrame* frame); /** * The #packetStore and the default destination of #tcQueue are initialized here. - * @return @c RETURN_OK on success, @c RETURN_FAILED otherwise. + * @return @c RETURN_OK on success, @c returnvalue::FAILED otherwise. */ ReturnValue_t initialize(); /** diff --git a/src/fsfw/datalinklayer/VirtualChannelReception.cpp b/src/fsfw/datalinklayer/VirtualChannelReception.cpp index 258bc1e6..4c44cf01 100644 --- a/src/fsfw/datalinklayer/VirtualChannelReception.cpp +++ b/src/fsfw/datalinklayer/VirtualChannelReception.cpp @@ -57,18 +57,18 @@ ReturnValue_t VirtualChannelReception::doFARM(TcTransferFrame* frame, ClcwIF* cl ReturnValue_t VirtualChannelReception::frameAcceptanceAndReportingMechanism(TcTransferFrame* frame, ClcwIF* clcw) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; result = doFARM(frame, &internalClcw); internalClcw.setReceiverFrameSequenceNumber(vR); internalClcw.setFarmBCount(farmBCounter); clcw->setWhole(internalClcw.getAsWhole()); switch (result) { - case RETURN_OK: + case returnvalue::OK: return mapDemultiplexing(frame); case BC_IS_SET_VR_COMMAND: case BC_IS_UNLOCK_COMMAND: // Need to catch these codes to avoid error reporting later. - return RETURN_OK; + return returnvalue::OK; default: break; } @@ -79,15 +79,15 @@ ReturnValue_t VirtualChannelReception::addMapChannel(uint8_t mapId, MapPacketExt std::pair returnValue = mapChannels.insert(std::pair(mapId, object)); if (returnValue.second == true) { - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t VirtualChannelReception::handleBDFrame(TcTransferFrame* frame, ClcwIF* clcw) { farmBCounter++; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t VirtualChannelReception::handleBCFrame(TcTransferFrame* frame, ClcwIF* clcw) { @@ -107,18 +107,18 @@ ReturnValue_t VirtualChannelReception::handleBCFrame(TcTransferFrame* frame, Clc uint8_t VirtualChannelReception::getChannelId() const { return channelId; } ReturnValue_t VirtualChannelReception::initialize() { - ReturnValue_t returnValue = RETURN_FAILED; + ReturnValue_t returnValue = returnvalue::FAILED; if ((slidingWindowWidth > 254) || (slidingWindowWidth % 2 != 0)) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VirtualChannelReception::initialize: Illegal sliding window width: " << (int)slidingWindowWidth << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } for (mapChannelIterator iterator = mapChannels.begin(); iterator != mapChannels.end(); iterator++) { returnValue = iterator->second->initialize(); - if (returnValue != RETURN_OK) break; + if (returnValue != returnvalue::OK) break; } return returnValue; } diff --git a/src/fsfw/datalinklayer/VirtualChannelReception.h b/src/fsfw/datalinklayer/VirtualChannelReception.h index 6dc17dd8..94757941 100644 --- a/src/fsfw/datalinklayer/VirtualChannelReception.h +++ b/src/fsfw/datalinklayer/VirtualChannelReception.h @@ -102,13 +102,14 @@ class VirtualChannelReception : public VirtualChannelReceptionIF, public CCSDSRe * Helper method to simplify adding a mapChannel during construction. * @param mapId The mapId of the object to add. * @param object Pointer to the MapPacketExtraction object itself. - * @return @c RETURN_OK if the channel was successfully inserted, @c RETURN_FAILED otherwise. + * @return @c RETURN_OK if the channel was successfully inserted, @c returnvalue::FAILED + * otherwise. */ ReturnValue_t addMapChannel(uint8_t mapId, MapPacketExtractionIF* object); /** * The initialization routine checks the set #slidingWindowWidth and initializes all MAP * channels. - * @return @c RETURN_OK on successful initialization, @c RETURN_FAILED otherwise. + * @return @c RETURN_OK on successful initialization, @c returnvalue::FAILED otherwise. */ ReturnValue_t initialize(); /** diff --git a/src/fsfw/datapool/PoolDataSetBase.cpp b/src/fsfw/datapool/PoolDataSetBase.cpp index b31f4725..0df21d2a 100644 --- a/src/fsfw/datapool/PoolDataSetBase.cpp +++ b/src/fsfw/datapool/PoolDataSetBase.cpp @@ -14,7 +14,7 @@ PoolDataSetBase::~PoolDataSetBase() {} ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF* variable) { if (registeredVariables == nullptr) { /* Underlying container invalid */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (state != States::STATE_SET_UNINITIALISED) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -42,17 +42,17 @@ ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF* variable) { } registeredVariables[fillCount] = variable; fillCount++; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; ReturnValue_t error = result; if (state == States::STATE_SET_UNINITIALISED) { lockDataPool(timeoutType, lockTimeout); for (uint16_t count = 0; count < fillCount; count++) { result = readVariable(count); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { error = result; } } @@ -71,7 +71,7 @@ ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t l result = SET_WAS_ALREADY_READ; } - if (error != HasReturnvaluesIF::RETURN_OK) { + if (error != returnvalue::OK) { result = error; } return result; @@ -80,10 +80,10 @@ ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t l uint16_t PoolDataSetBase::getFillCount() const { return fillCount; } ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (registeredVariables[count] == nullptr) { /* Configuration error. */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } /* These checks are often performed by the respective variable implementation too, but I guess @@ -98,7 +98,7 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) { result = ReadCommitIFAttorney::readWithoutLock(registeredVariables[count]); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { result = INVALID_PARAMETER_DEFINITION; } } @@ -108,7 +108,7 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) { ReturnValue_t PoolDataSetBase::commit(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { if (state == States::STATE_SET_WAS_READ) { handleAlreadyReadDatasetCommit(timeoutType, lockTimeout); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return handleUnreadDatasetCommit(timeoutType, lockTimeout); } @@ -134,7 +134,7 @@ void PoolDataSetBase::handleAlreadyReadDatasetCommit(MutexIF::TimeoutType timeou ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; lockDataPool(timeoutType, lockTimeout); for (uint16_t count = 0; count < fillCount; count++) { if ((registeredVariables[count]->getReadWriteMode() == PoolVariableIF::VAR_WRITE) and @@ -165,17 +165,17 @@ ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(MutexIF::TimeoutType ti ReturnValue_t PoolDataSetBase::lockDataPool(MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } -ReturnValue_t PoolDataSetBase::unlockDataPool() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t PoolDataSetBase::unlockDataPool() { return returnvalue::OK; } ReturnValue_t PoolDataSetBase::serialize(uint8_t** buffer, size_t* size, const size_t maxSize, SerializeIF::Endianness streamEndianness) const { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (uint16_t count = 0; count < fillCount; count++) { result = registeredVariables[count]->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -184,10 +184,10 @@ ReturnValue_t PoolDataSetBase::serialize(uint8_t** buffer, size_t* size, const s ReturnValue_t PoolDataSetBase::deSerialize(const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (uint16_t count = 0; count < fillCount; count++) { result = registeredVariables[count]->deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } diff --git a/src/fsfw/datapool/PoolDataSetBase.h b/src/fsfw/datapool/PoolDataSetBase.h index dc6ec135..79a1095b 100644 --- a/src/fsfw/datapool/PoolDataSetBase.h +++ b/src/fsfw/datapool/PoolDataSetBase.h @@ -29,20 +29,20 @@ * @author Bastian Baetz * @ingroup data_pool */ -class PoolDataSetBase : public PoolDataSetIF, public SerializeIF, public HasReturnvaluesIF { +class PoolDataSetBase : public PoolDataSetIF, public SerializeIF { public: /** * @brief Creates an empty dataset. Use registerVariable or * supply a pointer to this dataset to PoolVariable * initializations to register pool variables. */ - PoolDataSetBase(PoolVariableIF** registeredVariablesArray, const size_t maxFillCount); + PoolDataSetBase(PoolVariableIF** registeredVariablesArray, size_t maxFillCount); /* Forbidden for now */ PoolDataSetBase(const PoolDataSetBase& otherSet) = delete; const PoolDataSetBase& operator=(const PoolDataSetBase& otherSet) = delete; - virtual ~PoolDataSetBase(); + ~PoolDataSetBase() override; /** * @brief The read call initializes reading out all registered variables. diff --git a/src/fsfw/datapool/PoolReadGuard.h b/src/fsfw/datapool/PoolReadGuard.h index 24d98933..f9bf35fe 100644 --- a/src/fsfw/datapool/PoolReadGuard.h +++ b/src/fsfw/datapool/PoolReadGuard.h @@ -17,7 +17,7 @@ class PoolReadGuard { : readObject(readObject), mutexTimeout(mutexTimeout) { if (readObject != nullptr) { readResult = readObject->read(timeoutType, mutexTimeout); - if (readResult != HasReturnvaluesIF::RETURN_OK) { + if (readResult != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PoolReadHelper: Read failed!" << std::endl; @@ -47,7 +47,7 @@ class PoolReadGuard { private: ReadCommitIF* readObject = nullptr; - ReturnValue_t readResult = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t readResult = returnvalue::OK; bool noCommit = false; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; uint32_t mutexTimeout = 20; diff --git a/src/fsfw/datapool/ReadCommitIFAttorney.h b/src/fsfw/datapool/ReadCommitIFAttorney.h index ea39ffe5..361ac6e4 100644 --- a/src/fsfw/datapool/ReadCommitIFAttorney.h +++ b/src/fsfw/datapool/ReadCommitIFAttorney.h @@ -12,14 +12,14 @@ class ReadCommitIFAttorney { private: static ReturnValue_t readWithoutLock(ReadCommitIF* readCommitIF) { if (readCommitIF == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return readCommitIF->readWithoutLock(); } static ReturnValue_t commitWithoutLock(ReadCommitIF* readCommitIF) { if (readCommitIF == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return readCommitIF->commitWithoutLock(); } diff --git a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h index b7a6198e..8530fd77 100644 --- a/src/fsfw/datapoollocal/HasLocalDataPoolIF.h +++ b/src/fsfw/datapoollocal/HasLocalDataPoolIF.h @@ -110,10 +110,10 @@ class HasLocalDataPoolIF { * These function can be implemented by pool owner, if they are required * and used by the housekeeping message interface. * */ - virtual ReturnValue_t addDataSet(sid_t sid) { return HasReturnvaluesIF::RETURN_FAILED; }; - virtual ReturnValue_t removeDataSet(sid_t sid) { return HasReturnvaluesIF::RETURN_FAILED; }; + virtual ReturnValue_t addDataSet(sid_t sid) { return returnvalue::FAILED; }; + virtual ReturnValue_t removeDataSet(sid_t sid) { return returnvalue::FAILED; }; virtual ReturnValue_t changeCollectionInterval(sid_t sid, float newIntervalSeconds) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; }; /** diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 7a18b7bf..fa76d2a7 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -21,15 +21,15 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQue bool appendValidityBuffer) : appendValidityBuffer(appendValidityBuffer) { if (owner == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "LocalDataPoolManager", - HasReturnvaluesIF::RETURN_FAILED, "Invalid supplied owner"); + printWarningOrError(sif::OutputTypes::OUT_WARNING, "LocalDataPoolManager", returnvalue::FAILED, + "Invalid supplied owner"); return; } this->owner = owner; mutex = MutexFactory::instance()->createMutex(); if (mutex == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "LocalDataPoolManager", - HasReturnvaluesIF::RETURN_FAILED, "Could not create mutex"); + printWarningOrError(sif::OutputTypes::OUT_ERROR, "LocalDataPoolManager", returnvalue::FAILED, + "Could not create mutex"); } hkQueue = queueToUse; @@ -51,9 +51,9 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore == nullptr) { /* Error, all destinations invalid */ - printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", HasReturnvaluesIF::RETURN_FAILED, + printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", returnvalue::FAILED, "Could not set IPC store."); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (defaultHkDestination != objects::NO_OBJECT) { @@ -67,7 +67,7 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::initializeAfterTaskCreation(uint8_t nonDiagInvlFactor) { @@ -78,19 +78,19 @@ ReturnValue_t LocalDataPoolManager::initializeAfterTaskCreation(uint8_t nonDiagI ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() { if (not mapInitialized) { ReturnValue_t result = owner->initializeLocalDataPool(localPoolMap, *this); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { mapInitialized = true; } return result; } printWarningOrError(sif::OutputTypes::OUT_WARNING, "initializeHousekeepingPoolEntriesOnce", - HasReturnvaluesIF::RETURN_FAILED, "The map should only be initialized once"); - return HasReturnvaluesIF::RETURN_OK; + returnvalue::FAILED, "The map should only be initialized once"); + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::performHkOperation() { - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; for (auto& receiver : hkReceivers) { switch (receiver.reportingType) { case (ReportingType::PERIODIC): { @@ -115,7 +115,7 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() { } default: // This should never happen. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } resetHkUpdateResetHelper(); @@ -125,7 +125,7 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() { ReturnValue_t LocalDataPoolManager::handleHkUpdate(HkReceiver& receiver, ReturnValue_t& status) { if (receiver.dataType == DataType::LOCAL_POOL_VARIABLE) { /* Update packets shall only be generated from datasets. */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, receiver.dataId.sid); @@ -135,12 +135,12 @@ ReturnValue_t LocalDataPoolManager::handleHkUpdate(HkReceiver& receiver, ReturnV if (dataSet->hasChanged()) { /* Prepare and send update notification */ ReturnValue_t result = generateHousekeepingPacket(receiver.dataId.sid, dataSet, true); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } } handleChangeResetLogic(receiver.dataType, receiver.dataId, dataSet); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receiver, @@ -160,7 +160,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive HousekeepingMessage::setUpdateNotificationVariableCommand( ¬ification, gp_id_t(owner->getObjectId(), receiver.dataId.localPoolId)); ReturnValue_t result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } toReset = poolObj; @@ -179,7 +179,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive CommandMessage notification; HousekeepingMessage::setUpdateNotificationSetCommand(¬ification, receiver.dataId.sid); ReturnValue_t result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } toReset = dataSet; @@ -188,7 +188,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receive if (toReset != nullptr) { handleChangeResetLogic(receiver.dataType, receiver.dataId, toReset); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& receiver, @@ -205,7 +205,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei } if (not poolObj->hasChanged()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } /* Prepare and send update snapshot */ @@ -219,7 +219,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei store_address_t storeId; ReturnValue_t result = addUpdateToStore(updatePacket, storeId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -227,7 +227,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei HousekeepingMessage::setUpdateSnapshotVariableCommand( ¬ification, gp_id_t(owner->getObjectId(), receiver.dataId.localPoolId), storeId); result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } toReset = poolObj; @@ -241,7 +241,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei } if (not dataSet->hasChanged()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } /* Prepare and send update snapshot */ @@ -255,14 +255,14 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei store_address_t storeId; ReturnValue_t result = addUpdateToStore(updatePacket, storeId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } CommandMessage notification; HousekeepingMessage::setUpdateSnapshotSetCommand(¬ification, receiver.dataId.sid, storeId); result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } toReset = dataSet; @@ -270,7 +270,7 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei if (toReset != nullptr) { handleChangeResetLogic(receiver.dataType, receiver.dataId, toReset); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::addUpdateToStore(HousekeepingSnapshot& updatePacket, @@ -279,7 +279,7 @@ ReturnValue_t LocalDataPoolManager::addUpdateToStore(HousekeepingSnapshot& updat uint8_t* storePtr = nullptr; ReturnValue_t result = ipcStore->getFreeElement(&storeId, updatePacket.getSerializedSize(), &storePtr); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t serializedSize = 0; @@ -356,7 +356,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(subdp::ParamsBase } hkReceivers.push_back(hkReceiver); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::subscribeForRegularUpdatePacket( @@ -388,7 +388,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(subdp::ParamsBase& hkReceivers.push_back(hkReceiver); handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::subscribeForSetUpdateMessage(const uint32_t setId, @@ -409,7 +409,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForSetUpdateMessage(const uint32_t hkReceivers.push_back(hkReceiver); handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::subscribeForVariableUpdateMessage( @@ -429,7 +429,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForVariableUpdateMessage( hkReceivers.push_back(hkReceiver); handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void LocalDataPoolManager::handleHkUpdateResetListInsertion(DataType dataType, DataId dataId) { @@ -463,7 +463,7 @@ void LocalDataPoolManager::handleHkUpdateResetListInsertion(DataType dataType, D ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* message) { Command_t command = message->getCommand(); sid_t sid = HousekeepingMessage::getSid(message); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (command) { // Houskeeping interface handling. case (HousekeepingMessage::ENABLE_PERIODIC_DIAGNOSTICS_GENERATION): { @@ -488,7 +488,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me case (HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): { result = generateSetStructurePacket(sid, true); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return result; } break; @@ -496,7 +496,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me case (HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): { result = generateSetStructurePacket(sid, false); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return result; } break; @@ -536,12 +536,12 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me /* Notification handling */ case (HousekeepingMessage::UPDATE_NOTIFICATION_SET): { owner->handleChangedDataset(sid); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE): { gp_id_t globPoolId = HousekeepingMessage::getUpdateNotificationVariableCommand(message); owner->handleChangedPoolVariable(globPoolId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (HousekeepingMessage::UPDATE_SNAPSHOT_SET): { store_address_t storeId; @@ -551,7 +551,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me if (clearMessage) { message->clear(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE): { store_address_t storeId; @@ -561,7 +561,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me if (clearMessage) { message->clear(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } default: @@ -569,7 +569,7 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me } CommandMessage reply; - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { HousekeepingMessage::setHkRequestFailureReply(&reply, sid, result); } else { HousekeepingMessage::setHkRequestSuccessReply(&reply, sid); @@ -586,7 +586,7 @@ ReturnValue_t LocalDataPoolManager::printPoolEntry(lp_id_t localPoolId) { return localpool::POOL_ENTRY_NOT_FOUND; } poolIter->second->print(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MutexIF* LocalDataPoolManager::getMutexHandle() { return mutex; } @@ -609,7 +609,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, size_t serializedSize = 0; ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, storeId, forDownlink, &serializedSize); - if (result != HasReturnvaluesIF::RETURN_OK or serializedSize == 0) { + if (result != returnvalue::OK or serializedSize == 0) { return result; } @@ -647,7 +647,7 @@ ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore(HousekeepingPacke uint8_t* dataPtr = nullptr; const size_t maxSize = hkPacket.getSerializedSize(); ReturnValue_t result = ipcStore->getFreeElement(&storeId, maxSize, &dataPtr); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -687,7 +687,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { } ReturnValue_t result = generateHousekeepingPacket(sid, dataSet, true); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { /* Configuration error */ #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalDataPoolManager::performPeriodicHkOperation: HK generation failed." @@ -718,7 +718,7 @@ ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid, bool ena } LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enable); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, float newCollectionInterval, @@ -744,7 +744,7 @@ ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, float ne } periodicHelper->changeCollectionInterval(newCollectionInterval); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool isDiagnostics) { @@ -772,24 +772,22 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i uint8_t* storePtr = nullptr; store_address_t storeId; ReturnValue_t result = ipcStore->getFreeElement(&storeId, expectedSize, &storePtr); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { printWarningOrError(sif::OutputTypes::OUT_ERROR, "generateSetStructurePacket", - HasReturnvaluesIF::RETURN_FAILED, - "Could not get free element from IPC store."); + returnvalue::FAILED, "Could not get free element from IPC store."); return result; } // Serialize set packet into store. size_t size = 0; result = setPacket.serialize(&storePtr, &size, expectedSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeId); return result; } if (expectedSize != size) { printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateSetStructurePacket", - HasReturnvaluesIF::RETURN_FAILED, - "Expected size is not equal to serialized size"); + returnvalue::FAILED, "Expected size is not equal to serialized size"); } // Send structure reporting reply. @@ -801,7 +799,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i } result = hkQueue->reply(&reply); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ipcStore->deleteData(storeId); } return result; @@ -827,7 +825,7 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, errorPrint = "Dataset not found"; } else if (error == POOLOBJECT_NOT_FOUND) { errorPrint = "Pool Object not found"; - } else if (error == HasReturnvaluesIF::RETURN_FAILED) { + } else if (error == returnvalue::FAILED) { if (outputType == sif::OutputTypes::OUT_WARNING) { errorPrint = "Generic Warning"; } else { diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/datapoollocal/LocalDataPoolManager.h index 998ca03b..7db079f6 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.h @@ -361,7 +361,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces ReturnValue_t addUpdateToStore(HousekeepingSnapshot& updatePacket, store_address_t& storeId); void printWarningOrError(sif::OutputTypes outputType, const char* functionName, - ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED, + ReturnValue_t errorCode = returnvalue::FAILED, const char* errorPrint = nullptr); }; @@ -369,7 +369,7 @@ template inline ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, PoolEntry** poolEntry) { if (poolEntry == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } auto poolIter = localPoolMap.find(localPoolId); @@ -385,7 +385,7 @@ inline ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, localpool::POOL_ENTRY_TYPE_CONFLICT); return localpool::POOL_ENTRY_TYPE_CONFLICT; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } #endif /* FSFW_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ */ diff --git a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp index 62fdb184..38aad828 100644 --- a/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolDataSetBase.cpp @@ -85,13 +85,13 @@ ReturnValue_t LocalPoolDataSetBase::lockDataPool(MutexIF::TimeoutType timeoutTyp if (mutexIfSingleDataCreator != nullptr) { return mutexIfSingleDataCreator->lockMutex(timeoutType, timeoutMs); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer( uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; const uint8_t validityMaskSize = std::ceil(static_cast(fillCount) / 8.0); uint8_t *validityPtr = nullptr; #if defined(_MSC_VER) || defined(__clang__) @@ -119,7 +119,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer( } result = registeredVariables[count]->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -135,10 +135,10 @@ ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer( ReturnValue_t LocalPoolDataSetBase::deSerializeWithValidityBuffer( const uint8_t **buffer, size_t *size, SerializeIF::Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (uint16_t count = 0; count < fillCount; count++) { result = registeredVariables[count]->deSerialize(buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -169,7 +169,7 @@ ReturnValue_t LocalPoolDataSetBase::unlockDataPool() { if (mutexIfSingleDataCreator != nullptr) { return mutexIfSingleDataCreator->unlockMutex(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size_t *size, @@ -185,7 +185,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size lp_id_t currentPoolId = registeredVariables[count]->getDataPoolId(); auto result = SerializeAdapter::serialize(¤tPoolId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: " << "Serialization error!" << std::endl; @@ -197,7 +197,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size return result; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint8_t LocalPoolDataSetBase::getLocalPoolIdsSerializedSize(bool serializeFillCount) const { diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.h b/src/fsfw/datapoollocal/LocalPoolObjectBase.h index b2ffa4c1..f454fea3 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.h +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.h @@ -15,7 +15,7 @@ class HasLocalDataPoolIF; * @brief This class serves as a non-template base for pool objects like pool variables * or pool vectors. */ -class LocalPoolObjectBase : public PoolVariableIF, public HasReturnvaluesIF, public MarkChangedIF { +class LocalPoolObjectBase : public PoolVariableIF, public MarkChangedIF { public: LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet, pool_rwm_t setReadWriteMode); diff --git a/src/fsfw/datapoollocal/LocalPoolVariable.tpp b/src/fsfw/datapoollocal/LocalPoolVariable.tpp index f800dfd3..969a047b 100644 --- a/src/fsfw/datapoollocal/LocalPoolVariable.tpp +++ b/src/fsfw/datapoollocal/LocalPoolVariable.tpp @@ -29,7 +29,7 @@ inline ReturnValue_t LocalPoolVariable::read(MutexIF::TimeoutType timeoutType } MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager); ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = readWithoutLock(); @@ -49,7 +49,7 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { object_id_t ownerObjectId = hkManager->getCreatorObjectId(); reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId); return result; @@ -57,7 +57,7 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { this->value = *(poolEntry->getDataPtr()); this->valid = poolEntry->getValid(); - return RETURN_OK; + return returnvalue::OK; } template @@ -75,7 +75,7 @@ inline ReturnValue_t LocalPoolVariable::commit(MutexIF::TimeoutType timeoutTy } MutexIF* mutex = LocalDpManagerAttorney::getMutexHandle(*hkManager); ReturnValue_t result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = commitWithoutLock(); @@ -95,7 +95,7 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { object_id_t ownerObjectId = hkManager->getCreatorObjectId(); reportReadCommitError("LocalPoolVariable", result, false, ownerObjectId, localPoolId); return result; @@ -103,7 +103,7 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { *(poolEntry->getDataPtr()) = this->value; poolEntry->setValid(this->valid); - return RETURN_OK; + return returnvalue::OK; } template diff --git a/src/fsfw/datapoollocal/LocalPoolVector.tpp b/src/fsfw/datapoollocal/LocalPoolVector.tpp index a2c2b752..939405a9 100644 --- a/src/fsfw/datapoollocal/LocalPoolVector.tpp +++ b/src/fsfw/datapoollocal/LocalPoolVector.tpp @@ -43,14 +43,14 @@ inline ReturnValue_t LocalPoolVector::readWithoutLock() { LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); memset(this->value, 0, vectorSize * sizeof(T)); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { object_id_t targetObjectId = hkManager->getCreatorObjectId(); reportReadCommitError("LocalPoolVector", result, true, targetObjectId, localPoolId); return result; } std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize()); this->valid = poolEntry->getValid(); - return RETURN_OK; + return returnvalue::OK; } template @@ -79,14 +79,14 @@ inline ReturnValue_t LocalPoolVector::commitWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = LocalDpManagerAttorney::fetchPoolEntry(*hkManager, localPoolId, &poolEntry); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { object_id_t targetObjectId = hkManager->getCreatorObjectId(); reportReadCommitError("LocalPoolVector", result, false, targetObjectId, localPoolId); return result; } std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize()); poolEntry->setValid(this->valid); - return RETURN_OK; + return returnvalue::OK; } template @@ -131,10 +131,10 @@ template inline ReturnValue_t LocalPoolVector::serialize( uint8_t** buffer, size_t* size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (uint16_t i = 0; i < vectorSize; i++) { result = SerializeAdapter::serialize(&(value[i]), buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { break; } } @@ -149,10 +149,10 @@ inline size_t LocalPoolVector::getSerializedSize() const { template inline ReturnValue_t LocalPoolVector::deSerialize( const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (uint16_t i = 0; i < vectorSize; i++) { result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { break; } } diff --git a/src/fsfw/datapoollocal/SharedLocalDataSet.cpp b/src/fsfw/datapoollocal/SharedLocalDataSet.cpp index 248c1577..6d0b0b11 100644 --- a/src/fsfw/datapoollocal/SharedLocalDataSet.cpp +++ b/src/fsfw/datapoollocal/SharedLocalDataSet.cpp @@ -20,7 +20,7 @@ ReturnValue_t SharedLocalDataSet::lockDataset(MutexIF::TimeoutType timeoutType, if (datasetLock != nullptr) { return datasetLock->lockMutex(timeoutType, mutexTimeout); } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } SharedLocalDataSet::~SharedLocalDataSet() { MutexFactory::instance()->deleteMutex(datasetLock); } @@ -29,5 +29,5 @@ ReturnValue_t SharedLocalDataSet::unlockDataset() { if (datasetLock != nullptr) { return datasetLock->unlockMutex(); } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } diff --git a/src/fsfw/devicehandlers/AssemblyBase.cpp b/src/fsfw/devicehandlers/AssemblyBase.cpp index c29022e5..63178ab9 100644 --- a/src/fsfw/devicehandlers/AssemblyBase.cpp +++ b/src/fsfw/devicehandlers/AssemblyBase.cpp @@ -50,7 +50,7 @@ bool AssemblyBase::isInTransition() { bool AssemblyBase::handleChildrenChanged() { if (childrenChangedMode) { ReturnValue_t result = checkChildrenState(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { handleChildrenLostMode(result); } return true; @@ -116,7 +116,7 @@ void AssemblyBase::handleChildrenTransition() { break; } ReturnValue_t result = checkChildrenState(); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { handleModeReached(); } else { handleModeTransitionFailed(result); @@ -149,7 +149,7 @@ void AssemblyBase::handleModeTransitionFailed(ReturnValue_t result) { void AssemblyBase::sendHealthCommand(MessageQueueId_t sendTo, HealthState health) { CommandMessage command; HealthMessage::setHealthMessage(&command, HealthMessage::HEALTH_SET, health); - if (commandQueue->sendMessage(sendTo, &command) == RETURN_OK) { + if (commandQueue->sendMessage(sendTo, &command) == returnvalue::OK) { commandsOutstanding++; } } @@ -164,25 +164,25 @@ ReturnValue_t AssemblyBase::checkChildrenState() { ReturnValue_t AssemblyBase::checkChildrenStateOff() { for (const auto& childIter : childrenMap) { - if (checkChildOff(childIter.first) != RETURN_OK) { + if (checkChildOff(childIter.first) != returnvalue::OK) { return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE; } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t AssemblyBase::checkChildOff(uint32_t objectId) { ChildInfo childInfo = childrenMap.find(objectId)->second; if (healthHelper.healthTable->isCommandable(objectId)) { if (childInfo.submode != SUBMODE_NONE) { - return RETURN_FAILED; + return returnvalue::FAILED; } else { if ((childInfo.mode != MODE_OFF) && (childInfo.mode != DeviceHandlerIF::MODE_ERROR_ON)) { - return RETURN_FAILED; + return returnvalue::FAILED; } } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t AssemblyBase::checkModeCommand(Mode_t mode, Submode_t submode, @@ -192,7 +192,7 @@ ReturnValue_t AssemblyBase::checkModeCommand(Mode_t mode, Submode_t submode, if (submode != SUBMODE_NONE) { return INVALID_SUBMODE; } - return RETURN_OK; + return returnvalue::OK; } if ((mode != MODE_ON) && (mode != DeviceHandlerIF::MODE_NORMAL)) { @@ -212,7 +212,7 @@ ReturnValue_t AssemblyBase::handleHealthReply(CommandMessage* message) { if (health != EXTERNAL_CONTROL) { updateChildChangedHealth(message->getSender(), true); } - return RETURN_OK; + return returnvalue::OK; } if (message->getCommand() == HealthMessage::REPLY_HEALTH_SET || (message->getCommand() == CommandMessage::REPLY_REJECTED && @@ -220,9 +220,9 @@ ReturnValue_t AssemblyBase::handleHealthReply(CommandMessage* message) { if (isInTransition()) { commandsOutstanding--; } - return RETURN_OK; + return returnvalue::OK; } - return RETURN_FAILED; + return returnvalue::FAILED; } bool AssemblyBase::checkAndHandleRecovery() { diff --git a/src/fsfw/devicehandlers/AssemblyBase.h b/src/fsfw/devicehandlers/AssemblyBase.h index 3e235928..92feb6ae 100644 --- a/src/fsfw/devicehandlers/AssemblyBase.h +++ b/src/fsfw/devicehandlers/AssemblyBase.h @@ -79,7 +79,7 @@ class AssemblyBase : public SubsystemBase { * @param submode The targeted submmode * @return Any information why this combination is invalid from HasModesIF * like HasModesIF::INVALID_SUBMODE. - * On success return HasReturnvaluesIF::RETURN_OK + * On success return returnvalue::OK */ virtual ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) = 0; diff --git a/src/fsfw/devicehandlers/ChildHandlerBase.cpp b/src/fsfw/devicehandlers/ChildHandlerBase.cpp index be4f4798..ecd4cfc8 100644 --- a/src/fsfw/devicehandlers/ChildHandlerBase.cpp +++ b/src/fsfw/devicehandlers/ChildHandlerBase.cpp @@ -19,7 +19,7 @@ ChildHandlerBase::~ChildHandlerBase() {} ReturnValue_t ChildHandlerBase::initialize() { ReturnValue_t result = DeviceHandlerBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -28,7 +28,7 @@ ReturnValue_t ChildHandlerBase::initialize() { if (parentId != objects::NO_OBJECT) { SubsystemBase* parent = ObjectManager::instance()->get(parentId); if (parent == NULL) { - return RETURN_FAILED; + return returnvalue::FAILED; } parentQueue = parent->getCommandQueue(); @@ -39,5 +39,5 @@ ReturnValue_t ChildHandlerBase::initialize() { modeHelper.setParentQueue(parentQueue); - return RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/devicehandlers/DeviceCommunicationIF.h b/src/fsfw/devicehandlers/DeviceCommunicationIF.h index 7a860411..5af3f3f0 100644 --- a/src/fsfw/devicehandlers/DeviceCommunicationIF.h +++ b/src/fsfw/devicehandlers/DeviceCommunicationIF.h @@ -34,7 +34,7 @@ * @ingroup interfaces * @ingroup comm */ -class DeviceCommunicationIF : public HasReturnvaluesIF { +class DeviceCommunicationIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_COMMUNICATION_IF; diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index cf457a03..525a3dcc 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -32,7 +32,7 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device parameterHelper(this), actionHelper(this, nullptr), poolManager(this, nullptr), - childTransitionFailure(RETURN_OK), + childTransitionFailure(returnvalue::OK), fdirInstance(fdirInstance), defaultFDIRUsed(fdirInstance == nullptr), switchOffWasReported(false), @@ -45,8 +45,8 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device cookieInfo.state = COOKIE_UNUSED; cookieInfo.pendingCommand = deviceCommandMap.end(); if (comCookie == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "DeviceHandlerBase", - HasReturnvaluesIF::RETURN_FAILED, "Invalid cookie"); + printWarningOrError(sif::OutputTypes::OUT_ERROR, "DeviceHandlerBase", returnvalue::FAILED, + "Invalid cookie"); } if (this->fdirInstance == nullptr) { this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId, defaultFdirParentId); @@ -79,7 +79,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { this->lastStep = this->pstStep; if (getComAction() == CommunicationAction::NOTHING) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } if (getComAction() == CommunicationAction::PERFORM_OPERATION) { @@ -90,11 +90,11 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { decrementDeviceReplyMap(); fdirInstance->checkForFailures(); performOperationHook(); - return RETURN_OK; + return returnvalue::OK; } if (mode == MODE_OFF) { - return RETURN_OK; + return returnvalue::OK; } switch (getComAction()) { @@ -120,12 +120,12 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { default: break; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DeviceHandlerBase::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -138,7 +138,7 @@ ReturnValue_t DeviceHandlerBase::initialize() { } result = communicationInterface->initializeInterface(comCookie); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize", ObjectManagerIF::CHILD_INIT_FAILED, "ComIF initialization failed"); return result; @@ -192,30 +192,30 @@ ReturnValue_t DeviceHandlerBase::initialize() { } result = healthHelper.initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = modeHelper.initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = actionHelper.initialize(commandQueue); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = fdirInstance->initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = parameterHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = poolManager.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -224,14 +224,14 @@ ReturnValue_t DeviceHandlerBase::initialize() { if (thermalSet != nullptr) { // Set temperature target state to NON_OP. result = thermalSet->read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; thermalSet->heaterRequest.setValid(true); thermalSet->commit(); } } - return RETURN_OK; + return returnvalue::OK; } void DeviceHandlerBase::decrementDeviceReplyMap() { @@ -265,42 +265,42 @@ void DeviceHandlerBase::readCommandQueue() { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return; } result = healthHelper.handleHealthCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = modeHelper.handleModeCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = actionHelper.handleActionMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = parameterHelper.handleParameterMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = poolManager.handleHousekeepingMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = handleDeviceHandlerMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } result = letChildHandleMessage(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return; } @@ -328,7 +328,7 @@ void DeviceHandlerBase::doStateMachine() { sprintf(printout, "Transition timeout (%lu) occured !", static_cast(childTransitionDelay)); /* Common configuration error for development, so print it */ - printWarningOrError(sif::OutputTypes::OUT_WARNING, "doStateMachine", RETURN_FAILED, + printWarningOrError(sif::OutputTypes::OUT_WARNING, "doStateMachine", returnvalue::FAILED, printout); #endif triggerEvent(MODE_TRANSITION_FAILED, childTransitionFailure, 0); @@ -407,7 +407,7 @@ ReturnValue_t DeviceHandlerBase::isModeCombinationValid(Mode_t mode, Submode_t s case MODE_NORMAL: case MODE_RAW: if (submode == SUBMODE_NONE) { - return RETURN_OK; + return returnvalue::OK; } else { return INVALID_SUBMODE; } @@ -444,9 +444,9 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, info.countdown = countdown; auto resultPair = deviceReplyMap.emplace(replyId, info); if (resultPair.second) { - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } @@ -461,9 +461,9 @@ ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceComm info.alternativeReplyId = alternativeReplyId; auto resultPair = deviceCommandMap.emplace(deviceCommand, info); if (resultPair.second) { - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } @@ -499,7 +499,7 @@ ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceRep } info->delayCycles = delayCycles; info->periodic = periodic; - return RETURN_OK; + return returnvalue::OK; } } @@ -529,17 +529,17 @@ ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandI } } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t DeviceHandlerBase::setReplyDataset(DeviceCommandId_t replyId, LocalPoolDataSetBase* dataSet) { auto replyIter = deviceReplyMap.find(replyId); if (replyIter == deviceReplyMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } replyIter->second.dataSet = dataSet; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void DeviceHandlerBase::callChildStatemachine() { @@ -578,7 +578,7 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) { if (mode == MODE_OFF and thermalSet != nullptr) { ReturnValue_t result = thermalSet->read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { if (thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) { thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; } @@ -593,7 +593,7 @@ void DeviceHandlerBase::setMode(Mode_t newMode) { setMode(newMode, submode); } void DeviceHandlerBase::replyReturnvalueToCommand(ReturnValue_t status, uint32_t parameter) { // This is actually the reply protocol for raw and misc DH commands. - if (status == RETURN_OK) { + if (status == returnvalue::OK) { CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, parameter); commandQueue->reply(&reply); } else { @@ -606,7 +606,7 @@ void DeviceHandlerBase::replyToCommand(ReturnValue_t status, uint32_t parameter) // Check if we reply to a raw command. if (cookieInfo.pendingCommand->first == RAW_COMMAND_ID) { if (status == NO_REPLY_EXPECTED) { - status = RETURN_OK; + status = returnvalue::OK; } replyReturnvalueToCommand(status, parameter); // Always delete data from a raw command. @@ -617,7 +617,7 @@ void DeviceHandlerBase::replyToCommand(ReturnValue_t status, uint32_t parameter) if (cookieInfo.pendingCommand->second.sendReplyTo != NO_COMMANDER) { MessageQueueId_t queueId = cookieInfo.pendingCommand->second.sendReplyTo; if (status == NO_REPLY_EXPECTED) { - actionHelper.finish(true, queueId, cookieInfo.pendingCommand->first, RETURN_OK); + actionHelper.finish(true, queueId, cookieInfo.pendingCommand->first, returnvalue::OK); } else { actionHelper.step(1, queueId, cookieInfo.pendingCommand->first, status); } @@ -634,8 +634,8 @@ void DeviceHandlerBase::replyToReply(const DeviceCommandId_t command, DeviceRepl } DeviceCommandInfo* info = &replyInfo.command->second; if (info == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "replyToReply", - HasReturnvaluesIF::RETURN_FAILED, "Command pointer not found"); + printWarningOrError(sif::OutputTypes::OUT_ERROR, "replyToReply", returnvalue::FAILED, + "Command pointer not found"); return; } @@ -649,7 +649,7 @@ void DeviceHandlerBase::replyToReply(const DeviceCommandId_t command, DeviceRepl // Don't send any replies in that case. if (info->sendReplyTo != NO_COMMANDER) { bool success = false; - if (status == HasReturnvaluesIF::RETURN_OK) { + if (status == returnvalue::OK) { success = true; } actionHelper.finish(success, info->sendReplyTo, command, status); @@ -662,7 +662,7 @@ void DeviceHandlerBase::doSendWrite() { if (cookieInfo.state == COOKIE_WRITE_READY) { ReturnValue_t result = communicationInterface->sendMessage(comCookie, rawPacket, rawPacketLen); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { cookieInfo.state = COOKIE_WRITE_SENT; } else { // always generate a failure event, so that FDIR knows what's up @@ -680,7 +680,7 @@ void DeviceHandlerBase::doGetWrite() { } cookieInfo.state = COOKIE_UNUSED; ReturnValue_t result = communicationInterface->getSendSuccess(comCookie); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { if (wiretappingMode == RAW) { replyRawData(rawPacket, rawPacketLen, requestedRawTraffic, true); } @@ -694,7 +694,7 @@ void DeviceHandlerBase::doGetWrite() { // always generate a failure event, so that FDIR knows what's up triggerEvent(DEVICE_SENDING_COMMAND_FAILED, result, cookieInfo.pendingCommand->first); } - if (result != RETURN_OK) { + if (result != returnvalue::OK) { cookieInfo.pendingCommand->second.isExecuting = false; } replyToCommand(result); @@ -704,7 +704,7 @@ void DeviceHandlerBase::doSendRead() { ReturnValue_t result; result = doSendReadHook(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return; } @@ -715,7 +715,7 @@ void DeviceHandlerBase::doSendRead() { result = communicationInterface->requestReceiveMessage(comCookie, replyLen); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { cookieInfo.state = COOKIE_READ_SENT; } else { triggerEvent(DEVICE_REQUESTING_REPLY_FAILED, result); @@ -741,7 +741,7 @@ void DeviceHandlerBase::doGetRead() { ReturnValue_t result = communicationInterface->readReceivedMessage(comCookie, &receivedData, &receivedDataLen); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { triggerEvent(DEVICE_REQUESTING_REPLY_FAILED, result); // I think we can allow to ignore one missedReply. ignoreMissedRepliesCount++; @@ -764,7 +764,7 @@ void DeviceHandlerBase::doGetRead() { } void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedDataLen) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; DeviceCommandId_t foundId = DeviceHandlerIF::NO_COMMAND_ID; size_t foundLen = 0; /* The loop may not execute more often than the number of received bytes @@ -773,7 +773,7 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedD for (uint32_t count = 0; count < receivedDataLen; count++) { result = scanForReply(receivedData, remainingLength, &foundId, &foundLen); switch (result) { - case RETURN_OK: + case returnvalue::OK: handleReply(receivedData, foundId, foundLen); if (foundLen == 0) { printWarningOrError(sif::OutputTypes::OUT_WARNING, "parseReply", @@ -783,7 +783,7 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedD break; case APERIODIC_REPLY: { result = interpretDeviceReply(foundId, receivedData); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { replyRawReplyIfnotWiretapped(receivedData, foundLen); triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result, foundId); } @@ -846,7 +846,7 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, DeviceCommandId resetDelayCyclesControlledReply(info); } - if (result != RETURN_OK) { + if (result != returnvalue::OK) { // Report failed interpretation to FDIR. replyRawReplyIfnotWiretapped(receivedData, foundLen); triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result, foundId); @@ -887,12 +887,12 @@ ReturnValue_t DeviceHandlerBase::getStorageData(store_address_t storageAddress, if (IPCStore == nullptr) { *data = nullptr; *len = 0; - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t result = IPCStore->modifyData(storageAddress, data, &lenTmp); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { *len = lenTmp; - return RETURN_OK; + return returnvalue::OK; } else { triggerEvent(StorageManagerIF::GET_DATA_FAILED, result, storageAddress.raw); *data = nullptr; @@ -909,7 +909,7 @@ void DeviceHandlerBase::replyRawData(const uint8_t* data, size_t len, MessageQue store_address_t address; ReturnValue_t result = IPCStore->addData(&address, data, len); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { triggerEvent(StorageManagerIF::STORE_DATA_FAILED, result); return; } @@ -921,7 +921,7 @@ void DeviceHandlerBase::replyRawData(const uint8_t* data, size_t len, MessageQue result = commandQueue->sendMessage(sendTo, &command); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { IPCStore->deleteData(address); // Silently discard data, this indicates heavy TM traffic which // should not be increased by additional events. @@ -957,7 +957,7 @@ MessageQueueId_t DeviceHandlerBase::getCommandQueue() const { return commandQueu void DeviceHandlerBase::buildRawDeviceCommand(CommandMessage* commandMessage) { storedRawData = DeviceHandlerMessage::getStoreAddress(commandMessage); ReturnValue_t result = getStorageData(storedRawData, &rawPacket, &rawPacketLen); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { replyReturnvalueToCommand(result, RAW_COMMAND_ID); storedRawData.raw = StorageManagerIF::INVALID_ADDRESS; } else { @@ -974,7 +974,7 @@ void DeviceHandlerBase::commandSwitch(ReturnValue_t onOff) { const uint8_t* switches; uint8_t numberOfSwitches = 0; ReturnValue_t result = getSwitches(&switches, &numberOfSwitches); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { while (numberOfSwitches > 0) { powerSwitcher->sendSwitchCommand(switches[numberOfSwitches - 1], onOff); numberOfSwitches--; @@ -982,7 +982,7 @@ void DeviceHandlerBase::commandSwitch(ReturnValue_t onOff) { } } -ReturnValue_t DeviceHandlerBase::doSendReadHook() { return RETURN_OK; } +ReturnValue_t DeviceHandlerBase::doSendReadHook() { return returnvalue::OK; } ReturnValue_t DeviceHandlerBase::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { return DeviceHandlerBase::NO_SWITCH; @@ -1011,7 +1011,7 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(DeviceCommandMap::iterato info->countdown->resetTimer(); } info->active = true; - return RETURN_OK; + return returnvalue::OK; } else { return NO_REPLY_EXPECTED; } @@ -1029,7 +1029,7 @@ ReturnValue_t DeviceHandlerBase::getStateOfSwitches(void) { const uint8_t* switches; ReturnValue_t result = getSwitches(&switches, &numberOfSwitches); - if ((result == RETURN_OK) && (numberOfSwitches != 0)) { + if ((result == returnvalue::OK) && (numberOfSwitches != 0)) { while (numberOfSwitches > 0) { if (powerSwitcher->getSwitchState(switches[numberOfSwitches - 1]) == PowerSwitchIF::SWITCH_OFF) { @@ -1074,7 +1074,7 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode, Submode_ if ((commandedMode == MODE_ON) && (mode == MODE_OFF) and (thermalSet != nullptr)) { ReturnValue_t result = thermalSet->read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { if ((thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) and (not ThermalComponentIF::isOperational(thermalSet->thermalState.value))) { triggerEvent(ThermalComponentIF::TEMP_NOT_IN_OP_RANGE, thermalSet->thermalState.value); @@ -1134,7 +1134,7 @@ void DeviceHandlerBase::handleTransitionToOnMode(Mode_t commandedMode, Submode_t triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode); if (thermalSet != nullptr) { ReturnValue_t result = thermalSet->read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { if (thermalSet->heaterRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { thermalSet->heaterRequest = ThermalComponentIF::STATE_REQUEST_OPERATIONAL; thermalSet->commit(); @@ -1169,7 +1169,7 @@ HasHealthIF::HealthState DeviceHandlerBase::getHealth() { return healthHelper.ge ReturnValue_t DeviceHandlerBase::setHealth(HealthState health) { healthHelper.setHealth(health); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void DeviceHandlerBase::checkSwitchState() { @@ -1191,7 +1191,7 @@ ReturnValue_t DeviceHandlerBase::acceptExternalDeviceCommands() { if ((mode != MODE_ON) && (mode != MODE_NORMAL)) { return WRONG_MODE_FOR_COMMAND; } - return RETURN_OK; + return returnvalue::OK; } void DeviceHandlerBase::replyRawReplyIfnotWiretapped(const uint8_t* data, size_t len) { @@ -1220,10 +1220,10 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(CommandMessage* mess default: replyReturnvalueToCommand(INVALID_COMMAND_PARAMETER); wiretappingMode = OFF; - return RETURN_OK; + return returnvalue::OK; } - replyReturnvalueToCommand(RETURN_OK); - return RETURN_OK; + replyReturnvalueToCommand(returnvalue::OK); + return returnvalue::OK; case DeviceHandlerMessage::CMD_RAW: if ((mode != MODE_RAW)) { DeviceHandlerMessage::clear(message); @@ -1231,9 +1231,9 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(CommandMessage* mess } else { buildRawDeviceCommand(message); } - return RETURN_OK; + return returnvalue::OK; default: - return RETURN_FAILED; + return returnvalue::FAILED; } } @@ -1254,7 +1254,7 @@ bool DeviceHandlerBase::isAwaitingReply() { } ReturnValue_t DeviceHandlerBase::letChildHandleMessage(CommandMessage* message) { - return RETURN_FAILED; + return returnvalue::FAILED; } void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t replyId, @@ -1316,7 +1316,7 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t r ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { ReturnValue_t result = acceptExternalDeviceCommands(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } DeviceCommandMap::iterator iter = deviceCommandMap.find(actionId); @@ -1327,7 +1327,7 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueue } else { result = buildCommandFromCommand(actionId, data, size); } - if (result == RETURN_OK) { + if (result == returnvalue::OK) { iter->second.sendReplyTo = commandedBy; iter->second.isExecuting = true; cookieInfo.pendingCommand = iter; @@ -1345,7 +1345,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { if (result == BUSY) { /* So we can track misconfigurations */ printWarningOrError(sif::OutputTypes::OUT_WARNING, "buildInternalCommand", - HasReturnvaluesIF::RETURN_FAILED, "Busy."); + returnvalue::FAILED, "Busy."); /* No need to report this */ result = NOTHING_TO_SEND; } @@ -1361,7 +1361,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { if (result == NOTHING_TO_SEND) { return; } - if (result == RETURN_OK) { + if (result == returnvalue::OK) { DeviceCommandMap::iterator iter = deviceCommandMap.find(deviceCommandId); if (iter == deviceCommandMap.end()) { #if FSFW_VERBOSE_LEVEL >= 1 @@ -1378,7 +1378,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { sprintf(output, "Command 0x%08x is executing", static_cast(deviceCommandId)); // so we can track misconfigurations printWarningOrError(sif::OutputTypes::OUT_WARNING, "buildInternalCommand", - HasReturnvaluesIF::RETURN_FAILED, output); + returnvalue::FAILED, output); #endif // this is an internal command, no need to report a failure here, // missed reply will track if a reply is too late, otherwise, it's ok @@ -1390,7 +1390,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { cookieInfo.state = COOKIE_WRITE_READY; } } - if (result != RETURN_OK) { + if (result != returnvalue::OK) { triggerEvent(DEVICE_BUILDING_COMMAND_FAILED, result, deviceCommandId); } } @@ -1466,7 +1466,7 @@ ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(localpool::DataPool& lo localDataPoolMap.emplace(thermalSet->heaterRequestPoolId, new PoolEntry); } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() { @@ -1480,7 +1480,7 @@ ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() { if (setStartupImmediately) { startTransition(MODE_ON, SUBMODE_NONE); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } LocalPoolDataSetBase* DeviceHandlerBase::getDataSetHandle(sid_t sid) { @@ -1518,7 +1518,7 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const ch if (errorPrint == nullptr) { if (errorCode == ObjectManagerIF::CHILD_INIT_FAILED) { errorPrint = "Initialization error"; - } else if (errorCode == HasReturnvaluesIF::RETURN_FAILED) { + } else if (errorCode == returnvalue::FAILED) { if (errorType == sif::OutputTypes::OUT_WARNING) { errorPrint = "Generic Warning"; } else { diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index e29e6596..35a33eab 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -78,7 +78,6 @@ class StorageManagerIF; * @ingroup devices */ class DeviceHandlerBase : public DeviceHandlerIF, - public HasReturnvaluesIF, public ExecutableObjectIF, public SystemObject, public HasModesIF, @@ -359,7 +358,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * buffer is scanned at previous position + foundLen. * @return * - @c RETURN_OK a valid packet was found at @c start, @c foundLen is valid - * - @c RETURN_FAILED no reply could be found starting at @c start, + * - @c returnvalue::FAILED no reply could be found starting at @c start, * implies @c foundLen is not valid, base class will call scanForReply() * again with ++start * - @c DeviceHandlerIF::INVALID_DATA a packet was found but it is invalid, @@ -391,7 +390,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * - @c RETURN_OK when the reply was interpreted. * - @c IGNORE_REPLY_DATA Ignore the reply and don't reset reply cycle * counter. - * - @c RETURN_FAILED when the reply could not be interpreted, + * - @c returnvalue::FAILED when the reply could not be interpreted, * e.g. logical errors or range violations occurred */ virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) = 0; @@ -452,7 +451,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * to provide a pointer to a Countdown object which will signal the timeout * when expired * @return - @c RETURN_OK when the command was successfully inserted, - * - @c RETURN_FAILED else. + * - @c returnvalue::FAILED else. */ ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, LocalPoolDataSetBase *replyDataSet = nullptr, @@ -473,7 +472,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * to provide a pointer to a Countdown object which will signal the timeout * when expired * @return - @c RETURN_OK when the command was successfully inserted, - * - @c RETURN_FAILED else. + * - @c returnvalue::FAILED else. */ ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, LocalPoolDataSetBase *dataSet = nullptr, size_t replyLen = 0, @@ -483,7 +482,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @brief A simple command to add a command to the commandList. * @param deviceCommand The command to add * @return - @c RETURN_OK when the command was successfully inserted, - * - @c RETURN_FAILED else. + * - @c returnvalue::FAILED else. */ ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand, bool useAlternativeReply = false, @@ -520,7 +519,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * by the device repeatedly without request) or not. Default is aperiodic (0). * Warning: The setting always overrides the value that was entered in the map. * @return - @c RETURN_OK when the command was successfully inserted, - * - @c RETURN_FAILED else. + * - @c returnvalue::FAILED else. */ ReturnValue_t updateReplyMapEntry(DeviceCommandId_t deviceReply, uint16_t delayCycles, uint16_t maxDelayCycles, bool periodic = false); @@ -604,7 +603,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param submode * @return * - @c RETURN_OK if valid - * - @c RETURN_FAILED if invalid + * - @c returnvalue::FAILED if invalid */ virtual ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode); /** @@ -624,7 +623,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param[out] numberOfSwitches length of returned array * @return * - @c RETURN_OK if the parameters were set - * - @c RETURN_FAILED if no switches exist + * - @c returnvalue::FAILED if no switches exist */ virtual ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches); @@ -1033,7 +1032,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * by #switches are on * - @c PowerSwitchIF::SWITCH_OFF one of the switches specified by * #switches are off - * - @c PowerSwitchIF::RETURN_FAILED if an error occured + * - @c PowerSwitchIF::returnvalue::FAILED if an error occured */ ReturnValue_t getStateOfSwitches(); @@ -1275,7 +1274,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param[out] len * @return * - @c RETURN_OK @c data is valid - * - @c RETURN_FAILED IPCStore is nullptr + * - @c returnvalue::FAILED IPCStore is nullptr * - the return value from the IPCStore if it was not @c RETURN_OK */ ReturnValue_t getStorageData(store_address_t storageAddress, uint8_t **data, size_t *len); @@ -1306,7 +1305,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param errorPrint */ void printWarningOrError(sif::OutputTypes errorType, const char *functionName, - ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED, + ReturnValue_t errorCode = returnvalue::FAILED, const char *errorPrint = nullptr); }; diff --git a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp index 48783c20..a3ac9ff7 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -23,9 +23,9 @@ DeviceHandlerFailureIsolation::~DeviceHandlerFailureIsolation() {} ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event) { if (isFdirInActionOrAreWeFaulty(event)) { - return RETURN_OK; + return returnvalue::OK; } - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; switch (event->getEvent()) { case HasModesIF::MODE_TRANSITION_FAILED: case HasModesIF::OBJECT_IN_INVALID_MODE: @@ -48,7 +48,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event) // The two above should never be confirmed. case DeviceHandlerIF::DEVICE_MISSED_REPLY: result = sendConfirmationRequest(event); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { break; } // else @@ -72,7 +72,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event) case PowerSwitchIF::SWITCH_WENT_OFF: if (powerConfirmation != MessageQueueIF::NO_QUEUE) { result = sendConfirmationRequest(event, powerConfirmation); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { setFdirState(DEVICE_MIGHT_BE_OFF); } } @@ -106,9 +106,9 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event) // break; default: // We don't know the event, someone else should handle it. - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } void DeviceHandlerFailureIsolation::eventConfirmed(EventMessage* event) { @@ -162,7 +162,7 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() { ReturnValue_t DeviceHandlerFailureIsolation::initialize() { ReturnValue_t result = FailureIsolationBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerFailureIsolation::initialize: Could not" " initialize FailureIsolationBase." @@ -176,7 +176,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::initialize() { powerConfirmation = power->getEventReceptionQueue(); } - return RETURN_OK; + return returnvalue::OK; } void DeviceHandlerFailureIsolation::setFdirState(FDIRState state) { diff --git a/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp b/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp index 3da431dc..dc987e6d 100644 --- a/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp +++ b/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp @@ -12,11 +12,11 @@ ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&objectId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&actionId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return data->serialize(buffer, size, maxSize, streamEndianness); @@ -29,11 +29,11 @@ size_t DeviceTmReportingWrapper::getSerializedSize() const { ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&objectId, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&actionId, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return data->deSerialize(buffer, size, streamEndianness); diff --git a/src/fsfw/devicehandlers/HealthDevice.cpp b/src/fsfw/devicehandlers/HealthDevice.cpp index a626fa6c..4c09964a 100644 --- a/src/fsfw/devicehandlers/HealthDevice.cpp +++ b/src/fsfw/devicehandlers/HealthDevice.cpp @@ -16,7 +16,7 @@ HealthDevice::~HealthDevice() { QueueFactory::instance()->deleteMessageQueue(com ReturnValue_t HealthDevice::performOperation(uint8_t opCode) { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { result = healthHelper.handleHealthCommand(&command); } return result; @@ -24,7 +24,7 @@ ReturnValue_t HealthDevice::performOperation(uint8_t opCode) { ReturnValue_t HealthDevice::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (parentQueue != 0) { @@ -50,7 +50,7 @@ bool HealthDevice::hasHealthChanged() { ReturnValue_t HealthDevice::setHealth(HealthState health) { healthHelper.setHealth(health); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } HasHealthIF::HealthState HealthDevice::getHealth() { return healthHelper.getHealth(); } diff --git a/src/fsfw/events/EventManager.cpp b/src/fsfw/events/EventManager.cpp index 47270d2a..f4466817 100644 --- a/src/fsfw/events/EventManager.cpp +++ b/src/fsfw/events/EventManager.cpp @@ -30,18 +30,18 @@ EventManager::~EventManager() { MessageQueueId_t EventManager::getEventReportQueue() { return eventReportQueue->getId(); } ReturnValue_t EventManager::performOperation(uint8_t opCode) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while (result == HasReturnvaluesIF::RETURN_OK) { + ReturnValue_t result = returnvalue::OK; + while (result == returnvalue::OK) { EventMessage message; result = eventReportQueue->receiveMessage(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { #if FSFW_OBJ_EVENT_TRANSLATION == 1 printEvent(&message); #endif notifyListeners(&message); } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void EventManager::notifyListeners(EventMessage* message) { @@ -59,9 +59,9 @@ ReturnValue_t EventManager::registerListener(MessageQueueId_t listener, auto result = listenerList.insert(std::pair( listener, EventMatchTree(&factoryBackend, forwardAllButSelected))); if (!result.second) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t EventManager::subscribeToEvent(MessageQueueId_t listener, EventId_t event) { diff --git a/src/fsfw/events/eventmatching/EventMatchTree.cpp b/src/fsfw/events/eventmatching/EventMatchTree.cpp index b564e305..cd3da6a2 100644 --- a/src/fsfw/events/eventmatching/EventMatchTree.cpp +++ b/src/fsfw/events/eventmatching/EventMatchTree.cpp @@ -31,12 +31,12 @@ ReturnValue_t EventMatchTree::addMatch(EventId_t idFrom, EventId_t idTo, bool id iterator lastTest; ReturnValue_t result = findOrInsertRangeMatcher( begin(), idFrom, idTo, idInverted, &lastTest); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (reporterFrom == 0) { // No need to add another AND branch - return RETURN_OK; + return returnvalue::OK; } if (reporterTo == 0) { reporterTo = reporterFrom; @@ -95,7 +95,7 @@ inline ReturnValue_t EventMatchTree::findOrInsertRangeMatcher(iterator start, VA if ((matcher->rangeMatcher.lowerBound == idFrom) && (matcher->rangeMatcher.upperBound == idTo) && (matcher->rangeMatcher.inverted == inverted)) { - return RETURN_OK; + return returnvalue::OK; } else { iter = iter.right(); } @@ -115,9 +115,9 @@ inline ReturnValue_t EventMatchTree::findOrInsertRangeMatcher(iterator start, VA *lastTest = insert(attachToBranch, *lastTest, newNode); if (*lastTest == end()) { // This actaully never fails, so creating a dedicated returncode seems an overshoot. - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } template diff --git a/src/fsfw/events/eventmatching/EventMatchTree.h b/src/fsfw/events/eventmatching/EventMatchTree.h index 010e0623..7561e27d 100644 --- a/src/fsfw/events/eventmatching/EventMatchTree.h +++ b/src/fsfw/events/eventmatching/EventMatchTree.h @@ -7,7 +7,7 @@ #include "../../returnvalues/HasReturnvaluesIF.h" class StorageManagerIF; -class EventMatchTree : public MatchTree, public HasReturnvaluesIF { +class EventMatchTree : public MatchTree { public: EventMatchTree(StorageManagerIF* storageBackend, bool invertedMatch); virtual ~EventMatchTree(); diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index 3e6d5dcf..28df16d8 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -35,15 +35,15 @@ ReturnValue_t FailureIsolationBase::initialize() { " been initialized!" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t result = manager->registerListener(eventQueue->getId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (ownerId != objects::NO_OBJECT) { result = manager->subscribeToAllEventsFrom(eventQueue->getId(), ownerId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } owner = ObjectManager::instance()->get(ownerId); @@ -68,16 +68,16 @@ ReturnValue_t FailureIsolationBase::initialize() { sif::error << "Make sure it implements ConfirmsFailuresIF." << std::endl; #endif return ObjectManagerIF::CHILD_INIT_FAILED; - return RETURN_FAILED; + return returnvalue::FAILED; } eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue()); } - return RETURN_OK; + return returnvalue::OK; } void FailureIsolationBase::checkForFailures() { EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK; result = eventQueue->receiveMessage(&event)) { if (event.getSender() == eventQueue->getId()) { // We already got this event, because we sent it. @@ -124,7 +124,7 @@ ReturnValue_t FailureIsolationBase::sendConfirmationRequest(EventMessage* event, } else if (faultTreeParent != objects::NO_OBJECT) { return eventQueue->sendToDefault(event); } - return RETURN_FAILED; + return returnvalue::FAILED; } void FailureIsolationBase::eventConfirmed(EventMessage* event) {} diff --git a/src/fsfw/fdir/FailureIsolationBase.h b/src/fsfw/fdir/FailureIsolationBase.h index 85d18add..f7e2df26 100644 --- a/src/fsfw/fdir/FailureIsolationBase.h +++ b/src/fsfw/fdir/FailureIsolationBase.h @@ -9,9 +9,7 @@ #include "ConfirmsFailuresIF.h" #include "FaultCounter.h" -class FailureIsolationBase : public HasReturnvaluesIF, - public ConfirmsFailuresIF, - public HasParametersIF { +class FailureIsolationBase : public ConfirmsFailuresIF, public HasParametersIF { public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FDIR_1; static const Event FDIR_CHANGED_STATE = diff --git a/src/fsfw/fdir/FaultCounter.cpp b/src/fsfw/fdir/FaultCounter.cpp index 4515e5b1..eea08817 100644 --- a/src/fsfw/fdir/FaultCounter.cpp +++ b/src/fsfw/fdir/FaultCounter.cpp @@ -73,7 +73,7 @@ ReturnValue_t FaultCounter::getParameter(uint8_t domainId, uint8_t uniqueId, default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FaultCounter::setParameterDomain(uint8_t domain) { parameterDomain = domain; } diff --git a/src/fsfw/globalfunctions/AsciiConverter.cpp b/src/fsfw/globalfunctions/AsciiConverter.cpp index 6d49c777..b99814cb 100644 --- a/src/fsfw/globalfunctions/AsciiConverter.cpp +++ b/src/fsfw/globalfunctions/AsciiConverter.cpp @@ -44,7 +44,7 @@ ReturnValue_t AsciiConverter::scanAsciiHexByte(const uint8_t** dataPtr, uint8_t* *value = *value >> 4; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t AsciiConverter::scanAsciiDecimalNumber_(uint8_t const** dataPtr, uint8_t len, @@ -99,7 +99,7 @@ ReturnValue_t AsciiConverter::scanAsciiDecimalNumber_(uint8_t const** dataPtr, u *dataPtr = ptr; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t AsciiConverter::printFloat(uint8_t* buffer, uint32_t bufferLength, float value, @@ -124,7 +124,7 @@ ReturnValue_t AsciiConverter::printFloat(uint8_t* buffer, uint32_t bufferLength, ReturnValue_t result = printInteger(buffer + streamposition, bufferLength - streamposition - decimalPlaces - 1, value, &integerSize); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } streamposition += integerSize; @@ -161,7 +161,7 @@ ReturnValue_t AsciiConverter::printInteger(uint8_t* buffer, uint32_t bufferLengt } if (!leadingZeros && (value == 0)) { buffer[(*printedSize)++] = '0'; - return RETURN_OK; + return returnvalue::OK; } while (maximumNumber >= 1) { uint8_t number = value / maximumNumber; @@ -174,7 +174,7 @@ ReturnValue_t AsciiConverter::printInteger(uint8_t* buffer, uint32_t bufferLengt maximumNumber /= 10; } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t AsciiConverter::printSignedInteger(uint8_t* buffer, uint32_t bufferLength, diff --git a/src/fsfw/globalfunctions/AsciiConverter.h b/src/fsfw/globalfunctions/AsciiConverter.h index db382b61..7eb28882 100644 --- a/src/fsfw/globalfunctions/AsciiConverter.h +++ b/src/fsfw/globalfunctions/AsciiConverter.h @@ -3,7 +3,7 @@ #include "../returnvalues/HasReturnvaluesIF.h" -class AsciiConverter : public HasReturnvaluesIF { +class AsciiConverter { public: static const uint8_t INTERFACE_ID = CLASS_ID::ASCII_CONVERTER; static const ReturnValue_t TOO_LONG_FOR_TARGET_TYPE = MAKE_RETURN_CODE(1); diff --git a/src/fsfw/globalfunctions/DleEncoder.cpp b/src/fsfw/globalfunctions/DleEncoder.cpp index 23caf02a..c93b37c3 100644 --- a/src/fsfw/globalfunctions/DleEncoder.cpp +++ b/src/fsfw/globalfunctions/DleEncoder.cpp @@ -73,7 +73,7 @@ ReturnValue_t DleEncoder::encodeStreamEscaped(const uint8_t *sourceStream, size_ ++encodedIndex; } *encodedLen = encodedIndex; - return RETURN_OK; + return returnvalue::OK; } else { return STREAM_TOO_SHORT; } @@ -119,7 +119,7 @@ ReturnValue_t DleEncoder::encodeStreamNonEscaped(const uint8_t *sourceStream, si destStream[encodedIndex++] = ETX_CHAR; } *encodedLen = encodedIndex; - return RETURN_OK; + return returnvalue::OK; } else { return STREAM_TOO_SHORT; } @@ -191,7 +191,7 @@ ReturnValue_t DleEncoder::decodeStreamEscaped(const uint8_t *sourceStream, size_ case (ETX_CHAR): { *readLen = ++encodedIndex; *decodedLen = decodedIndex; - return RETURN_OK; + return returnvalue::OK; } default: { destStream[decodedIndex] = sourceStream[encodedIndex]; @@ -255,7 +255,7 @@ ReturnValue_t DleEncoder::decodeStreamNonEscaped(const uint8_t *sourceStream, // End of stream reached *readLen = encodedIndex + 2; *decodedLen = decodedIndex; - return RETURN_OK; + return returnvalue::OK; } else { *readLen = encodedIndex; return DECODING_ERROR; diff --git a/src/fsfw/globalfunctions/DleEncoder.h b/src/fsfw/globalfunctions/DleEncoder.h index 009c8656..a18527fb 100644 --- a/src/fsfw/globalfunctions/DleEncoder.h +++ b/src/fsfw/globalfunctions/DleEncoder.h @@ -30,7 +30,7 @@ * are escaped with DLE. If the receiver detects a DLE char, it needs to read the next char * to determine whether a start (STX) or end (ETX) of a frame has been detected. */ -class DleEncoder : public HasReturnvaluesIF { +class DleEncoder { public: /** * Create an encoder instance with the given configuration. diff --git a/src/fsfw/globalfunctions/Type.cpp b/src/fsfw/globalfunctions/Type.cpp index 71193673..42c6817e 100644 --- a/src/fsfw/globalfunctions/Type.cpp +++ b/src/fsfw/globalfunctions/Type.cpp @@ -52,12 +52,12 @@ ReturnValue_t Type::serialize(uint8_t** buffer, size_t* size, size_t maxSize, uint8_t ptc; uint8_t pfc; ReturnValue_t result = getPtcPfc(&ptc, &pfc); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&ptc, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -75,18 +75,18 @@ ReturnValue_t Type::deSerialize(const uint8_t** buffer, size_t* size, Endianness uint8_t ptc; uint8_t pfc; ReturnValue_t result = SerializeAdapter::deSerialize(&ptc, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&pfc, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } actualType = getActualType(ptc, pfc); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Type::getPtcPfc(uint8_t* ptc, uint8_t* pfc) const { @@ -124,9 +124,9 @@ ReturnValue_t Type::getPtcPfc(uint8_t* ptc, uint8_t* pfc) const { *pfc = 2; break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } Type::ActualType_t Type::getActualType(uint8_t ptc, uint8_t pfc) { diff --git a/src/fsfw/globalfunctions/matching/MatchTree.h b/src/fsfw/globalfunctions/matching/MatchTree.h index ec98e22a..0c31cf2a 100644 --- a/src/fsfw/globalfunctions/matching/MatchTree.h +++ b/src/fsfw/globalfunctions/matching/MatchTree.h @@ -40,34 +40,34 @@ class MatchTree : public SerializeableMatcherIF, public BinaryTreecountRight(iter); ReturnValue_t result = SerializeAdapter::serialize(&count, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (iter == this->end()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } result = iter->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (maxDepth > 0) { MatchTree temp(iter.left(), maxDepth - 1); result = temp.serialize(buffer, size, maxSize, streamEndianness); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } iter = iter.right(); while (iter != this->end()) { result = iter->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (maxDepth > 0) { MatchTree temp(iter.left(), maxDepth - 1); result = temp.serialize(buffer, size, maxSize, streamEndianness); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } iter = iter.right(); @@ -106,7 +106,7 @@ class MatchTree : public SerializeableMatcherIF, public BinaryTree, public BinaryTreeerase(position); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (children.first != this->end()) { result = removeElementAndAllChildren(children.first); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (children.second != this->end()) { result = removeElementAndAllChildren(children.second); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } // Delete element itself. @@ -143,13 +143,13 @@ class MatchTree : public SerializeableMatcherIF, public BinaryTreeend()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // Delete everything from the AND branch. - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (position.left() != this->end()) { result = removeElementAndAllChildren(position.left()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -176,7 +176,7 @@ class MatchTree : public SerializeableMatcherIF, public BinaryTree { SerializeIF::Endianness streamEndianness) const override { ReturnValue_t result = SerializeAdapter::serialize(&lowerBound, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&upperBound, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::serialize(&inverted, buffer, size, maxSize, streamEndianness); @@ -45,11 +45,11 @@ class RangeMatcher : public SerializeableMatcherIF { SerializeIF::Endianness streamEndianness) override { ReturnValue_t result = SerializeAdapter::deSerialize(&lowerBound, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&upperBound, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::deSerialize(&inverted, buffer, size, streamEndianness); diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index 0f51ddeb..bf1a92d2 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -11,13 +11,13 @@ ReturnValue_t HealthHelper::handleHealthCommand(CommandMessage* message) { switch (message->getCommand()) { case HealthMessage::HEALTH_SET: handleSetHealthCommand(message); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case HealthMessage::HEALTH_ANNOUNCE: { eventSender->forwardEvent(HasHealthIF::HEALTH_INFO, getHealth(), getHealth()); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -53,10 +53,10 @@ ReturnValue_t HealthHelper::initialize() { } ReturnValue_t result = healthTable->registerObject(objectId, HasHealthIF::HEALTHY); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void HealthHelper::setHealth(HasHealthIF::HealthState health) { @@ -76,7 +76,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health, CommandMessage information; HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO, health, oldHealth); if (MessageQueueSenderIF::sendMessage(parentQueue, &information, owner->getCommandQueue()) != - HasReturnvaluesIF::RETURN_OK) { + returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "HealthHelper::informParent: sending health reply failed." << std::endl; #endif @@ -89,13 +89,13 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) { return; } CommandMessage reply; - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { HealthMessage::setHealthMessage(&reply, HealthMessage::REPLY_HEALTH_SET); } else { reply.setReplyRejected(result, command->getCommand()); } if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()) != - HasReturnvaluesIF::RETURN_OK) { + returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "HealthHelper::handleHealthCommand: sending health " "reply failed." diff --git a/src/fsfw/health/HealthHelper.h b/src/fsfw/health/HealthHelper.h index 9b3b0e2b..0b9a9c78 100644 --- a/src/fsfw/health/HealthHelper.h +++ b/src/fsfw/health/HealthHelper.h @@ -56,7 +56,7 @@ class HealthHelper { * @param message * @return * -@c RETURN_OK if the message was handled - * -@c RETURN_FAILED if the message could not be handled + * -@c returnvalue::FAILED if the message could not be handled * (ie it was not a @c HEALTH_SET or @c HEALTH_READ message) */ ReturnValue_t handleHealthCommand(CommandMessage* message); @@ -90,7 +90,7 @@ class HealthHelper { * @return * -@c RETURN_OK if the Health Table was found and the object * could be registered - * -@c RETURN_FAILED else + * -@c returnvalue::FAILED else */ ReturnValue_t initialize(MessageQueueId_t parentQueue); diff --git a/src/fsfw/health/HealthTable.cpp b/src/fsfw/health/HealthTable.cpp index f4bda1c3..5fb45fb9 100644 --- a/src/fsfw/health/HealthTable.cpp +++ b/src/fsfw/health/HealthTable.cpp @@ -21,19 +21,19 @@ HealthTable::~HealthTable() { MutexFactory::instance()->deleteMutex(mutex); } ReturnValue_t HealthTable::registerObject(object_id_t object, HasHealthIF::HealthState initilialState) { if (healthMap.count(object) != 0) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } healthMap.emplace(object, initilialState); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t HealthTable::removeObject(object_id_t object) { mapIterator = healthMap.find(object); if (mapIterator == healthMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } healthMap.erase(mapIterator); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void HealthTable::setHealth(object_id_t object, HasHealthIF::HealthState newState) { @@ -76,7 +76,7 @@ void HealthTable::printAll(uint8_t* pointer, size_t maxSize) { uint16_t count = healthMap.size(); ReturnValue_t result = SerializeAdapter::serialize(&count, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "HealthTable::printAll: Serialization of health table failed" << std::endl; @@ -89,26 +89,26 @@ void HealthTable::printAll(uint8_t* pointer, size_t maxSize) { for (const auto& health : healthMap) { result = SerializeAdapter::serialize(&health.first, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } uint8_t healthValue = health.second; result = SerializeAdapter::serialize(&healthValue, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } } } ReturnValue_t HealthTable::iterate(HealthEntry* value, bool reset) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; MutexGuard(mutex, timeoutType, mutexTimeoutMs); if (reset) { mapIterator = healthMap.begin(); } if (mapIterator == healthMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *value = *mapIterator; mapIterator++; diff --git a/src/fsfw/housekeeping/HousekeepingSetPacket.h b/src/fsfw/housekeeping/HousekeepingSetPacket.h index 96eaaed9..fa039da8 100644 --- a/src/fsfw/housekeeping/HousekeepingSetPacket.h +++ b/src/fsfw/housekeeping/HousekeepingSetPacket.h @@ -22,7 +22,7 @@ class HousekeepingSetPacket : public SerialLinkedListAdapter { Endianness streamEndianness) const override { ReturnValue_t result = SerialLinkedListAdapter::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return dataSet->serializeLocalPoolIds(buffer, size, maxSize, streamEndianness); @@ -36,7 +36,7 @@ class HousekeepingSetPacket : public SerialLinkedListAdapter { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } private: diff --git a/src/fsfw/housekeeping/HousekeepingSnapshot.h b/src/fsfw/housekeeping/HousekeepingSnapshot.h index c3eabe80..fe9d3617 100644 --- a/src/fsfw/housekeeping/HousekeepingSnapshot.h +++ b/src/fsfw/housekeeping/HousekeepingSnapshot.h @@ -64,7 +64,7 @@ class HousekeepingSnapshot : public SerializeIF { *buffer += timeStampSize; } if (updateData == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return updateData->serialize(buffer, size, maxSize, streamEndianness); @@ -92,7 +92,7 @@ class HousekeepingSnapshot : public SerializeIF { } if (updateData == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (*size < updateData->getSerializedSize()) { return SerializeIF::STREAM_TOO_SHORT; diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index 0e404d22..b3b77366 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -52,7 +52,7 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { { PoolReadGuard readGuard(&internalErrorDataset); - if (readGuard.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + if (readGuard.getReadResult() == returnvalue::OK) { internalErrorDataset.queueHits.value += newQueueHits; internalErrorDataset.storeHits.value += newStoreHits; internalErrorDataset.tmHits.value += newTmHits; @@ -64,7 +64,7 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { } poolManager.performHkOperation(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void InternalErrorReporter::queueMessageNotSent() { incrementQueueHits(); } @@ -133,7 +133,7 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool internalErrorSid, false, static_cast(getPeriodicOperationFrequency()) / static_cast(1000.0))); internalErrorDataset.setValidity(true, true); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } dur_millis_t InternalErrorReporter::getPeriodicOperationFrequency() const { @@ -148,7 +148,7 @@ void InternalErrorReporter::setTaskIF(PeriodicTaskIF *task) { this->executingTas ReturnValue_t InternalErrorReporter::initialize() { ReturnValue_t result = poolManager.initialize(commandQueue); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SystemObject::initialize(); diff --git a/src/fsfw/ipc/MutexGuard.h b/src/fsfw/ipc/MutexGuard.h index f7b90663..f6d2f25f 100644 --- a/src/fsfw/ipc/MutexGuard.h +++ b/src/fsfw/ipc/MutexGuard.h @@ -30,7 +30,7 @@ class MutexGuard { timeoutMs); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - } else if (result != HasReturnvaluesIF::RETURN_OK) { + } else if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MutexGuard: Lock of Mutex failed with code " << result << std::endl; #else @@ -51,7 +51,7 @@ class MutexGuard { private: MutexIF* internalMutex; - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; }; #endif /* FRAMEWORK_IPC_MUTEXGUARD_H_ */ diff --git a/src/fsfw/memory/GenericFileSystemMessage.cpp b/src/fsfw/memory/GenericFileSystemMessage.cpp index 805c7dcc..cdbfeb62 100644 --- a/src/fsfw/memory/GenericFileSystemMessage.cpp +++ b/src/fsfw/memory/GenericFileSystemMessage.cpp @@ -157,10 +157,10 @@ ReturnValue_t GenericFileSystemMessage::clear(CommandMessage *message) { store_address_t storeId = GenericFileSystemMessage::getStoreId(message); auto ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return ipcStore->deleteData(storeId); } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/memory/HasMemoryIF.h b/src/fsfw/memory/HasMemoryIF.h index 7aa66377..73edfe4b 100644 --- a/src/fsfw/memory/HasMemoryIF.h +++ b/src/fsfw/memory/HasMemoryIF.h @@ -30,15 +30,13 @@ class HasMemoryIF { * Sets the address of the memory, if possible. * startAddress is a proposal for an address, or the base address if multiple addresses are set. */ - virtual ReturnValue_t setAddress(uint32_t* startAddress) { - return HasReturnvaluesIF::RETURN_FAILED; - } + virtual ReturnValue_t setAddress(uint32_t* startAddress) { return returnvalue::FAILED; } static bool memAccessWasSuccessful(ReturnValue_t result) { switch (result) { case DO_IT_MYSELF: case POINTS_TO_MEMORY: case POINTS_TO_VARIABLE: - case HasReturnvaluesIF::RETURN_OK: + case returnvalue::OK: case ACTIVITY_COMPLETED: return true; default: diff --git a/src/fsfw/memory/MemoryHelper.cpp b/src/fsfw/memory/MemoryHelper.cpp index 462a818e..cf4d205d 100644 --- a/src/fsfw/memory/MemoryHelper.cpp +++ b/src/fsfw/memory/MemoryHelper.cpp @@ -24,13 +24,13 @@ ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) { switch (lastCommand) { case MemoryMessage::CMD_MEMORY_DUMP: handleMemoryCheckOrDump(message); - return RETURN_OK; + return returnvalue::OK; case MemoryMessage::CMD_MEMORY_LOAD: handleMemoryLoad(message); - return RETURN_OK; + return returnvalue::OK; case MemoryMessage::CMD_MEMORY_CHECK: handleMemoryCheckOrDump(message); - return RETURN_OK; + return returnvalue::OK; default: lastCommand = CommandMessage::CMD_NONE; return UNKNOWN_CMD; @@ -51,7 +51,7 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode, const uint8_t* dataToCo EndianConverter::convertBigEndian(copyHere, dataToCopy, size); break; case HasMemoryIF::ACTIVITY_COMPLETED: - case RETURN_OK: + case returnvalue::OK: break; default: ipcStore->deleteData(ipcAddress); @@ -75,7 +75,7 @@ void MemoryHelper::completeDump(ReturnValue_t errorCode, const uint8_t* dataToCo case HasMemoryIF::DO_IT_MYSELF: busy = true; return; - case HasReturnvaluesIF::RETURN_OK: + case returnvalue::OK: case HasMemoryIF::POINTS_TO_MEMORY: case HasMemoryIF::POINTS_TO_VARIABLE: //"data" must be valid pointer! @@ -118,7 +118,7 @@ void MemoryHelper::completeDump(ReturnValue_t errorCode, const uint8_t* dataToCo ipcStore->deleteData(ipcAddress); break; } - if (queueToUse->sendMessage(lastSender, &reply) != RETURN_OK) { + if (queueToUse->sendMessage(lastSender, &reply) != returnvalue::OK) { reply.clear(); } } @@ -148,7 +148,7 @@ void MemoryHelper::handleMemoryLoad(CommandMessage* message) { uint8_t* dataPointer = NULL; size_t size = 0; ReturnValue_t returnCode = ipcStore->getData(ipcAddress, &p_data, &size); - if (returnCode == RETURN_OK) { + if (returnCode == returnvalue::OK) { returnCode = workOnThis->handleMemoryLoad(address, p_data, size, &dataPointer); completeLoad(returnCode, p_data, size, dataPointer); } else { @@ -164,7 +164,7 @@ void MemoryHelper::handleMemoryCheckOrDump(CommandMessage* message) { uint32_t size = MemoryMessage::getLength(message); uint8_t* dataPointer = NULL; ReturnValue_t returnCode = ipcStore->getFreeElement(&ipcAddress, size, &reservedSpaceInIPC); - if (returnCode == RETURN_OK) { + if (returnCode == returnvalue::OK) { returnCode = workOnThis->handleMemoryDump(address, size, &dataPointer, reservedSpaceInIPC); completeDump(returnCode, dataPointer, size); } else { @@ -176,7 +176,7 @@ void MemoryHelper::handleMemoryCheckOrDump(CommandMessage* message) { ReturnValue_t MemoryHelper::initialize(MessageQueueIF* queueToUse_) { if (queueToUse_ == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } this->queueToUse = queueToUse_; return initialize(); @@ -185,8 +185,8 @@ ReturnValue_t MemoryHelper::initialize(MessageQueueIF* queueToUse_) { ReturnValue_t MemoryHelper::initialize() { ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore != nullptr) { - return RETURN_OK; + return returnvalue::OK; } else { - return RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/memory/MemoryHelper.h b/src/fsfw/memory/MemoryHelper.h index 7a645b79..3a51f7dc 100644 --- a/src/fsfw/memory/MemoryHelper.h +++ b/src/fsfw/memory/MemoryHelper.h @@ -10,7 +10,7 @@ /** * @brief TODO: documentation. */ -class MemoryHelper : public HasReturnvaluesIF { +class MemoryHelper { public: static const uint8_t INTERFACE_ID = CLASS_ID::MEMORY_HELPER; static const ReturnValue_t UNKNOWN_CMD = MAKE_RETURN_CODE(0xE0); diff --git a/src/fsfw/modes/HasModesIF.h b/src/fsfw/modes/HasModesIF.h index 0ebe77d8..03cc45bf 100644 --- a/src/fsfw/modes/HasModesIF.h +++ b/src/fsfw/modes/HasModesIF.h @@ -53,7 +53,7 @@ class HasModesIF { protected: virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } virtual void startTransition(Mode_t mode, Submode_t submode) {} diff --git a/src/fsfw/modes/ModeHelper.cpp b/src/fsfw/modes/ModeHelper.cpp index 2ea392ab..8c83012f 100644 --- a/src/fsfw/modes/ModeHelper.cpp +++ b/src/fsfw/modes/ModeHelper.cpp @@ -25,7 +25,7 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) { submode = ModeMessage::getSubmode(command); uint32_t timeout; ReturnValue_t result = owner->checkModeCommand(mode, submode, &timeout); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { ModeMessage::setCantReachMode(&reply, result); MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()); break; @@ -55,9 +55,9 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) { owner->announceMode(true); break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ModeHelper::initialize(MessageQueueId_t parentQueueId) { @@ -99,7 +99,7 @@ void ModeHelper::setParentQueue(MessageQueueId_t parentQueueId) { this->parentQueueId = parentQueueId; } -ReturnValue_t ModeHelper::initialize(void) { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t ModeHelper::initialize(void) { return returnvalue::OK; } bool ModeHelper::isTimedOut() { return countdown.hasTimedOut(); } diff --git a/src/fsfw/monitoring/AbsLimitMonitor.h b/src/fsfw/monitoring/AbsLimitMonitor.h index c6400166..790808ee 100644 --- a/src/fsfw/monitoring/AbsLimitMonitor.h +++ b/src/fsfw/monitoring/AbsLimitMonitor.h @@ -29,7 +29,7 @@ class AbsLimitMonitor : public MonitorBase { return MonitoringIF::OUT_OF_RANGE; } } - return HasReturnvaluesIF::RETURN_OK; // We're not out of range. + return returnvalue::OK; // We're not out of range. } virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId, @@ -49,7 +49,7 @@ class AbsLimitMonitor : public MonitorBase { default: return this->INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool isOutOfLimits() { if (this->oldState == MonitoringIF::OUT_OF_RANGE) { diff --git a/src/fsfw/monitoring/LimitMonitor.h b/src/fsfw/monitoring/LimitMonitor.h index 229f1dc2..4fe9ee39 100644 --- a/src/fsfw/monitoring/LimitMonitor.h +++ b/src/fsfw/monitoring/LimitMonitor.h @@ -32,7 +32,7 @@ class LimitMonitor : public MonitorBase { *crossedLimit = lowerLimit; return MonitoringIF::BELOW_LOW_LIMIT; } else { - return HasReturnvaluesIF::RETURN_OK; // Within limits. + return returnvalue::OK; // Within limits. } } @@ -55,7 +55,7 @@ class LimitMonitor : public MonitorBase { default: return this->INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool isOutOfLimits() { if (this->oldState == MonitoringIF::ABOVE_HIGH_LIMIT or diff --git a/src/fsfw/monitoring/LimitViolationReporter.cpp b/src/fsfw/monitoring/LimitViolationReporter.cpp index 43ecf4d3..ec6fa2e6 100644 --- a/src/fsfw/monitoring/LimitViolationReporter.cpp +++ b/src/fsfw/monitoring/LimitViolationReporter.cpp @@ -7,7 +7,7 @@ ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF* data) { ReturnValue_t result = checkClassLoaded(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } store_address_t storeId; @@ -17,12 +17,12 @@ ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF return MonitoringIF::INVALID_SIZE; } result = ipcStore->getFreeElement(&storeId, maxSize, &dataTarget); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t size = 0; result = data->serialize(&dataTarget, &size, maxSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } CommandMessage report; @@ -42,10 +42,10 @@ ReturnValue_t LimitViolationReporter::checkClassLoaded() { if (ipcStore == nullptr) { ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); if (ipcStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // Lazy initialization. diff --git a/src/fsfw/monitoring/MonitorBase.h b/src/fsfw/monitoring/MonitorBase.h index b2653d75..dd0792b2 100644 --- a/src/fsfw/monitoring/MonitorBase.h +++ b/src/fsfw/monitoring/MonitorBase.h @@ -36,7 +36,7 @@ class MonitorBase : public MonitorReporter { // 2. If returning from fetch != OK, parameter is invalid. // Report (if oldState is != invalidity). - if (validity != HasReturnvaluesIF::RETURN_OK) { + if (validity != returnvalue::OK) { this->monitorStateIs(validity, sample, 0); } else { // 3. Otherwise, check sample. @@ -56,14 +56,14 @@ class MonitorBase : public MonitorReporter { protected: virtual ReturnValue_t fetchSample(T* sample) { ReturnValue_t result = poolVariable.read(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (not poolVariable.isValid()) { return MonitoringIF::INVALID; } *sample = poolVariable.value; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } LocalPoolVariable poolVariable; diff --git a/src/fsfw/monitoring/MonitorReporter.h b/src/fsfw/monitoring/MonitorReporter.h index bcbaf26d..09c39222 100644 --- a/src/fsfw/monitoring/MonitorReporter.h +++ b/src/fsfw/monitoring/MonitorReporter.h @@ -70,7 +70,7 @@ class MonitorReporter : public HasParametersIF { default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } virtual ReturnValue_t setToUnchecked() { return setToState(MonitoringIF::UNCHECKED); } virtual ReturnValue_t setToInvalid() { return setToState(MonitoringIF::INVALID); } @@ -135,7 +135,7 @@ class MonitorReporter : public HasParametersIF { case MonitoringIF::UNCHECKED: case MonitoringIF::UNSELECTED: case MonitoringIF::INVALID: - case HasReturnvaluesIF::RETURN_OK: + case returnvalue::OK: break; default: EventManagerIF::triggerEvent(reportingId, MonitoringIF::MONITOR_CHANGED_STATE, state); @@ -159,7 +159,7 @@ class MonitorReporter : public HasParametersIF { LimitViolationReporter::sendLimitViolationReport(&report); oldState = state; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } }; diff --git a/src/fsfw/monitoring/TriplexMonitor.h b/src/fsfw/monitoring/TriplexMonitor.h index 1d9182aa..e007ea5f 100644 --- a/src/fsfw/monitoring/TriplexMonitor.h +++ b/src/fsfw/monitoring/TriplexMonitor.h @@ -49,7 +49,7 @@ class TriplexMonitor : public HasParametersIF { nAvailable++; } } - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; switch (nAvailable) { case 3: result = doTriplexMonitoring(); @@ -67,9 +67,9 @@ class TriplexMonitor : public HasParametersIF { ReturnValue_t initialize() { healthTable = ObjectManager::instance()->get(objects::HEALTH_TABLE); if (healthTable == NULL) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper *parameterWrapper, @@ -84,7 +84,7 @@ class TriplexMonitor : public HasParametersIF { default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } protected: @@ -96,7 +96,7 @@ class TriplexMonitor : public HasParametersIF { HealthTableIF *healthTable; uint8_t domainId; ReturnValue_t doTriplexMonitoring() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; // Find middle value, by ordering indices uint8_t index[3] = {0, 1, 2}; if (values[index[0]].value > values[index[1]].value) { @@ -118,7 +118,7 @@ class TriplexMonitor : public HasParametersIF { if (values[index[2]] > (values[index[1]] + limit)) { EventManagerIF::triggerEvent(getRefereneceObject(index[2]), eventTripleCheck, HIGHEST_VALUE_OOL, 0); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { result = HIGHEST_VALUE_OOL; } else { result = BOTH_VALUES_OOL; @@ -142,7 +142,7 @@ class TriplexMonitor : public HasParametersIF { return DUPLEX_OOL; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } virtual bool checkObjectHealthState(uint8_t valueIndex) = 0; virtual object_id_t getRefereneceObject(uint8_t valueIndex) = 0; diff --git a/src/fsfw/monitoring/TwoValueLimitMonitor.h b/src/fsfw/monitoring/TwoValueLimitMonitor.h index 79b8c4bb..ad3f5c86 100644 --- a/src/fsfw/monitoring/TwoValueLimitMonitor.h +++ b/src/fsfw/monitoring/TwoValueLimitMonitor.h @@ -18,7 +18,7 @@ class TwoValueLimitMonitor : public LimitMonitor { ReturnValue_t doCheck(T lowSample, T highSample) { T crossedLimit; ReturnValue_t currentState = this->checkSample(lowSample, &crossedLimit); - if (currentState != HasReturnvaluesIF::RETURN_OK) { + if (currentState != returnvalue::OK) { return this->monitorStateIs(currentState, lowSample, crossedLimit); } currentState = this->checkSample(highSample, &crossedLimit); diff --git a/src/fsfw/objectmanager/ObjectManager.cpp b/src/fsfw/objectmanager/ObjectManager.cpp index a0278988..ddf5ab80 100644 --- a/src/fsfw/objectmanager/ObjectManager.cpp +++ b/src/fsfw/objectmanager/ObjectManager.cpp @@ -36,7 +36,7 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) { // sif::debug << "ObjectManager::insert: Object " << std::hex // << (int)id << std::dec << " inserted." << std::endl; #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::insert: Object ID " << std::hex << static_cast(id) @@ -59,7 +59,7 @@ ReturnValue_t ObjectManager::remove(object_id_t id) { // sif::debug << "ObjectManager::removeObject: Object " << std::hex // << (int)id << std::dec << " removed." << std::endl; #endif - return RETURN_OK; + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::removeObject: Requested object " << std::hex << (int)id @@ -90,11 +90,11 @@ void ObjectManager::initialize() { return; } objectFactoryFunction(factoryArgs); - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; uint32_t errorCount = 0; for (auto const& it : objectList) { result = it.second->initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 object_id_t var = it.first; sif::error << "ObjectManager::initialize: Object 0x" << std::hex << std::setw(8) @@ -116,7 +116,7 @@ void ObjectManager::initialize() { errorCount = 0; for (auto const& it : objectList) { result = it.second->checkObjectConnections(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::ObjectManager: Object 0x" << std::hex << (int)it.first << " connection check failed with code 0x" << result << std::dec << std::endl; diff --git a/src/fsfw/objectmanager/ObjectManagerIF.h b/src/fsfw/objectmanager/ObjectManagerIF.h index 32a0942f..58ee9ab4 100644 --- a/src/fsfw/objectmanager/ObjectManagerIF.h +++ b/src/fsfw/objectmanager/ObjectManagerIF.h @@ -16,7 +16,7 @@ * @author Bastian Baetz * @ingroup system_objects */ -class ObjectManagerIF : public HasReturnvaluesIF { +class ObjectManagerIF { public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::OBJECT_MANAGER_IF; static constexpr ReturnValue_t INSERTION_FAILED = MAKE_RETURN_CODE(1); diff --git a/src/fsfw/objectmanager/SystemObject.cpp b/src/fsfw/objectmanager/SystemObject.cpp index 7f8acfd8..90839013 100644 --- a/src/fsfw/objectmanager/SystemObject.cpp +++ b/src/fsfw/objectmanager/SystemObject.cpp @@ -22,9 +22,9 @@ void SystemObject::triggerEvent(Event event, uint32_t parameter1, uint32_t param EventManagerIF::triggerEvent(objectId, event, parameter1, parameter2); } -ReturnValue_t SystemObject::initialize() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SystemObject::initialize() { return returnvalue::OK; } -ReturnValue_t SystemObject::checkObjectConnections() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SystemObject::checkObjectConnections() { return returnvalue::OK; } void SystemObject::forwardEvent(Event event, uint32_t parameter1, uint32_t parameter2) const { EventManagerIF::triggerEvent(objectId, event, parameter1, parameter2); diff --git a/src/fsfw/objectmanager/SystemObjectIF.h b/src/fsfw/objectmanager/SystemObjectIF.h index 99e26b9c..02f24837 100644 --- a/src/fsfw/objectmanager/SystemObjectIF.h +++ b/src/fsfw/objectmanager/SystemObjectIF.h @@ -46,7 +46,7 @@ class SystemObjectIF : public EventReportingProxyIF { * Therefore, a two-step initialization resolves this problem and prevents * circular dependencies of not-fully initialized objects on start up. * @return - @c RETURN_OK in case the initialization was successful - * - @c RETURN_FAILED otherwise + * - @c returnvalue::FAILED otherwise */ virtual ReturnValue_t initialize() = 0; /** diff --git a/src/fsfw/osal/common/TcpIpBase.cpp b/src/fsfw/osal/common/TcpIpBase.cpp index 67e71053..7e989c36 100644 --- a/src/fsfw/osal/common/TcpIpBase.cpp +++ b/src/fsfw/osal/common/TcpIpBase.cpp @@ -21,10 +21,10 @@ ReturnValue_t TcpIpBase::initialize() { sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: WSAStartup failed with error: " << err << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } TcpIpBase::~TcpIpBase() { diff --git a/src/fsfw/osal/common/TcpTmTcBridge.cpp b/src/fsfw/osal/common/TcpTmTcBridge.cpp index 4b2bea73..6b3561ba 100644 --- a/src/fsfw/osal/common/TcpTmTcBridge.cpp +++ b/src/fsfw/osal/common/TcpTmTcBridge.cpp @@ -26,7 +26,7 @@ TcpTmTcBridge::TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination, ob ReturnValue_t TcpTmTcBridge::initialize() { ReturnValue_t result = TmTcBridge::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcpTmTcBridge::initialize: TmTcBridge initialization failed!" << std::endl; #else @@ -35,7 +35,7 @@ ReturnValue_t TcpTmTcBridge::initialize() { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } TcpTmTcBridge::~TcpTmTcBridge() { @@ -48,21 +48,20 @@ ReturnValue_t TcpTmTcBridge::handleTm() { // Simply store the telemetry in the FIFO, the server will use it to access the TM MutexGuard guard(mutex, timeoutType, mutexTimeoutMs); TmTcMessage message; - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; for (ReturnValue_t result = tmTcReceptionQueue->receiveMessage(&message); - result == HasReturnvaluesIF::RETURN_OK; - result = tmTcReceptionQueue->receiveMessage(&message)) { + result == returnvalue::OK; result = tmTcReceptionQueue->receiveMessage(&message)) { status = storeDownlinkData(&message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { break; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TcpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) { // Not used. The Server uses the FIFO to access and send the telemetry. - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TcpTmTcBridge::setMutexProperties(MutexIF::TimeoutType timeoutType, dur_millis_t timeoutMs) { diff --git a/src/fsfw/osal/common/TcpTmTcServer.cpp b/src/fsfw/osal/common/TcpTmTcServer.cpp index a8890006..f9cb923e 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.cpp +++ b/src/fsfw/osal/common/TcpTmTcServer.cpp @@ -39,7 +39,7 @@ ReturnValue_t TcpTmTcServer::initialize() { using namespace tcpip; ReturnValue_t result = TcpIpBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -47,7 +47,7 @@ ReturnValue_t TcpTmTcServer::initialize() { case (ReceptionModes::SPACE_PACKETS): { spacePacketParser = new SpacePacketParser(validPacketIds); if (spacePacketParser == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #if defined PLATFORM_UNIX tcpConfig.tcpFlags |= MSG_DONTWAIT; @@ -79,7 +79,7 @@ ReturnValue_t TcpTmTcServer::initialize() { retval = getaddrinfo(nullptr, tcpConfig.tcpPort.c_str(), &hints, &addrResult); if (retval != 0) { handleError(Protocol::TCP, ErrorSources::GETADDRINFO_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // Open TCP (stream) socket @@ -88,7 +88,7 @@ ReturnValue_t TcpTmTcServer::initialize() { if (listenerTcpSocket == INVALID_SOCKET) { freeaddrinfo(addrResult); handleError(Protocol::TCP, ErrorSources::SOCKET_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // Bind to the address found by getaddrinfo @@ -96,11 +96,11 @@ ReturnValue_t TcpTmTcServer::initialize() { if (retval == SOCKET_ERROR) { freeaddrinfo(addrResult); handleError(Protocol::TCP, ErrorSources::BIND_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } freeaddrinfo(addrResult); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } TcpTmTcServer::~TcpTmTcServer() { closeSocket(listenerTcpSocket); } @@ -151,7 +151,7 @@ ReturnValue_t TcpTmTcServer::initializeAfterTaskCreation() { targetTcDestination = tmtcBridge->getRequestQueue(); tcStore = tmtcBridge->tcStore; tmStore = tmtcBridge->tmStore; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TcpTmTcServer::handleServerOperation(socket_t& connSocket) { @@ -214,11 +214,11 @@ ReturnValue_t TcpTmTcServer::handleTcReception(uint8_t* spacePacket, size_t pack } if (spacePacket == nullptr or packetSize == 0) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } store_address_t storeId; ReturnValue_t result = tcStore->addData(&storeId, spacePacket, packetSize); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TcpTmTcServer::handleServerOperation: Data storage with packet size" @@ -236,7 +236,7 @@ ReturnValue_t TcpTmTcServer::handleTcReception(uint8_t* spacePacket, size_t pack TmTcMessage message(storeId); result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TcpTmTcServer::handleServerOperation: " @@ -273,7 +273,7 @@ ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket, bool& tmSent) // Using the store accessor will take care of deleting TM from the store automatically ConstStorageAccessor storeAccessor(storeId); ReturnValue_t result = tmStore->getData(storeId, storeAccessor); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (wiretappingEnabled) { @@ -297,12 +297,12 @@ ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket, bool& tmSent) return CONN_BROKEN; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; + ReturnValue_t result = returnvalue::OK; size_t readAmount = availableReadData; lastRingBufferSize = availableReadData; if (readAmount >= ringBuffer.getMaxSize()) { @@ -341,7 +341,7 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { size_t readLen = 0; while (readLen < readAmount) { if (spacePacketParser == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } result = spacePacketParser->parseSpacePackets(bufPtrPtr, readAmount, startIdx, foundSize, readLen); @@ -350,9 +350,9 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { case (SpacePacketParser::SPLIT_PACKET): { break; } - case (HasReturnvaluesIF::RETURN_OK): { + case (returnvalue::OK): { result = handleTcReception(receptionBuffer.data() + startIdx, foundSize); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } } diff --git a/src/fsfw/osal/common/TcpTmTcServer.h b/src/fsfw/osal/common/TcpTmTcServer.h index 1181ff10..0e2182a5 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.h +++ b/src/fsfw/osal/common/TcpTmTcServer.h @@ -108,7 +108,7 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb StorageManagerIF* tmStore = nullptr; private: - static constexpr ReturnValue_t CONN_BROKEN = result::makeCode(1, 0); + static constexpr ReturnValue_t CONN_BROKEN = returnvalue::makeCode(1, 0); //! TMTC bridge is cached. object_id_t tmtcBridgeId = objects::NO_OBJECT; TcpTmTcBridge* tmtcBridge = nullptr; diff --git a/src/fsfw/osal/common/UdpTcPollingTask.cpp b/src/fsfw/osal/common/UdpTcPollingTask.cpp index bcc8e9e3..4304fdd2 100644 --- a/src/fsfw/osal/common/UdpTcPollingTask.cpp +++ b/src/fsfw/osal/common/UdpTcPollingTask.cpp @@ -66,7 +66,7 @@ UdpTcPollingTask::UdpTcPollingTask(object_id_t objectId, object_id_t tmtcUdpBrid #endif /* FSFW_UDP_RCV_WIRETAPPING_ENABLED == 1 */ ReturnValue_t result = handleSuccessfullTcRead(bytesReceived); - if (result != HasReturnvaluesIF::RETURN_FAILED) { + if (result != returnvalue::FAILED) { } tmtcBridge->checkAndSetClientAddress(senderAddress); } @@ -80,20 +80,20 @@ ReturnValue_t UdpTcPollingTask::handleSuccessfullTcRead(size_t bytesRead) { #endif ReturnValue_t result = tcStore->addData(&storeId, receptionBuffer.data(), bytesRead); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UdpTcPollingTask::transferPusToSoftwareBus: Data storage failed." << std::endl; sif::warning << "Packet size: " << bytesRead << std::endl; #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } TmTcMessage message(storeId); result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UdpTcPollingTask::handleSuccessfullTcRead: " @@ -124,11 +124,11 @@ ReturnValue_t UdpTcPollingTask::initialize() { } ReturnValue_t result = TcpIpBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t UdpTcPollingTask::initializeAfterTaskCreation() { @@ -138,7 +138,7 @@ ReturnValue_t UdpTcPollingTask::initializeAfterTaskCreation() { /* The server socket is set up in the bridge intialization. Calling this function here ensures that it is set up regardless of which class was initialized first */ this->serverSocket = tmtcBridge->serverSocket; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void UdpTcPollingTask::setTimeout(double timeoutSeconds) { diff --git a/src/fsfw/osal/common/UdpTmTcBridge.cpp b/src/fsfw/osal/common/UdpTmTcBridge.cpp index e3cad58f..0a847271 100644 --- a/src/fsfw/osal/common/UdpTmTcBridge.cpp +++ b/src/fsfw/osal/common/UdpTmTcBridge.cpp @@ -35,7 +35,7 @@ UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, ReturnValue_t UdpTmTcBridge::initialize() { ReturnValue_t result = TmTcBridge::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "UdpTmTcBridge::initialize: TmTcBridge initialization failed!" << std::endl; #endif @@ -56,7 +56,7 @@ ReturnValue_t UdpTmTcBridge::initialize() { #else sif::printError("UdpTmTcBridge::UdpTmTcBridge: WSAStartup failed with error: %d\n", err); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #endif @@ -75,14 +75,14 @@ ReturnValue_t UdpTmTcBridge::initialize() { int retval = getaddrinfo(nullptr, udpServerPort.c_str(), &hints, &addrResult); if (retval != 0) { tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::GETADDRINFO_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } serverSocket = socket(addrResult->ai_family, addrResult->ai_socktype, addrResult->ai_protocol); if (serverSocket == INVALID_SOCKET) { freeaddrinfo(addrResult); tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::SOCKET_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #if FSFW_UDP_SEND_WIRETAPPING_ENABLED == 1 @@ -93,10 +93,10 @@ ReturnValue_t UdpTmTcBridge::initialize() { if (retval != 0) { freeaddrinfo(addrResult); tcpip::handleError(tcpip::Protocol::UDP, tcpip::ErrorSources::BIND_CALL); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } freeaddrinfo(addrResult); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } UdpTmTcBridge::~UdpTmTcBridge() { @@ -131,7 +131,7 @@ ReturnValue_t UdpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) { " sent." << std::endl; #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void UdpTmTcBridge::checkAndSetClientAddress(sockaddr &newAddress) { diff --git a/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp b/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp index 7ffd61d3..54226e18 100644 --- a/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp +++ b/src/fsfw/osal/freertos/BinSemaphUsingTask.cpp @@ -42,7 +42,7 @@ ReturnValue_t BinarySemaphoreUsingTask::acquireWithTickTimeout(TimeoutType timeo TickType_t timeoutTicks) { BaseType_t returncode = ulTaskNotifyTake(pdTRUE, timeoutTicks); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SemaphoreIF::SEMAPHORE_TIMEOUT; } @@ -56,10 +56,10 @@ ReturnValue_t BinarySemaphoreUsingTask::release(TaskHandle_t taskHandle) { } BaseType_t returncode = xTaskNotifyGive(taskHandle); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { // This should never happen. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -82,7 +82,7 @@ ReturnValue_t BinarySemaphoreUsingTask::releaseFromISR(TaskHandle_t taskHandle, return SemaphoreIF::SEMAPHORE_NOT_OWNED; } vTaskNotifyGiveFromISR(taskHandle, higherPriorityTaskWoken); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint8_t BinarySemaphoreUsingTask::getSemaphoreCounterFromISR(TaskHandle_t taskHandle, diff --git a/src/fsfw/osal/freertos/BinSemaphUsingTask.h b/src/fsfw/osal/freertos/BinSemaphUsingTask.h index 34b0d031..a88863c9 100644 --- a/src/fsfw/osal/freertos/BinSemaphUsingTask.h +++ b/src/fsfw/osal/freertos/BinSemaphUsingTask.h @@ -51,7 +51,7 @@ class BinarySemaphoreUsingTask : public SemaphoreIF, public HasReturnvaluesIF { * Same as acquire() with timeout in FreeRTOS ticks. * @param timeoutTicks * @return - @c RETURN_OK on success - * - @c RETURN_FAILED on failure + * - @c returnvalue::FAILED on failure */ ReturnValue_t acquireWithTickTimeout(TimeoutType timeoutType = TimeoutType::BLOCKING, TickType_t timeoutTicks = portMAX_DELAY); @@ -66,7 +66,7 @@ class BinarySemaphoreUsingTask : public SemaphoreIF, public HasReturnvaluesIF { * Wrapper function to give back semaphore from handle * @param semaphore * @return - @c RETURN_OK on success - * - @c RETURN_FAILED on failure + * - @c returnvalue::FAILED on failure */ static ReturnValue_t release(TaskHandle_t taskToNotify); @@ -77,7 +77,7 @@ class BinarySemaphoreUsingTask : public SemaphoreIF, public HasReturnvaluesIF { * a higher priority was unblocked. A context switch should be requested * from an ISR if this is the case (see TaskManagement functions) * @return - @c RETURN_OK on success - * - @c RETURN_FAILED on failure + * - @c returnvalue::FAILED on failure */ static ReturnValue_t releaseFromISR(TaskHandle_t taskToNotify, BaseType_t* higherPriorityTaskWoken); diff --git a/src/fsfw/osal/freertos/BinarySemaphore.cpp b/src/fsfw/osal/freertos/BinarySemaphore.cpp index 6e53380c..0ab621bc 100644 --- a/src/fsfw/osal/freertos/BinarySemaphore.cpp +++ b/src/fsfw/osal/freertos/BinarySemaphore.cpp @@ -59,7 +59,7 @@ ReturnValue_t BinarySemaphore::acquireWithTickTimeout(TimeoutType timeoutType, BaseType_t returncode = xSemaphoreTake(handle, timeoutTicks); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SemaphoreIF::SEMAPHORE_TIMEOUT; } @@ -73,7 +73,7 @@ ReturnValue_t BinarySemaphore::release(SemaphoreHandle_t semaphore) { } BaseType_t returncode = xSemaphoreGive(semaphore); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SemaphoreIF::SEMAPHORE_NOT_OWNED; } @@ -91,7 +91,7 @@ ReturnValue_t BinarySemaphore::releaseFromISR(SemaphoreHandle_t semaphore, } BaseType_t returncode = xSemaphoreGiveFromISR(semaphore, higherPriorityTaskWoken); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SemaphoreIF::SEMAPHORE_NOT_OWNED; } diff --git a/src/fsfw/osal/freertos/Clock.cpp b/src/fsfw/osal/freertos/Clock.cpp index cabf7d81..dc00ac7e 100644 --- a/src/fsfw/osal/freertos/Clock.cpp +++ b/src/fsfw/osal/freertos/Clock.cpp @@ -17,7 +17,7 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { timeval time_timeval; ReturnValue_t result = convertTimeOfDayToTimeval(time, &time_timeval); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -31,7 +31,7 @@ ReturnValue_t Clock::setClock(const timeval* time) { Timekeeper::instance()->setOffset(offset); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getClock_timeval(timeval* time) { @@ -41,13 +41,13 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { *time = offset + uptime; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getUptime(timeval* uptime) { *uptime = getUptime(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } timeval Clock::getUptime() { @@ -58,7 +58,7 @@ timeval Clock::getUptime() { ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { timeval uptime = getUptime(); *uptimeMs = uptime.tv_sec * 1000 + uptime.tv_usec / 1000; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // uint32_t Clock::getUptimeSeconds() { @@ -69,17 +69,17 @@ ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { ReturnValue_t Clock::getClock_usecs(uint64_t* time) { timeval time_timeval; ReturnValue_t result = getClock_timeval(&time_timeval); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *time = time_timeval.tv_sec * 1000000 + time_timeval.tv_usec; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { timeval time_timeval; ReturnValue_t result = getClock_timeval(&time_timeval); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } struct tm time_tm; @@ -96,7 +96,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { time->usecond = time_timeval.tv_usec; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) { @@ -115,10 +115,10 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to->tv_sec = seconds; to->tv_usec = from->usecond; // Fails in 2038.. - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) { *JD2000 = (time.tv_sec - 946728000. + time.tv_usec / 1000000.) / 24. / 3600.; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp b/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp index 0e4d967d..f58e1be9 100644 --- a/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp +++ b/src/fsfw/osal/freertos/CountingSemaphUsingTask.cpp @@ -65,7 +65,7 @@ ReturnValue_t CountingSemaphoreUsingTask::acquireWithTickTimeout(TimeoutType tim // Decrement notfication value without resetting it. BaseType_t oldCount = ulTaskNotifyTake(pdFALSE, timeoutTicks); if (getSemaphoreCounter() == oldCount - 1) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SemaphoreIF::SEMAPHORE_TIMEOUT; } @@ -81,10 +81,10 @@ ReturnValue_t CountingSemaphoreUsingTask::release() { ReturnValue_t CountingSemaphoreUsingTask::release(TaskHandle_t taskToNotify) { BaseType_t returncode = xTaskNotifyGive(taskToNotify); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { // This should never happen. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -99,7 +99,7 @@ TaskHandle_t CountingSemaphoreUsingTask::getTaskHandle() { return handle; } ReturnValue_t CountingSemaphoreUsingTask::releaseFromISR(TaskHandle_t taskToNotify, BaseType_t* higherPriorityTaskWoken) { vTaskNotifyGiveFromISR(taskToNotify, higherPriorityTaskWoken); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint8_t CountingSemaphoreUsingTask::getSemaphoreCounterFromISR( diff --git a/src/fsfw/osal/freertos/FixedTimeslotTask.cpp b/src/fsfw/osal/freertos/FixedTimeslotTask.cpp index e86636ab..a0a4ecee 100644 --- a/src/fsfw/osal/freertos/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/freertos/FixedTimeslotTask.cpp @@ -48,7 +48,7 @@ ReturnValue_t FixedTimeslotTask::startTask() { vTaskResume(handle); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } [[noreturn]] void FixedTimeslotTask::taskFunctionality() { @@ -108,7 +108,7 @@ void FixedTimeslotTask::handleMissedDeadline() { ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) { vTaskDelay(pdMS_TO_TICKS(ms)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } TaskHandle_t FixedTimeslotTask::getTaskHandle() { return handle; } diff --git a/src/fsfw/osal/freertos/MessageQueue.cpp b/src/fsfw/osal/freertos/MessageQueue.cpp index d1a7f691..e449ef1e 100644 --- a/src/fsfw/osal/freertos/MessageQueue.cpp +++ b/src/fsfw/osal/freertos/MessageQueue.cpp @@ -48,14 +48,14 @@ ReturnValue_t MessageQueue::handleSendResult(BaseType_t result, bool ignoreFault } return MessageQueueIF::FULL; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { BaseType_t result = xQueueReceive(handle, reinterpret_cast(message->getBuffer()), 0); if (result == pdPASS) { this->last = message->getSender(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return MessageQueueIF::EMPTY; } @@ -65,7 +65,7 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) { // TODO FreeRTOS does not support flushing partially // Is always successful xQueueReset(handle); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // static core function to send messages. diff --git a/src/fsfw/osal/freertos/Mutex.cpp b/src/fsfw/osal/freertos/Mutex.cpp index 1995e1ea..6c264dd6 100644 --- a/src/fsfw/osal/freertos/Mutex.cpp +++ b/src/fsfw/osal/freertos/Mutex.cpp @@ -31,7 +31,7 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { BaseType_t returncode = xSemaphoreTake(handle, timeout); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return MutexIF::MUTEX_TIMEOUT; } @@ -43,7 +43,7 @@ ReturnValue_t Mutex::unlockMutex() { } BaseType_t returncode = xSemaphoreGive(handle); if (returncode == pdPASS) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return MutexIF::CURR_THREAD_DOES_NOT_OWN_MUTEX; } diff --git a/src/fsfw/osal/freertos/PeriodicTask.cpp b/src/fsfw/osal/freertos/PeriodicTask.cpp index 665be06c..2b6a94db 100644 --- a/src/fsfw/osal/freertos/PeriodicTask.cpp +++ b/src/fsfw/osal/freertos/PeriodicTask.cpp @@ -55,12 +55,12 @@ ReturnValue_t PeriodicTask::startTask() { vTaskResume(handle); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) { vTaskDelay(pdMS_TO_TICKS(ms)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } [[noreturn]] void PeriodicTask::taskFunctionality() { diff --git a/src/fsfw/osal/freertos/QueueMapManager.cpp b/src/fsfw/osal/freertos/QueueMapManager.cpp index cb3afb1c..172d9dff 100644 --- a/src/fsfw/osal/freertos/QueueMapManager.cpp +++ b/src/fsfw/osal/freertos/QueueMapManager.cpp @@ -34,12 +34,12 @@ ReturnValue_t QueueMapManager::addMessageQueue(QueueHandle_t queue, MessageQueue "QueueMapManager::addMessageQueue This ID is already " "inside the map!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (id != nullptr) { *id = currentId; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } QueueHandle_t QueueMapManager::getMessageQueue(MessageQueueId_t messageQueueId) const { diff --git a/src/fsfw/osal/freertos/TaskFactory.cpp b/src/fsfw/osal/freertos/TaskFactory.cpp index 7acd812f..c79a6cf1 100644 --- a/src/fsfw/osal/freertos/TaskFactory.cpp +++ b/src/fsfw/osal/freertos/TaskFactory.cpp @@ -31,16 +31,16 @@ ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) { if (task == nullptr) { // delete self vTaskDelete(nullptr); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { // TODO not implemented - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) { vTaskDelay(pdMS_TO_TICKS(delayMs)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TaskFactory::printMissedDeadline() { diff --git a/src/fsfw/osal/host/Clock.cpp b/src/fsfw/osal/host/Clock.cpp index 2f7ede89..29c6c1a6 100644 --- a/src/fsfw/osal/host/Clock.cpp +++ b/src/fsfw/osal/host/Clock.cpp @@ -32,7 +32,7 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { #else sif::printWarning("Clock::setClock: Not implemented for host OSAL\n"); #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::setClock(const timeval* time) { @@ -43,7 +43,7 @@ ReturnValue_t Clock::setClock(const timeval* time) { #else sif::printWarning("Clock::setClock: Not implemented for host OSAL\n"); #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getClock_timeval(timeval* time) { @@ -54,33 +54,33 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { time->tv_sec = std::chrono::duration_cast(epoch).count(); auto fraction = now - secondsChrono; time->tv_usec = std::chrono::duration_cast(fraction).count(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; #elif defined(PLATFORM_UNIX) timespec timeUnix; int status = clock_gettime(CLOCK_REALTIME, &timeUnix); if (status != 0) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } time->tv_sec = timeUnix.tv_sec; time->tv_usec = timeUnix.tv_nsec / 1000.0; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; #else #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::getUptime: Not implemented for found OS!" << std::endl; #else sif::printWarning("Clock::getUptime: Not implemented for found OS!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; #endif } ReturnValue_t Clock::getClock_usecs(uint64_t* time) { if (time == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } using namespace std::chrono; *time = duration_cast(system_clock::now().time_since_epoch()).count(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } timeval Clock::getUptime() { @@ -108,13 +108,13 @@ timeval Clock::getUptime() { ReturnValue_t Clock::getUptime(timeval* uptime) { *uptime = getUptime(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { timeval uptime = getUptime(); *uptimeMs = uptime.tv_sec * 1000 + uptime.tv_usec / 1000; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { @@ -126,7 +126,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { auto fraction = now - seconds; time_t tt = SystemClock::to_time_t(now); ReturnValue_t result = checkOrCreateClockMutex(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } MutexGuard helper(timeMutex); @@ -142,7 +142,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { time->second = timeInfo->tm_sec; auto usecond = std::chrono::duration_cast(fraction); time->usecond = usecond.count(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) { @@ -162,10 +162,10 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to->tv_sec = seconds; to->tv_usec = from->usecond; // Fails in 2038.. - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) { *JD2000 = (time.tv_sec - 946728000. + time.tv_usec / 1000000.) / 24. / 3600.; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/host/FixedTimeslotTask.cpp b/src/fsfw/osal/host/FixedTimeslotTask.cpp index 1d10b8d8..edb2d52d 100644 --- a/src/fsfw/osal/host/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/host/FixedTimeslotTask.cpp @@ -66,12 +66,12 @@ ReturnValue_t FixedTimeslotTask::startTask() { std::lock_guard lock(initMutex); initCondition.notify_one(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) { std::this_thread::sleep_for(std::chrono::milliseconds(ms)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FixedTimeslotTask::taskFunctionality() { diff --git a/src/fsfw/osal/host/MessageQueue.cpp b/src/fsfw/osal/host/MessageQueue.cpp index dad05a5a..a4781cdb 100644 --- a/src/fsfw/osal/host/MessageQueue.cpp +++ b/src/fsfw/osal/host/MessageQueue.cpp @@ -14,7 +14,7 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize, MqArgs* a messageDepth(messageDepth) { queueLock = MutexFactory::instance()->createMutex(); auto result = QueueMapManager::instance()->addMessageQueue(this, &id); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::MessageQueue: Could not be created" << std::endl; #else @@ -40,14 +40,14 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { messageQueue.pop(); // The last partner is the first uint32_t field in the message this->last = message->getSender(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueue::flush(uint32_t* count) { *count = messageQueue.size(); // Clears the queue. messageQueue = std::queue>(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // static core function to send messages. @@ -56,14 +56,14 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, MessageQueueId_t sentFrom, bool ignoreFault) { if (message == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } message->setSender(sentFrom); if (message->getMessageSize() > message->getMaximumMessageSize()) { // Actually, this should never happen or an error will be emitted // in MessageQueueMessage. // But I will still return a failure here. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } auto* targetQueue = dynamic_cast(QueueMapManager::instance()->getMessageQueue(sendTo)); @@ -92,7 +92,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, } return MessageQueueIF::FULL; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueue::lockQueue(MutexIF::TimeoutType timeoutType, dur_millis_t lockTimeout) { diff --git a/src/fsfw/osal/host/Mutex.cpp b/src/fsfw/osal/host/Mutex.cpp index 4b7a9582..2b67c7b5 100644 --- a/src/fsfw/osal/host/Mutex.cpp +++ b/src/fsfw/osal/host/Mutex.cpp @@ -7,15 +7,15 @@ Mutex::Mutex() {} ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { if (timeoutType == TimeoutType::BLOCKING) { mutex.lock(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else if (timeoutType == TimeoutType::POLLING) { if (mutex.try_lock()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } else if (timeoutType == TimeoutType::WAITING) { auto chronoMs = std::chrono::milliseconds(timeoutMs); if (mutex.try_lock_for(chronoMs)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } return MutexIF::MUTEX_TIMEOUT; @@ -23,7 +23,7 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { ReturnValue_t Mutex::unlockMutex() { mutex.unlock(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } std::timed_mutex* Mutex::getMutexHandle() { return &mutex; } diff --git a/src/fsfw/osal/host/PeriodicTask.cpp b/src/fsfw/osal/host/PeriodicTask.cpp index 1f18d335..e16aead0 100644 --- a/src/fsfw/osal/host/PeriodicTask.cpp +++ b/src/fsfw/osal/host/PeriodicTask.cpp @@ -63,12 +63,12 @@ ReturnValue_t PeriodicTask::startTask() { std::lock_guard lock(initMutex); initCondition.notify_one(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) { std::this_thread::sleep_for(std::chrono::milliseconds(ms)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void PeriodicTask::taskFunctionality() { diff --git a/src/fsfw/osal/host/QueueMapManager.cpp b/src/fsfw/osal/host/QueueMapManager.cpp index 301ed131..d7efb0dd 100644 --- a/src/fsfw/osal/host/QueueMapManager.cpp +++ b/src/fsfw/osal/host/QueueMapManager.cpp @@ -39,12 +39,12 @@ ReturnValue_t QueueMapManager::addMessageQueue(MessageQueueIF* queueToInsert, "QueueMapManager::addMessageQueue This ID is already " "inside the map!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (id != nullptr) { *id = currentId; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MessageQueueIF* QueueMapManager::getMessageQueue(MessageQueueId_t messageQueueId) const { diff --git a/src/fsfw/osal/host/TaskFactory.cpp b/src/fsfw/osal/host/TaskFactory.cpp index ec4c1554..e9415f5a 100644 --- a/src/fsfw/osal/host/TaskFactory.cpp +++ b/src/fsfw/osal/host/TaskFactory.cpp @@ -37,12 +37,12 @@ FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask( ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) { // This might block for some time! delete task; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) { std::this_thread::sleep_for(std::chrono::milliseconds(delayMs)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TaskFactory::printMissedDeadline() { diff --git a/src/fsfw/osal/host/taskHelpers.cpp b/src/fsfw/osal/host/taskHelpers.cpp index 432cf30c..e5a931ed 100644 --- a/src/fsfw/osal/host/taskHelpers.cpp +++ b/src/fsfw/osal/host/taskHelpers.cpp @@ -10,9 +10,9 @@ ReturnValue_t tasks::insertTaskName(std::thread::id threadId, const std::string& std::lock_guard lg(nameMapLock); auto returnPair = taskNameMap.emplace(threadId, taskName); if (not returnPair.second) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } std::string tasks::getTaskName(std::thread::id threadId) { diff --git a/src/fsfw/osal/linux/BinarySemaphore.cpp b/src/fsfw/osal/linux/BinarySemaphore.cpp index 4fb67f15..9b954d6c 100644 --- a/src/fsfw/osal/linux/BinarySemaphore.cpp +++ b/src/fsfw/osal/linux/BinarySemaphore.cpp @@ -43,7 +43,7 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType, uint32_t timeout } } if (result == 0) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } switch (errno) { @@ -62,10 +62,10 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType, uint32_t timeout case (EINTR): { // Call was interrupted by signal handler utility::printUnixErrorGeneric(CLASS_NAME, "acquire", "EINTR"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -73,13 +73,13 @@ ReturnValue_t BinarySemaphore::release() { return BinarySemaphore::release(&this ReturnValue_t BinarySemaphore::release(sem_t* handle) { ReturnValue_t countResult = checkCount(handle, 1); - if (countResult != HasReturnvaluesIF::RETURN_OK) { + if (countResult != returnvalue::OK) { return countResult; } int result = sem_post(handle); if (result == 0) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } switch (errno) { @@ -91,10 +91,10 @@ ReturnValue_t BinarySemaphore::release(sem_t* handle) { case (EOVERFLOW): { // SEM_MAX_VALUE overflow. This should never happen utility::printUnixErrorGeneric(CLASS_NAME, "release", "EOVERFLOW"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -145,9 +145,9 @@ ReturnValue_t BinarySemaphore::checkCount(sem_t* handle, uint8_t maxCount) { // This is a config error use lightweight printf is this is called // from an interrupt printf("BinarySemaphore::release: Value of binary semaphore greater than 1!\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return SemaphoreIF::SEMAPHORE_NOT_OWNED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/linux/Clock.cpp b/src/fsfw/osal/linux/Clock.cpp index a173bbc5..5afecb59 100644 --- a/src/fsfw/osal/linux/Clock.cpp +++ b/src/fsfw/osal/linux/Clock.cpp @@ -25,9 +25,9 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { int status = clock_settime(CLOCK_REALTIME, &timeUnix); if (status != 0) { // TODO errno - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::setClock(const timeval* time) { @@ -37,37 +37,37 @@ ReturnValue_t Clock::setClock(const timeval* time) { int status = clock_settime(CLOCK_REALTIME, &timeUnix); if (status != 0) { // TODO errno - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getClock_timeval(timeval* time) { timespec timeUnix{}; int status = clock_gettime(CLOCK_REALTIME, &timeUnix); if (status != 0) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } time->tv_sec = timeUnix.tv_sec; time->tv_usec = timeUnix.tv_nsec / 1000.0; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getClock_usecs(uint64_t* time) { timeval timeVal{}; ReturnValue_t result = getClock_timeval(&timeVal); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *time = static_cast(timeVal.tv_sec) * 1e6 + timeVal.tv_usec; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } timeval Clock::getUptime() { timeval uptime{}; auto result = getUptime(&uptime); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Clock::getUptime: Error getting uptime" << std::endl; #endif @@ -83,7 +83,7 @@ ReturnValue_t Clock::getUptime(timeval* uptime) { uptime->tv_sec = uptimeSeconds; uptime->tv_usec = uptimeSeconds * (double)1e6 - (uptime->tv_sec * 1e6); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // Wait for new FSFW Clock function delivering seconds uptime. @@ -92,7 +92,7 @@ ReturnValue_t Clock::getUptime(timeval* uptime) { // struct sysinfo sysInfo; // int result = sysinfo(&sysInfo); // if(result != 0){ -// return HasReturnvaluesIF::RETURN_FAILED; +// return HasReturnvaluesIF::returnvalue::FAILED; // } // return sysInfo.uptime; //} @@ -100,11 +100,11 @@ ReturnValue_t Clock::getUptime(timeval* uptime) { ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { timeval uptime{}; ReturnValue_t result = getUptime(&uptime); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *uptimeMs = uptime.tv_sec * 1e3 + uptime.tv_usec / 1e3; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { @@ -112,10 +112,10 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { int status = clock_gettime(CLOCK_REALTIME, &timeUnix); if (status != 0) { // TODO errno - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t result = checkOrCreateClockMutex(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } MutexGuard helper(timeMutex); @@ -131,7 +131,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { time->second = timeInfo->tm_sec; time->usecond = timeUnix.tv_nsec / 1000.0; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) { @@ -147,10 +147,10 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to->tv_sec = timegm(&fromTm); to->tv_usec = from->usecond; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) { *JD2000 = (time.tv_sec - 946728000. + time.tv_usec / 1000000.) / 24. / 3600.; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/linux/CountingSemaphore.cpp b/src/fsfw/osal/linux/CountingSemaphore.cpp index 78210996..e2b006d9 100644 --- a/src/fsfw/osal/linux/CountingSemaphore.cpp +++ b/src/fsfw/osal/linux/CountingSemaphore.cpp @@ -35,7 +35,7 @@ CountingSemaphore& CountingSemaphore::operator=(CountingSemaphore&& other) { ReturnValue_t CountingSemaphore::release() { ReturnValue_t result = checkCount(&handle, maxCount); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return CountingSemaphore::release(&this->handle); @@ -44,7 +44,7 @@ ReturnValue_t CountingSemaphore::release() { ReturnValue_t CountingSemaphore::release(sem_t* handle) { int result = sem_post(handle); if (result == 0) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } switch (errno) { @@ -61,7 +61,7 @@ ReturnValue_t CountingSemaphore::release(sem_t* handle) { } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/linux/FixedTimeslotTask.cpp b/src/fsfw/osal/linux/FixedTimeslotTask.cpp index 156413ea..34729c22 100644 --- a/src/fsfw/osal/linux/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/linux/FixedTimeslotTask.cpp @@ -23,7 +23,7 @@ void* FixedTimeslotTask::taskEntryPoint(void* arg) { ReturnValue_t FixedTimeslotTask::startTask() { started = true; posixThread.createTask(&taskEntryPoint, this); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) { diff --git a/src/fsfw/osal/linux/InternalErrorCodes.cpp b/src/fsfw/osal/linux/InternalErrorCodes.cpp index 11913906..41472b0c 100644 --- a/src/fsfw/osal/linux/InternalErrorCodes.cpp +++ b/src/fsfw/osal/linux/InternalErrorCodes.cpp @@ -2,7 +2,7 @@ ReturnValue_t InternalErrorCodes::translate(uint8_t code) { // TODO This class can be removed - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } InternalErrorCodes::InternalErrorCodes() {} diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index ec212165..b2cca3f1 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -54,7 +54,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { "nullptr!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (message->getMaximumMessageSize() < maxMessageSize) { @@ -62,7 +62,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { sif::error << "MessageQueue::receiveMessage: Message size " << message->getMaximumMessageSize() << " too small to receive data!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } unsigned int messagePriority = 0; @@ -72,9 +72,9 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { this->last = message->getSender(); // Check size of incoming message. if (message->getMessageSize() < message->getMinimumMessageSize()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else if (status == 0) { // Success but no message received return MessageQueueIF::EMPTY; @@ -131,9 +131,9 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -152,9 +152,9 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) { utility::printUnixErrorGeneric(CLASS_NAME, "flush", "EINVAL"); break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *count = attrib.mq_curmsgs; attrib.mq_curmsgs = 0; @@ -176,11 +176,11 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) { utility::printUnixErrorGeneric(CLASS_NAME, "flush", "EINVAL"); break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, @@ -200,7 +200,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, #else sif::printError("MessageQueue::sendMessageFromMessageQueue: Message is nullptr\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } message->setSender(sentFrom); @@ -257,11 +257,11 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, utility::printUnixErrorGeneric(CLASS_NAME, "sendMessageFromMessageQueue", "EMSGSIZE"); break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messageDepth) { @@ -320,7 +320,7 @@ ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messag if (tempId != -1) { // Successful mq_open this->id = tempId; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } break; @@ -331,5 +331,5 @@ ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messag utility::printUnixErrorGeneric(CLASS_NAME, "MessageQueue", "Unknown"); } } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } diff --git a/src/fsfw/osal/linux/Mutex.cpp b/src/fsfw/osal/linux/Mutex.cpp index 2698fb54..be7a0a85 100644 --- a/src/fsfw/osal/linux/Mutex.cpp +++ b/src/fsfw/osal/linux/Mutex.cpp @@ -82,9 +82,9 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { return CURR_THREAD_ALREADY_OWNS_MUTEX; case 0: // Success - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; }; } @@ -103,8 +103,8 @@ ReturnValue_t Mutex::unlockMutex() { return CURR_THREAD_DOES_NOT_OWN_MUTEX; case 0: // Success - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; }; } diff --git a/src/fsfw/osal/linux/PeriodicPosixTask.cpp b/src/fsfw/osal/linux/PeriodicPosixTask.cpp index 09b106ed..556a0367 100644 --- a/src/fsfw/osal/linux/PeriodicPosixTask.cpp +++ b/src/fsfw/osal/linux/PeriodicPosixTask.cpp @@ -23,11 +23,11 @@ ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) { ReturnValue_t PeriodicPosixTask::startTask() { if (isEmpty()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } started = true; posixThread.createTask(&taskEntryPoint, this); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } [[noreturn]] void PeriodicPosixTask::taskFunctionality() { diff --git a/src/fsfw/osal/linux/PosixThread.cpp b/src/fsfw/osal/linux/PosixThread.cpp index 9fc088ae..811d58e2 100644 --- a/src/fsfw/osal/linux/PosixThread.cpp +++ b/src/fsfw/osal/linux/PosixThread.cpp @@ -29,16 +29,16 @@ ReturnValue_t PosixThread::sleep(uint64_t ns) { switch (errno) { case EINTR: // The nanosleep() function was interrupted by a signal. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case EINVAL: // The rqtp argument specified a nanosecond value less than zero or // greater than or equal to 1000 million. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void PosixThread::suspend() { diff --git a/src/fsfw/osal/linux/TaskFactory.cpp b/src/fsfw/osal/linux/TaskFactory.cpp index a28e685d..2cd4fd67 100644 --- a/src/fsfw/osal/linux/TaskFactory.cpp +++ b/src/fsfw/osal/linux/TaskFactory.cpp @@ -28,7 +28,7 @@ FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask( ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) { // TODO not implemented - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) { diff --git a/src/fsfw/osal/rtems/BinarySemaphore.cpp b/src/fsfw/osal/rtems/BinarySemaphore.cpp index 06b0bf77..3677dd22 100644 --- a/src/fsfw/osal/rtems/BinarySemaphore.cpp +++ b/src/fsfw/osal/rtems/BinarySemaphore.cpp @@ -7,9 +7,9 @@ BinarySemaphore::BinarySemaphore() {} BinarySemaphore::~BinarySemaphore() {} ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType, uint32_t timeoutMs) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } -ReturnValue_t BinarySemaphore::release() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t BinarySemaphore::release() { return returnvalue::OK; } uint8_t BinarySemaphore::getSemaphoreCounter() const { return 0; } diff --git a/src/fsfw/osal/rtems/Clock.cpp b/src/fsfw/osal/rtems/Clock.cpp index 831c67d4..cb7bd042 100644 --- a/src/fsfw/osal/rtems/Clock.cpp +++ b/src/fsfw/osal/rtems/Clock.cpp @@ -23,13 +23,13 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { rtems_status_code status = rtems_clock_set(&timeRtems); switch (status) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_INVALID_ADDRESS: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_CLOCK: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -38,7 +38,7 @@ ReturnValue_t Clock::setClock(const timeval* time) { newTime.tv_sec = time->tv_sec; if (time->tv_usec < 0) { // better returnvalue. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } newTime.tv_nsec = time->tv_usec * TOD_NANOSECONDS_PER_MICROSECOND; @@ -48,10 +48,10 @@ ReturnValue_t Clock::setClock(const timeval* time) { Status_Control status = _TOD_Set(&newTime, &context); _TOD_Unlock(); if (status == STATUS_SUCCESSFUL) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } // better returnvalue - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t Clock::getClock_timeval(timeval* time) { @@ -59,11 +59,11 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { rtems_status_code status = rtems_clock_get_tod_timeval(time); switch (status) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_NOT_DEFINED: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -77,16 +77,16 @@ ReturnValue_t Clock::getUptime(timeval* uptime) { uptime->tv_usec = time.tv_nsec; switch (status) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { // This counter overflows after 50 days *uptimeMs = rtems_clock_get_ticks_since_boot(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getClock_usecs(uint64_t* time) { @@ -95,9 +95,9 @@ ReturnValue_t Clock::getClock_usecs(uint64_t* time) { *time = ((uint64_t)temp_time.tv_sec * 1000000) + temp_time.tv_usec; switch (returnValue) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -118,16 +118,16 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { time->usecond = static_cast(timeRtems.ticks) / rtems_clock_get_ticks_per_second() * 1e6; time->year = timeRtems.year; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case RTEMS_NOT_DEFINED: /* System date and time is not set */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_ADDRESS: /* time_buffer is NULL */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -143,10 +143,10 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* timeRtems.ticks = from->usecond * getTicksPerSecond() / 1e6; to->tv_sec = _TOD_To_seconds(&timeRtems); to->tv_usec = from->usecond; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) { *JD2000 = (time.tv_sec - 946728000. + time.tv_usec / 1000000.) / 24. / 3600.; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/rtems/CpuUsage.cpp b/src/fsfw/osal/rtems/CpuUsage.cpp index 2613a698..4ffc2271 100644 --- a/src/fsfw/osal/rtems/CpuUsage.cpp +++ b/src/fsfw/osal/rtems/CpuUsage.cpp @@ -86,7 +86,7 @@ ReturnValue_t CpuUsage::serialize(uint8_t** buffer, size_t* size, size_t maxSize Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&timeSinceLastReset, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerialArrayListAdapter::serialize(&threadData, buffer, size, maxSize, @@ -106,7 +106,7 @@ ReturnValue_t CpuUsage::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&timeSinceLastReset, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerialArrayListAdapter::deSerialize(&threadData, buffer, size, @@ -116,7 +116,7 @@ ReturnValue_t CpuUsage::deSerialize(const uint8_t** buffer, size_t* size, ReturnValue_t CpuUsage::ThreadData::serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&id, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size + MAX_LENGTH_OF_THREAD_NAME > maxSize) { @@ -126,14 +126,14 @@ ReturnValue_t CpuUsage::ThreadData::serialize(uint8_t** buffer, size_t* size, si *size += MAX_LENGTH_OF_THREAD_NAME; *buffer += MAX_LENGTH_OF_THREAD_NAME; result = SerializeAdapter::serialize(&timeRunning, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&percentUsage, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint32_t CpuUsage::ThreadData::getSerializedSize() const { @@ -150,7 +150,7 @@ uint32_t CpuUsage::ThreadData::getSerializedSize() const { ReturnValue_t CpuUsage::ThreadData::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&id, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (*size < MAX_LENGTH_OF_THREAD_NAME) { @@ -159,12 +159,12 @@ ReturnValue_t CpuUsage::ThreadData::deSerialize(const uint8_t** buffer, size_t* memcpy(name, *buffer, MAX_LENGTH_OF_THREAD_NAME); *buffer -= MAX_LENGTH_OF_THREAD_NAME; result = SerializeAdapter::deSerialize(&timeRunning, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&percentUsage, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/osal/rtems/FixedTimeslotTask.cpp b/src/fsfw/osal/rtems/FixedTimeslotTask.cpp index f400c213..77582d75 100644 --- a/src/fsfw/osal/rtems/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/rtems/FixedTimeslotTask.cpp @@ -48,14 +48,14 @@ ReturnValue_t FixedTimeslotTask::startTask() { switch (status) { case RTEMS_SUCCESSFUL: // ask started successfully - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: /* RTEMS_INVALID_ADDRESS - invalid task entry point RTEMS_INVALID_ID - invalid task id RTEMS_INCORRECT_STATE - task not in the dormant state RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/InternalErrorCodes.cpp b/src/fsfw/osal/rtems/InternalErrorCodes.cpp index 4d78186c..9e0c1ae7 100644 --- a/src/fsfw/osal/rtems/InternalErrorCodes.cpp +++ b/src/fsfw/osal/rtems/InternalErrorCodes.cpp @@ -50,7 +50,7 @@ ReturnValue_t InternalErrorCodes::translate(uint8_t code) { // case INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0: // return UNLIMITED_AND_MAXIMUM_IS_0; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/MessageQueue.cpp b/src/fsfw/osal/rtems/MessageQueue.cpp index 534015dc..bae3b5e0 100644 --- a/src/fsfw/osal/rtems/MessageQueue.cpp +++ b/src/fsfw/osal/rtems/MessageQueue.cpp @@ -32,7 +32,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { this->last = message->getSender(); // Check size of incoming message. if (message->getMessageSize() < message->getMinimumMessageSize()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } else { // No message was received. Keep lastPartner anyway, I might send something later. @@ -66,7 +66,7 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo, MessageQueu ReturnValue_t returnCode = convertReturnCode(result); if (returnCode == MessageQueueIF::EMPTY) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return returnCode; @@ -75,23 +75,23 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo, MessageQueu ReturnValue_t MessageQueue::convertReturnCode(rtems_status_code inValue) { switch (inValue) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_INVALID_ID: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_TIMEOUT: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_OBJECT_WAS_DELETED: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_ADDRESS: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_SIZE: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_TOO_MANY: return MessageQueueIF::FULL; case RTEMS_UNSATISFIED: return MessageQueueIF::EMPTY; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/Mutex.cpp b/src/fsfw/osal/rtems/Mutex.cpp index 94f0041e..eb1a3718 100644 --- a/src/fsfw/osal/rtems/Mutex.cpp +++ b/src/fsfw/osal/rtems/Mutex.cpp @@ -43,7 +43,7 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType = TimeoutType::BLOCKING, switch (status) { case RTEMS_SUCCESSFUL: // semaphore obtained successfully - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_UNSATISFIED: // semaphore not available return MUTEX_NOT_FOUND; @@ -57,7 +57,7 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType = TimeoutType::BLOCKING, // invalid semaphore id return MUTEX_INVALID_ID; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -66,7 +66,7 @@ ReturnValue_t Mutex::unlockMutex() { switch (status) { case RTEMS_SUCCESSFUL: // semaphore obtained successfully - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_NOT_OWNER_OF_RESOURCE: // semaphore not available return CURR_THREAD_DOES_NOT_OWN_MUTEX; @@ -74,6 +74,6 @@ ReturnValue_t Mutex::unlockMutex() { // invalid semaphore id return MUTEX_INVALID_ID; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/PeriodicTask.cpp b/src/fsfw/osal/rtems/PeriodicTask.cpp index cccf937f..5c397815 100644 --- a/src/fsfw/osal/rtems/PeriodicTask.cpp +++ b/src/fsfw/osal/rtems/PeriodicTask.cpp @@ -37,13 +37,13 @@ ReturnValue_t PeriodicTask::startTask() { switch (status) { case RTEMS_SUCCESSFUL: /* Task started successfully */ - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: /* RTEMS_INVALID_ADDRESS - invalid task entry point RTEMS_INVALID_ID - invalid task id RTEMS_INCORRECT_STATE - task not in the dormant state RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/QueueFactory.cpp b/src/fsfw/osal/rtems/QueueFactory.cpp index 074ce273..1918f7bc 100644 --- a/src/fsfw/osal/rtems/QueueFactory.cpp +++ b/src/fsfw/osal/rtems/QueueFactory.cpp @@ -16,25 +16,25 @@ ReturnValue_t MessageQueueSenderIF::sendMessage(MessageQueueId_t sendTo, switch (result) { case RTEMS_SUCCESSFUL: // message sent successfully - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_INVALID_ID: // invalid queue id - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_SIZE: // invalid message size - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_ADDRESS: // buffer is NULL - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_UNSATISFIED: // out of message buffers - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_TOO_MANY: // queue's limit has been reached return MessageQueueIF::FULL; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/RTEMSTaskBase.cpp b/src/fsfw/osal/rtems/RTEMSTaskBase.cpp index a306b9e2..b235f6a0 100644 --- a/src/fsfw/osal/rtems/RTEMSTaskBase.cpp +++ b/src/fsfw/osal/rtems/RTEMSTaskBase.cpp @@ -21,7 +21,7 @@ RTEMSTaskBase::RTEMSTaskBase(rtems_task_priority set_priority, size_t stack_size RTEMS_FLOATING_POINT, &id); } ReturnValue_t result = convertReturnCode(status); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TaskBase::TaskBase: createTask with name " << std::hex << osalName << std::dec << " failed with return code " << (uint32_t)status << std::endl; @@ -42,21 +42,21 @@ ReturnValue_t RTEMSTaskBase::sleepFor(uint32_t ms) { ReturnValue_t RTEMSTaskBase::convertReturnCode(rtems_status_code inValue) { switch (inValue) { case RTEMS_SUCCESSFUL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case RTEMS_MP_NOT_CONFIGURED: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_NAME: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_TOO_MANY: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_ADDRESS: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_UNSATISFIED: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; case RTEMS_INVALID_PRIORITY: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/osal/rtems/TaskFactory.cpp b/src/fsfw/osal/rtems/TaskFactory.cpp index fb52eb0e..f10e5cf3 100644 --- a/src/fsfw/osal/rtems/TaskFactory.cpp +++ b/src/fsfw/osal/rtems/TaskFactory.cpp @@ -31,13 +31,13 @@ FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask( ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) { // This should call the OS specific destructor delete (dynamic_cast(task)); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) { rtems_task_wake_after(RtemsBasic::convertMsToTicks(delayMs)); // Only return value is "RTEMS_SUCCESSFUL - always successful" so it has been neglected - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TaskFactory::printMissedDeadline() { diff --git a/src/fsfw/osal/windows/winTaskHelpers.cpp b/src/fsfw/osal/windows/winTaskHelpers.cpp index c863c4ca..206ee7a7 100644 --- a/src/fsfw/osal/windows/winTaskHelpers.cpp +++ b/src/fsfw/osal/windows/winTaskHelpers.cpp @@ -89,7 +89,7 @@ ReturnValue_t tasks::setTaskPriority(HANDLE nativeHandle, TaskPriority priority) #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; #endif } result = SetThreadPriority(reinterpret_cast(nativeHandle), nPriorityNumber); @@ -97,8 +97,8 @@ ReturnValue_t tasks::setTaskPriority(HANDLE nativeHandle, TaskPriority priority) #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; #endif } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/parameters/ParameterHelper.cpp b/src/fsfw/parameters/ParameterHelper.cpp index 58356af5..ba0e70a4 100644 --- a/src/fsfw/parameters/ParameterHelper.cpp +++ b/src/fsfw/parameters/ParameterHelper.cpp @@ -10,10 +10,10 @@ ParameterHelper::~ParameterHelper() {} ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { if (storage == nullptr) { // ParameterHelper was not initialized - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; switch (message->getCommand()) { case ParameterMessage::CMD_PARAMETER_DUMP: { ParameterWrapper description; @@ -21,7 +21,7 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { uint8_t uniqueIdentifier = HasParametersIF::getUniqueIdentifierId(ParameterMessage::getParameterId(message)); result = owner->getParameter(domain, uniqueIdentifier, &description, &description, 0); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { result = sendParameter(message->getSender(), ParameterMessage::getParameterId(message), &description); } @@ -42,7 +42,7 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { ConstStorageAccessor accessor(storeId); result = storage->getData(storeId, accessor); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ParameterHelper::handleParameterMessage: Getting" << " store data failed for load command." << std::endl; @@ -52,19 +52,19 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { ParameterWrapper streamWrapper; result = streamWrapper.set(type, rows, columns, accessor.data(), accessor.size()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } ParameterWrapper ownerWrapper; result = owner->getParameter(domain, uniqueIdentifier, &ownerWrapper, &streamWrapper, linearIndex); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = ownerWrapper.copyFrom(&streamWrapper, linearIndex); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -73,14 +73,14 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) { break; } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { rejectCommand(message->getSender(), result, message->getCommand()); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id, @@ -91,7 +91,7 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id, store_address_t address; ReturnValue_t result = storage->getFreeElement(&address, serializedSize, &storeElement); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -100,7 +100,7 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id, result = description->serialize(&storeElement, &storeElementSize, serializedSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { storage->deleteData(address); return result; } @@ -111,7 +111,7 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id, MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ParameterHelper::initialize() { @@ -121,7 +121,7 @@ ReturnValue_t ParameterHelper::initialize() { if (storage == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason, diff --git a/src/fsfw/parameters/ParameterWrapper.cpp b/src/fsfw/parameters/ParameterWrapper.cpp index 27552290..522a68b1 100644 --- a/src/fsfw/parameters/ParameterWrapper.cpp +++ b/src/fsfw/parameters/ParameterWrapper.cpp @@ -28,16 +28,16 @@ ReturnValue_t ParameterWrapper::serialize(uint8_t **buffer, size_t *size, size_t ReturnValue_t result; result = SerializeAdapter::serialize(&type, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&columns, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&rows, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -91,11 +91,11 @@ template ReturnValue_t ParameterWrapper::serializeData(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { const T *element = (const T *)readonlyData; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; uint16_t dataSize = columns * rows; while (dataSize != 0) { result = SerializeAdapter::serialize(element, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } element++; @@ -112,7 +112,7 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow, uint8_t sta const uint8_t *fromAsStream = reinterpret_cast(from); size_t streamSize = fromRows * fromColumns * sizeof(T); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; for (uint8_t fromRow = 0; fromRow < fromRows; fromRow++) { // get the start element of this row in data @@ -122,7 +122,7 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow, uint8_t sta for (uint8_t fromColumn = 0; fromColumn < fromColumns; fromColumn++) { result = SerializeAdapter::deSerialize(dataWithDataType + fromColumn, &fromAsStream, &streamSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -142,7 +142,7 @@ ReturnValue_t ParameterWrapper::deSerialize(const uint8_t **buffer, size_t *size ParameterWrapper streamDescription; ReturnValue_t result = streamDescription.set(*buffer, *size, buffer, size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -163,24 +163,24 @@ ReturnValue_t ParameterWrapper::set(Type type, uint8_t rows, uint8_t columns, co this->data = nullptr; this->readonlyData = data; pointsToStream = true; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize, const uint8_t **remainingStream, size_t *remainingSize) { ReturnValue_t result = SerializeAdapter::deSerialize(&type, &stream, &streamSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&columns, &stream, &streamSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&rows, &stream, &streamSize, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -203,7 +203,7 @@ ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize, *remainingSize = streamSize; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from, @@ -265,7 +265,7 @@ ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from, uint8_t typeSize = type.getSize(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; // copy data if (from->pointsToStream) { switch (type) { diff --git a/src/fsfw/parameters/ParameterWrapper.h b/src/fsfw/parameters/ParameterWrapper.h index 873db7b2..3b04199a 100644 --- a/src/fsfw/parameters/ParameterWrapper.h +++ b/src/fsfw/parameters/ParameterWrapper.h @@ -185,7 +185,7 @@ inline ReturnValue_t ParameterWrapper::getElement(T *value, uint8_t row, uint8_t } else { const T *dataWithType = static_cast(readonlyData); *value = dataWithType[row * columns + column]; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } diff --git a/src/fsfw/power/DummyPowerSwitcher.cpp b/src/fsfw/power/DummyPowerSwitcher.cpp index 48ab22c6..952a5a57 100644 --- a/src/fsfw/power/DummyPowerSwitcher.cpp +++ b/src/fsfw/power/DummyPowerSwitcher.cpp @@ -20,28 +20,28 @@ ReturnValue_t DummyPowerSwitcher::sendSwitchCommand(power::Switch_t switchNr, Re if (switchNr < switcherList.size()) { switcherList[switchNr] = onOff; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t DummyPowerSwitcher::sendFuseOnCommand(uint8_t fuseNr) { if (fuseNr < fuseList.size()) { fuseList[fuseNr] = FUSE_ON; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t DummyPowerSwitcher::getSwitchState(power::Switch_t switchNr) const { if (switchNr < switcherList.size()) { return switcherList[switchNr]; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t DummyPowerSwitcher::getFuseState(uint8_t fuseNr) const { if (fuseNr < fuseList.size()) { return fuseList[fuseNr]; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint32_t DummyPowerSwitcher::getSwitchDelayMs(void) const { return switchDelayMs; } diff --git a/src/fsfw/power/Fuse.cpp b/src/fsfw/power/Fuse.cpp index 81b51c89..73b29452 100644 --- a/src/fsfw/power/Fuse.cpp +++ b/src/fsfw/power/Fuse.cpp @@ -32,22 +32,22 @@ void Fuse::addDevice(PowerComponentIF* switchSet) { devices.push_back(switchSet) ReturnValue_t Fuse::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = parameterHelper.initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } powerIF = ObjectManager::instance()->get(powerSwitchId); if (powerIF == NULL) { - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } void Fuse::calculatePowerLimits(float* low, float* high) { @@ -66,7 +66,7 @@ ReturnValue_t Fuse::check() { set.setValidity(false, true); return set.commit(); } - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; checkFuseState(); calculateFusePower(); // Check if power is valid and if fuse state is off or invalid. @@ -89,14 +89,14 @@ ReturnValue_t Fuse::check() { ReturnValue_t Fuse::serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (DeviceList::const_iterator iter = devices.begin(); iter != devices.end(); iter++) { result = (*iter)->serialize(buffer, size, maxSize, streamEndianness); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } } - return RETURN_OK; + return returnvalue::OK; } size_t Fuse::getSerializedSize() const { @@ -108,21 +108,21 @@ size_t Fuse::getSerializedSize() const { } ReturnValue_t Fuse::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { - ReturnValue_t result = RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; for (DeviceList::iterator iter = devices.begin(); iter != devices.end(); iter++) { result = (*iter)->deSerialize(buffer, size, streamEndianness); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } } - return RETURN_OK; + return returnvalue::OK; } uint8_t Fuse::getFuseId() const { return fuseId; } void Fuse::calculateFusePower() { ReturnValue_t result1 = currentLimit.check(); - if (result1 != HasReturnvaluesIF::RETURN_OK || !(voltage.isValid())) { + if (result1 != returnvalue::OK || !(voltage.isValid())) { power.setValid(PoolVariableIF::INVALID); return; } @@ -133,7 +133,7 @@ void Fuse::calculateFusePower() { ReturnValue_t Fuse::performOperation(uint8_t opCode) { checkCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void Fuse::reportEvents(Event event) { @@ -157,15 +157,15 @@ void Fuse::setAllMonitorsToUnchecked() { void Fuse::checkCommandQueue() { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } result = healthHelper.handleHealthCommand(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } result = parameterHelper.handleParameterMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } command.setToUnknownCommand(); @@ -227,7 +227,7 @@ bool Fuse::isPowerValid() { return power.isValid(); } ReturnValue_t Fuse::setHealth(HealthState health) { healthHelper.setHealth(health); - return RETURN_OK; + return returnvalue::OK; } HasHealthIF::HealthState Fuse::getHealth() { return healthHelper.getHealth(); } @@ -238,6 +238,6 @@ ReturnValue_t Fuse::PowerMonitor::checkPower(float sample, float lowerLimit, flo } else if (sample < lowerLimit) { return this->monitorStateIs(MonitoringIF::BELOW_LOW_LIMIT, sample, lowerLimit); } else { - return this->monitorStateIs(RETURN_OK, sample, 0.0); // Within limits. + return this->monitorStateIs(returnvalue::OK, sample, 0.0); // Within limits. } } diff --git a/src/fsfw/power/Fuse.h b/src/fsfw/power/Fuse.h index 43896f75..1f880f3a 100644 --- a/src/fsfw/power/Fuse.h +++ b/src/fsfw/power/Fuse.h @@ -16,7 +16,6 @@ void setStaticFrameworkObjectIds(); class Fuse : public SystemObject, public HasHealthIF, - public HasReturnvaluesIF, public ReceivesParameterMessagesIF, public SerializeIF { friend void(Factory::setStaticFrameworkObjectIds)(); diff --git a/src/fsfw/power/PowerComponent.cpp b/src/fsfw/power/PowerComponent.cpp index e4c336c7..fd780841 100644 --- a/src/fsfw/power/PowerComponent.cpp +++ b/src/fsfw/power/PowerComponent.cpp @@ -18,7 +18,7 @@ ReturnValue_t PowerComponent::serialize(uint8_t** buffer, size_t* size, size_t m Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&minPower, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::serialize(&maxPower, buffer, size, maxSize, streamEndianness); @@ -41,7 +41,7 @@ float PowerComponent::getMax() { return maxPower; } ReturnValue_t PowerComponent::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&minPower, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::deSerialize(&maxPower, buffer, size, streamEndianness); @@ -64,5 +64,5 @@ ReturnValue_t PowerComponent::getParameter(uint8_t domainId, uint8_t uniqueId, default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/power/PowerSensor.cpp b/src/fsfw/power/PowerSensor.cpp index 08ff4724..69c9e272 100644 --- a/src/fsfw/power/PowerSensor.cpp +++ b/src/fsfw/power/PowerSensor.cpp @@ -22,8 +22,8 @@ PowerSensor::~PowerSensor() { QueueFactory::instance()->deleteMessageQueue(comma ReturnValue_t PowerSensor::calculatePower() { powerSensorSet.read(); - ReturnValue_t result1 = HasReturnvaluesIF::RETURN_FAILED; - ReturnValue_t result2 = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result1 = returnvalue::FAILED; + ReturnValue_t result2 = returnvalue::FAILED; if (healthHelper.healthTable->isHealthy(getObjectId()) && voltage.isValid() && current.isValid()) { result1 = voltageLimit.doCheck(voltage.value); @@ -33,7 +33,7 @@ ReturnValue_t PowerSensor::calculatePower() { currentLimit.setToInvalid(); result1 = OBJECT_NOT_HEALTHY; } - if (result1 != HasReturnvaluesIF::RETURN_OK || result2 != HasReturnvaluesIF::RETURN_OK) { + if (result1 != returnvalue::OK || result2 != returnvalue::OK) { result1 = MonitoringIF::INVALID; power.setValid(PoolVariableIF::INVALID); } else { @@ -46,22 +46,22 @@ ReturnValue_t PowerSensor::calculatePower() { ReturnValue_t PowerSensor::performOperation(uint8_t opCode) { checkCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MessageQueueId_t PowerSensor::getCommandQueue() const { return commandQueue->getId(); } ReturnValue_t PowerSensor::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = parameterHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return result; @@ -75,15 +75,15 @@ void PowerSensor::setAllMonitorsToUnchecked() { void PowerSensor::checkCommandQueue() { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } result = healthHelper.handleHealthCommand(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } result = parameterHelper.handleParameterMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } command.setToUnknownCommand(); @@ -106,7 +106,7 @@ float PowerSensor::getPower() { ReturnValue_t PowerSensor::setHealth(HealthState health) { healthHelper.setHealth(health); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } HasHealthIF::HealthState PowerSensor::getHealth() { return healthHelper.getHealth(); } diff --git a/src/fsfw/power/PowerSwitchIF.h b/src/fsfw/power/PowerSwitchIF.h index bc883fbc..054923f4 100644 --- a/src/fsfw/power/PowerSwitchIF.h +++ b/src/fsfw/power/PowerSwitchIF.h @@ -13,7 +13,7 @@ * because they can be called asynchronosuly (const ending). * @ingroup interfaces */ -class PowerSwitchIF : public HasReturnvaluesIF { +class PowerSwitchIF { public: /** * Empty dtor. @@ -50,7 +50,7 @@ class PowerSwitchIF : public HasReturnvaluesIF { * @return * - @c SWITCH_ON if the specified switch is on. * - @c SWITCH_OFF if the specified switch is off. - * - @c RETURN_FAILED if an error occured + * - @c returnvalue::FAILED if an error occured */ virtual ReturnValue_t getSwitchState(power::Switch_t switchNr) const = 0; /** @@ -59,7 +59,7 @@ class PowerSwitchIF : public HasReturnvaluesIF { * @return * - @c FUSE_ON if the specified fuse is on. * - @c FUSE_OFF if the specified fuse is off. - * - @c RETURN_FAILED if an error occured + * - @c returnvalue::FAILED if an error occured */ virtual ReturnValue_t getFuseState(uint8_t fuseNr) const = 0; /** diff --git a/src/fsfw/power/PowerSwitcher.cpp b/src/fsfw/power/PowerSwitcher.cpp index 7608c6e7..77733884 100644 --- a/src/fsfw/power/PowerSwitcher.cpp +++ b/src/fsfw/power/PowerSwitcher.cpp @@ -24,11 +24,11 @@ ReturnValue_t PowerSwitcher::getStateOfSwitches() { (secondSwitchState == PowerSwitchIF::SWITCH_OFF)) { return PowerSwitchIF::SWITCH_OFF; } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -111,18 +111,18 @@ ReturnValue_t PowerSwitcher::checkSwitchState() { return IN_POWER_TRANSITION; case SWITCH_IS_OFF: if (getStateOfSwitches() == PowerSwitchIF::SWITCH_OFF) { - return RETURN_OK; + return returnvalue::OK; } else { return SWITCH_STATE_MISMATCH; } case SWITCH_IS_ON: if (getStateOfSwitches() == PowerSwitchIF::SWITCH_ON) { - return RETURN_OK; + return returnvalue::OK; } else { return SWITCH_STATE_MISMATCH; } } - return RETURN_FAILED; + return returnvalue::FAILED; } PowerSwitcher::State_t PowerSwitcher::getState() { return state; } diff --git a/src/fsfw/power/PowerSwitcher.h b/src/fsfw/power/PowerSwitcher.h index 279ffacf..7aa60494 100644 --- a/src/fsfw/power/PowerSwitcher.h +++ b/src/fsfw/power/PowerSwitcher.h @@ -6,7 +6,7 @@ #include "../timemanager/Countdown.h" #include "PowerSwitchIF.h" -class PowerSwitcher : public HasReturnvaluesIF { +class PowerSwitcher { public: enum State_t { WAIT_OFF, diff --git a/src/fsfw/power/PowerSwitcherComponent.cpp b/src/fsfw/power/PowerSwitcherComponent.cpp index 9c1ed4cf..b6b67a83 100644 --- a/src/fsfw/power/PowerSwitcherComponent.cpp +++ b/src/fsfw/power/PowerSwitcherComponent.cpp @@ -16,15 +16,15 @@ ReturnValue_t PowerSwitcherComponent::performOperation(uint8_t opCode) { ReturnValue_t result; CommandMessage command; - for (result = queue->receiveMessage(&command); result == RETURN_OK; + for (result = queue->receiveMessage(&command); result == returnvalue::OK; result = queue->receiveMessage(&command)) { result = healthHelper.handleHealthCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = modeHelper.handleModeCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } } @@ -37,16 +37,16 @@ ReturnValue_t PowerSwitcherComponent::performOperation(uint8_t opCode) { setMode(MODE_ON, 0); } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t PowerSwitcherComponent::initialize() { ReturnValue_t result = modeHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SystemObject::initialize(); @@ -61,7 +61,7 @@ void PowerSwitcherComponent::getMode(Mode_t *mode, Submode_t *submode) { ReturnValue_t PowerSwitcherComponent::setHealth(HealthState health) { healthHelper.setHealth(health); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t PowerSwitcherComponent::checkModeCommand(Mode_t mode, Submode_t submode, @@ -70,7 +70,7 @@ ReturnValue_t PowerSwitcherComponent::checkModeCommand(Mode_t mode, Submode_t su if (mode != MODE_ON and mode != MODE_OFF) { return TRANS_NOT_ALLOWED; } - return RETURN_OK; + return returnvalue::OK; } void PowerSwitcherComponent::startTransition(Mode_t mode, Submode_t submode) { diff --git a/src/fsfw/power/PowerSwitcherComponent.h b/src/fsfw/power/PowerSwitcherComponent.h index a3ed640e..01689bef 100644 --- a/src/fsfw/power/PowerSwitcherComponent.h +++ b/src/fsfw/power/PowerSwitcherComponent.h @@ -23,7 +23,6 @@ class PowerSwitchIF; * commanding in to MODE_ON will cause the switcher to turn the switch on. */ class PowerSwitcherComponent : public SystemObject, - public HasReturnvaluesIF, public ExecutableObjectIF, public HasModesIF, public HasHealthIF { diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index 9990280c..3f37bec7 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -20,7 +20,7 @@ ReturnValue_t CService200ModeCommanding::isValidSubservice(uint8_t subservice) { case (Subservice::COMMAND_MODE_COMMAND): case (Subservice::COMMAND_MODE_READ): case (Subservice::COMMAND_MODE_ANNCOUNCE): - return RETURN_OK; + return returnvalue::OK; default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } @@ -47,7 +47,7 @@ ReturnValue_t CService200ModeCommanding::checkInterfaceAndAcquireMessageQueue( } *messageQueueToSet = destination->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CService200ModeCommanding::prepareCommand(CommandMessage *message, uint8_t subservice, @@ -56,7 +56,7 @@ ReturnValue_t CService200ModeCommanding::prepareCommand(CommandMessage *message, ModePacket modeCommandPacket; ReturnValue_t result = modeCommandPacket.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -70,7 +70,7 @@ ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply CommandMessage *optionalNextCommand, object_id_t objectId, bool *isStep) { Command_t replyId = reply->getCommand(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; switch (replyId) { case (ModeMessage::REPLY_MODE_REPLY): { result = prepareModeReply(reply, objectId); @@ -88,7 +88,7 @@ ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply result = INVALID_REPLY; break; default: - result = RETURN_FAILED; + result = returnvalue::FAILED; } return result; } @@ -103,9 +103,9 @@ ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMess object_id_t objectId) { ModePacket wrongModeReply(objectId, ModeMessage::getMode(reply), ModeMessage::getSubmode(reply)); ReturnValue_t result = sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, wrongModeReply); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { // We want to produce an error here in any case because the mode was not correct - return RETURN_FAILED; + return returnvalue::FAILED; } return result; } @@ -114,9 +114,9 @@ ReturnValue_t CService200ModeCommanding::prepareCantReachModeReply(const Command object_id_t objectId) { CantReachModePacket cantReachModePacket(objectId, ModeMessage::getCantReachModeReason(reply)); ReturnValue_t result = sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, cantReachModePacket); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { // We want to produce an error here in any case because the mode was not reached - return RETURN_FAILED; + return returnvalue::FAILED; } return result; } diff --git a/src/fsfw/pus/CService201HealthCommanding.cpp b/src/fsfw/pus/CService201HealthCommanding.cpp index c668ea52..c8458edb 100644 --- a/src/fsfw/pus/CService201HealthCommanding.cpp +++ b/src/fsfw/pus/CService201HealthCommanding.cpp @@ -18,7 +18,7 @@ ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) case (Subservice::COMMAND_SET_HEALTH): case (Subservice::COMMAND_ANNOUNCE_HEALTH): case (Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): - return RETURN_OK; + return returnvalue::OK; default: #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Invalid Subservice" << std::endl; @@ -48,19 +48,19 @@ ReturnValue_t CService201HealthCommanding::checkInterfaceAndAcquireMessageQueue( } *messageQueueToSet = destination->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CService201HealthCommanding::prepareCommand(CommandMessage *message, uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, uint32_t *state, object_id_t objectId) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (subservice) { case (Subservice::COMMAND_SET_HEALTH): { HealthSetCommand healthCommand; result = healthCommand.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { break; } HealthMessage::setHealthMessage(message, HealthMessage::HEALTH_SET, @@ -77,7 +77,7 @@ ReturnValue_t CService201HealthCommanding::prepareCommand(CommandMessage *messag } default: { // Should never happen, subservice was already checked - result = RETURN_FAILED; + result = returnvalue::FAILED; } } return result; diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 83713266..b2f35fd3 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -59,13 +59,13 @@ inline ReturnValue_t Service11TelecommandScheduling::handleRequest( default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } - return RETURN_OK; + return returnvalue::OK; } template inline ReturnValue_t Service11TelecommandScheduling::performService() { if (not schedulingEnabled) { - return RETURN_OK; + return returnvalue::OK; } // get current time as UNIX timestamp timeval tNow = {}; @@ -81,7 +81,7 @@ inline ReturnValue_t Service11TelecommandScheduling::performService TmTcMessage releaseMsg(it->second.storeAddr); auto sendRet = psbParams.reqQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false); - if (sendRet != HasReturnvaluesIF::RETURN_OK) { + if (sendRet != returnvalue::OK) { return sendRet; } if (debugMode) { @@ -100,13 +100,13 @@ inline ReturnValue_t Service11TelecommandScheduling::performService it++; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template inline ReturnValue_t Service11TelecommandScheduling::initialize() { ReturnValue_t res = PusServiceBase::initialize(); - if (res != HasReturnvaluesIF::RETURN_OK) { + if (res != returnvalue::OK) { return res; } @@ -127,7 +127,7 @@ template inline ReturnValue_t Service11TelecommandScheduling::handleResetCommand() { for (auto it = telecommandMap.begin(); it != telecommandMap.end(); it++) { ReturnValue_t result = tcStore->deleteData(it->second.storeAddr); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 // This should not happen sif::warning << "Service11TelecommandScheduling::handleRequestDeleting: Deletion failed" @@ -140,7 +140,7 @@ inline ReturnValue_t Service11TelecommandScheduling::handleResetCom } } telecommandMap.clear(); - return RETURN_OK; + return returnvalue::OK; } template @@ -148,7 +148,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi const uint8_t *data, size_t size) { uint32_t timestamp = 0; ReturnValue_t result = SerializeAdapter::deSerialize(×tamp, &data, &size, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -166,12 +166,12 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi "Service11TelecommandScheduling::doInsertActivity: Release time too close to current " "time\n"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } // store currentPacket and receive the store address store_address_t addr{}; - if (tcStore->addData(&addr, data, size) != RETURN_OK || + if (tcStore->addData(&addr, data, size) != returnvalue::OK || addr.raw == store_address_t::INVALID_RAW) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed" @@ -180,7 +180,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi sif::printError( "Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed\n"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } // insert into multimap with new store address @@ -191,7 +191,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi auto it = telecommandMap.insert(std::pair(timestamp, tc)); if (it == telecommandMap.end()) { - return RETURN_FAILED; + return returnvalue::FAILED; } if (debugMode) { @@ -202,7 +202,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi #endif debugPrintMultimapContent(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template @@ -211,7 +211,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doDeleteActivi // Get request ID uint64_t requestId; ReturnValue_t result = getRequestIdFromData(data, size, requestId); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -245,11 +245,11 @@ inline ReturnValue_t Service11TelecommandScheduling::doDeleteActivi "Service11TelecommandScheduling::doDeleteActivity: No or more than 1 TC found. " "Cannot explicitly delete TC"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } // delete packet from store - if (tcStore->deleteData(tcToDelete->second.storeAddr) != RETURN_OK) { + if (tcStore->deleteData(tcToDelete->second.storeAddr) != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service11TelecommandScheduling::doDeleteActivity: Could not delete TC from Store" << std::endl; @@ -257,7 +257,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doDeleteActivi sif::printError( "Service11TelecommandScheduling::doDeleteActivity: Could not delete TC from Store\n"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } telecommandMap.erase(tcToDelete); @@ -269,7 +269,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doDeleteActivi #endif } - return RETURN_OK; + return returnvalue::OK; } template @@ -280,14 +280,14 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterDelete ReturnValue_t result = getMapFilterFromData(data, size, itBegin, itEnd); // get the filter window as map range via dedicated method - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } int deletedTCs = 0; for (TcMapIter it = itBegin; it != itEnd; it++) { // delete packet from store - if (tcStore->deleteData(it->second.storeAddr) != RETURN_OK) { + if (tcStore->deleteData(it->second.storeAddr) != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service11TelecommandScheduling::doFilterDeleteActivity: Could not delete TC " "from Store" @@ -318,7 +318,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterDelete sif::printInfo("PUS11::doFilterDeleteActivity: Deleted %d TCs\n", deletedTCs); #endif } - return RETURN_OK; + return returnvalue::OK; } template @@ -327,7 +327,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doTimeshiftAct // Get relative time uint32_t relativeTime = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&relativeTime, &data, &size, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (relativeTime == 0) { @@ -338,7 +338,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doTimeshiftAct // Get request ID uint64_t requestId; result = getRequestIdFromData(data, size, requestId); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -396,7 +396,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doTimeshiftAct debugPrintMultimapContent(); } - return RETURN_OK; + return returnvalue::OK; } template @@ -405,7 +405,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterTimesh // Get relative time uint32_t relativeTime = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&relativeTime, &data, &size, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (relativeTime == 0) { @@ -416,7 +416,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterTimesh TcMapIter itBegin; TcMapIter itEnd; result = getMapFilterFromData(data, size, itBegin, itEnd); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -445,9 +445,9 @@ inline ReturnValue_t Service11TelecommandScheduling::doFilterTimesh } if (shiftedItemsCount > 0) { - return RETURN_OK; + return returnvalue::OK; } - return RETURN_FAILED; + return returnvalue::FAILED; } template @@ -467,20 +467,20 @@ inline ReturnValue_t Service11TelecommandScheduling::getRequestIdFr uint16_t ssc = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&srcId, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&apid, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&ssc, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } requestId = buildRequestId(srcId, apid, ssc); - return RETURN_OK; + return returnvalue::OK; } template @@ -500,7 +500,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr // get filter type first uint32_t typeRaw = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&typeRaw, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -523,7 +523,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr case TypeOfTimeWindow::FROM_TIMETAG: { uint32_t fromTimestamp = 0; result = SerializeAdapter::deSerialize(&fromTimestamp, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -539,7 +539,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr case TypeOfTimeWindow::TO_TIMETAG: { uint32_t toTimestamp; result = SerializeAdapter::deSerialize(&toTimestamp, &data, &dataSize, DEF_END); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } itBegin = telecommandMap.begin(); @@ -556,12 +556,12 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr result = SerializeAdapter::deSerialize(&fromTimestamp, &data, &dataSize, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&toTimestamp, &data, &dataSize, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } itBegin = telecommandMap.begin(); @@ -577,7 +577,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr } default: - return RETURN_FAILED; + return returnvalue::FAILED; } // additional security check, this should never be true @@ -586,11 +586,11 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr #else sif::printError("11::GetMapFilterFromData: itBegin > itEnd\n"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } // the map range should now be set according to the sent filter. - return RETURN_OK; + return returnvalue::OK; } template @@ -603,7 +603,7 @@ inline ReturnValue_t Service11TelecommandScheduling::handleInvalidD sif::printWarning("Service11TelecommandScheduling::%s: Invalid buffer\n", ctx); #endif #endif - return RETURN_FAILED; + return returnvalue::FAILED; } template diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index 14257334..0a9db32f 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -16,7 +16,7 @@ ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { switch (subservice) { case Subservice::CONNECTION_TEST: { ReturnValue_t result = tmHelper.prepareTmPacket(Subservice::CONNECTION_TEST_REPORT); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return tmHelper.storeAndSendTmPacket(); @@ -24,7 +24,7 @@ ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { case Subservice::EVENT_TRIGGER_TEST: { triggerEvent(TEST, 1234, 5678); ReturnValue_t result = tmHelper.prepareTmPacket(Subservice::EVENT_TRIGGER_TEST); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return tmHelper.storeAndSendTmPacket(); @@ -34,11 +34,11 @@ ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { } } -ReturnValue_t Service17Test::performService() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t Service17Test::performService() { return returnvalue::OK; } ReturnValue_t Service17Test::initialize() { ReturnValue_t result = PusServiceBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } initializeTmHelpers(sendHelper, storeHelper); diff --git a/src/fsfw/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index 0e6e302c..adc00588 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -32,15 +32,15 @@ MessageQueueId_t Service1TelecommandVerification::getVerificationQueue() { ReturnValue_t Service1TelecommandVerification::performOperation(uint8_t operationCode) { PusVerificationMessage message; ReturnValue_t status = tmQueue->receiveMessage(&message); - while (status == HasReturnvaluesIF::RETURN_OK) { + while (status == returnvalue::OK) { status = sendVerificationReport(&message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { return status; } status = tmQueue->receiveMessage(&message); } if (status == MessageQueueIF::EMPTY) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return status; } @@ -60,14 +60,14 @@ ReturnValue_t Service1TelecommandVerification::sendVerificationReport( "%d detected\n", reportId); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (message->getReportId() % 2 == 0) { result = generateFailureReport(message); } else { result = generateSuccessReport(message); } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service1TelecommandVerification::sendVerificationReport: " "Sending verification packet failed !" @@ -84,11 +84,11 @@ ReturnValue_t Service1TelecommandVerification::generateFailureReport( message->getParameter1(), message->getParameter2()); ReturnValue_t result = storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = storeHelper.setSourceDataSerializable(report); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return tmHelper.storeAndSendTmPacket(); @@ -100,11 +100,11 @@ ReturnValue_t Service1TelecommandVerification::generateSuccessReport( message->getTcSequenceControl(), message->getStep()); ReturnValue_t result = storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = storeHelper.setSourceDataSerializable(report); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return tmHelper.storeAndSendTmPacket(); diff --git a/src/fsfw/pus/Service1TelecommandVerification.h b/src/fsfw/pus/Service1TelecommandVerification.h index 01bd9714..6d16c7a9 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.h +++ b/src/fsfw/pus/Service1TelecommandVerification.h @@ -41,8 +41,7 @@ */ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, public SystemObject, - public ExecutableObjectIF, - public HasReturnvaluesIF { + public ExecutableObjectIF { public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_1; diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index 6d6ca339..f58a0d6c 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -20,7 +20,7 @@ ReturnValue_t Service20ParameterManagement::isValidSubservice(uint8_t subservice switch (static_cast(subservice)) { case Subservice::PARAMETER_LOAD: case Subservice::PARAMETER_DUMP: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Invalid Subservice for Service 20" << std::endl; @@ -37,7 +37,7 @@ ReturnValue_t Service20ParameterManagement::getMessageQueueAndObject(uint8_t sub MessageQueueId_t* id, object_id_t* objectId) { ReturnValue_t result = checkAndAcquireTargetID(objectId, tcData, tcDataLen); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } return checkInterfaceAndAcquireMessageQueue(id, objectId); @@ -47,7 +47,7 @@ ReturnValue_t Service20ParameterManagement::checkAndAcquireTargetID(object_id_t* const uint8_t* tcData, size_t tcDataLen) { if (SerializeAdapter::deSerialize(objectIdToSet, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG) != HasReturnvaluesIF::RETURN_OK) { + SerializeIF::Endianness::BIG) != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service20ParameterManagement::checkAndAcquireTargetID: " << "Invalid data." << std::endl; @@ -58,7 +58,7 @@ ReturnValue_t Service20ParameterManagement::checkAndAcquireTargetID(object_id_t* #endif return CommandingServiceBase::INVALID_TC; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue( @@ -82,7 +82,7 @@ ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue return CommandingServiceBase::INVALID_OBJECT; } *messageQueueToSet = possibleTarget->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service20ParameterManagement::prepareCommand(CommandMessage* message, @@ -97,7 +97,7 @@ ReturnValue_t Service20ParameterManagement::prepareCommand(CommandMessage* messa return prepareLoadCommand(message, tcData, tcDataLen); } break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -110,7 +110,7 @@ ReturnValue_t Service20ParameterManagement::prepareDumpCommand(CommandMessage* m tcDataLen -= sizeof(object_id_t); ParameterId_t parameterId; if (SerializeAdapter::deSerialize(¶meterId, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG) != HasReturnvaluesIF::RETURN_OK) { + SerializeIF::Endianness::BIG) != returnvalue::OK) { return CommandingServiceBase::INVALID_TC; } /* The length should have been decremented to 0 by this point */ @@ -119,7 +119,7 @@ ReturnValue_t Service20ParameterManagement::prepareDumpCommand(CommandMessage* m } ParameterMessage::setParameterDumpCommand(message, parameterId); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service20ParameterManagement::prepareLoadCommand(CommandMessage* message, @@ -137,7 +137,7 @@ ReturnValue_t Service20ParameterManagement::prepareLoadCommand(CommandMessage* m return CommandingServiceBase::INVALID_TC; } ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, parameterDataLen, &storePointer); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -150,14 +150,14 @@ ReturnValue_t Service20ParameterManagement::prepareLoadCommand(CommandMessage* m 4. Number of columns */ ParameterLoadCommand command(storePointer, parameterDataLen); result = command.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } ParameterMessage::setParameterLoadCommand(message, command.getParameterId(), storeAddress, command.getPtc(), command.getPfc(), command.getRows(), command.getColumns()); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service20ParameterManagement::handleReply(const CommandMessage* reply, @@ -169,8 +169,8 @@ ReturnValue_t Service20ParameterManagement::handleReply(const CommandMessage* re switch (replyId) { case ParameterMessage::REPLY_PARAMETER_DUMP: { ConstAccessorPair parameterData = ipcStore->getData(ParameterMessage::getStoreId(reply)); - if (parameterData.first != HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_FAILED; + if (parameterData.first != returnvalue::OK) { + return returnvalue::FAILED; } ParameterId_t parameterId = ParameterMessage::getParameterId(reply); diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index 414f0812..6eea1807 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -23,7 +23,7 @@ ReturnValue_t Service2DeviceAccess::isValidSubservice(uint8_t subservice) { switch (static_cast(subservice)) { case Subservice::COMMAND_RAW_COMMANDING: case Subservice::COMMAND_TOGGLE_WIRETAPPING: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Invalid Subservice" << std::endl; @@ -51,7 +51,7 @@ ReturnValue_t Service2DeviceAccess::checkInterfaceAndAcquireMessageQueue( return CommandingServiceBase::INVALID_OBJECT; } *messageQueueToSet = possibleTarget->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service2DeviceAccess::prepareCommand(CommandMessage* message, uint8_t subservice, @@ -65,7 +65,7 @@ ReturnValue_t Service2DeviceAccess::prepareCommand(CommandMessage* message, uint return prepareWiretappingCommand(message, tcData, tcDataLen); } break; default: - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -99,7 +99,7 @@ ReturnValue_t Service2DeviceAccess::handleReply(const CommandMessage* reply, object_id_t objectId, bool* isStep) { switch (reply->getCommand()) { case CommandMessage::REPLY_COMMAND_OK: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; case CommandMessage::REPLY_REJECTED: return reply->getReplyRejectedReason(); default: @@ -136,7 +136,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs const uint8_t* data = nullptr; size_t size = 0; ReturnValue_t result = ipcStore->getData(storeAddress, &data, &size); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in " "handleUnrequestedReply with failure ID " @@ -149,7 +149,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs // sending it back. WiretappingPacket tmPacket(DeviceHandlerMessage::getDeviceObjectId(reply), data); result = sendTmPacket(subservice, tmPacket.objectId, tmPacket.data, size); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { // TODO: Warning return; } diff --git a/src/fsfw/pus/Service3Housekeeping.cpp b/src/fsfw/pus/Service3Housekeeping.cpp index 7ef5636d..41bb2472 100644 --- a/src/fsfw/pus/Service3Housekeeping.cpp +++ b/src/fsfw/pus/Service3Housekeeping.cpp @@ -22,7 +22,7 @@ ReturnValue_t Service3Housekeeping::isValidSubservice(uint8_t subservice) { case Subservice::GENERATE_ONE_DIAGNOSTICS_REPORT: case Subservice::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL: case Subservice::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; // Telemetry or invalid subservice. case Subservice::HK_DEFINITIONS_REPORT: case Subservice::DIAGNOSTICS_DEFINITION_REPORT: @@ -38,7 +38,7 @@ ReturnValue_t Service3Housekeeping::getMessageQueueAndObject(uint8_t subservice, size_t tcDataLen, MessageQueueId_t* id, object_id_t* objectId) { ReturnValue_t result = checkAndAcquireTargetID(objectId, tcData, tcDataLen); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } return checkInterfaceAndAcquireMessageQueue(id, objectId); @@ -48,10 +48,10 @@ ReturnValue_t Service3Housekeeping::checkAndAcquireTargetID(object_id_t* objectI const uint8_t* tcData, size_t tcDataLen) { if (SerializeAdapter::deSerialize(objectIdToSet, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG) != HasReturnvaluesIF::RETURN_OK) { + SerializeIF::Endianness::BIG) != returnvalue::OK) { return CommandingServiceBase::INVALID_TC; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::checkInterfaceAndAcquireMessageQueue( @@ -63,7 +63,7 @@ ReturnValue_t Service3Housekeeping::checkInterfaceAndAcquireMessageQueue( return CommandingServiceBase::INVALID_OBJECT; } *messageQueueToSet = possibleTarget->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::prepareCommand(CommandMessage* message, uint8_t subservice, @@ -100,9 +100,9 @@ ReturnValue_t Service3Housekeeping::prepareCommand(CommandMessage* message, uint return CommandingServiceBase::INVALID_TC; default: // should never happen, subservice was already checked. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand( @@ -116,7 +116,7 @@ ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand( sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen); HousekeepingMessage::setToggleReportingCommand(command, targetSid, enableReporting, isDiagnostics); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::prepareStructureReportingCommand(CommandMessage* command, @@ -131,7 +131,7 @@ ReturnValue_t Service3Housekeeping::prepareStructureReportingCommand(CommandMess sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen); HousekeepingMessage::setStructureReportingCommand(command, targetSid, isDiagnostics); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::prepareOneShotReportCommand(CommandMessage* command, @@ -146,7 +146,7 @@ ReturnValue_t Service3Housekeeping::prepareOneShotReportCommand(CommandMessage* sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen); HousekeepingMessage::setOneShotReportCommand(command, targetSid, isDiagnostics); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand( @@ -163,7 +163,7 @@ ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand SerializeIF::Endianness::BIG); HousekeepingMessage::setCollectionIntervalModificationCommand( command, targetSid, newCollectionInterval, isDiagnostics); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, @@ -174,7 +174,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, switch (command) { case (HousekeepingMessage::HK_REPORT): { ReturnValue_t result = generateHkReply(reply, static_cast(Subservice::HK_REPORT)); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return CommandingServiceBase::EXECUTION_COMPLETE; @@ -183,7 +183,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, case (HousekeepingMessage::DIAGNOSTICS_REPORT): { ReturnValue_t result = generateHkReply(reply, static_cast(Subservice::DIAGNOSTICS_REPORT)); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return CommandingServiceBase::EXECUTION_COMPLETE; @@ -205,7 +205,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, case (HousekeepingMessage::HK_REQUEST_FAILURE): { failureParameter1 = objectId; - ReturnValue_t error = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t error = returnvalue::FAILED; HousekeepingMessage::getHkRequestFailureReply(reply, &error); failureParameter2 = error; return CommandingServiceBase::EXECUTION_COMPLETE; @@ -223,11 +223,11 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, #endif return CommandingServiceBase::INVALID_REPLY; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void Service3Housekeeping::handleUnrequestedReply(CommandMessage* reply) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; Command_t command = reply->getCommand(); switch (command) { @@ -264,7 +264,7 @@ void Service3Housekeeping::handleUnrequestedReply(CommandMessage* reply) { } } - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { /* Configuration error */ #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service3Housekeeping::handleUnrequestedReply: Could not generate reply!" @@ -285,7 +285,7 @@ ReturnValue_t Service3Housekeeping::generateHkReply(const CommandMessage* hkMess sid_t sid = HousekeepingMessage::getHkDataReply(hkMessage, &storeId); auto resultPair = ipcStore->getData(storeId); - if (resultPair.first != HasReturnvaluesIF::RETURN_OK) { + if (resultPair.first != returnvalue::OK) { return resultPair.first; } diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index fa518d0f..9fbbc8d9 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -22,17 +22,17 @@ Service5EventReporting::~Service5EventReporting() { ReturnValue_t Service5EventReporting::performService() { EventMessage message; - ReturnValue_t status = RETURN_OK; + ReturnValue_t status = returnvalue::OK; for (uint8_t counter = 0; counter < maxNumberReportsPerCycle; counter++) { // Receive messages even if reporting is disabled for now. status = eventQueue->receiveMessage(&message); if (status == MessageQueueIF::EMPTY) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } if (enableEventReport) { status = generateEventReport(message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { return status; } } @@ -40,7 +40,7 @@ ReturnValue_t Service5EventReporting::performService() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service5EventReporting::generateEventReport: Too many events" << std::endl; #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) { @@ -49,7 +49,7 @@ ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) storeHelper.preparePacket(psbParams.serviceId, message.getSeverity(), tmHelper.sendCounter); storeHelper.setSourceDataSerializable(report); ReturnValue_t result = tmHelper.storeAndSendTmPacket(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service5EventReporting::generateEventReport: " "Could not send TM packet" @@ -67,11 +67,11 @@ ReturnValue_t Service5EventReporting::handleRequest(uint8_t subservice) { switch (subservice) { case Subservice::ENABLE: { enableEventReport = true; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case Subservice::DISABLE: { enableEventReport = false; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; @@ -82,16 +82,16 @@ ReturnValue_t Service5EventReporting::handleRequest(uint8_t subservice) { // to be registered to the event manager to listen for events. ReturnValue_t Service5EventReporting::initialize() { ReturnValue_t result = PusServiceBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } auto* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (manager == nullptr) { - return RETURN_FAILED; + return returnvalue::FAILED; } // register Service 5 as listener for events result = manager->registerListener(eventQueue->getId(), true); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } initializeTmHelpers(sendHelper, storeHelper); diff --git a/src/fsfw/pus/Service8FunctionManagement.cpp b/src/fsfw/pus/Service8FunctionManagement.cpp index c9da6d58..b9ef6c4d 100644 --- a/src/fsfw/pus/Service8FunctionManagement.cpp +++ b/src/fsfw/pus/Service8FunctionManagement.cpp @@ -20,7 +20,7 @@ Service8FunctionManagement::~Service8FunctionManagement() {} ReturnValue_t Service8FunctionManagement::isValidSubservice(uint8_t subservice) { switch (static_cast(subservice)) { case Subservice::COMMAND_DIRECT_COMMANDING: - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } @@ -48,7 +48,7 @@ ReturnValue_t Service8FunctionManagement::checkInterfaceAndAcquireMessageQueue( return CommandingServiceBase::INVALID_OBJECT; } *messageQueueToSet = possibleTarget->getCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Service8FunctionManagement::prepareCommand(CommandMessage* message, @@ -62,7 +62,7 @@ ReturnValue_t Service8FunctionManagement::prepareDirectCommand(CommandMessage* m const uint8_t* tcData, size_t tcDataLen) { if (message == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (tcDataLen < sizeof(object_id_t) + sizeof(ActionId_t)) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -91,7 +91,7 @@ ReturnValue_t Service8FunctionManagement::handleReply(const CommandMessage* repl CommandMessage* optionalNextCommand, object_id_t objectId, bool* isStep) { Command_t replyId = reply->getCommand(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; ActionId_t actionId = ActionMessage::getActionId(reply); ReturnValue_t returnCode = ActionMessage::getReturnCode(reply); @@ -103,7 +103,7 @@ ReturnValue_t Service8FunctionManagement::handleReply(const CommandMessage* repl } case ActionMessage::STEP_SUCCESS: { *isStep = true; - result = HasReturnvaluesIF::RETURN_OK; + result = returnvalue::OK; break; } case ActionMessage::DATA_REPLY: { @@ -131,7 +131,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* size_t size = 0; const uint8_t* buffer = nullptr; ReturnValue_t result = ipcStore->getData(storeId, &buffer, &size); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service 8: Could not retrieve data for data reply" << std::endl; #endif @@ -141,7 +141,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* result = sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), dataReply); auto deletionResult = ipcStore->deleteData(storeId); - if (deletionResult != HasReturnvaluesIF::RETURN_OK) { + if (deletionResult != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service8FunctionManagement::handleReply: Deletion" << " of data in pool failed." << std::endl; diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 4a26f993..698290c9 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -9,7 +9,7 @@ Service9TimeManagement::Service9TimeManagement(PsbParams params) : PusServiceBas Service9TimeManagement::~Service9TimeManagement() = default; -ReturnValue_t Service9TimeManagement::performService() { return RETURN_OK; } +ReturnValue_t Service9TimeManagement::performService() { return returnvalue::OK; } ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { switch (subservice) { @@ -26,7 +26,7 @@ ReturnValue_t Service9TimeManagement::setTime() { TimePacket timePacket(currentPacket.getUserData(), currentPacket.getUserDataLen()); ReturnValue_t result = CCSDSTime::convertFromCcsds(&timeToSet, timePacket.getTime(), timePacket.getTimeSize()); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { triggerEvent(CLOCK_SET_FAILURE, result, 0); return result; } @@ -35,13 +35,13 @@ ReturnValue_t Service9TimeManagement::setTime() { Clock::getUptime(&formerUptime); result = Clock::setClock(&timeToSet); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { uint32_t newUptime; Clock::getUptime(&newUptime); triggerEvent(CLOCK_SET, newUptime, formerUptime); - return RETURN_OK; + return returnvalue::OK; } else { triggerEvent(CLOCK_SET_FAILURE, result, 0); - return RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/pus/servicepackets/Service1Packets.h b/src/fsfw/pus/servicepackets/Service1Packets.h index dce7657a..70bf167e 100644 --- a/src/fsfw/pus/servicepackets/Service1Packets.h +++ b/src/fsfw/pus/servicepackets/Service1Packets.h @@ -42,26 +42,26 @@ class FailureReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6 SerializeIF::Endianness streamEndianness) const override { ReturnValue_t result = SerializeAdapter::serialize(&packetId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&packetSequenceControl, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (failureSubtype == tcverif::PROGRESS_FAILURE) { result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } result = SerializeAdapter::serialize(&errorCode, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&errorParameter1, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -91,7 +91,7 @@ class FailureReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6 */ ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } private: @@ -122,17 +122,17 @@ class SuccessReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5 SerializeIF::Endianness streamEndianness) const override { ReturnValue_t result = SerializeAdapter::serialize(&packetId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&packetSequenceControl, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (subtype == tcverif::PROGRESS_SUCCESS) { result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -151,7 +151,7 @@ class SuccessReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5 ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } private: diff --git a/src/fsfw/pus/servicepackets/Service5Packets.h b/src/fsfw/pus/servicepackets/Service5Packets.h index 9ff2e4d4..05d92674 100644 --- a/src/fsfw/pus/servicepackets/Service5Packets.h +++ b/src/fsfw/pus/servicepackets/Service5Packets.h @@ -28,19 +28,19 @@ class EventReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 2, 3, SerializeIF::Endianness streamEndianness) const override { ReturnValue_t result = SerializeAdapter::serialize(&reportId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&objectId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(¶meter1, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(¶meter2, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return result; @@ -57,7 +57,7 @@ class EventReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 2, 3, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } private: diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/HasReturnvaluesIF.h index e5e42047..6e7fd7a8 100644 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ b/src/fsfw/returnvalues/HasReturnvaluesIF.h @@ -1,5 +1,5 @@ -#ifndef FSFW_RETURNVALUES_HASRETURNVALUESIF_H_ -#define FSFW_RETURNVALUES_HASRETURNVALUESIF_H_ +#ifndef FSFW_RETURNVALUES_RETURNVALUES_H_ +#define FSFW_RETURNVALUES_RETURNVALUES_H_ #include @@ -8,34 +8,25 @@ #include "FwClassIds.h" #define MAKE_RETURN_CODE(number) ((INTERFACE_ID << 8) + (number)) + typedef uint16_t ReturnValue_t; -namespace result { -static constexpr ReturnValue_t OK = 0; -static constexpr ReturnValue_t FAILED = 1; +namespace returnvalue { +static const ReturnValue_t OK = 0; +static const ReturnValue_t FAILED = 1; + +/** + * It is discouraged to use the input parameters 0,0 and 0,1 as this + * will generate the RETURN_OK and returnvalue::FAILED returnvalues. + * @param interfaceId + * @param number + * @return + */ static constexpr ReturnValue_t makeCode(uint8_t classId, uint8_t number) { return (static_cast(classId) << 8) + number; } -} // namespace result -class HasReturnvaluesIF { - public: - static const ReturnValue_t RETURN_OK = result::OK; - static const ReturnValue_t RETURN_FAILED = result::FAILED; +} // namespace returnvalue - virtual ~HasReturnvaluesIF() = default; - - /** - * It is discouraged to use the input parameters 0,0 and 0,1 as this - * will generate the RETURN_OK and RETURN_FAILED returnvalues. - * @param interfaceId - * @param number - * @return - */ - static constexpr ReturnValue_t makeReturnCode(uint8_t classId, uint8_t number) { - return result::makeCode(classId, number); - } -}; - -#endif /* FSFW_RETURNVALUES_HASRETURNVALUESIF_H_ */ +#endif /* FSFW_RETURNVALUES_RETURNVALUES_H_ */ diff --git a/src/fsfw/rmap/RmapDeviceCommunicationIF.cpp b/src/fsfw/rmap/RmapDeviceCommunicationIF.cpp index cf5d49ea..70a5e7a6 100644 --- a/src/fsfw/rmap/RmapDeviceCommunicationIF.cpp +++ b/src/fsfw/rmap/RmapDeviceCommunicationIF.cpp @@ -26,7 +26,7 @@ ReturnValue_t RmapDeviceCommunicationIF::readReceivedMessage(CookieIF *cookie, u ReturnValue_t RmapDeviceCommunicationIF::setAddress(CookieIF *cookie, uint32_t address) { ((RMAPCookie *)cookie)->setAddress(address); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint32_t RmapDeviceCommunicationIF::getAddress(CookieIF *cookie) { @@ -35,7 +35,7 @@ uint32_t RmapDeviceCommunicationIF::getAddress(CookieIF *cookie) { ReturnValue_t RmapDeviceCommunicationIF::setParameter(CookieIF *cookie, uint32_t parameter) { // TODO Empty? - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint32_t RmapDeviceCommunicationIF::getParameter(CookieIF *cookie) { return 0; } diff --git a/src/fsfw/serialize/SerialArrayListAdapter.h b/src/fsfw/serialize/SerialArrayListAdapter.h index d7c99aae..fa87ddbe 100644 --- a/src/fsfw/serialize/SerialArrayListAdapter.h +++ b/src/fsfw/serialize/SerialArrayListAdapter.h @@ -26,7 +26,7 @@ class SerialArrayListAdapter : public SerializeIF { ReturnValue_t result = SerializeAdapter::serialize(&list->size, buffer, size, maxSize, streamEndianness); count_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < list->size)) { + while ((result == returnvalue::OK) && (i < list->size)) { result = SerializeAdapter::serialize(&list->entries[i], buffer, size, maxSize, streamEndianness); ++i; @@ -56,7 +56,7 @@ class SerialArrayListAdapter : public SerializeIF { size_t* size, Endianness streamEndianness) { count_t tempSize = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&tempSize, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (tempSize > list->maxSize()) { @@ -65,7 +65,7 @@ class SerialArrayListAdapter : public SerializeIF { list->size = tempSize; count_t i = 0; - while ((result == HasReturnvaluesIF::RETURN_OK) && (i < list->size)) { + while ((result == returnvalue::OK) && (i < list->size)) { result = SerializeAdapter::deSerialize(&list->front()[i], buffer, size, streamEndianness); ++i; } diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 83129982..81919f37 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -30,7 +30,7 @@ ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, size_t* if (serializeLength) { ReturnValue_t result = SerializeAdapter::serialize(&bufferLength, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -46,11 +46,11 @@ ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, size_t* // set if non-const buffer is set. std::memcpy(*buffer, this->buffer, bufferLength); } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *size += bufferLength; (*buffer) += bufferLength; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } template @@ -66,14 +66,14 @@ template ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { if (this->buffer == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (serializeLength) { count_t lengthField = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&lengthField, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (lengthField > bufferLength) { @@ -86,7 +86,7 @@ ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, *size -= bufferLength; std::memcpy(this->buffer, *buffer, bufferLength); (*buffer) += bufferLength; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return STREAM_TOO_SHORT; } diff --git a/src/fsfw/serialize/SerialLinkedListAdapter.h b/src/fsfw/serialize/SerialLinkedListAdapter.h index 4975c0a5..6c2fb7df 100644 --- a/src/fsfw/serialize/SerialLinkedListAdapter.h +++ b/src/fsfw/serialize/SerialLinkedListAdapter.h @@ -51,7 +51,7 @@ class SerialLinkedListAdapter : public SinglyLinkedList, public SerializeIF { count_t mySize = SinglyLinkedList::getSize(); ReturnValue_t result = SerializeAdapter::serialize(&mySize, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -60,8 +60,8 @@ class SerialLinkedListAdapter : public SinglyLinkedList, public SerializeIF { static ReturnValue_t serialize(const LinkedElement* element, uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while ((result == HasReturnvaluesIF::RETURN_OK) and (element != nullptr)) { + ReturnValue_t result = returnvalue::OK; + while ((result == returnvalue::OK) and (element != nullptr)) { result = element->value->serialize(buffer, size, maxSize, streamEndianness); element = element->getNext(); } @@ -92,8 +92,8 @@ class SerialLinkedListAdapter : public SinglyLinkedList, public SerializeIF { static ReturnValue_t deSerialize(LinkedElement* element, const uint8_t** buffer, size_t* size, Endianness streamEndianness) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while ((result == HasReturnvaluesIF::RETURN_OK) and (element != nullptr)) { + ReturnValue_t result = returnvalue::OK; + while ((result == returnvalue::OK) and (element != nullptr)) { result = element->value->deSerialize(buffer, size, streamEndianness); element = element->getNext(); } diff --git a/src/fsfw/serialize/SerializeAdapter.h b/src/fsfw/serialize/SerializeAdapter.h index 4580986f..5b51e747 100644 --- a/src/fsfw/serialize/SerializeAdapter.h +++ b/src/fsfw/serialize/SerializeAdapter.h @@ -39,7 +39,7 @@ class SerializeAdapter { * SerializeIF::Endianness * @return * - @c BUFFER_TOO_SHORT The given buffer in is too short - * - @c RETURN_FAILED Generic Error + * - @c returnvalue::FAILED Generic Error * - @c RETURN_OK Successful serialization */ template @@ -64,14 +64,14 @@ class SerializeAdapter { * SerializeIF::Endianness * @return * - @c BUFFER_TOO_SHORT The given buffer in is too short - * - @c RETURN_FAILED Generic Error + * - @c returnvalue::FAILED Generic Error * - @c RETURN_OK Successful serialization */ template static ReturnValue_t serialize(const T *object, uint8_t *const buffer, size_t *serSize, size_t maxSize, SerializeIF::Endianness streamEndianness) { if (object == nullptr or buffer == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } InternalSerializeAdapter::value> adapter; auto **tempPtr = const_cast(&buffer); @@ -113,7 +113,7 @@ class SerializeAdapter { * @return * - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object * - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected - * - @c RETURN_FAILED Generic Error + * - @c returnvalue::FAILED Generic Error * - @c RETURN_OK Successful deserialization */ template @@ -136,14 +136,14 @@ class SerializeAdapter { * @return * - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object * - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected - * - @c RETURN_FAILED Generic Error + * - @c returnvalue::FAILED Generic Error * - @c RETURN_OK Successful deserialization */ template static ReturnValue_t deSerialize(T *object, const uint8_t *buffer, size_t *deserSize, SerializeIF::Endianness streamEndianness) { if (object == nullptr or buffer == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } InternalSerializeAdapter::value> adapter; const uint8_t **tempPtr = &buffer; @@ -200,7 +200,7 @@ class SerializeAdapter { std::memcpy(*buffer, &tmp, sizeof(T)); *size += sizeof(T); (*buffer) += sizeof(T); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SerializeIF::BUFFER_TOO_SHORT; } @@ -226,7 +226,7 @@ class SerializeAdapter { } *buffer += sizeof(T); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } else { return SerializeIF::STREAM_TOO_SHORT; } diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index f20bf21f..a02b5f9e 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -56,7 +56,7 @@ class SerializeIF { * SerializeIF::Endianness * @return * - @c BUFFER_TOO_SHORT The given buffer in is too short - * - @c RETURN_FAILED Generic error + * - @c returnvalue::FAILED Generic error * - @c RETURN_OK Successful serialization */ [[nodiscard]] virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, @@ -92,7 +92,7 @@ class SerializeIF { * @return * - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object * - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected - * - @c RETURN_FAILED Generic Error + * - @c returnvalue::FAILED Generic Error * - @c RETURN_OK Successful deserialization */ virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, diff --git a/src/fsfw/storagemanager/ConstStorageAccessor.cpp b/src/fsfw/storagemanager/ConstStorageAccessor.cpp index df2fc750..f64334f7 100644 --- a/src/fsfw/storagemanager/ConstStorageAccessor.cpp +++ b/src/fsfw/storagemanager/ConstStorageAccessor.cpp @@ -58,16 +58,16 @@ ReturnValue_t ConstStorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (size_ > maxSize) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "StorageAccessor: Supplied buffer not large enough" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } std::copy(constDataPointer, constDataPointer + size_, pointer); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void ConstStorageAccessor::release() { deleteData = false; } diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index f8b2bdb3..d907a9b3 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -34,7 +34,7 @@ LocalPool::~LocalPool(void) {} ReturnValue_t LocalPool::addData(store_address_t* storageId, const uint8_t* data, size_t size, bool ignoreFault) { ReturnValue_t status = reserveSpace(size, storageId, ignoreFault); - if (status == RETURN_OK) { + if (status == returnvalue::OK) { write(*storageId, data, size); } return status; @@ -67,7 +67,7 @@ ConstAccessorPair LocalPool::getData(store_address_t storeId) { ReturnValue_t LocalPool::getFreeElement(store_address_t* storageId, const size_t size, uint8_t** pData, bool ignoreFault) { ReturnValue_t status = reserveSpace(size, storageId, ignoreFault); - if (status == RETURN_OK) { + if (status == returnvalue::OK) { *pData = &store[storageId->poolIndex][getRawPosition(*storageId)]; } else { *pData = nullptr; @@ -90,7 +90,7 @@ ReturnValue_t LocalPool::modifyData(store_address_t storeId, StorageAccessor& st } ReturnValue_t LocalPool::modifyData(store_address_t storeId, uint8_t** packetPtr, size_t* size) { - ReturnValue_t status = RETURN_FAILED; + ReturnValue_t status = returnvalue::FAILED; if (storeId.poolIndex >= NUMBER_OF_SUBPOOLS) { return ILLEGAL_STORAGE_ID; } @@ -102,7 +102,7 @@ ReturnValue_t LocalPool::modifyData(store_address_t storeId, uint8_t** packetPtr size_type packetPosition = getRawPosition(storeId); *packetPtr = &store[storeId.poolIndex][packetPosition]; *size = sizeLists[storeId.poolIndex][storeId.packetIndex]; - status = RETURN_OK; + status = returnvalue::OK; } else { status = DATA_DOES_NOT_EXIST; } @@ -117,7 +117,7 @@ ReturnValue_t LocalPool::deleteData(store_address_t storeId) { #endif #endif - ReturnValue_t status = RETURN_OK; + ReturnValue_t status = returnvalue::OK; size_type pageSize = getSubpoolElementSize(storeId.poolIndex); if ((pageSize != 0) and (storeId.packetIndex < numberOfElements[storeId.poolIndex])) { uint16_t packetPosition = getRawPosition(storeId); @@ -166,7 +166,7 @@ ReturnValue_t LocalPool::deleteData(uint8_t* ptr, size_t size, store_address_t* ReturnValue_t LocalPool::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } internalErrorReporter = @@ -186,7 +186,7 @@ ReturnValue_t LocalPool::initialize() { return StorageManagerIF::POOL_TOO_LARGE; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void LocalPool::clearStore() { @@ -200,7 +200,7 @@ void LocalPool::clearStore() { ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeId, bool ignoreFault) { ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); - if (status != RETURN_OK) { + if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool( " << std::hex << getObjectId() << std::dec << " )::reserveSpace: Packet too large." << std::endl; @@ -208,15 +208,15 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeI return status; } status = findEmpty(storeId->poolIndex, &storeId->packetIndex); - while (status != RETURN_OK && spillsToHigherPools) { + while (status != returnvalue::OK && spillsToHigherPools) { status = getSubPoolIndex(size, &storeId->poolIndex, storeId->poolIndex + 1); - if (status != RETURN_OK) { + if (status != returnvalue::OK) { // We don't find any fitting pool anymore. break; } status = findEmpty(storeId->poolIndex, &storeId->packetIndex); } - if (status == RETURN_OK) { + if (status == returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 2 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Reserve: Pool: " << std::dec << storeId->poolIndex @@ -263,7 +263,7 @@ ReturnValue_t LocalPool::getSubPoolIndex(size_t packetSize, uint16_t* subpoolInd #endif if (elementSizes[n] >= packetSize) { *subpoolIndex = n; - return RETURN_OK; + return returnvalue::OK; } } return DATA_TOO_LARGE; @@ -278,7 +278,7 @@ ReturnValue_t LocalPool::findEmpty(n_pool_elem_t poolIndex, uint16_t* element) { for (uint16_t foundElement = 0; foundElement < numberOfElements[poolIndex]; foundElement++) { if (sizeLists[poolIndex][foundElement] == STORAGE_FREE) { *element = foundElement; - status = RETURN_OK; + status = returnvalue::OK; break; } } diff --git a/src/fsfw/storagemanager/StorageAccessor.cpp b/src/fsfw/storagemanager/StorageAccessor.cpp index b8096c1e..8a96dcec 100644 --- a/src/fsfw/storagemanager/StorageAccessor.cpp +++ b/src/fsfw/storagemanager/StorageAccessor.cpp @@ -26,7 +26,7 @@ ReturnValue_t StorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (size_ > maxSize) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -34,10 +34,10 @@ ReturnValue_t StorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { "enough" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } std::copy(dataPointer, dataPointer + size_, pointer); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint8_t* StorageAccessor::data() { @@ -54,7 +54,7 @@ ReturnValue_t StorageAccessor::write(uint8_t* data, size_t size, uint16_t offset #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (offset + size > size_) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -62,10 +62,10 @@ ReturnValue_t StorageAccessor::write(uint8_t* data, size_t size, uint16_t offset "entry!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } std::copy(data, data + size, dataPointer + offset); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void StorageAccessor::assignConstPointer() { constDataPointer = dataPointer; } diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index 90ea4587..11bdacad 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -25,7 +25,7 @@ using ConstAccessorPair = std::pair; * @author Bastian Baetz * @date 18.09.2012 */ -class StorageManagerIF : public HasReturnvaluesIF { +class StorageManagerIF { public: using size_type = size_t; using max_subpools_t = uint8_t; @@ -55,7 +55,7 @@ class StorageManagerIF : public HasReturnvaluesIF { /** * @brief This is the empty virtual destructor as required for C++ interfaces. */ - ~StorageManagerIF() override = default; + ~StorageManagerIF() = default; /** * @brief With addData, a free storage position is allocated and data * stored there. @@ -64,7 +64,7 @@ class StorageManagerIF : public HasReturnvaluesIF { * @param data The data to be stored in the StorageManager. * @param size The amount of data to be stored. * @return Returns @li RETURN_OK if data was added. - * @li RETURN_FAILED if data could not be added. + * @li returnvalue::FAILED if data could not be added. * storageId is unchanged then. */ virtual ReturnValue_t addData(store_address_t* storageId, const uint8_t* data, size_t size, @@ -74,7 +74,7 @@ class StorageManagerIF : public HasReturnvaluesIF { * identified by packet_id. * @param packet_id The identifier of the memory region to be freed. * @return @li RETURN_OK on success. - * @li RETURN_FAILED if deletion did not work + * @li returnvalue::FAILED if deletion did not work * (e.g. an illegal packet_id was passed). */ virtual ReturnValue_t deleteData(store_address_t packet_id) = 0; @@ -117,7 +117,7 @@ class StorageManagerIF : public HasReturnvaluesIF { * position * @param size The exact size of the stored data is returned here. * @return @li RETURN_OK on success. - * @li RETURN_FAILED if fetching data did not work + * @li returnvalue::FAILED if fetching data did not work * (e.g. an illegal packet_id was passed). */ virtual ReturnValue_t getData(store_address_t packet_id, const uint8_t** packet_ptr, @@ -157,7 +157,7 @@ class StorageManagerIF : public HasReturnvaluesIF { * @param size The size of the space to be reserved. * @param p_data A pointer to the element data is returned here. * @return Returns @li RETURN_OK if data was added. - * @li RETURN_FAILED if data could not be added. + * @li 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** p_data, diff --git a/src/fsfw/subsystem/Subsystem.cpp b/src/fsfw/subsystem/Subsystem.cpp index 27e6ae8e..b2af5ac3 100644 --- a/src/fsfw/subsystem/Subsystem.cpp +++ b/src/fsfw/subsystem/Subsystem.cpp @@ -39,12 +39,12 @@ ReturnValue_t Subsystem::checkSequence(HybridIterator iter, return TABLE_DOES_NOT_EXIST; } else { ReturnValue_t result = checkTable(getTable(iter->getTableId())); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t Subsystem::checkSequence(Mode_t sequence) { @@ -55,9 +55,11 @@ ReturnValue_t Subsystem::checkSequence(Mode_t sequence) { return checkSequence(iter, getFallbackSequence(sequence)); } -bool Subsystem::existsModeSequence(Mode_t id) { return modeSequences.exists(id) == RETURN_OK; } +bool Subsystem::existsModeSequence(Mode_t id) { + return modeSequences.exists(id) == returnvalue::OK; +} -bool Subsystem::existsModeTable(Mode_t id) { return modeTables.exists(id) == RETURN_OK; } +bool Subsystem::existsModeTable(Mode_t id) { return modeTables.exists(id) == returnvalue::OK; } HybridIterator Subsystem::getCurrentTable() { return getTable(currentSequenceIterator->getTableId()); @@ -67,7 +69,7 @@ void Subsystem::performChildOperation() { if (isInTransition) { if (commandsOutstanding <= 0) { // all children of the current table were commanded and replied if (currentSequenceIterator.value == nullptr) { // we're through with this sequence - if (checkStateAgainstTable(currentTargetTable, targetSubmode) == RETURN_OK) { + if (checkStateAgainstTable(currentTargetTable, targetSubmode) == returnvalue::OK) { setMode(targetMode, targetSubmode); isInTransition = false; return; @@ -82,7 +84,7 @@ void Subsystem::performChildOperation() { } } if (currentSequenceIterator->checkSuccess()) { - if (checkStateAgainstTable(getCurrentTable(), targetSubmode) != RETURN_OK) { + if (checkStateAgainstTable(getCurrentTable(), targetSubmode) != returnvalue::OK) { transitionFailed(TABLE_CHECK_FAILED, currentSequenceIterator->getTableId()); return; } @@ -111,7 +113,7 @@ void Subsystem::performChildOperation() { childrenChangedHealth = false; startTransition(mode, submode); } else if (childrenChangedMode) { - if (checkStateAgainstTable(currentTargetTable, submode) != RETURN_OK) { + if (checkStateAgainstTable(currentTargetTable, submode) != returnvalue::OK) { triggerEvent(CANT_KEEP_MODE, mode, submode); cantKeepMode(); } @@ -154,15 +156,15 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage *message) { size_t sizeRead; ReturnValue_t result = IPCStore->getData(ModeSequenceMessage::getStoreAddress(message), &pointer, &sizeRead); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { Mode_t fallbackId; size_t size = sizeRead; result = SerializeAdapter::deSerialize(&fallbackId, &pointer, &size, SerializeIF::Endianness::BIG); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { result = SerialArrayListAdapter::deSerialize(&sequence, &pointer, &size, SerializeIF::Endianness::BIG); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { result = addSequence(&sequence, ModeSequenceMessage::getSequenceId(message), fallbackId); } @@ -177,11 +179,11 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage *message) { size_t sizeRead; ReturnValue_t result = IPCStore->getData(ModeSequenceMessage::getStoreAddress(message), &pointer, &sizeRead); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { size_t size = sizeRead; result = SerialArrayListAdapter::deSerialize(&table, &pointer, &size, SerializeIF::Endianness::BIG); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { result = addTable(&table, ModeSequenceMessage::getSequenceId(message)); } IPCStore->deleteData(ModeSequenceMessage::getStoreAddress(message)); @@ -228,7 +230,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage *message) { Mode_t sequence = ModeSequenceMessage::getSequenceId(message); SequenceInfo *sequenceInfo = NULL; result = modeSequences.find(sequence, &sequenceInfo); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { replyToCommand(result, 0); } @@ -255,7 +257,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage *message) { Mode_t table = ModeSequenceMessage::getSequenceId(message); EntryPointer *entry = nullptr; result = modeTables.find(table, &entry); - if (result != RETURN_OK or entry == nullptr) { + if (result != returnvalue::OK or entry == nullptr) { replyToCommand(result, 0); if (entry == nullptr) { return result; @@ -292,13 +294,13 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage *message) { commandQueue->reply(&reply); } break; default: - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } void Subsystem::replyToCommand(ReturnValue_t status, uint32_t parameter) { - if (status == RETURN_OK) { + if (status == returnvalue::OK) { CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, 0); commandQueue->reply(&reply); } else { @@ -322,7 +324,7 @@ ReturnValue_t Subsystem::addSequence(ArrayList *sequence, Mode_t if (!preInit) { result = checkSequence(HybridIterator(sequence->front(), sequence->back()), fallbackSequence); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -336,19 +338,19 @@ ReturnValue_t Subsystem::addSequence(ArrayList *sequence, Mode_t result = modeSequences.insert(id, info); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (inStore) { #if FSFW_USE_MODESTORE == 1 result = modeStore->storeArray(sequence, &(modeSequences.find(id)->entries.firstLinkedElement)); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { modeSequences.erase(id); } #else modeSequences.erase(id); - return RETURN_FAILED; + return returnvalue::FAILED; #endif } @@ -367,7 +369,7 @@ ReturnValue_t Subsystem::addTable(ArrayList *table, Mode_t id, bo // are not added yet. Tables added before are checked by initialize() if (!preInit) { result = checkTable(HybridIterator(table->front(), table->back())); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -379,19 +381,19 @@ ReturnValue_t Subsystem::addTable(ArrayList *table, Mode_t id, bo result = modeTables.insert(id, pointer); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (inStore) { #if FSFW_USE_MODESTORE == 1 result = modeStore->storeArray(table, &(modeTables.find(id)->firstLinkedElement)); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { modeTables.erase(id); } #else modeTables.erase(id); - return RETURN_FAILED; + return returnvalue::FAILED; #endif } return result; @@ -405,7 +407,7 @@ ReturnValue_t Subsystem::deleteSequence(Mode_t id) { SequenceInfo *sequenceInfo; ReturnValue_t result; result = modeSequences.find(id, &sequenceInfo); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (!sequenceInfo->entries.islinked) { @@ -416,7 +418,7 @@ ReturnValue_t Subsystem::deleteSequence(Mode_t id) { modeStore->deleteList(sequenceInfo->entries.firstLinkedElement); #endif modeSequences.erase(id); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t Subsystem::deleteTable(Mode_t id) { @@ -427,7 +429,7 @@ ReturnValue_t Subsystem::deleteTable(Mode_t id) { EntryPointer *pointer; ReturnValue_t result; result = modeTables.find(id, &pointer); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (!pointer->islinked) { @@ -438,26 +440,26 @@ ReturnValue_t Subsystem::deleteTable(Mode_t id) { modeStore->deleteList(pointer->firstLinkedElement); #endif modeSequences.erase(id); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t Subsystem::initialize() { ReturnValue_t result = SubsystemBase::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); if (IPCStore == NULL) { - return RETURN_FAILED; + return returnvalue::FAILED; } #if FSFW_USE_MODESTORE == 1 modeStore = ObjectManager::instance()->get(objects::MODE_STORE); if (modeStore == nullptr) { - return RETURN_FAILED; + return returnvalue::FAILED; } #endif @@ -469,7 +471,7 @@ ReturnValue_t Subsystem::initialize() { mode = initialMode; submode = initSubmode; - return RETURN_OK; + return returnvalue::OK; } MessageQueueId_t Subsystem::getSequenceCommandQueue() const { @@ -553,7 +555,7 @@ void Subsystem::transitionFailed(ReturnValue_t failureCode, uint32_t parameter) // so we come here at the next fail modeHelper.setForced(true); ReturnValue_t result; - if ((result = checkSequence(getFallbackSequence(mode))) != RETURN_OK) { + if ((result = checkSequence(getFallbackSequence(mode))) != returnvalue::OK) { triggerEvent(FALLBACK_FAILED, result, getFallbackSequence(mode)); // keep still and allow arbitrary mode commands to recover isInTransition = false; @@ -579,7 +581,7 @@ void Subsystem::sendSerializablesAsCommandMessage(Command_t command, SerializeIF size_t size = 0; result = IPCStore->getFreeElement(&address, maxSize, &storeBuffer); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { replyToCommand(result, 0); return; } @@ -588,21 +590,21 @@ void Subsystem::sendSerializablesAsCommandMessage(Command_t command, SerializeIF } CommandMessage reply; ModeSequenceMessage::setModeSequenceMessage(&reply, command, address); - if (commandQueue->reply(&reply) != RETURN_OK) { + if (commandQueue->reply(&reply) != returnvalue::OK) { IPCStore->deleteData(address); } } ReturnValue_t Subsystem::checkObjectConnections() { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; for (FixedMap::Iterator iter = modeSequences.begin(); iter != modeSequences.end(); iter++) { result = checkSequence(iter.value->first); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } } - return RETURN_OK; + return returnvalue::OK; } void Subsystem::setInitialMode(Mode_t mode, Submode_t submode) { @@ -612,7 +614,7 @@ void Subsystem::setInitialMode(Mode_t mode, Submode_t submode) { void Subsystem::cantKeepMode() { ReturnValue_t result; - if ((result = checkSequence(getFallbackSequence(mode))) != RETURN_OK) { + if ((result = checkSequence(getFallbackSequence(mode))) != returnvalue::OK) { triggerEvent(FALLBACK_FAILED, result, getFallbackSequence(mode)); return; } diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 104db3c3..17bbdf46 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -42,7 +42,7 @@ ReturnValue_t SubsystemBase::registerChild(object_id_t objectId) { if (not resultPair.second) { return COULD_NOT_INSERT_CHILD; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t SubsystemBase::checkStateAgainstTable(HybridIterator tableIter, @@ -53,11 +53,11 @@ ReturnValue_t SubsystemBase::checkStateAgainstTable(HybridIteratorgetObject(); if ((childIter = childrenMap.find(object)) == childrenMap.end()) { - return RETURN_FAILED; + return returnvalue::FAILED; } if (childIter->second.mode != tableIter.value->getMode()) { - return RETURN_FAILED; + return returnvalue::FAILED; } Submode_t submodeToCheckAgainst = tableIter.value->getSubmode(); @@ -66,10 +66,10 @@ ReturnValue_t SubsystemBase::checkStateAgainstTable(HybridIteratorsecond.submode != submodeToCheckAgainst) { - return RETURN_FAILED; + return returnvalue::FAILED; } } - return RETURN_OK; + return returnvalue::OK; } void SubsystemBase::executeTable(HybridIterator tableIter, Submode_t targetSubmode) { @@ -122,7 +122,7 @@ void SubsystemBase::executeTable(HybridIterator tableIter, Submod // mode is forced to reach lower levels } ReturnValue_t result = commandQueue->sendMessage(iter->second.commandQueue, &command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { ++commandsOutstanding; } } @@ -136,7 +136,7 @@ ReturnValue_t SubsystemBase::updateChildMode(MessageQueueId_t queue, Mode_t mode if (iter->second.commandQueue == queue) { iter->second.mode = mode; iter->second.submode = submode; - return RETURN_OK; + return returnvalue::OK; } } return CHILD_NOT_FOUND; @@ -146,7 +146,7 @@ ReturnValue_t SubsystemBase::updateChildChangedHealth(MessageQueueId_t queue, bo for (auto iter = childrenMap.begin(); iter != childrenMap.end(); iter++) { if (iter->second.commandQueue == queue) { iter->second.healthChanged = changedHealth; - return RETURN_OK; + return returnvalue::OK; } } return CHILD_NOT_FOUND; @@ -158,14 +158,14 @@ ReturnValue_t SubsystemBase::initialize() { MessageQueueId_t parentQueue = MessageQueueIF::NO_QUEUE; ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (parentId != objects::NO_OBJECT) { SubsystemBase* parent = ObjectManager::instance()->get(parentId); if (parent == nullptr) { - return RETURN_FAILED; + return returnvalue::FAILED; } parentQueue = parent->getCommandQueue(); @@ -174,17 +174,17 @@ ReturnValue_t SubsystemBase::initialize() { result = healthHelper.initialize(parentQueue); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = modeHelper.initialize(parentQueue); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t SubsystemBase::performOperation(uint8_t opCode) { @@ -194,7 +194,7 @@ ReturnValue_t SubsystemBase::performOperation(uint8_t opCode) { performChildOperation(); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) { @@ -203,14 +203,14 @@ ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) { updateChildMode(message->getSender(), ModeMessage::getMode(message), ModeMessage::getSubmode(message)); childrenChangedMode = true; - return RETURN_OK; + return returnvalue::OK; case ModeMessage::REPLY_MODE_REPLY: case ModeMessage::REPLY_WRONG_MODE_REPLY: updateChildMode(message->getSender(), ModeMessage::getMode(message), ModeMessage::getSubmode(message)); childrenChangedMode = true; commandsOutstanding--; - return RETURN_OK; + return returnvalue::OK; case ModeMessage::REPLY_CANT_REACH_MODE: commandsOutstanding--; { @@ -220,7 +220,7 @@ ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) { } } } - return RETURN_OK; + return returnvalue::OK; // case ModeMessage::CMD_MODE_COMMAND: // handleCommandedMode(message); // return RETURN_OK; @@ -232,7 +232,7 @@ ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) { // commandAllChildren(message); // return RETURN_OK; default: - return RETURN_FAILED; + return returnvalue::FAILED; } } @@ -242,7 +242,7 @@ ReturnValue_t SubsystemBase::checkTable(HybridIterator tableIter) return TABLE_CONTAINS_INVALID_OBJECT_ID; } } - return RETURN_OK; + return returnvalue::OK; } void SubsystemBase::replyToCommand(CommandMessage* message) { commandQueue->reply(message); } @@ -284,25 +284,25 @@ void SubsystemBase::checkCommandQueue() { ReturnValue_t result; CommandMessage command; - for (result = commandQueue->receiveMessage(&command); result == RETURN_OK; + for (result = commandQueue->receiveMessage(&command); result == returnvalue::OK; result = commandQueue->receiveMessage(&command)) { result = healthHelper.handleHealthCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = modeHelper.handleModeCommand(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = handleModeReply(&command); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { continue; } result = handleCommandMessage(&command); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { CommandMessage reply; reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, command.getCommand()); replyToCommand(&reply); @@ -315,7 +315,7 @@ ReturnValue_t SubsystemBase::setHealth(HealthState health) { case HEALTHY: case EXTERNAL_CONTROL: healthHelper.setHealth(health); - return RETURN_OK; + return returnvalue::OK; default: return INVALID_HEALTH_STATE; } diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index 52f9891e..ad341b80 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -20,7 +20,6 @@ class SubsystemBase : public SystemObject, public HasModesIF, public HasHealthIF, - public HasReturnvaluesIF, public ExecutableObjectIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::SUBSYSTEM_BASE; diff --git a/src/fsfw/subsystem/modes/ModeDefinitions.h b/src/fsfw/subsystem/modes/ModeDefinitions.h index 9a6b8e31..d22bcd95 100644 --- a/src/fsfw/subsystem/modes/ModeDefinitions.h +++ b/src/fsfw/subsystem/modes/ModeDefinitions.h @@ -21,17 +21,17 @@ class ModeListEntry : public SerializeIF, public LinkedElement { result = SerializeAdapter::serialize(&value1, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&value2, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&value3, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -50,17 +50,17 @@ class ModeListEntry : public SerializeIF, public LinkedElement { result = SerializeAdapter::deSerialize(&value1, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&value2, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&value3, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&value4, buffer, size, streamEndianness); diff --git a/src/fsfw/subsystem/modes/ModeStore.cpp b/src/fsfw/subsystem/modes/ModeStore.cpp index c70b5e21..2fb16d31 100644 --- a/src/fsfw/subsystem/modes/ModeStore.cpp +++ b/src/fsfw/subsystem/modes/ModeStore.cpp @@ -54,28 +54,28 @@ ReturnValue_t ModeStore::storeArray(ArrayList* sequence, } pointer->setNext(NULL); OSAL::unlockMutex(mutex); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ModeStore::deleteList(ModeListEntry* sequence) { ReturnValue_t result = isValidEntry(sequence); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT); deleteListNoLock(sequence); OSAL::unlockMutex(mutex); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ModeStore::readList(ModeListEntry* sequence, ArrayList* into) { ReturnValue_t result = isValidEntry(sequence); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } OSAL::lockMutex(mutex, OSAL::NO_TIMEOUT); result = into->insert(*sequence->value); - while ((result == HasReturnvaluesIF::RETURN_OK) && (sequence->getNext() != NULL)) { + while ((result == returnvalue::OK) && (sequence->getNext() != NULL)) { result = into->insert(*sequence->value); sequence = sequence->getNext()->value; } @@ -117,7 +117,7 @@ ReturnValue_t ModeStore::isValidEntry(ModeListEntry* sequence) { if ((sequence < store.front()) || (sequence > store.back()) || sequence->getNext() == emptySlot) { return INVALID_ENTRY; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } #endif diff --git a/src/fsfw/tasks/ExecutableObjectIF.h b/src/fsfw/tasks/ExecutableObjectIF.h index 753a124f..60f38259 100644 --- a/src/fsfw/tasks/ExecutableObjectIF.h +++ b/src/fsfw/tasks/ExecutableObjectIF.h @@ -45,7 +45,7 @@ class ExecutableObjectIF { * called so the execution frequency can't be cached in initialize() * @return */ - virtual ReturnValue_t initializeAfterTaskCreation() { return HasReturnvaluesIF::RETURN_OK; } + virtual ReturnValue_t initializeAfterTaskCreation() { return returnvalue::OK; } }; #endif /* FRAMEWORK_TASKS_EXECUTABLEOBJECTIF_H_ */ diff --git a/src/fsfw/tasks/FixedSlotSequence.cpp b/src/fsfw/tasks/FixedSlotSequence.cpp index 9305b441..e538c9fc 100644 --- a/src/fsfw/tasks/FixedSlotSequence.cpp +++ b/src/fsfw/tasks/FixedSlotSequence.cpp @@ -98,7 +98,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { if (customChecker != nullptr) { ReturnValue_t result = customChecker(slotList, customCheckArgs); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { // Continue for now but print error output. #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FixedSlotSequence::checkSequence:" @@ -132,9 +132,9 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { // << slotList.size() << std::endl; #endif if (errorCount > 0) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { @@ -144,7 +144,7 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { // Ensure that each unique object is initialized once. if (uniqueObjects.find(slot.executableObject) == uniqueObjects.end()) { ReturnValue_t result = slot.executableObject->initializeAfterTaskCreation(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { count++; } uniqueObjects.emplace(slot.executableObject); @@ -156,9 +156,9 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { "Counted " << count << " failed initializations!" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FixedSlotSequence::addCustomCheck(CustomCheckFunc customChecker_, void* checkerArgs_) { diff --git a/src/fsfw/tasks/FixedTimeslotTaskBase.cpp b/src/fsfw/tasks/FixedTimeslotTaskBase.cpp index 5d12d565..3327deae 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskBase.cpp +++ b/src/fsfw/tasks/FixedTimeslotTaskBase.cpp @@ -20,8 +20,8 @@ ReturnValue_t FixedTimeslotTaskBase::addSlot(object_id_t execId, ExecutableObjec #else sif::printError("Component 0x%08x not found, not adding it to PST\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } pollingSeqTable.addSlot(execId, slotTimeMs, executionStep, execObj, this); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tasks/FixedTimeslotTaskIF.h b/src/fsfw/tasks/FixedTimeslotTaskIF.h index c7b90ec3..916af639 100644 --- a/src/fsfw/tasks/FixedTimeslotTaskIF.h +++ b/src/fsfw/tasks/FixedTimeslotTaskIF.h @@ -15,7 +15,7 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF { ~FixedTimeslotTaskIF() override = default; static constexpr ReturnValue_t SLOT_LIST_EMPTY = - result::makeCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0); + returnvalue::makeCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0); /** * Add an object with a slot time and the execution step to the task. @@ -51,11 +51,11 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF { virtual ReturnValue_t checkSequence() = 0; ReturnValue_t addComponent(object_id_t object, uint8_t opCode) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t addComponent(ExecutableObjectIF* object, uint8_t opCode) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } }; diff --git a/src/fsfw/tasks/PeriodicTaskBase.cpp b/src/fsfw/tasks/PeriodicTaskBase.cpp index ce925a45..3ae8afe7 100644 --- a/src/fsfw/tasks/PeriodicTaskBase.cpp +++ b/src/fsfw/tasks/PeriodicTaskBase.cpp @@ -29,13 +29,13 @@ ReturnValue_t PeriodicTaskBase::addComponent(ExecutableObjectIF* object) { ReturnValue_t PeriodicTaskBase::initObjsAfterTaskCreation() { std::set uniqueObjects; - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; uint32_t count = 0; for (const auto& obj : objectList) { // Ensure that each unique object is initialized once. if (uniqueObjects.find(obj.first) == uniqueObjects.end()) { ReturnValue_t result = obj.first->initializeAfterTaskCreation(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { count++; status = result; } @@ -62,10 +62,10 @@ ReturnValue_t PeriodicTaskBase::addComponent(ExecutableObjectIF* object, uint8_t "PeriodicTask::addComponent: Invalid object. Make sure it " "implements ExecutableObjectIF!\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } objectList.push_back({object, opCode}); object->setTaskIF(this); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tasks/PeriodicTaskIF.h b/src/fsfw/tasks/PeriodicTaskIF.h index 03b709ab..04415533 100644 --- a/src/fsfw/tasks/PeriodicTaskIF.h +++ b/src/fsfw/tasks/PeriodicTaskIF.h @@ -29,7 +29,7 @@ class PeriodicTaskIF { * The objects are executed in the order added. The object needs to implement * ExecutableObjectIF * @param object Id of the object to add. - * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. + * @return RETURN_OK on success, returnvalue::FAILED if the object could not be added. */ virtual ReturnValue_t addComponent(object_id_t object, uint8_t opCode) = 0; virtual ReturnValue_t addComponent(object_id_t object) { return addComponent(object, 0); }; @@ -38,7 +38,7 @@ class PeriodicTaskIF { * Adds an object to the list of objects to be executed. * The objects are executed in the order added. * @param object pointer to the object to add. - * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. + * @return RETURN_OK on success, returnvalue::FAILED if the object could not be added. */ virtual ReturnValue_t addComponent(ExecutableObjectIF* object, uint8_t opCode) = 0; virtual ReturnValue_t addComponent(ExecutableObjectIF* object) { return addComponent(object, 0); } diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index 7c2974a4..db408e6d 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -27,7 +27,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { const uint8_t* packet = nullptr; size_t size = 0; ReturnValue_t result = tcStore->getData(currentMessage.getStorageId(), &packet, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CCSDSDistributor::selectDestination: Getting data from" @@ -43,7 +43,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { } SpacePacketReader currentPacket(packet, size); result = packetChecker->checkPacket(currentPacket, size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { } #if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1 sif::info << "CCSDSDistributor::selectDestination has packet with APID 0x" << std::hex @@ -62,20 +62,20 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { MessageQueueId_t CCSDSDistributor::getRequestQueue() { return tcQueue->getId(); } ReturnValue_t CCSDSDistributor::registerApplication(AcceptsTelecommandsIF* application) { - ReturnValue_t returnValue = RETURN_OK; + ReturnValue_t returnValue = returnvalue::OK; auto insertPair = this->queueMap.emplace(application->getIdentifier(), application->getRequestQueue()); if (not insertPair.second) { - returnValue = RETURN_FAILED; + returnValue = returnvalue::FAILED; } return returnValue; } ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid, MessageQueueId_t id) { - ReturnValue_t returnValue = RETURN_OK; + ReturnValue_t returnValue = returnvalue::OK; auto insertPair = this->queueMap.emplace(apid, id); if (not insertPair.second) { - returnValue = RETURN_FAILED; + returnValue = returnvalue::FAILED; } return returnValue; } @@ -100,14 +100,14 @@ ReturnValue_t CCSDSDistributor::initialize() { " TC store!\n"); #endif #endif - status = RETURN_FAILED; + status = returnvalue::FAILED; } return status; } ReturnValue_t CCSDSDistributor::callbackAfterSending(ReturnValue_t queueStatus) { - if (queueStatus != RETURN_OK) { + if (queueStatus != returnvalue::OK) { tcStore->deleteData(currentMessage.getStorageId()); } - return RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/CCSDSDistributorIF.h b/src/fsfw/tcdistribution/CCSDSDistributorIF.h index da4a943f..f4ca9505 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributorIF.h +++ b/src/fsfw/tcdistribution/CCSDSDistributorIF.h @@ -18,7 +18,7 @@ class CCSDSDistributorIF { * at the distributor. * @param application A pointer to the Application to register. * @return - @c RETURN_OK on success, - * - @c RETURN_FAILED on failure. + * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerApplication(AcceptsTelecommandsIF* application) = 0; /** @@ -28,7 +28,7 @@ class CCSDSDistributorIF { * @param id The MessageQueueId of the message queue to send the * TC Packets to. * @return - @c RETURN_OK on success, - * - @c RETURN_FAILED on failure. + * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerApplication(uint16_t apid, MessageQueueId_t id) = 0; /** diff --git a/src/fsfw/tcdistribution/CFDPDistributor.cpp b/src/fsfw/tcdistribution/CFDPDistributor.cpp index d7a02793..796e3cf2 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.cpp +++ b/src/fsfw/tcdistribution/CFDPDistributor.cpp @@ -13,7 +13,7 @@ CFDPDistributor::CFDPDistributor(uint16_t setApid, object_id_t setObjectId, : TcDistributor(setObjectId), apid(setApid), checker(setApid), - tcStatus(RETURN_FAILED), + tcStatus(returnvalue::FAILED), packetSource(setPacketSource) {} CFDPDistributor::~CFDPDistributor() = default; @@ -36,7 +36,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); if (currentPacket->getFullData() != nullptr) { tcStatus = checker.checkPacket(*currentPacket, currentPacket->getFullPacketLen()); - if (tcStatus != HasReturnvaluesIF::RETURN_OK) { + if (tcStatus != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "CFDPDistributor::handlePacket: Packet format invalid, code " @@ -63,7 +63,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() { #endif } - if (tcStatus != RETURN_OK) { + if (tcStatus != returnvalue::OK) { return this->queueMap.end(); } else { return queueMapIt; @@ -95,7 +95,7 @@ ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) { #endif return SERVICE_ID_ALREADY_EXISTS; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MessageQueueId_t CFDPDistributor::getRequestQueue() { return tcQueue->getId(); } @@ -110,7 +110,7 @@ MessageQueueId_t CFDPDistributor::getRequestQueue() { return tcQueue->getId(); } // // A failed packet is deleted immediately after reporting, // // otherwise it will block memory. // currentPacket->deletePacket(); -// return RETURN_FAILED; +// return returnvalue::FAILED; // } else { // this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, // currentPacket); @@ -136,7 +136,7 @@ ReturnValue_t CFDPDistributor::initialize() { sif::printError("CFDPDistributor::initialize: Packet source invalid\n"); sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); #endif - return RETURN_FAILED; + return returnvalue::FAILED; } return ccsdsDistributor->registerApplication(this); } diff --git a/src/fsfw/tcdistribution/CFDPDistributorIF.h b/src/fsfw/tcdistribution/CFDPDistributorIF.h index 3f048bbf..4b7ec807 100644 --- a/src/fsfw/tcdistribution/CFDPDistributorIF.h +++ b/src/fsfw/tcdistribution/CFDPDistributorIF.h @@ -18,7 +18,7 @@ class CFDPDistributorIF { * With this method, Handlers can register themselves at the CFDP Distributor. * @param handler A pointer to the registering Handler. * @return - @c RETURN_OK on success, - * - @c RETURN_FAILED on failure. + * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) = 0; }; diff --git a/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp b/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp index 394f5a57..08ec1811 100644 --- a/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp +++ b/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp @@ -24,7 +24,7 @@ ReturnValue_t CcsdsPacketChecker::checkPacket(const SpacePacketReader& currentPa if (currentPacket.getFullPacketLen() != packetLen) { return tcdistrib::INCOMPLETE_PACKET; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void CcsdsPacketChecker::setApidToCheck(uint16_t apid_) { diff --git a/src/fsfw/tcdistribution/CcsdsPacketChecker.h b/src/fsfw/tcdistribution/CcsdsPacketChecker.h index f910aac4..7def030d 100644 --- a/src/fsfw/tcdistribution/CcsdsPacketChecker.h +++ b/src/fsfw/tcdistribution/CcsdsPacketChecker.h @@ -4,7 +4,7 @@ #include "CcsdsPacketCheckIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" -class CcsdsPacketChecker : public CcsdsPacketCheckIF, public HasReturnvaluesIF { +class CcsdsPacketChecker : public CcsdsPacketCheckIF { public: CcsdsPacketChecker(ccsds::PacketType packetType, uint8_t ccsdsVersion = 0b000); diff --git a/src/fsfw/tcdistribution/CfdpPacketChecker.h b/src/fsfw/tcdistribution/CfdpPacketChecker.h index 5ad802f9..b1d46ae4 100644 --- a/src/fsfw/tcdistribution/CfdpPacketChecker.h +++ b/src/fsfw/tcdistribution/CfdpPacketChecker.h @@ -10,7 +10,7 @@ class CfdpPacketStored; * This class performs a formal packet check for incoming CFDP Packets. * @ingroup tc_distribution */ -class CfdpPacketChecker : public CcsdsPacketCheckIF, public HasReturnvaluesIF { +class CfdpPacketChecker : public CcsdsPacketCheckIF { protected: /** * The packet id each correct packet should have. diff --git a/src/fsfw/tcdistribution/PUSDistributorIF.h b/src/fsfw/tcdistribution/PUSDistributorIF.h index da6db283..85619fee 100644 --- a/src/fsfw/tcdistribution/PUSDistributorIF.h +++ b/src/fsfw/tcdistribution/PUSDistributorIF.h @@ -18,7 +18,7 @@ class PUSDistributorIF { * With this method, Services can register themselves at the PUS Distributor. * @param service A pointer to the registering Service. * @return - @c RETURN_OK on success, - * - @c RETURN_FAILED on failure. + * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerService(AcceptsTelecommandsIF* service) = 0; }; diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index ade49201..88a7800c 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -14,7 +14,7 @@ PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, store(store_), checker(setApid, ccsds::PacketType::TC), ccsdsDistributor(distributor), - tcStatus(RETURN_FAILED) {} + tcStatus(returnvalue::FAILED) {} PusDistributor::~PusDistributor() = default; @@ -28,24 +28,23 @@ PusDistributor::TcMqMapIter PusDistributor::selectDestination() { // TODO: Need to set the data const uint8_t* packetPtr = nullptr; size_t packetLen = 0; - if (store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != - HasReturnvaluesIF::RETURN_OK) { + if (store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != returnvalue::OK) { return queueMapIt; } ReturnValue_t result = reader.setReadOnlyData(packetPtr, packetLen); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { tcStatus = PACKET_LOST; return queueMapIt; } // CRC check done by checker result = reader.parseDataWithoutCrcCheck(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { tcStatus = PACKET_LOST; return queueMapIt; } if (reader.getFullData() != nullptr) { tcStatus = checker.checkPacket(reader, reader.getFullPacketLen()); - if (tcStatus != HasReturnvaluesIF::RETURN_OK) { + if (tcStatus != returnvalue::OK) { checkerFailurePrinter(); } uint32_t queue_id = reader.getService(); @@ -65,7 +64,7 @@ PusDistributor::TcMqMapIter PusDistributor::selectDestination() { #endif } - if (tcStatus != RETURN_OK) { + if (tcStatus != returnvalue::OK) { return this->queueMap.end(); } else { return queueMapIt; @@ -95,25 +94,25 @@ ReturnValue_t PusDistributor::registerService(AcceptsTelecommandsIF* service) { #endif return SERVICE_ID_ALREADY_EXISTS; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MessageQueueId_t PusDistributor::getRequestQueue() { return tcQueue->getId(); } ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { - if (queueStatus != RETURN_OK) { + if (queueStatus != returnvalue::OK) { tcStatus = queueStatus; } - if (tcStatus != RETURN_OK) { + if (tcStatus != returnvalue::OK) { verifyChannel->sendFailureReport( VerifFailureParams(tcverif::ACCEPTANCE_FAILURE, reader, tcStatus)); // A failed packet is deleted immediately after reporting, // otherwise it will block memory. store->deleteData(currentMessage.getStorageId()); - return RETURN_FAILED; + return returnvalue::FAILED; } else { verifyChannel->sendSuccessReport(VerifSuccessParams(tcverif::ACCEPTANCE_SUCCESS, reader)); - return RETURN_OK; + return returnvalue::OK; } } diff --git a/src/fsfw/tcdistribution/PusPacketChecker.cpp b/src/fsfw/tcdistribution/PusPacketChecker.cpp index 8ea8b6a8..dc5b9ab9 100644 --- a/src/fsfw/tcdistribution/PusPacketChecker.cpp +++ b/src/fsfw/tcdistribution/PusPacketChecker.cpp @@ -24,7 +24,7 @@ ReturnValue_t PusPacketChecker::checkPacket(const PusTcReader& pusPacket, size_t if (pusPacket.getPusVersion() != pusVersion) { return tcdistrib::INVALID_PUS_VERSION; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint16_t PusPacketChecker::getApid() const { return apid; } diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index 4ec85ed9..24ed5140 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -12,19 +12,19 @@ TcDistributor::~TcDistributor() { QueueFactory::instance()->deleteMessageQueue(t ReturnValue_t TcDistributor::performOperation(uint8_t opCode) { ReturnValue_t status; - for (status = tcQueue->receiveMessage(¤tMessage); status == RETURN_OK; + for (status = tcQueue->receiveMessage(¤tMessage); status == returnvalue::OK; status = tcQueue->receiveMessage(¤tMessage)) { status = handlePacket(); } if (status == MessageQueueIF::EMPTY) { - return RETURN_OK; + return returnvalue::OK; } return status; } ReturnValue_t TcDistributor::handlePacket() { auto queueMapIt = selectDestination(); - ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = returnvalue::FAILED; if (queueMapIt != queueMap.end()) { result = tcQueue->sendMessage(queueMapIt->second, ¤tMessage); } @@ -42,4 +42,6 @@ void TcDistributor::print() { #endif } -ReturnValue_t TcDistributor::callbackAfterSending(ReturnValue_t queueStatus) { return RETURN_OK; } +ReturnValue_t TcDistributor::callbackAfterSending(ReturnValue_t queueStatus) { + return returnvalue::OK; +} diff --git a/src/fsfw/tcdistribution/TcDistributor.h b/src/fsfw/tcdistribution/TcDistributor.h index 1b783ff4..7c7e539c 100644 --- a/src/fsfw/tcdistribution/TcDistributor.h +++ b/src/fsfw/tcdistribution/TcDistributor.h @@ -27,7 +27,7 @@ * implementations. * @ingroup tc_distribution */ -class TcDistributor : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { +class TcDistributor : public SystemObject, public ExecutableObjectIF { public: using TcMessageQueueMap = std::map; using TcMqMapIter = std::map::iterator; @@ -93,7 +93,7 @@ class TcDistributor : public SystemObject, public ExecutableObjectIF, public Has /** * The handlePacket method calls the child class's selectDestination method * and forwards the packet to its destination, if found. - * @return The message queue return value or @c RETURN_FAILED, in case no + * @return The message queue return value or @c returnvalue::FAILED, in case no * destination was found. */ ReturnValue_t handlePacket(); @@ -105,7 +105,7 @@ class TcDistributor : public SystemObject, public ExecutableObjectIF, public Has * @param queueStatus The status of the message queue after an attempt * to send the TC. * @return - @c RETURN_OK on success - * - @c RETURN_FAILED on failure + * - @c returnvalue::FAILED on failure */ virtual ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus); diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp index 9a0b89bd..8171a392 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp @@ -5,7 +5,7 @@ CfdpPacketChecker::CfdpPacketChecker(uint16_t setApid) : apid(setApid) {} ReturnValue_t CfdpPacketChecker::checkPacket(const SpacePacketReader& currentPacket, size_t packetLen) { - return RETURN_OK; + return returnvalue::OK; } uint16_t CfdpPacketChecker::getApid() const { return apid; } diff --git a/src/fsfw/thermal/AbstractTemperatureSensor.cpp b/src/fsfw/thermal/AbstractTemperatureSensor.cpp index 68cd3aca..fc182bf1 100644 --- a/src/fsfw/thermal/AbstractTemperatureSensor.cpp +++ b/src/fsfw/thermal/AbstractTemperatureSensor.cpp @@ -24,11 +24,11 @@ MessageQueueId_t AbstractTemperatureSensor::getCommandQueue() const { ReturnValue_t AbstractTemperatureSensor::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = parameterHelper.initialize(); @@ -38,24 +38,24 @@ ReturnValue_t AbstractTemperatureSensor::initialize() { ReturnValue_t AbstractTemperatureSensor::performOperation(uint8_t opCode) { handleCommandQueue(); doChildOperation(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t AbstractTemperatureSensor::performHealthOp() { handleCommandQueue(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void AbstractTemperatureSensor::handleCommandQueue() { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { result = healthHelper.handleHealthCommand(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } result = parameterHelper.handleParameterMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } command.setToUnknownCommand(); @@ -65,7 +65,7 @@ void AbstractTemperatureSensor::handleCommandQueue() { ReturnValue_t AbstractTemperatureSensor::setHealth(HealthState health) { healthHelper.setHealth(health); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } HasHealthIF::HealthState AbstractTemperatureSensor::getHealth() { return healthHelper.getHealth(); } diff --git a/src/fsfw/thermal/Heater.cpp b/src/fsfw/thermal/Heater.cpp index 4f0f8060..64348106 100644 --- a/src/fsfw/thermal/Heater.cpp +++ b/src/fsfw/thermal/Heater.cpp @@ -21,14 +21,14 @@ ReturnValue_t Heater::set() { passive = false; // wait for clear before doing anything if (internalState == STATE_WAIT) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } if (healthHelper.healthTable->isHealthy(getObjectId())) { doAction(SET); if ((internalState == STATE_OFF) || (internalState == STATE_PASSIVE)) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } else { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } else { if (healthHelper.healthTable->isFaulty(getObjectId())) { @@ -37,7 +37,7 @@ ReturnValue_t Heater::set() { doAction(CLEAR); } } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -186,7 +186,7 @@ ReturnValue_t Heater::performOperation(uint8_t opCode) { wasOn = false; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void Heater::setSwitch(uint8_t number, ReturnValue_t state, uint32_t* uptimeOfSwitching) { @@ -220,54 +220,54 @@ MessageQueueId_t Heater::getCommandQueue() const { return commandQueue->getId(); ReturnValue_t Heater::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (manager == NULL) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } result = manager->registerListener(eventQueue->getId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } ConfirmsFailuresIF* pcdu = ObjectManager::instance()->get( DeviceHandlerFailureIsolation::powerConfirmationId); if (pcdu == NULL) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } pcduQueueId = pcdu->getEventReceptionQueue(); result = manager->subscribeToAllEventsFrom(eventQueue->getId(), getObjectId()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = parameterHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void Heater::handleQueue() { CommandMessage command; ReturnValue_t result = commandQueue->receiveMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { result = healthHelper.handleHealthCommand(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } result = parameterHelper.handleParameterMessage(&command); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { return; } } @@ -286,13 +286,13 @@ ReturnValue_t Heater::getParameter(uint8_t domainId, uint8_t uniqueId, default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void Heater::handleEventQueue() { EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); - result == HasReturnvaluesIF::RETURN_OK; result = eventQueue->receiveMessage(&event)) { + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK; + result = eventQueue->receiveMessage(&event)) { switch (event.getMessageId()) { case EventMessage::EVENT_MESSAGE: switch (event.getEvent()) { diff --git a/src/fsfw/thermal/RedundantHeater.cpp b/src/fsfw/thermal/RedundantHeater.cpp index 431d9900..24b70c89 100644 --- a/src/fsfw/thermal/RedundantHeater.cpp +++ b/src/fsfw/thermal/RedundantHeater.cpp @@ -14,7 +14,7 @@ void RedundantHeater::performOperation(uint8_t opCode) { void RedundantHeater::set(bool on, bool both, bool passive) { if (on) { ReturnValue_t result = heater0.set(); - if (result != HasReturnvaluesIF::RETURN_OK || both) { + if (result != returnvalue::OK || both) { heater1.set(); } else { heater1.clear(passive); diff --git a/src/fsfw/thermal/TemperatureSensor.h b/src/fsfw/thermal/TemperatureSensor.h index 591fd7d9..4cb2a083 100644 --- a/src/fsfw/thermal/TemperatureSensor.h +++ b/src/fsfw/thermal/TemperatureSensor.h @@ -117,7 +117,7 @@ class TemperatureSensor : public AbstractTemperatureSensor { void doChildOperation() { ReturnValue_t result = inputTemperature->read(MutexIF::TimeoutType::WAITING, 20); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } @@ -209,7 +209,7 @@ class TemperatureSensor : public AbstractTemperatureSensor { default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } virtual void resetOldState() { sensorMonitor.setToUnchecked(); } diff --git a/src/fsfw/thermal/ThermalComponent.cpp b/src/fsfw/thermal/ThermalComponent.cpp index 000f2e19..e0077af2 100644 --- a/src/fsfw/thermal/ThermalComponent.cpp +++ b/src/fsfw/thermal/ThermalComponent.cpp @@ -21,18 +21,18 @@ ReturnValue_t ThermalComponent::setTargetState(int8_t newState) { targetState.setReadWriteMode(pool_rwm_t::VAR_READ_WRITE); targetState.read(); if ((targetState == STATE_REQUEST_OPERATIONAL) and (newState != STATE_REQUEST_IGNORE)) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } switch (newState) { case STATE_REQUEST_NON_OPERATIONAL: targetState = newState; targetState.setValid(true); targetState.commit(PoolVariableIF::VALID); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; default: return ThermalComponentCore::setTargetState(newState); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t ThermalComponent::setLimits(const uint8_t* data, size_t size) { @@ -48,7 +48,7 @@ ReturnValue_t ThermalComponent::setLimits(const uint8_t* data, size_t size) { SerializeIF::Endianness::BIG); SerializeAdapter::deSerialize(&nopParameters.upperNopLimit, &data, &readSize, SerializeIF::Endianness::BIG); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ThermalComponentIF::State ThermalComponent::getState(float temperature, @@ -155,5 +155,5 @@ ReturnValue_t ThermalComponent::getParameter(uint8_t domainId, uint8_t uniqueId, default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/thermal/ThermalComponentCore.cpp b/src/fsfw/thermal/ThermalComponentCore.cpp index 887c30f2..ef47f49f 100644 --- a/src/fsfw/thermal/ThermalComponentCore.cpp +++ b/src/fsfw/thermal/ThermalComponentCore.cpp @@ -18,7 +18,7 @@ ThermalComponentCore::ThermalComponentCore(object_id_t reportingObjectId, uint8_ // Set thermal state once, then leave to operator. targetState.setReadWriteMode(PoolVariableIF::VAR_WRITE); ReturnValue_t result = targetState.read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { targetState = initialTargetState; targetState.setValid(true); targetState.commit(); @@ -91,7 +91,7 @@ ReturnValue_t ThermalComponentCore::setTargetState(int8_t newState) { targetState.setReadWriteMode(pool_rwm_t::VAR_READ_WRITE); targetState.read(); if ((targetState == STATE_REQUEST_OPERATIONAL) and (newState != STATE_REQUEST_IGNORE)) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } switch (newState) { @@ -106,7 +106,7 @@ ReturnValue_t ThermalComponentCore::setTargetState(int8_t newState) { } targetState.setValid(true); targetState.commit(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void ThermalComponentCore::setOutputInvalid() { @@ -267,5 +267,5 @@ ReturnValue_t ThermalComponentCore::getParameter(uint8_t domainId, uint8_t uniqu default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/thermal/ThermalModule.cpp b/src/fsfw/thermal/ThermalModule.cpp index 976bbe45..6f62a02b 100644 --- a/src/fsfw/thermal/ThermalModule.cpp +++ b/src/fsfw/thermal/ThermalModule.cpp @@ -233,7 +233,7 @@ bool ThermalModule::calculateModuleHeaterRequestAndSetModuleStatus(Strategy stra void ThermalModule::setHeating(bool on) { ReturnValue_t result = targetState.read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { if (on) { targetState.value = STATE_REQUEST_HEATING; } else { diff --git a/src/fsfw/thermal/ThermalMonitorReporter.cpp b/src/fsfw/thermal/ThermalMonitorReporter.cpp index dc64280e..2e6796a6 100644 --- a/src/fsfw/thermal/ThermalMonitorReporter.cpp +++ b/src/fsfw/thermal/ThermalMonitorReporter.cpp @@ -46,20 +46,20 @@ ReturnValue_t ThermalMonitorReporter::translateState(ThermalComponentIF::State s if (componentIsOperational) { return monitorStateIs(ThermalComponentIF::BELOW_OPERATIONAL_LIMIT, sample, lowerLimit); } else { - return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0); + return monitorStateIs(returnvalue::OK, sample, 0.0); } case ThermalComponentIF::OPERATIONAL: - return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0); + return monitorStateIs(returnvalue::OK, sample, 0.0); case ThermalComponentIF::NON_OPERATIONAL_HIGH: if (componentIsOperational) { return monitorStateIs(ThermalComponentIF::ABOVE_OPERATIONAL_LIMIT, sample, upperLimit); } else { - return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0); + return monitorStateIs(returnvalue::OK, sample, 0.0); } case ThermalComponentIF::OUT_OF_RANGE_HIGH: return monitorStateIs(MonitoringIF::ABOVE_HIGH_LIMIT, sample, upperLimit); default: // Never reached, all states covered. - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/src/fsfw/timemanager/CCSDSTime.cpp b/src/fsfw/timemanager/CCSDSTime.cpp index 4d5de9b3..cb0d5758 100644 --- a/src/fsfw/timemanager/CCSDSTime.cpp +++ b/src/fsfw/timemanager/CCSDSTime.cpp @@ -8,7 +8,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(Ccs_seconds* to, const Clock::TimeOfDay_t* from) { ReturnValue_t result = checkTimeOfDay(from); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -22,12 +22,12 @@ ReturnValue_t CCSDSTime::convertToCcsds(Ccs_seconds* to, const Clock::TimeOfDay_ to->minute = from->minute; to->second = from->second; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertToCcsds(Ccs_mseconds* to, const Clock::TimeOfDay_t* from) { ReturnValue_t result = checkTimeOfDay(from); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -43,7 +43,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(Ccs_mseconds* to, const Clock::TimeOfDay to->secondEminus2 = from->usecond / 10000; to->secondEminus4 = (from->usecond % 10000) / 100; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, const uint8_t* from, @@ -53,8 +53,8 @@ ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, const uint8_t* return LENGTH_MISMATCH; } result = convertFromASCII(to, from, length); // Try to parse it as ASCII - if (result == RETURN_OK) { - return RETURN_OK; + if (result == returnvalue::OK) { + return returnvalue::OK; } // Seems to be no ascii, try the other formats @@ -84,7 +84,7 @@ ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to, const uint8_t* f uint8_t length) { timeval time; ReturnValue_t result = convertFromCDS(&time, from, NULL, length); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return Clock::convertTimevalToTimeOfDay(&time, to); @@ -102,7 +102,7 @@ ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* f ReturnValue_t result = checkCcs(from, maxLength); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } // At this point we made sure that this is a valid ccs time @@ -118,7 +118,7 @@ ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* f uint8_t tempDay = 0; uint8_t tempMonth = 0; result = convertDaysOfYear(tempDayOfYear, to->year, &tempMonth, &tempDay); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } to->month = tempMonth; @@ -144,13 +144,13 @@ ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* f to->usecond += temp->secondEminus4 * 100; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* from, uint8_t length) { if (length < 19) { - return RETURN_FAILED; + return returnvalue::FAILED; } // Newlib nano can't parse uint8, see SCNu8 documentation and https://sourceware.org/newlib/README // Suggestion: use uint16 all the time. This should work on all systems. @@ -174,7 +174,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* to->minute = minute; to->second = second; to->usecond = (second - floor(second)) * 1000000; - return RETURN_OK; + return returnvalue::OK; } // try Code B (yyyy-ddd) @@ -187,8 +187,8 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* uint8_t tempDay; ReturnValue_t result = CCSDSTime::convertDaysOfYear( day, year, reinterpret_cast(&month), reinterpret_cast(&tempDay)); - if (result != RETURN_OK) { - return RETURN_FAILED; + if (result != returnvalue::OK) { + return returnvalue::FAILED; } to->year = year; to->month = month; @@ -197,7 +197,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* to->minute = minute; to->second = second; to->usecond = (second - floor(second)) * 1000000; - return RETURN_OK; + return returnvalue::OK; } // Warning: Compiler/Linker fails ambiguously if library does not implement // C99 I/O @@ -220,7 +220,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* to->minute = minute; to->second = second; to->usecond = (second - floor(second)) * 1000000; - return RETURN_OK; + return returnvalue::OK; } // try Code B (yyyy-ddd) @@ -229,8 +229,8 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* if (count == 5) { uint8_t tempDay; ReturnValue_t result = CCSDSTime::convertDaysOfYear(day, year, &month, &tempDay); - if (result != RETURN_OK) { - return RETURN_FAILED; + if (result != returnvalue::OK) { + return returnvalue::FAILED; } to->year = year; to->month = month; @@ -239,7 +239,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* to->minute = minute; to->second = second; to->usecond = (second - floor(second)) * 1000000; - return RETURN_OK; + return returnvalue::OK; } #endif @@ -284,7 +284,7 @@ ReturnValue_t CCSDSTime::checkCcs(const uint8_t* time, uint8_t length) { return INVALID_TIME_FORMAT; } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertDaysOfYear(uint16_t dayofYear, uint16_t year, uint8_t* month, @@ -301,21 +301,21 @@ ReturnValue_t CCSDSTime::convertDaysOfYear(uint16_t dayofYear, uint16_t year, ui *month = 1; if (dayofYear <= 31) { *day = dayofYear; - return RETURN_OK; + return returnvalue::OK; } *month += 1; dayofYear -= 31; if (isLeapYear(year)) { if (dayofYear <= 29) { *day = dayofYear; - return RETURN_OK; + return returnvalue::OK; } *month += 1; dayofYear -= 29; } else { if (dayofYear <= 28) { *day = dayofYear; - return RETURN_OK; + return returnvalue::OK; } *month += 1; dayofYear -= 28; @@ -323,7 +323,7 @@ ReturnValue_t CCSDSTime::convertDaysOfYear(uint16_t dayofYear, uint16_t year, ui while (*month <= 12) { if (dayofYear <= 31) { *day = dayofYear; - return RETURN_OK; + return returnvalue::OK; } *month += 1; dayofYear -= 31; @@ -334,7 +334,7 @@ ReturnValue_t CCSDSTime::convertDaysOfYear(uint16_t dayofYear, uint16_t year, ui if (dayofYear <= 30) { *day = dayofYear; - return RETURN_OK; + return returnvalue::OK; } *month += 1; dayofYear -= 30; @@ -369,7 +369,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(CDS_short* to, const timeval* from) { to->msDay_h = (msDay & 0xFF0000) >> 16; to->msDay_l = (msDay & 0xFF00) >> 8; to->msDay_ll = (msDay & 0xFF); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertToCcsds(OBT_FLP* to, const timeval* from) { @@ -387,7 +387,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(OBT_FLP* to, const timeval* from) { to->subsecondsMSB = (temp >> 8) & 0xff; to->subsecondsLSB = temp & 0xff; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from, size_t* foundLength, @@ -396,7 +396,7 @@ ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from, size Clock::TimeOfDay_t timeOfDay; /* Try to parse it as ASCII */ ReturnValue_t result = convertFromASCII(&timeOfDay, from, maxLength); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { return Clock::convertTimeOfDayToTimeval(&timeOfDay, to); } } @@ -423,7 +423,7 @@ ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, const uint8_t* from, size_t uint8_t pField = *from; from++; ReturnValue_t result = convertFromCUC(to, pField, from, foundLength, maxLength - 1); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { if (foundLength != nullptr) { *foundLength += 1; } @@ -482,7 +482,7 @@ ReturnValue_t CCSDSTime::checkTimeOfDay(const Clock::TimeOfDay_t* time) { return INVALID_TIME_FORMAT; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from, size_t* foundLength, @@ -545,12 +545,12 @@ ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from, size_t // Not very useful. to->tv_usec += (picosecs / 1000); } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const CCSDSTime::CDS_short* from) { if (to == nullptr or from == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint16_t days = (from->dayMSB << 8) + from->dayLSB; if (days <= DAYS_CCSDS_TO_UNIX_EPOCH) { @@ -562,16 +562,16 @@ ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const CCSDSTime::CDS_short* (from->msDay_hh << 24) + (from->msDay_h << 16) + (from->msDay_l << 8) + from->msDay_ll; to->tv_sec += (msDay / 1000); to->tv_usec = (msDay % 1000) * 1000; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to, const CCSDSTime::CDS_short* from) { if (to == nullptr or from == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } timeval tempTimeval; ReturnValue_t result = convertFromCDS(&tempTimeval, from); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return Clock::convertTimevalToTimeOfDay(&tempTimeval, to); @@ -605,7 +605,7 @@ ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, uint8_t pField, const uint8 to->tv_sec -= (DAYS_CCSDS_TO_UNIX_EPOCH * SECONDS_PER_DAY); } to->tv_usec = subsecondsToMicroseconds(subSeconds); - return RETURN_OK; + return returnvalue::OK; } uint32_t CCSDSTime::subsecondsToMicroseconds(uint16_t subseconds) { @@ -617,7 +617,7 @@ ReturnValue_t CCSDSTime::convertFromCCS(timeval* to, const uint8_t* from, size_t size_t maxLength) { Clock::TimeOfDay_t tempTime; ReturnValue_t result = convertFromCCS(&tempTime, from, foundLength, maxLength); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index 3f4361f8..10836f9b 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -20,7 +20,7 @@ bool operator==(const timeval &lhs, const timeval &rhs); * * Still work in progress */ -class CCSDSTime : public HasReturnvaluesIF { +class CCSDSTime { public: /** * The Time code identifications, bits 4-6 in the P-Field diff --git a/src/fsfw/timemanager/CdsShortTimeStamper.cpp b/src/fsfw/timemanager/CdsShortTimeStamper.cpp index cdce62c1..8095e28d 100644 --- a/src/fsfw/timemanager/CdsShortTimeStamper.cpp +++ b/src/fsfw/timemanager/CdsShortTimeStamper.cpp @@ -20,7 +20,7 @@ ReturnValue_t CdsShortTimeStamper::serialize(uint8_t **buffer, size_t *size, siz Clock::getClock_timeval(&now); CCSDSTime::CDS_short cds{}; ReturnValue_t result = CCSDSTime::convertToCcsds(&cds, &now); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } std::memcpy(*buffer, &cds, sizeof(cds)); @@ -33,7 +33,7 @@ size_t CdsShortTimeStamper::getSerializedSize() const { return getTimestampSize( ReturnValue_t CdsShortTimeStamper::deSerialize(const uint8_t **buffer, size_t *size, SerializeIF::Endianness streamEndianness) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t CdsShortTimeStamper::readTimeStamp(const uint8_t *buffer, size_t maxSize) { diff --git a/src/fsfw/timemanager/Clock.h b/src/fsfw/timemanager/Clock.h index 2dd01dd9..0544cab3 100644 --- a/src/fsfw/timemanager/Clock.h +++ b/src/fsfw/timemanager/Clock.h @@ -137,7 +137,7 @@ class Clock { * @param[out] tt timeval, corresponding to Terrestial Time * @return * - @c RETURN_OK on success - * - @c RETURN_FAILED if leapSeconds are not set + * - @c returnvalue::FAILED if leapSeconds are not set */ static ReturnValue_t convertUTCToTT(timeval utc, timeval *tt); @@ -158,7 +158,7 @@ class Clock { * @param[out] leapSeconds_ * @return * - @c RETURN_OK on success. - * - @c RETURN_FAILED on error + * - @c returnvalue::FAILED on error */ static ReturnValue_t getLeapSeconds(uint16_t *leapSeconds_); @@ -167,7 +167,7 @@ class Clock { * Function to check and create the Mutex for the clock * @return * - @c RETURN_OK on success. - * - Otherwise @c RETURN_FAILED if not able to create one + * - Otherwise @c returnvalue::FAILED if not able to create one */ static ReturnValue_t checkOrCreateClockMutex(); diff --git a/src/fsfw/timemanager/ClockCommon.cpp b/src/fsfw/timemanager/ClockCommon.cpp index ca8b12a4..45755f35 100644 --- a/src/fsfw/timemanager/ClockCommon.cpp +++ b/src/fsfw/timemanager/ClockCommon.cpp @@ -10,7 +10,7 @@ bool Clock::leapSecondsSet = false; ReturnValue_t Clock::convertUTCToTT(timeval utc, timeval* tt) { uint16_t leapSeconds; ReturnValue_t result = getLeapSeconds(&leapSeconds); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } timeval leapSeconds_timeval = {0, 0}; @@ -23,33 +23,33 @@ ReturnValue_t Clock::convertUTCToTT(timeval utc, timeval* tt) { *tt = utc + leapSeconds_timeval + UTCtoTAI1972 + TAItoTT; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) { - if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_FAILED; + if (checkOrCreateClockMutex() != returnvalue::OK) { + return returnvalue::FAILED; } MutexGuard helper(timeMutex); leapSeconds = leapSeconds_; leapSecondsSet = true; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) { if (not leapSecondsSet) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_FAILED; + if (checkOrCreateClockMutex() != returnvalue::OK) { + return returnvalue::FAILED; } MutexGuard helper(timeMutex); *leapSeconds_ = leapSeconds; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::convertTimevalToTimeOfDay(const timeval* from, TimeOfDay_t* to) { @@ -58,7 +58,7 @@ ReturnValue_t Clock::convertTimevalToTimeOfDay(const timeval* from, TimeOfDay_t* // in the Windows CRT is incompatible with the C standard but this should not be an issue for // this implementation ReturnValue_t result = checkOrCreateClockMutex(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } MutexGuard helper(timeMutex); @@ -72,19 +72,19 @@ ReturnValue_t Clock::convertTimevalToTimeOfDay(const timeval* from, TimeOfDay_t* to->minute = timeInfo->tm_min; to->second = timeInfo->tm_sec; to->usecond = from->tv_usec; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t Clock::checkOrCreateClockMutex() { if (timeMutex == nullptr) { MutexFactory* mutexFactory = MutexFactory::instance(); if (mutexFactory == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } timeMutex = mutexFactory->createMutex(); if (timeMutex == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tmstorage/TmStoreMessage.cpp b/src/fsfw/tmstorage/TmStoreMessage.cpp index a6bab6c5..6165df6d 100644 --- a/src/fsfw/tmstorage/TmStoreMessage.cpp +++ b/src/fsfw/tmstorage/TmStoreMessage.cpp @@ -9,13 +9,13 @@ TmStoreMessage::TmStoreMessage() {} ReturnValue_t TmStoreMessage::setEnableStoringMessage(CommandMessage* cmd, bool setEnabled) { cmd->setCommand(ENABLE_STORING); cmd->setParameter(setEnabled); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmStoreMessage::setDeleteContentMessage(CommandMessage* cmd, ApidSsc upTo) { cmd->setCommand(DELETE_STORE_CONTENT); cmd->setParameter((upTo.apid << 16) + upTo.ssc); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmStoreMessage::setDownlinkContentMessage(CommandMessage* cmd, ApidSsc fromPacket, @@ -23,7 +23,7 @@ ReturnValue_t TmStoreMessage::setDownlinkContentMessage(CommandMessage* cmd, Api cmd->setCommand(DOWNLINK_STORE_CONTENT); cmd->setParameter((fromPacket.apid << 16) + fromPacket.ssc); cmd->setParameter2((toPacket.apid << 16) + toPacket.ssc); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ApidSsc TmStoreMessage::getPacketId1(CommandMessage* cmd) { @@ -86,7 +86,7 @@ bool TmStoreMessage::getAddToSelection(CommandMessage* cmd) { return (bool)cmd-> ReturnValue_t TmStoreMessage::setReportSelectionDefinitionMessage(CommandMessage* cmd) { cmd->setCommand(REPORT_SELECTION_DEFINITION); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TmStoreMessage::setSelectionDefinitionReportMessage(CommandMessage* cmd, @@ -97,7 +97,7 @@ void TmStoreMessage::setSelectionDefinitionReportMessage(CommandMessage* cmd, ReturnValue_t TmStoreMessage::setReportStoreCatalogueMessage(CommandMessage* cmd) { cmd->setCommand(REPORT_STORE_CATALOGUE); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TmStoreMessage::setStoreCatalogueReportMessage(CommandMessage* cmd, object_id_t objectId, @@ -127,18 +127,18 @@ ReturnValue_t TmStoreMessage::setDeleteBlocksMessage(CommandMessage* cmd, uint32 cmd->setCommand(DELETE_STORE_CONTENT_BLOCKS); cmd->setParameter(addressLow); cmd->setParameter2(addressHigh); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmStoreMessage::setDownlinkBlocksMessage(CommandMessage* cmd, uint32_t addressLow, uint32_t addressHigh) { cmd->setCommand(DOWNLINK_STORE_CONTENT_BLOCKS); cmd->setParameter(addressLow); cmd->setParameter2(addressHigh); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmStoreMessage::setIndexRequestMessage(CommandMessage* cmd) { cmd->setCommand(REPORT_INDEX_REQUEST); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TmStoreMessage::setIndexReportMessage(CommandMessage* cmd, store_address_t storeId) { diff --git a/src/fsfw/tmstorage/TmStorePackets.h b/src/fsfw/tmstorage/TmStorePackets.h index 0640fd36..a5d2f5a0 100644 --- a/src/fsfw/tmstorage/TmStorePackets.h +++ b/src/fsfw/tmstorage/TmStorePackets.h @@ -32,7 +32,7 @@ class ApidSsc : public SerializeIF { Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::serialize(&ssc, buffer, size, maxSize, streamEndianness); @@ -42,7 +42,7 @@ class ApidSsc : public SerializeIF { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::deSerialize(&ssc, buffer, size, streamEndianness); @@ -87,7 +87,7 @@ class TmPacketInformation : public SerializeIF { const uint8_t* pField = NULL; uint32_t size = 0; ReturnValue_t result = packet->getPacketTimeRaw(&pField, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } if (*pField == CCSDSTime::P_FIELD_CDS_SHORT && size <= TimeStamperIF::MISSION_TIMESTAMP_SIZE) { @@ -97,13 +97,13 @@ class TmPacketInformation : public SerializeIF { } timeval time = {0, 0}; result = packet->getPacketTime(&time); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } CCSDSTime::CDS_short cdsFormat; result = CCSDSTime::convertToCcsds(&cdsFormat, &time); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return; } memcpy(rawTimestamp, &cdsFormat, sizeof(cdsFormat)); @@ -196,24 +196,24 @@ class TmPacketInformation : public SerializeIF { Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&sourceSequenceCount, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&serviceType, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&serviceSubtype, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&subCounter, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } SerialBufferAdapter adapter(rawTimestamp, sizeof(rawTimestamp)); @@ -234,23 +234,23 @@ class TmPacketInformation : public SerializeIF { ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&sourceSequenceCount, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&serviceType, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&serviceSubtype, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::deSerialize(&subCounter, buffer, size, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } SerialBufferAdapter adapter(rawTimestamp, sizeof(rawTimestamp)); diff --git a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h index 56038036..e2da84a3 100644 --- a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h +++ b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h @@ -23,7 +23,7 @@ class RedirectableDataPointerIF { * @param args Any additional user arguments required to set the data pointer * @return * - RETURN_OK if the pointer was set successfully - * - RETURN_FAILED on general error of if the maximum size is too small + * - returnvalue::FAILED on general error of if the maximum size is too small */ virtual ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) = 0; virtual ReturnValue_t setData(uint8_t* dataPtr, size_t size) { diff --git a/src/fsfw/tmtcpacket/ccsds/PacketId.h b/src/fsfw/tmtcpacket/ccsds/PacketId.h index 518b2d41..5b61db7d 100644 --- a/src/fsfw/tmtcpacket/ccsds/PacketId.h +++ b/src/fsfw/tmtcpacket/ccsds/PacketId.h @@ -55,7 +55,7 @@ struct PacketId : public SerializeIF { **buffer = idRaw & 0xff; *size += 1; *buffer += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } [[nodiscard]] size_t getSerializedSize() const override { return 2; } @@ -73,7 +73,7 @@ struct PacketId : public SerializeIF { packetType = static_cast((highByte >> 4) & 0b1); secHeaderFlag = (highByte >> 3) & 0b1; apid = static_cast((highByte & 0b111) << 8 | lowByte); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ccsds::PacketType packetType = ccsds::PacketType::TM; diff --git a/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h b/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h index a1e73460..1944e8c2 100644 --- a/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h +++ b/src/fsfw/tmtcpacket/ccsds/PacketSeqCtrl.h @@ -50,7 +50,7 @@ struct PacketSeqCtrl : public SerializeIF { *size -= 2; seqFlags = static_cast((highByte >> 6) & 0b11); seqCount = ((highByte << 8) | lowByte) & 0x3FFF; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ccsds::SequenceFlags seqFlags = ccsds::SequenceFlags::CONTINUATION; diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp index ee27cc9b..8c4822cd 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp @@ -23,18 +23,18 @@ uint16_t SpacePacketCreator::getPacketDataLen() const { return params.dataLen; } ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { if (not isValid()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint16_t packetIdAndVersion = (static_cast(params.version) << 13) | params.packetId.raw(); ReturnValue_t result = SerializeAdapter::serialize(&packetIdAndVersion, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } uint16_t pscRaw = params.packetSeqCtrl.raw(); result = SerializeAdapter::serialize(&pscRaw, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return SerializeAdapter::serialize(¶ms.dataLen, buffer, size, maxSize, streamEndianness); @@ -44,7 +44,7 @@ size_t SpacePacketCreator::getSerializedSize() const { return 6; } ReturnValue_t SpacePacketCreator::deSerialize(const uint8_t **buffer, size_t *size, SerializeIF::Endianness streamEndianness) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } bool SpacePacketCreator::isValid() const { return valid; } diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp index b6f03de9..091a641a 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp @@ -9,12 +9,12 @@ SpacePacketReader::SpacePacketReader(const uint8_t* setAddress, size_t maxSize_) ReturnValue_t SpacePacketReader::checkSize() const { if (isNull()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (getFullPacketLen() > bufSize) { return SerializeIF::STREAM_TOO_SHORT; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } SpacePacketReader::~SpacePacketReader() = default; diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp index e597cf35..94430aeb 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp @@ -13,9 +13,15 @@ CfdpPacketStored::CfdpPacketStored(const uint8_t* data, size_t size) : CfdpReade return; } if (this->checkAndSetStore()) { +<<<<<<< HEAD ReturnValue_t status = STORE->addData(&storeAddress, data, size); if (status != HasReturnvaluesIF::RETURN_OK) { this->setData(nullptr, -1, nullptr); +======= + ReturnValue_t status = store->addData(&storeAddress, data, size); + if (status != returnvalue::OK) { + this->setData(nullptr, -1); +>>>>>>> mueller/expand-retval-if } const uint8_t* storePtr = nullptr; // Repoint base data pointer to the data in the store. @@ -39,12 +45,17 @@ void CfdpPacketStored::setStoreAddress(store_address_t setAddress) { this->storeAddress = setAddress; const uint8_t* tempData = nullptr; size_t tempSize; - ReturnValue_t status = StorageManagerIF::RETURN_FAILED; + ReturnValue_t status = returnvalue::FAILED; if (this->checkAndSetStore()) { status = STORE->getData(this->storeAddress, &tempData, &tempSize); } +<<<<<<< HEAD if (status == StorageManagerIF::RETURN_OK) { this->setData(const_cast(tempData), tempSize, nullptr); +======= + if (status == returnvalue::OK) { + this->setData(const_cast(tempData), tempSize); +>>>>>>> mueller/expand-retval-if } else { // To circumvent size checks this->setData(nullptr, -1, nullptr); @@ -56,12 +67,17 @@ store_address_t CfdpPacketStored::getStoreAddress() { return this->storeAddress; CfdpPacketStored::~CfdpPacketStored() = default; +<<<<<<< HEAD ReturnValue_t CfdpPacketStored::getData(const uint8_t** dataPtr, size_t* dataSize) { return HasReturnvaluesIF::RETURN_OK; +======= +ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSize) { + return returnvalue::OK; +>>>>>>> mueller/expand-retval-if } // ReturnValue_t CFDPPacketStored::setData(const uint8_t *data) { -// return HasReturnvaluesIF::RETURN_OK; +// return returnvalue::OK; // } bool CfdpPacketStored::checkAndSetStore() { @@ -80,8 +96,13 @@ bool CfdpPacketStored::checkAndSetStore() { bool CfdpPacketStored::isSizeCorrect() { const uint8_t* temp_data = nullptr; size_t temp_size; +<<<<<<< HEAD ReturnValue_t status = STORE->getData(this->storeAddress, &temp_data, &temp_size); if (status == StorageManagerIF::RETURN_OK) { +======= + ReturnValue_t status = store->getData(this->storeAddress, &temp_data, &temp_size); + if (status == returnvalue::OK) { +>>>>>>> mueller/expand-retval-if if (this->getFullSize() == temp_size) { return true; } diff --git a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp index fe0e1f69..8542694a 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp +++ b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp @@ -43,7 +43,7 @@ ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t sub findOrInsertMatch(this->begin(), &testPacket, &lastTest); if (result == NEW_NODE_CREATED) { rollback = lastTest; - } else if (result != RETURN_OK) { + } else if (result != returnvalue::OK) { return result; } if (type == 0) { @@ -52,7 +52,7 @@ ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t sub if (lastTest.left() != PacketMatchTree::end()) { removeElementAndAllChildren(lastTest.left()); } - return RETURN_OK; + return returnvalue::OK; } // Type insertion required. result = findOrInsertMatch(lastTest.left(), &testPacket, &lastTest); @@ -60,7 +60,7 @@ ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t sub if (rollback == PacketMatchTree::end()) { rollback = lastTest; } - } else if (result != RETURN_OK) { + } else if (result != returnvalue::OK) { if (rollback != PacketMatchTree::end()) { removeElementAndAllChildren(rollback); } @@ -71,19 +71,19 @@ ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t sub // See above removeElementAndAllChildren(lastTest.left()); } - return RETURN_OK; + return returnvalue::OK; } // Subtype insertion required. result = findOrInsertMatch(lastTest.left(), &testPacket, &lastTest); if (result == NEW_NODE_CREATED) { - return RETURN_OK; - } else if (result != RETURN_OK) { + return returnvalue::OK; + } else if (result != returnvalue::OK) { if (rollback != PacketMatchTree::end()) { removeElementAndAllChildren(rollback); } return result; } - return RETURN_OK; + return returnvalue::OK; } template @@ -96,7 +96,7 @@ ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test, attachToBranch = OR; *lastTest = iter; if (isMatch) { - return RETURN_OK; + return returnvalue::OK; } else { // Go down OR branch. iter = iter.right(); @@ -116,7 +116,7 @@ ReturnValue_t PacketMatchTree::findOrInsertMatch(iterator startAt, VALUE_T test, *lastTest = insert(attachToBranch, *lastTest, newNode); if (*lastTest == end()) { // This actaully never fails, so creating a dedicated returncode seems an overshoot. - return RETURN_FAILED; + return returnvalue::FAILED; } return NEW_NODE_CREATED; } diff --git a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h index fa3aab44..b9d03f1d 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h +++ b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h @@ -7,7 +7,7 @@ #include "fsfw/tmtcpacket/pus/tm/PusTmIF.h" #include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h" -class PacketMatchTree : public MatchTree, public HasReturnvaluesIF { +class PacketMatchTree : public MatchTree { public: explicit PacketMatchTree(Node* root); explicit PacketMatchTree(iterator root); diff --git a/src/fsfw/tmtcpacket/pus/PusIF.h b/src/fsfw/tmtcpacket/pus/PusIF.h index 3c802cfa..ed447c75 100644 --- a/src/fsfw/tmtcpacket/pus/PusIF.h +++ b/src/fsfw/tmtcpacket/pus/PusIF.h @@ -9,8 +9,8 @@ class PusIF : public SpacePacketIF { public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::PUS_IF; - static constexpr ReturnValue_t INVALID_PUS_VERSION = result::makeCode(INTERFACE_ID, 0); - static constexpr ReturnValue_t INVALID_CRC_16 = result::makeCode(INTERFACE_ID, 1); + static constexpr ReturnValue_t INVALID_PUS_VERSION = returnvalue::makeCode(INTERFACE_ID, 0); + static constexpr ReturnValue_t INVALID_CRC_16 = returnvalue::makeCode(INTERFACE_ID, 1); ~PusIF() override = default; /** diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index e1b96945..d85d5b72 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -22,7 +22,7 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max return PusIF::INVALID_PUS_VERSION; } ReturnValue_t result = spCreator.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } **buffer = pusParams.pusVersion << 4 | pusParams.ackFlags; @@ -34,7 +34,7 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max *size += 3; result = SerializeAdapter::serialize(&pusParams.sourceId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (pusParams.dataWrapper.type == ecss::DataTypes::RAW) { @@ -48,7 +48,7 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max pusParams.dataWrapper.dataUnion.serializable != nullptr) { result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -66,7 +66,7 @@ size_t PusTcCreator::getSerializedSize() const { return spCreator.getFullPacketL ReturnValue_t PusTcCreator::deSerialize(const uint8_t **buffer, size_t *size, SerializeIF::Endianness streamEndianness) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint16_t PusTcCreator::getPacketIdRaw() const { return spCreator.getPacketIdRaw(); } @@ -93,14 +93,14 @@ ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { // TODO: Check length field? pusParams.dataWrapper.setRawData({data, len}); updateSpLengthField(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF &serializable) { // TODO: Check length field? pusParams.dataWrapper.setSerializable(serializable); updateSpLengthField(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void PusTcCreator::setup() { diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp index 31bb1011..06805e30 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcReader.cpp @@ -17,10 +17,10 @@ ReturnValue_t PusTcReader::parseDataWithoutCrcCheck() { return parseData(false); ReturnValue_t PusTcReader::parseData(bool withCrc) { if (pointers.spHeaderStart == nullptr or spReader.isNull()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t result = spReader.checkSize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentOffset = SpacePacketReader::getHeaderLen(); @@ -42,7 +42,7 @@ ReturnValue_t PusTcReader::parseData(bool withCrc) { return PusIF::INVALID_CRC_16; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint8_t PusTcReader::getPusVersion() const { return (pointers.secHeaderStart[0] >> 4) & 0b1111; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 44172de3..80853221 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -48,7 +48,7 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max return SerializeIF::BUFFER_TOO_SHORT; } ReturnValue_t result = spCreator.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t userDataLen = pusParams.dataWrapper.getLength(); @@ -62,17 +62,17 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max *size += 3; result = SerializeAdapter::serialize(&pusParams.secHeader.messageTypeCounter, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = SerializeAdapter::serialize(&pusParams.secHeader.destId, buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (getTimestamper() != nullptr) { result = pusParams.secHeader.timeStamper->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -86,7 +86,7 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max pusParams.dataWrapper.dataUnion.serializable != nullptr) { result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } } @@ -97,13 +97,13 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max // Even if no CRC is calculated, account for the space taken by it *size += 2; *buffer += 2; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t PusTmCreator::getSerializedSize() const { return getFullPacketLen(); } ReturnValue_t PusTmCreator::deSerialize(const uint8_t** buffer, size_t* size, SerializeIF::Endianness streamEndianness) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } TimeStamperIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader.timeStamper; } @@ -136,12 +136,12 @@ void PusTmCreator::setDestId(uint16_t destId) { pusParams.secHeader.destId = des ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { pusParams.dataWrapper.setRawData({data, len}); updateSpLengthField(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t PusTmCreator::setSerializableUserData(SerializeIF& serializable) { pusParams.dataWrapper.setSerializable(serializable); updateSpLengthField(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void PusTmCreator::setService(uint8_t service) { pusParams.secHeader.service = service; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp index a389551c..3c0e6f64 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.cpp @@ -14,7 +14,7 @@ PusTmMinimal::~PusTmMinimal() = default; ReturnValue_t PusTmMinimal::getPacketTime(timeval* timestamp) { if (timestampInterpreter == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } return timestampInterpreter->getPacketTime(this, timestamp); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp index 75abdbf6..491eccac 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmReader.cpp @@ -51,10 +51,10 @@ TimeReaderIF *PusTmReader::getTimeReader() { return timeReader; } ReturnValue_t PusTmReader::parseData(bool crcCheck) { // Time reader is required to read the time stamp length at run-time if (pointers.spHeaderStart == nullptr or spReader.isNull() or timeReader == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t result = spReader.checkSize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t currentOffset = SpacePacketReader::getHeaderLen(); @@ -62,7 +62,7 @@ ReturnValue_t PusTmReader::parseData(bool crcCheck) { currentOffset += PusTmIF::MIN_SEC_HEADER_LEN; size_t minTimestampLen = spReader.getFullPacketLen() - currentOffset; result = timeReader->readTimeStamp(pointers.spHeaderStart + currentOffset, minTimestampLen); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t timestampLen = timeReader->getTimestampSize(); @@ -84,7 +84,7 @@ ReturnValue_t PusTmReader::parseData(bool crcCheck) { return PusIF::INVALID_CRC_16; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } bool PusTmReader::isNull() const { return spReader.isNull() or pointers.secHeaderStart == nullptr; } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index d7e3b514..4fb022b8 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -47,7 +47,7 @@ ReturnValue_t CommandingServiceBase::performOperation(uint8_t opCode) { handleRequestQueue(); checkTimeout(); doPeriodicOperation(); - return RETURN_OK; + return returnvalue::OK; } uint16_t CommandingServiceBase::getIdentifier() { return service; } @@ -56,7 +56,7 @@ MessageQueueId_t CommandingServiceBase::getRequestQueue() { return requestQueue- ReturnValue_t CommandingServiceBase::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -129,7 +129,7 @@ ReturnValue_t CommandingServiceBase::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } } - return RETURN_OK; + return returnvalue::OK; } void CommandingServiceBase::handleCommandQueue() { @@ -137,7 +137,7 @@ void CommandingServiceBase::handleCommandQueue() { ReturnValue_t result; while (true) { result = commandQueue->receiveMessage(&reply); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { handleCommandMessage(&reply); continue; } else if (result == MessageQueueIF::EMPTY) { @@ -177,18 +177,18 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) { iter->second.objectId, &isStep); /* If the child implementation does not implement special handling for - * rejected replies (RETURN_FAILED or INVALID_REPLY is returned), a + * rejected replies (returnvalue::FAILED or INVALID_REPLY is returned), a * failure verification will be generated with the reason as the * return code and the initial command as failure parameter 1 */ if ((reply->getCommand() == CommandMessage::REPLY_REJECTED) and - (result == RETURN_FAILED or result == INVALID_REPLY)) { + (result == returnvalue::FAILED or result == INVALID_REPLY)) { result = reply->getReplyRejectedReason(); failureParameter1 = iter->second.command; } switch (result) { case EXECUTION_COMPLETE: - case RETURN_OK: + case returnvalue::OK: case NO_STEP_MESSAGE: // handle result of reply handler implemented by developer. handleReplyHandlerResult(result, iter, &nextCommand, reply, isStep); @@ -222,12 +222,12 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, Comma // In case a new command is to be sent immediately, this is performed here. // If no new command is sent, only analyse reply result by initializing // sendResult as RETURN_OK - ReturnValue_t sendResult = RETURN_OK; + ReturnValue_t sendResult = returnvalue::OK; if (nextCommand->getCommand() != CommandMessage::CMD_NONE) { sendResult = commandQueue->sendMessage(reply->getSender(), nextCommand); } - if (sendResult == RETURN_OK) { + if (sendResult == returnvalue::OK) { if (isStep and result != NO_STEP_MESSAGE) { prepareVerificationSuccessWithFullInfo(tcverif::PROGRESS_SUCCESS, iter->second.tcInfo); successParams.step = ++iter->second.step; @@ -262,23 +262,23 @@ void CommandingServiceBase::handleRequestQueue() { store_address_t address; MessageQueueId_t queue; object_id_t objectId; - for (result = requestQueue->receiveMessage(&message); result == RETURN_OK; + for (result = requestQueue->receiveMessage(&message); result == returnvalue::OK; result = requestQueue->receiveMessage(&message)) { address = message.getStorageId(); result = setUpTcReader(address); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { rejectPacketInvalidTc(result, address); continue; } if ((tcReader.getSubService() == 0) or - (isValidSubservice(tcReader.getSubService()) != RETURN_OK)) { + (isValidSubservice(tcReader.getSubService()) != returnvalue::OK)) { rejectPacket(tcverif::START_FAILURE, address, INVALID_SUBSERVICE); continue; } result = getMessageQueueAndObject(tcReader.getSubService(), tcReader.getUserData(), tcReader.getUserDataLen(), &queue, &objectId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { rejectPacket(tcverif::START_FAILURE, address, result); continue; } @@ -289,14 +289,14 @@ void CommandingServiceBase::handleRequestQueue() { if (iter != commandMap.end()) { result = iter->second.fifo.insert(address); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { rejectPacket(tcverif::START_FAILURE, address, OBJECT_BUSY); } } else { CommandInfo newInfo; // Info will be set by startExecution if neccessary newInfo.objectId = objectId; result = commandMap.insert(queue, newInfo, &iter); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { rejectPacket(tcverif::START_FAILURE, address, BUSY); } else { startExecution(address, iter); @@ -308,7 +308,7 @@ void CommandingServiceBase::handleRequestQueue() { ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen) { ReturnValue_t result = tmHelper.prepareTmPacket(subservice, sourceData, sourceDataLen); - if (result != result::OK) { + if (result != returnvalue::OK) { return result; } return tmHelper.storeAndSendTmPacket(); @@ -318,7 +318,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_ const uint8_t* data, size_t dataLen) { telemetry::DataWithObjectIdPrefix dataWithObjId(objectId, data, dataLen); ReturnValue_t result = tmHelper.prepareTmPacket(subservice, dataWithObjId); - if (result != result::OK) { + if (result != returnvalue::OK) { return result; } return tmHelper.storeAndSendTmPacket(); @@ -326,7 +326,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, object_id_ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeIF& sourceData) { ReturnValue_t result = tmHelper.prepareTmPacket(subservice, sourceData); - if (result != result::OK) { + if (result != returnvalue::OK) { return result; } return tmHelper.storeAndSendTmPacket(); @@ -339,13 +339,13 @@ void CommandingServiceBase::startExecution(store_address_t storeId, CommandMapIt prepareCommand(&command, iter->second.subservice, tcReader.getUserData(), tcReader.getUserDataLen(), &iter->second.state, iter->second.objectId); - ReturnValue_t sendResult = RETURN_OK; + ReturnValue_t sendResult = returnvalue::OK; switch (result) { - case RETURN_OK: + case returnvalue::OK: if (command.getCommand() != CommandMessage::CMD_NONE) { sendResult = commandQueue->sendMessage(iter.value->first, &command); } - if (sendResult == RETURN_OK) { + if (sendResult == returnvalue::OK) { Clock::getUptime(&iter->second.uptimeOfStart); iter->second.step = 0; iter->second.subservice = tcReader.getSubService(); @@ -365,7 +365,7 @@ void CommandingServiceBase::startExecution(store_address_t storeId, CommandMapIt // Fire-and-forget command. sendResult = commandQueue->sendMessage(iter.value->first, &command); } - if (sendResult == RETURN_OK) { + if (sendResult == returnvalue::OK) { verificationReporter->sendSuccessReport( VerifSuccessParams(tcverif::START_SUCCESS, tcReader)); acceptPacket(tcverif::COMPLETION_SUCCESS, storeId); @@ -410,11 +410,11 @@ ReturnValue_t CommandingServiceBase::acceptPacket(uint8_t reportId, store_addres void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) { store_address_t address; - if (iter->second.fifo.retrieve(&address) != RETURN_OK) { + if (iter->second.fifo.retrieve(&address) != returnvalue::OK) { commandMap.erase(&iter); } else { ReturnValue_t result = setUpTcReader(address); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { startExecution(address, iter); } else { // TODO: Warning? diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index c16d9ded..02a8c127 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -40,8 +40,7 @@ void setStaticFrameworkObjectIds(); */ class CommandingServiceBase : public SystemObject, public AcceptsTelecommandsIF, - public ExecutableObjectIF, - public HasReturnvaluesIF { + public ExecutableObjectIF { friend void Factory::setStaticFrameworkObjectIds(); public: @@ -156,7 +155,7 @@ class CommandingServiceBase : public SystemObject, * @param objectId Object ID is extracted and stored here * @return * - @c RETURN_OK Cotinue message handling - * - @c RETURN_FAILED Reject the packet and generates a start failure + * - @c returnvalue::FAILED Reject the packet and generates a start failure * verification */ virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice, const uint8_t* tcData, @@ -204,7 +203,7 @@ class CommandingServiceBase : public SystemObject, * - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to * generate TC verification success * - @c INVALID_REPLY Calls handleUnrequestedReply - * - Anything else triggers a TC verification failure. If RETURN_FAILED or + * - Anything else triggers a TC verification failure. If returnvalue::FAILED or * INVALID_REPLY is returned and the command ID is * CommandMessage::REPLY_REJECTED, a failure verification message with * the reason as the error parameter and the initial command as @@ -243,14 +242,14 @@ class CommandingServiceBase : public SystemObject, ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; }; [[nodiscard]] size_t getSerializedSize() const override { return 0; }; ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; }; }; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index b555449b..414c6560 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -25,14 +25,14 @@ PusServiceBase::~PusServiceBase() { ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { handleRequestQueue(); ReturnValue_t result = performService(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PusService " << psbParams.serviceId << ": performService returned with " << static_cast(result) << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } void PusServiceBase::setTaskIF(PeriodicTaskIF* taskHandle_) { this->taskHandle = taskHandle_; } @@ -44,7 +44,7 @@ void PusServiceBase::handleRequestQueue() { ReturnValue_t status = psbParams.reqQueue->receiveMessage(&message); if (status == MessageQueueIF::EMPTY) { break; - } else if (status != HasReturnvaluesIF::RETURN_OK) { + } else if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PusServiceBase::performOperation: Service " << psbParams.serviceId << ": Error receiving packet. Code: " << std::hex << status << std::dec @@ -57,7 +57,7 @@ void PusServiceBase::handleRequestQueue() { break; } result = tc::prepareTcReader(*psbParams.tcPool, message.getStorageId(), currentPacket); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { // We were not even able to retrieve the TC, so we can not retrieve any TC properties either // without segfaulting auto verifParams = VerifFailureParams(tcverif::START_FAILURE, 0, 0, result); @@ -67,7 +67,7 @@ void PusServiceBase::handleRequestQueue() { continue; } result = handleRequest(currentPacket.getSubService()); - if (result == RETURN_OK) { + if (result == returnvalue::OK) { psbParams.verifReporter->sendSuccessReport( VerifSuccessParams(tcverif::COMPLETION_SUCCESS, currentPacket)); } else { @@ -93,7 +93,7 @@ MessageQueueId_t PusServiceBase::getRequestQueue() { ReturnValue_t PusServiceBase::initialize() { ReturnValue_t result = SystemObject::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (psbParams.reqQueue == nullptr) { @@ -131,7 +131,7 @@ ReturnValue_t PusServiceBase::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void PusServiceBase::setTcPool(StorageManagerIF& tcPool) { psbParams.tcPool = &tcPool; } @@ -143,7 +143,7 @@ void PusServiceBase::setErrorReporter(InternalErrorReporterIF& errReporter_) { ReturnValue_t PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper) { ReturnValue_t result = initializeTmSendHelper(tmSendHelper); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return initializeTmStoreHelper(tmStoreHelper); @@ -164,7 +164,7 @@ ReturnValue_t PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) } else { tmSendHelper.setInternalErrorReporter(*psbParams.errReporter); } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { @@ -186,7 +186,7 @@ ReturnValue_t PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelp // Generally, all TM packets will pass through a layer where the sequence count is set. // This avoids duplicate calculation of the CRC16 tmStoreHelper.disableCrcCalculation(); - return RETURN_OK; + return returnvalue::OK; } void PusServiceBase::setVerificationReporter(VerificationReporterIF& reporter) { diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 86d8ea1a..934376fb 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -92,8 +92,7 @@ void setStaticFrameworkObjectIds(); */ class PusServiceBase : public ExecutableObjectIF, public AcceptsTelecommandsIF, - public SystemObject, - public HasReturnvaluesIF { + public SystemObject { friend void Factory::setStaticFrameworkObjectIds(); public: @@ -185,7 +184,7 @@ class PusServiceBase : public ExecutableObjectIF, * the TC requests afterwards. * performService is always executed afterwards. * @return @c RETURN_OK if the periodic performService was successful. - * @c RETURN_FAILED else. + * @c returnvalue::FAILED else. */ ReturnValue_t performOperation(uint8_t opCode) override; uint16_t getIdentifier() override; diff --git a/src/fsfw/tmtcservices/SpacePacketParser.cpp b/src/fsfw/tmtcservices/SpacePacketParser.cpp index 4c10ae9e..b8364138 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.cpp +++ b/src/fsfw/tmtcservices/SpacePacketParser.cpp @@ -22,7 +22,7 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const #else sif::printWarning("SpacePacketParser::parseSpacePackets: Frame invalid\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } const uint8_t* bufPtr = *buffer; @@ -30,7 +30,7 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const uint16_t lengthField = bufPtr[idx + 4] << 8 | bufPtr[idx + 5]; size_t packetSize = lengthField + 7; startIndex = idx; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (lengthField == 0) { // Skip whole header for now foundSize = 6; diff --git a/src/fsfw/tmtcservices/TmSendHelper.cpp b/src/fsfw/tmtcservices/TmSendHelper.cpp index a8e23186..210ed5f6 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmSendHelper.cpp @@ -32,11 +32,11 @@ void TmSendHelper::setMsgQueue(MessageQueueIF &queue_) { queue = &queue_; } ReturnValue_t TmSendHelper::sendPacket(MessageQueueId_t dest, const store_address_t &storeId) { if (queue == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } TmTcMessage message(storeId); ReturnValue_t result = queue->sendMessage(dest, &message, ignoreFault); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { if (errReporter != nullptr and not ignoreFault) { errReporter->lostTm(); } diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp index 7d4c61d6..3057800a 100644 --- a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp @@ -14,11 +14,11 @@ TmStoreAndSendWrapper::TmStoreAndSendWrapper(uint8_t defaultService, TmStoreHelp */ ReturnValue_t TmStoreAndSendWrapper::storeAndSendTmPacket() { ReturnValue_t result = storeHelper.addPacketToStore(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = sendHelper.sendPacket(storeHelper.getCurrentAddr()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { if (delOnFailure) { storeHelper.deletePacket(); } @@ -33,7 +33,7 @@ ReturnValue_t TmStoreAndSendWrapper::storeAndSendTmPacket() { ReturnValue_t TmStoreAndSendWrapper::prepareTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen) { ReturnValue_t result = storeHelper.preparePacket(defaultService, subservice, sendCounter); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return storeHelper.setSourceDataRaw(sourceData, sourceDataLen); @@ -42,7 +42,7 @@ ReturnValue_t TmStoreAndSendWrapper::prepareTmPacket(uint8_t subservice, const u ReturnValue_t TmStoreAndSendWrapper::prepareTmPacket( uint8_t subservice, telemetry::DataWithObjectIdPrefix& dataWithObjectId) { ReturnValue_t result = storeHelper.preparePacket(defaultService, subservice, sendCounter); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return storeHelper.setSourceDataSerializable(dataWithObjectId); @@ -50,7 +50,7 @@ ReturnValue_t TmStoreAndSendWrapper::prepareTmPacket( ReturnValue_t TmStoreAndSendWrapper::prepareTmPacket(uint8_t subservice, SerializeIF& sourceData) { ReturnValue_t result = storeHelper.preparePacket(defaultService, subservice, sendCounter); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return storeHelper.setSourceDataSerializable(sourceData); @@ -58,7 +58,7 @@ ReturnValue_t TmStoreAndSendWrapper::prepareTmPacket(uint8_t subservice, Seriali ReturnValue_t TmStoreAndSendWrapper::prepareTmPacket(uint8_t subservice) { ReturnValue_t result = storeHelper.preparePacket(defaultService, subservice, sendCounter); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return storeHelper.setSourceDataRaw(nullptr, 0); diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index 8b7e5948..501a7840 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -21,7 +21,7 @@ ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, creator.setService(service); creator.setSubservice(subservice); creator.setMessageTypeCounter(counter); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } StorageManagerIF* TmStoreHelper::getTmStore() const { return tmStore; } @@ -32,7 +32,7 @@ const store_address_t& TmStoreHelper::getCurrentAddr() const { return currentAdd ReturnValue_t TmStoreHelper::deletePacket() { ReturnValue_t result = tmStore->deleteData(currentAddr); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { currentAddr = store_address_t::invalid(); } return result; @@ -51,7 +51,7 @@ ReturnValue_t TmStoreHelper::addPacketToStore() { uint8_t* dataPtr; ReturnValue_t result = tmStore->getFreeElement(¤tAddr, creator.getSerializedSize(), &dataPtr); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } size_t serLen = 0; diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index 6af03600..f4ea50d0 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -23,28 +23,28 @@ TmTcBridge::~TmTcBridge() { QueueFactory::instance()->deleteMessageQueue(tmTcRec ReturnValue_t TmTcBridge::setNumberOfSentPacketsPerCycle(uint8_t sentPacketsPerCycle) { if (sentPacketsPerCycle <= LIMIT_STORED_DATA_SENT_PER_CYCLE) { this->sentPacketsPerCycle = sentPacketsPerCycle; - return RETURN_OK; + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TmTcBridge::setNumberOfSentPacketsPerCycle: Number of " << "packets sent per cycle exceeds limits. " << "Keeping default value." << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored) { if (maxNumberOfPacketsStored <= LIMIT_DOWNLINK_PACKETS_STORED) { this->maxNumberOfPacketsStored = maxNumberOfPacketsStored; - return RETURN_OK; + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TmTcBridge::setMaxNumberOfPacketsStored: Number of " << "packets stored exceeds limits. " << "Keeping default value." << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } } @@ -79,20 +79,20 @@ ReturnValue_t TmTcBridge::initialize() { tmFifo = new DynamicFIFO(maxNumberOfPacketsStored); tmTcReceptionQueue->setDefaultDestination(tcDistributor->getRequestQueue()); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmTcBridge::performOperation(uint8_t operationCode) { ReturnValue_t result; result = handleTc(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "TmTcBridge::performOperation: " << "Error handling TCs" << std::endl; #endif } result = handleTm(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "TmTcBridge::performOperation: " << "Error handling TMs" << std::endl; @@ -101,12 +101,12 @@ ReturnValue_t TmTcBridge::performOperation(uint8_t operationCode) { return result; } -ReturnValue_t TmTcBridge::handleTc() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t TmTcBridge::handleTc() { return returnvalue::OK; } ReturnValue_t TmTcBridge::handleTm() { - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; ReturnValue_t result = handleTmQueue(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::handleTm: Error handling TM queue with error code 0x" << std::hex << result << std::dec << "!" << std::endl; @@ -116,7 +116,7 @@ ReturnValue_t TmTcBridge::handleTm() { if (tmStored and communicationLinkUp and (packetSentCounter < sentPacketsPerCycle)) { result = handleStoredTm(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::handleTm: Error handling stored TMs!" << std::endl; #endif @@ -131,10 +131,9 @@ ReturnValue_t TmTcBridge::handleTmQueue() { TmTcMessage message; const uint8_t* data = nullptr; size_t size = 0; - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; for (ReturnValue_t result = tmTcReceptionQueue->receiveMessage(&message); - result == HasReturnvaluesIF::RETURN_OK; - result = tmTcReceptionQueue->receiveMessage(&message)) { + result == returnvalue::OK; result = tmTcReceptionQueue->receiveMessage(&message)) { #if FSFW_VERBOSE_LEVEL >= 3 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "Sent packet counter: " << static_cast(packetSentCounter) << std::endl; @@ -149,13 +148,13 @@ ReturnValue_t TmTcBridge::handleTmQueue() { } result = tmStore->getData(message.getStorageId(), &data, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; continue; } result = sendTm(data, size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } else { tmStore->deleteData(message.getStorageId()); @@ -168,7 +167,7 @@ ReturnValue_t TmTcBridge::handleTmQueue() { ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage* message) { store_address_t storeId; if (tmFifo == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (tmFifo->full()) { @@ -185,18 +184,18 @@ ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage* message) { tmFifo->retrieve(&storeId); tmStore->deleteData(storeId); } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } storeId = message->getStorageId(); tmFifo->insert(storeId); tmStored = true; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TmTcBridge::handleStoredTm() { - ReturnValue_t status = RETURN_OK; + ReturnValue_t status = returnvalue::OK; while (not tmFifo->empty() and packetSentCounter < sentPacketsPerCycle) { #if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::info << "TMTC Bridge: Sending stored TM data. There are " @@ -208,12 +207,12 @@ ReturnValue_t TmTcBridge::handleStoredTm() { size_t size = 0; tmFifo->retrieve(&storeId); ReturnValue_t result = tmStore->getData(storeId, &data, &size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } result = sendTm(data, size); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TMTC Bridge: Could not send stored downlink data" << std::endl; #endif diff --git a/src/fsfw/tmtcservices/TmTcBridge.h b/src/fsfw/tmtcservices/TmTcBridge.h index 237f1f3e..3ebdac95 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.h +++ b/src/fsfw/tmtcservices/TmTcBridge.h @@ -13,7 +13,6 @@ class TmTcBridge : public AcceptsTelemetryIF, public AcceptsTelecommandsIF, public ExecutableObjectIF, - public HasReturnvaluesIF, public SystemObject { public: static constexpr uint8_t TMTC_RECEPTION_QUEUE_DEPTH = 20; @@ -32,7 +31,7 @@ class TmTcBridge : public AcceptsTelemetryIF, * value must be smaller than MAX_STORED_DATA_SENT_PER_CYCLE * @param sentPacketsPerCycle * @return -@c RETURN_OK if value was set successfully - * -@c RETURN_FAILED otherwise, stored value stays the same + * -@c returnvalue::FAILED otherwise, stored value stays the same */ ReturnValue_t setNumberOfSentPacketsPerCycle(uint8_t sentPacketsPerCycle); @@ -41,7 +40,7 @@ class TmTcBridge : public AcceptsTelemetryIF, * value must be smaller than MAX_DOWNLINK_PACKETS_STORED * @param sentPacketsPerCycle * @return -@c RETURN_OK if value was set successfully - * -@c RETURN_FAILED otherwise, stored value stays the same + * -@c returnvalue::FAILED otherwise, stored value stays the same */ ReturnValue_t setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored); diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 2eb0c771..5b9f4477 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -25,7 +25,7 @@ ReturnValue_t VerificationReporter::sendFailureReport(VerifFailureParams params) params.errorCode, params.step, params.errorParam1, params.errorParam2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendSuccessReport: Error writing " << "to queue. Code: " << std::hex << status << std::dec << std::endl; @@ -36,9 +36,9 @@ ReturnValue_t VerificationReporter::sendFailureReport(VerifFailureParams params) ReturnValue_t VerificationReporter::sendSuccessReport(VerifSuccessParams params) { PusVerificationMessage message(params.reportId, params.ackFlags, params.tcPacketId, params.tcPsc, - result::OK, params.step); + returnvalue::OK, params.step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); - if (status != HasReturnvaluesIF::RETURN_OK) { + if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendSuccessReport: Error writing " << "to queue. Code: " << std::hex << status << std::dec << std::endl; diff --git a/src/fsfw/tmtcservices/VerificationReporterIF.h b/src/fsfw/tmtcservices/VerificationReporterIF.h index df0d5a38..d2330b88 100644 --- a/src/fsfw/tmtcservices/VerificationReporterIF.h +++ b/src/fsfw/tmtcservices/VerificationReporterIF.h @@ -48,12 +48,12 @@ struct VerifFailureParams : public VerifParamsBase { : VerifParamsBase(reportId, tc.getPacketIdRaw(), tc.getPacketSeqCtrlRaw()) {} void resetFailParams() { - errorCode = result::FAILED; + errorCode = returnvalue::FAILED; errorParam1 = 0; errorParam2 = 0; } - ReturnValue_t errorCode = result::FAILED; + ReturnValue_t errorCode = returnvalue::FAILED; uint8_t step = 0; uint32_t errorParam1 = 0; uint32_t errorParam2 = 0; diff --git a/src/fsfw/tmtcservices/tcHelpers.cpp b/src/fsfw/tmtcservices/tcHelpers.cpp index a51bab46..c497979b 100644 --- a/src/fsfw/tmtcservices/tcHelpers.cpp +++ b/src/fsfw/tmtcservices/tcHelpers.cpp @@ -5,11 +5,11 @@ ReturnValue_t tc::prepareTcReader(StorageManagerIF &tcStore, store_address_t sto const uint8_t *dataPtr; size_t dataLen = 0; ReturnValue_t result = tcStore.getData(storeId, &dataPtr, &dataLen); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = tcReader.setReadOnlyData(dataPtr, dataLen); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return tcReader.parseDataWithoutCrcCheck(); diff --git a/src/fsfw/tmtcservices/tmHelpers.h b/src/fsfw/tmtcservices/tmHelpers.h index 2cb39c78..ab69c9c8 100644 --- a/src/fsfw/tmtcservices/tmHelpers.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -28,16 +28,16 @@ class DataWithObjectIdPrefix : public SerializeIF { } if (dataWrapper.type != ecss::DataTypes::RAW) { if ((dataWrapper.dataUnion.raw.data == nullptr) and (dataWrapper.dataUnion.raw.len > 0)) { - return result::FAILED; + return returnvalue::FAILED; } } else if (dataWrapper.type == ecss::DataTypes::SERIALIZABLE) { if (dataWrapper.dataUnion.serializable == nullptr) { - return result::FAILED; + return returnvalue::FAILED; } } ReturnValue_t result = SerializeAdapter::serialize(&objectId, buffer, size, maxSize, streamEndianness); - if (result != result::OK) { + if (result != returnvalue::OK) { return result; } if (dataWrapper.type != ecss::DataTypes::RAW) { @@ -47,7 +47,7 @@ class DataWithObjectIdPrefix : public SerializeIF { } else { return dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, streamEndianness); } - return result::OK; + return returnvalue::OK; } [[nodiscard]] size_t getSerializedSize() const override { @@ -58,7 +58,7 @@ class DataWithObjectIdPrefix : public SerializeIF { Endianness streamEndianness) override { // As long as there is no way to know how long the expected data will be, this function // does not make sense - return result::FAILED; + return returnvalue::FAILED; } private: diff --git a/src/fsfw_hal/common/gpio/GpioCookie.cpp b/src/fsfw_hal/common/gpio/GpioCookie.cpp index 4c4b4d14..f75ba4e8 100644 --- a/src/fsfw_hal/common/gpio/GpioCookie.cpp +++ b/src/fsfw_hal/common/gpio/GpioCookie.cpp @@ -11,7 +11,7 @@ ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) { #else sif::printWarning("GpioCookie::addGpio: gpioConfig is nullpointer\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } auto gpioMapIter = gpioMap.find(gpioId); if (gpioMapIter == gpioMap.end()) { @@ -25,9 +25,9 @@ ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) { sif::printWarning("GpioCookie::addGpio: Failed to add GPIO %d to GPIO map\n", gpioId); #endif #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -36,7 +36,7 @@ ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) { sif::printWarning("GpioCookie::addGpio: GPIO already exists in GPIO map\n"); #endif #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } GpioMap GpioCookie::getGpioMap() const { return gpioMap; } diff --git a/src/fsfw_hal/common/gpio/GpioIF.h b/src/fsfw_hal/common/gpio/GpioIF.h index 5cca1481..feb356f4 100644 --- a/src/fsfw_hal/common/gpio/GpioIF.h +++ b/src/fsfw_hal/common/gpio/GpioIF.h @@ -13,7 +13,7 @@ class GpioCookie; * over GPIOs. * @author J. Meier */ -class GpioIF : public HasReturnvaluesIF { +class GpioIF { public: virtual ~GpioIF(){}; @@ -29,7 +29,7 @@ class GpioIF : public HasReturnvaluesIF { * functionality to pull a certain GPIO to high logic level. * * @param gpioId A unique number which specifies the GPIO to drive. - * @return Returns RETURN_OK for success. This should never return RETURN_FAILED. + * @return Returns RETURN_OK for success. This should never return returnvalue::FAILED. */ virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0; diff --git a/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp b/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp index 94e1331c..1ffc60f1 100644 --- a/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp +++ b/src/fsfw_hal/devicehandlers/GyroL3GD20Handler.cpp @@ -70,9 +70,9 @@ ReturnValue_t GyroHandlerL3GD20H::buildTransitionDeviceCommand(DeviceCommandId_t "GyroL3GD20Handler::buildTransitionDeviceCommand: " "Unknown internal state!\n"); #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroHandlerL3GD20H::buildNormalDeviceCommand(DeviceCommandId_t *id) { @@ -135,7 +135,7 @@ ReturnValue_t GyroHandlerL3GD20H::buildCommandFromCommand(DeviceCommandId_t devi default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroHandlerL3GD20H::scanForReply(const uint8_t *start, size_t len, @@ -144,12 +144,12 @@ ReturnValue_t GyroHandlerL3GD20H::scanForReply(const uint8_t *start, size_t len, *foundId = this->getPendingCommand(); *foundLen = this->rawPacketLen; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (id) { case (L3GD20H::CONFIGURE_CTRL_REGS): { commandExecuted = true; @@ -207,7 +207,7 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id, } PoolReadGuard readSet(&dataset); - if (readSet.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + if (readSet.getReadResult() == returnvalue::OK) { if (std::abs(angVelocX) < this->absLimitX) { dataset.angVelocX = angVelocX; dataset.angVelocX.setValid(true); @@ -252,7 +252,7 @@ ReturnValue_t GyroHandlerL3GD20H::initializeLocalDataPool(localpool::DataPool &l localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Y, new PoolEntry({0.0})); localDataPoolMap.emplace(L3GD20H::ANG_VELOC_Z, new PoolEntry({0.0})); localDataPoolMap.emplace(L3GD20H::TEMPERATURE, new PoolEntry({0.0})); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void GyroHandlerL3GD20H::fillCommandAndReplyMap() { diff --git a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index 28d15e46..10fe66d0 100644 --- a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -82,7 +82,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildTransitionDeviceCommand(DeviceCommandId_t #else sif::printWarning("GyroHandler::buildTransitionDeviceCommand: Unknown internal state!\n"); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } return buildCommandFromCommand(*id, NULL, 0); @@ -137,7 +137,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic rawPacket = commandBuffer; rawPacketLen = MGMLIS3MDL::NR_OF_DATA_AND_CFG_REGISTERS + 1; - return RETURN_OK; + return returnvalue::OK; } case (MGMLIS3MDL::READ_TEMPERATURE): { std::memset(commandBuffer, 0, 3); @@ -145,7 +145,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic rawPacket = commandBuffer; rawPacketLen = 3; - return RETURN_OK; + return returnvalue::OK; } case (MGMLIS3MDL::IDENTIFY_DEVICE): { return identifyDevice(); @@ -155,7 +155,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic } case (MGMLIS3MDL::SETUP_MGM): { setupMgm(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } case (MGMLIS3MDL::ACCURACY_OP_MODE_SET): { return setOperatingMode(commandData, commandDataLen); @@ -163,7 +163,7 @@ ReturnValue_t MgmLIS3MDLHandler::buildCommandFromCommand(DeviceCommandId_t devic default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t MgmLIS3MDLHandler::identifyDevice() { @@ -174,7 +174,7 @@ ReturnValue_t MgmLIS3MDLHandler::identifyDevice() { rawPacket = commandBuffer; rawPacketLen = size; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len, @@ -234,7 +234,7 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len, /* Data with SPI Interface always has this answer */ if (start[0] == 0b11111111) { - return RETURN_OK; + return returnvalue::OK; } else { return DeviceHandlerIF::INVALID_DATA; } @@ -285,7 +285,7 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons } PoolReadGuard readHelper(&dataset); - if (readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + if (readHelper.getReadResult() == returnvalue::OK) { if (std::abs(mgmX) > absLimitX or std::abs(mgmY) > absLimitY or std::abs(mgmZ) > absLimitZ) { dataset.fieldStrengths.setValid(false); @@ -320,7 +320,7 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons } ReturnValue_t result = dataset.read(); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { dataset.temperature = tempValue; dataset.commit(); } @@ -331,7 +331,7 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } } - return RETURN_OK; + return returnvalue::OK; } MGMLIS3MDL::Sensitivies MgmLIS3MDLHandler::getSensitivity(uint8_t ctrlRegister2) { @@ -394,7 +394,7 @@ ReturnValue_t MgmLIS3MDLHandler::enableTemperatureSensor(const uint8_t *commandD rawPacket = commandBuffer; rawPacketLen = size; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmLIS3MDLHandler::setOperatingMode(const uint8_t *commandData, @@ -451,7 +451,7 @@ ReturnValue_t MgmLIS3MDLHandler::prepareCtrlRegisterWrite() { rawPacketLen = MGMLIS3MDL::NR_OF_CTRL_REGISTERS + 1; // We dont have to check if this is working because we just did i - return RETURN_OK; + return returnvalue::OK; } void MgmLIS3MDLHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { @@ -468,7 +468,7 @@ ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(localpool::DataPool &lo localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, &temperature); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(dataset.getSid(), false, 10.0)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void MgmLIS3MDLHandler::setAbsoluteLimits(float xLimit, float yLimit, float zLimit) { diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index e8f61b9f..8b4cb029 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -93,7 +93,7 @@ ReturnValue_t MgmRM3100Handler::buildTransitionDeviceCommand(DeviceCommandId_t * "Unknown internal state\n"); #endif #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return buildCommandFromCommand(*id, commandBuffer, commandLen); @@ -146,7 +146,7 @@ ReturnValue_t MgmRM3100Handler::buildCommandFromCommand(DeviceCommandId_t device default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmRM3100Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { @@ -159,11 +159,11 @@ ReturnValue_t MgmRM3100Handler::scanForReply(const uint8_t *start, size_t len, // For SPI, ID will always be the one of the last sent command *foundId = this->getPendingCommand(); *foundLen = len; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (id) { case (RM3100::CONFIGURE_CMM): case (RM3100::CONFIGURE_CYCLE_COUNT): @@ -250,7 +250,7 @@ ReturnValue_t MgmRM3100Handler::handleCycleCountConfigCommand(DeviceCommandId_t std::memcpy(commandBuffer + 5, &cycleCountRegValueZ, 2); rawPacketLen = 7; rawPacket = commandBuffer; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmRM3100Handler::handleCycleCommand(bool oneCycleValue, const uint8_t *commandData, @@ -258,7 +258,7 @@ ReturnValue_t MgmRM3100Handler::handleCycleCommand(bool oneCycleValue, const uin RM3100::CycleCountCommand command(oneCycleValue); ReturnValue_t result = command.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -274,7 +274,7 @@ ReturnValue_t MgmRM3100Handler::handleCycleCommand(bool oneCycleValue, const uin cycleCountRegValueX = command.cycleCountX; cycleCountRegValueY = command.cycleCountY; cycleCountRegValueZ = command.cycleCountZ; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MgmRM3100Handler::handleTmrcConfigCommand(DeviceCommandId_t deviceCommand, @@ -289,7 +289,7 @@ ReturnValue_t MgmRM3100Handler::handleTmrcConfigCommand(DeviceCommandId_t device tmrcRegValue = commandData[0]; rawPacketLen = 2; rawPacket = commandBuffer; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void MgmRM3100Handler::fillCommandAndReplyMap() { @@ -312,7 +312,7 @@ ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(localpool::DataPool &loc localDataPoolMap.emplace(RM3100::FIELD_STRENGTHS, &mgmXYZ); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(primaryDataset.getSid(), false, 10.0)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint32_t MgmRM3100Handler::getTransitionDelayMs(Mode_t from, Mode_t to) { @@ -353,13 +353,13 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) { // TODO: Sanity check on values? PoolReadGuard readGuard(&primaryDataset); - if (readGuard.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + if (readGuard.getReadResult() == returnvalue::OK) { primaryDataset.fieldStrengths[0] = fieldStrengthX; primaryDataset.fieldStrengths[1] = fieldStrengthY; primaryDataset.fieldStrengths[2] = fieldStrengthZ; primaryDataset.setValidity(true, true); } - return RETURN_OK; + return returnvalue::OK; } void MgmRM3100Handler::enablePeriodicPrintouts(bool enable, uint8_t divider) { diff --git a/src/fsfw_hal/linux/CommandExecutor.cpp b/src/fsfw_hal/linux/CommandExecutor.cpp index 49c44ebf..8b81d94f 100644 --- a/src/fsfw_hal/linux/CommandExecutor.cpp +++ b/src/fsfw_hal/linux/CommandExecutor.cpp @@ -23,7 +23,7 @@ ReturnValue_t CommandExecutor::load(std::string command, bool blocking, bool pri if (state == States::IDLE) { state = States::COMMAND_LOADED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CommandExecutor::execute() { @@ -35,7 +35,7 @@ ReturnValue_t CommandExecutor::execute() { currentCmdFile = popen(currentCmd.c_str(), "r"); if (currentCmdFile == nullptr) { lastError = errno; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (blocking) { ReturnValue_t result = executeBlocking(); @@ -46,7 +46,7 @@ ReturnValue_t CommandExecutor::execute() { waiter.fd = currentFd; } state = States::PENDING; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CommandExecutor::close() { @@ -56,7 +56,7 @@ ReturnValue_t CommandExecutor::close() { pclose(currentCmdFile); } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void CommandExecutor::printLastError(std::string funcName) const { @@ -79,7 +79,7 @@ void CommandExecutor::setRingBuffer(SimpleRingBuffer* ringBuffer, ReturnValue_t CommandExecutor::check(bool& replyReceived) { if (blocking) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } switch (state) { case (States::IDLE): @@ -94,7 +94,7 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) { int result = poll(&waiter, 1, 0); switch (result) { case (0): { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; break; } case (1): { @@ -151,7 +151,7 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) { ReturnValue_t retval = EXECUTION_FINISHED; if (result != 0) { lastError = result; - retval = HasReturnvaluesIF::RETURN_FAILED; + retval = returnvalue::FAILED; } state = States::IDLE; currentCmdFile = nullptr; @@ -161,7 +161,7 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) { break; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void CommandExecutor::reset() { @@ -201,7 +201,7 @@ ReturnValue_t CommandExecutor::executeBlocking() { int result = pclose(currentCmdFile); if (result != 0) { lastError = result; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h index 1696e229..64ebe13d 100644 --- a/src/fsfw_hal/linux/CommandExecutor.h +++ b/src/fsfw_hal/linux/CommandExecutor.h @@ -31,18 +31,18 @@ class CommandExecutor { static constexpr uint8_t CLASS_ID = CLASS_ID::LINUX_OSAL; //! [EXPORT] : [COMMENT] Execution of the current command has finished - static constexpr ReturnValue_t EXECUTION_FINISHED = result::makeCode(CLASS_ID, 0); + static constexpr ReturnValue_t EXECUTION_FINISHED = returnvalue::makeCode(CLASS_ID, 0); //! [EXPORT] : [COMMENT] Command is pending. This will also be returned if the user tries //! to load another command but a command is still pending - static constexpr ReturnValue_t COMMAND_PENDING = result::makeCode(CLASS_ID, 1); + static constexpr ReturnValue_t COMMAND_PENDING = returnvalue::makeCode(CLASS_ID, 1); //! [EXPORT] : [COMMENT] Some bytes have been read from the executing process - static constexpr ReturnValue_t BYTES_READ = result::makeCode(CLASS_ID, 2); + static constexpr ReturnValue_t BYTES_READ = returnvalue::makeCode(CLASS_ID, 2); //! [EXPORT] : [COMMENT] Command execution failed - static constexpr ReturnValue_t COMMAND_ERROR = result::makeCode(CLASS_ID, 3); + static constexpr ReturnValue_t COMMAND_ERROR = returnvalue::makeCode(CLASS_ID, 3); //! [EXPORT] : [COMMENT] - static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = result::makeCode(CLASS_ID, 4); - static constexpr ReturnValue_t PCLOSE_CALL_ERROR = result::makeCode(CLASS_ID, 6); + static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = returnvalue::makeCode(CLASS_ID, 4); + static constexpr ReturnValue_t PCLOSE_CALL_ERROR = returnvalue::makeCode(CLASS_ID, 6); /** * Constructor. Is initialized with maximum size of internal buffer to read data from the @@ -62,7 +62,7 @@ class CommandExecutor { /** * Execute the loaded command. * @return - * - In blocking mode, it will return RETURN_FAILED if + * - In blocking mode, it will return returnvalue::FAILED if * the result of the system call was not 0. The error value can be accessed using * getLastError * - In non-blocking mode, this call will start @@ -76,7 +76,7 @@ class CommandExecutor { * - BYTES_READ if bytes have been read from the executing process. It is recommended to call * check again after this * - RETURN_OK execution is pending, but no bytes have been read from the executing process - * - RETURN_FAILED if execution has failed, error value can be accessed using getLastError + * - returnvalue::FAILED if execution has failed, error value can be accessed using getLastError * - EXECUTION_FINISHED if the process was executed successfully * - NO_COMMAND_LOADED_OR_PENDING self-explanatory * - COMMAND_ERROR internal poll error diff --git a/src/fsfw_hal/linux/UnixFileGuard.h b/src/fsfw_hal/linux/UnixFileGuard.h index d94234b6..1fe47116 100644 --- a/src/fsfw_hal/linux/UnixFileGuard.h +++ b/src/fsfw_hal/linux/UnixFileGuard.h @@ -24,7 +24,7 @@ class UnixFileGuard { private: int* fileDescriptor = nullptr; - ReturnValue_t openStatus = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t openStatus = returnvalue::OK; }; #endif /* LINUX_UTILITY_UNIXFILEGUARD_H_ */ diff --git a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp index 15061d14..cecc1f3f 100644 --- a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp +++ b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp @@ -23,30 +23,30 @@ ReturnValue_t LinuxLibgpioIF::addGpios(GpioCookie* gpioCookie) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LinuxLibgpioIF::addGpios: Invalid cookie" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } GpioMap mapToAdd = gpioCookie->getGpioMap(); /* Check whether this ID already exists in the map and remove duplicates */ result = checkForConflicts(mapToAdd); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = configureGpios(mapToAdd); - if (result != RETURN_OK) { - return RETURN_FAILED; + if (result != returnvalue::OK) { + return returnvalue::FAILED; } /* Register new GPIOs in gpioMap */ gpioMap.insert(mapToAdd.begin(), mapToAdd.end()); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; for (auto& gpioConfig : mapToAdd) { auto& gpioType = gpioConfig.second->gpioType; switch (gpioType) { @@ -86,7 +86,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpios(GpioMap& mapToAdd) { gpioCallback->initValue, gpioCallback->callbackArgs); } } - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return GPIO_INIT_FAILED; } } @@ -102,7 +102,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByLabel(gpioId_t gpioId, sif::warning << "LinuxLibgpioIF::configureGpioByLabel: Failed to open gpio from gpio " << "group with label " << label << ". Gpio ID: " << gpioId << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } std::string failOutput = "label: " + label; return configureRegularGpio(gpioId, chip, gpioByLabel, failOutput); @@ -116,7 +116,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByChip(gpioId_t gpioId, GpiodRegularB sif::warning << "LinuxLibgpioIF::configureGpioByChip: Failed to open chip " << chipname << ". Gpio ID: " << gpioId << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } std::string failOutput = "chipname: " + chipname; return configureRegularGpio(gpioId, chip, gpioByChip, failOutput); @@ -132,7 +132,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByLineName(gpioId_t gpioId, gpiod_ctxless_find_line(lineName.c_str(), chipname, MAX_CHIPNAME_LENGTH, &lineOffset); if (result != LINE_FOUND) { parseFindeLineResult(result, lineName); - return RETURN_FAILED; + return returnvalue::FAILED; } gpioByLineName.lineNum = static_cast(lineOffset); @@ -143,7 +143,7 @@ ReturnValue_t LinuxLibgpioIF::configureGpioByLineName(gpioId_t gpioId, sif::warning << "LinuxLibgpioIF::configureGpioByLineName: Failed to open chip " << chipname << ". callback(gpioMapIter->first, gpio::GpioOperation::WRITE, gpio::Levels::HIGH, gpioCallback->callbackArgs); - return RETURN_OK; + return returnvalue::OK; } return GPIO_TYPE_FAILURE; } @@ -270,7 +270,7 @@ ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) { } gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::WRITE, gpio::Levels::LOW, gpioCallback->callbackArgs); - return RETURN_OK; + return returnvalue::OK; } return GPIO_TYPE_FAILURE; } @@ -291,7 +291,7 @@ ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, GpiodRegularBase& regul return DRIVE_GPIO_FAILURE; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) { @@ -321,14 +321,14 @@ ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, int* gpioState) { } gpioCallback->callback(gpioMapIter->first, gpio::GpioOperation::READ, gpio::Levels::NONE, gpioCallback->callbackArgs); - return RETURN_OK; + return returnvalue::OK; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) { - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; + ReturnValue_t result = returnvalue::OK; for (auto& gpioConfig : mapToAdd) { switch (gpioConfig.second->gpioType) { case (gpio::GpioTypes::GPIO_REGULAR_BY_CHIP): @@ -340,7 +340,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) { } // Check for conflicts and remove duplicates if necessary result = checkForConflictsById(gpioConfig.first, gpioConfig.second->gpioType, mapToAdd); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } break; @@ -352,7 +352,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflicts(GpioMap& mapToAdd) { } // Check for conflicts and remove duplicates if necessary result = checkForConflictsById(gpioConfig.first, gpioConfig.second->gpioType, mapToAdd); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { status = result; } break; @@ -426,7 +426,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsById(gpioId_t gpioIdToCheck, mapToAdd.erase(gpioIdToCheck); return GPIO_DUPLICATE_DETECTED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void LinuxLibgpioIF::parseFindeLineResult(int result, std::string& lineName) { diff --git a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h index fcc9c775..f9ba680b 100644 --- a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h +++ b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h @@ -71,7 +71,7 @@ class LinuxLibgpioIF : public GpioIF, public SystemObject { * * @param mapToAdd The GPIOs which shall be added to the gpioMap. * - * @return RETURN_OK if successful, otherwise RETURN_FAILED + * @return RETURN_OK if successful, otherwise returnvalue::FAILED */ ReturnValue_t checkForConflicts(GpioMap& mapToAdd); diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp index 4f53dc1f..8edeb8ab 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -52,16 +52,16 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { << i2cAddress << "to I2C device " << "map" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::initializeInterface: Device with address " << i2cAddress << "already in use" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { @@ -73,11 +73,11 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::sendMessage: Send Data is nullptr" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (sendLen == 0) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } I2cCookie* i2cCookie = dynamic_cast(cookie); @@ -95,16 +95,16 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not " << "registered in i2cDeviceMap" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } deviceFile = i2cCookie->getDeviceFile(); UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::sendMessage"); - if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + if (fileHelper.getOpenResult() != returnvalue::OK) { return fileHelper.getOpenResult(); } result = openDevice(deviceFile, i2cAddress, &fd); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -114,17 +114,17 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s "device with error code " << errno << ". Error description: " << strerror(errno) << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #if FSFW_HAL_I2C_WIRETAPPING == 1 sif::info << "Sent I2C data to bus " << deviceFile << ":" << std::endl; arrayprinter::print(sendData, sendLen); #endif - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } -ReturnValue_t I2cComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t I2cComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { ReturnValue_t result; @@ -132,7 +132,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe std::string deviceFile; if (requestLen == 0) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } I2cCookie* i2cCookie = dynamic_cast(cookie); @@ -152,16 +152,16 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe << "registered in i2cDeviceMap" << std::endl; #endif i2cDeviceMapIter->second.replyLen = 0; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } deviceFile = i2cCookie->getDeviceFile(); UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::requestReceiveMessage"); - if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + if (fileHelper.getOpenResult() != returnvalue::OK) { return fileHelper.getOpenResult(); } result = openDevice(deviceFile, i2cAddress, &fd); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { i2cDeviceMapIter->second.replyLen = 0; return result; } @@ -182,7 +182,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen << " bytes" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } #if FSFW_HAL_I2C_WIRETAPPING == 1 @@ -191,7 +191,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe #endif i2cDeviceMapIter->second.replyLen = requestLen; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { @@ -210,12 +210,12 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not " << "found in i2cDeviceMap" << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *buffer = i2cDeviceMapIter->second.replyBuffer.data(); *size = i2cDeviceMapIter->second.replyLen; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress, @@ -231,7 +231,7 @@ ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress, sif::printWarning("Error description: %s\n", strerror(errno)); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.h b/src/fsfw_hal/linux/i2c/I2cComIF.h index cf3bbe49..7101b9b6 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.h +++ b/src/fsfw_hal/linux/i2c/I2cComIF.h @@ -49,7 +49,7 @@ class I2cComIF : public DeviceCommunicationIF, public SystemObject { * @param deviceFile The name of the device file. E.g. i2c-0 * @param i2cAddress The address of the i2c slave device. * @param fileDescriptor Pointer to device descriptor. - * @return RETURN_OK if successful, otherwise RETURN_FAILED. + * @return RETURN_OK if successful, otherwise returnvalue::FAILED. */ ReturnValue_t openDevice(std::string deviceFile, address_t i2cAddress, int *fileDescriptor); }; diff --git a/src/fsfw_hal/linux/rpi/GpioRPi.cpp b/src/fsfw_hal/linux/rpi/GpioRPi.cpp index d3c0a577..a6b097bf 100644 --- a/src/fsfw_hal/linux/rpi/GpioRPi.cpp +++ b/src/fsfw_hal/linux/rpi/GpioRPi.cpp @@ -9,7 +9,7 @@ ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int std::string consumer, gpio::Direction direction, gpio::Levels initValue) { if (cookie == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } auto config = new GpiodRegularByChip(); @@ -30,9 +30,9 @@ ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int sif::printError("createRpiGpioConfig: BCM pin %d invalid!\n", bcmPin); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } config->lineNum = bcmPin; cookie->addGpio(gpioId, config); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_hal/linux/spi/SpiComIF.cpp b/src/fsfw_hal/linux/spi/SpiComIF.cpp index b06def69..cc52b689 100644 --- a/src/fsfw_hal/linux/spi/SpiComIF.cpp +++ b/src/fsfw_hal/linux/spi/SpiComIF.cpp @@ -56,7 +56,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { static_cast(spiAddress)); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } /* Now we emplaced the read buffer in the map, we still need to assign that location to the SPI driver transfer struct */ @@ -69,7 +69,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { sif::printError("SpiComIF::initializeInterface: SPI address already exists!\n"); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } /* Pull CS high in any case to be sure that device is inactive */ @@ -87,7 +87,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { int fileDescriptor = 0; UnixFileGuard fileHelper(spiCookie->getSpiDevice(), &fileDescriptor, O_RDWR, "SpiComIF::initializeInterface"); - if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + if (fileHelper.getOpenResult() != returnvalue::OK) { return fileHelper.getOpenResult(); } @@ -129,12 +129,12 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { "Could not write bits per word!"); } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { SpiCookie* spiCookie = dynamic_cast(cookie); - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (spiCookie == nullptr) { return NULLPOINTER; @@ -178,13 +178,13 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const spiCookie->assignReadBuffer(iter->second.replyBuffer.data()); } - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; int retval = 0; /* Prepare transfer */ int fileDescriptor = 0; std::string device = spiCookie->getSpiDevice(); UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); - if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + if (fileHelper.getOpenResult() != returnvalue::OK) { return OPENING_FILE_FAILED; } spi::SpiModes spiMode = spi::SpiModes::MODE_0; @@ -200,7 +200,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const /* Pull SPI CS low. For now, no support for active high given */ if (gpioId != gpio::NO_GPIO) { result = spiMutex->lockMutex(timeoutType, timeoutMs); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl; @@ -211,7 +211,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const return result; } result = gpioComIF->pullLow(gpioId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "SpiComIF::sendMessage: Pulling low CS pin failed" << std::endl; @@ -251,7 +251,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const if (gpioId != gpio::NO_GPIO) { gpioComIF->pullHigh(gpioId); result = spiMutex->unlockMutex(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "SpiComIF::sendMessage: Failed to unlock mutex" << std::endl; #endif @@ -261,7 +261,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const return result; } -ReturnValue_t SpiComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SpiComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { SpiCookie* spiCookie = dynamic_cast(cookie); @@ -270,32 +270,32 @@ ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe } if (spiCookie->isFullDuplex()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return performHalfDuplexReception(spiCookie); } ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::string device = spiCookie->getSpiDevice(); int fileDescriptor = 0; UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::requestReceiveMessage"); - if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + if (fileHelper.getOpenResult() != returnvalue::OK) { return OPENING_FILE_FAILED; } uint8_t* rxBuf = nullptr; size_t readSize = spiCookie->getCurrentTransferSize(); result = getReadBuffer(spiCookie->getSpiAddress(), &rxBuf); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } gpioId_t gpioId = spiCookie->getChipSelectPin(); if (gpioId != gpio::NO_GPIO) { result = spiMutex->lockMutex(timeoutType, timeoutMs); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "SpiComIF::getSendSuccess: Failed to lock mutex" << std::endl; #endif @@ -318,7 +318,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { if (gpioId != gpio::NO_GPIO) { gpioComIF->pullHigh(gpioId); result = spiMutex->unlockMutex(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "SpiComIF::getSendSuccess: Failed to unlock mutex" << std::endl; #endif @@ -332,18 +332,18 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { ReturnValue_t SpiComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { SpiCookie* spiCookie = dynamic_cast(cookie); if (spiCookie == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint8_t* rxBuf = nullptr; ReturnValue_t result = getReadBuffer(spiCookie->getSpiAddress(), &rxBuf); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *buffer = rxBuf; *size = spiCookie->getCurrentTransferSize(); spiCookie->setTransferSize(0); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MutexIF* SpiComIF::getMutex(MutexIF::TimeoutType* timeoutType, uint32_t* timeoutMs) { @@ -377,16 +377,16 @@ void SpiComIF::performSpiWiretapping(SpiCookie* spiCookie) { ReturnValue_t SpiComIF::getReadBuffer(address_t spiAddress, uint8_t** buffer) { if (buffer == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } auto iter = spiDeviceMap.find(spiAddress); if (iter == spiDeviceMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *buffer = iter->second.replyBuffer.data(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } GpioIF* SpiComIF::getGpioInterface() { return gpioComIF; } diff --git a/src/fsfw_hal/linux/uart/UartComIF.cpp b/src/fsfw_hal/linux/uart/UartComIF.cpp index f77bdeae..8947c562 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -37,7 +37,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { if (uartDeviceMapIter == uartDeviceMap.end()) { int fileDescriptor = configureUartPort(uartCookie); if (fileDescriptor < 0) { - return RETURN_FAILED; + return returnvalue::FAILED; } size_t maxReplyLen = uartCookie->getMaxReplyLen(); UartElements uartElements = {fileDescriptor, std::vector(maxReplyLen), 0}; @@ -47,17 +47,17 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { sif::warning << "UartComIF::initializeInterface: Failed to insert device " << deviceFile << "to UART device map" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::initializeInterface: UART device " << deviceFile << " already in use" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } int UartComIF::configureUartPort(UartCookie* uartCookie) { @@ -329,14 +329,14 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, UartDeviceMapIter uartDeviceMapIter; if (sendLen == 0) { - return RETURN_OK; + return returnvalue::OK; } if (sendData == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::sendMessage: Send data is nullptr" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } UartCookie* uartCookie = dynamic_cast(cookie); @@ -354,7 +354,7 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, sif::debug << "UartComIF::sendMessage: Device file " << deviceFile << "not in UART map" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } fd = uartDeviceMapIter->second.fileDescriptor; @@ -364,13 +364,13 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, sif::error << "UartComIF::sendMessage: Failed to send data with error code " << errno << ": Error description: " << strerror(errno) << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } -ReturnValue_t UartComIF::getSendSuccess(CookieIF* cookie) { return RETURN_OK; } +ReturnValue_t UartComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { std::string deviceFile; @@ -389,7 +389,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartMode == UartModes::NON_CANONICAL and requestLen == 0) { - return RETURN_OK; + return returnvalue::OK; } if (uartDeviceMapIter == uartDeviceMap.end()) { @@ -397,7 +397,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL sif::debug << "UartComIF::requestReceiveMessage: Device file " << deviceFile << " not in uart map" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } if (uartMode == UartModes::CANONICAL) { @@ -405,13 +405,13 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL } else if (uartMode == UartModes::NON_CANONICAL) { return handleNoncanonicalRead(*uartCookie, uartDeviceMapIter, requestLen); } else { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, size_t requestLen) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; uint8_t maxReadCycles = uartCookie.getReadCycles(); uint8_t currentReadCycles = 0; int bytesRead = 0; @@ -454,7 +454,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM strerror(errno)); #endif #endif - return RETURN_FAILED; + return returnvalue::FAILED; } } else if (bytesRead > 0) { @@ -487,18 +487,18 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi } int bytesRead = read(fd, bufferPtr, requestLen); if (bytesRead < 0) { - return RETURN_FAILED; + return returnvalue::FAILED; } else if (bytesRead != static_cast(requestLen)) { if (uartCookie.isReplySizeFixed()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::requestReceiveMessage: Only read " << bytesRead << " of " << requestLen << " bytes" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } } iter->second.replyLen = bytesRead; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { @@ -520,7 +520,7 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, sif::debug << "UartComIF::readReceivedMessage: Device file " << deviceFile << " not in uart map" << std::endl; #endif - return RETURN_FAILED; + return returnvalue::FAILED; } *buffer = uartDeviceMapIter->second.replyBuffer.data(); @@ -529,7 +529,7 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, /* Length is reset to 0 to prevent reading the same data twice */ uartDeviceMapIter->second.replyLen = 0; - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { @@ -547,9 +547,9 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCIFLUSH); - return RETURN_OK; + return returnvalue::OK; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { @@ -567,9 +567,9 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCOFLUSH); - return RETURN_OK; + return returnvalue::OK; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { @@ -587,9 +587,9 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCIOFLUSH); - return RETURN_OK; + return returnvalue::OK; } - return RETURN_FAILED; + return returnvalue::FAILED; } void UartComIF::setUartMode(struct termios* options, UartCookie& uartCookie) { diff --git a/src/fsfw_hal/linux/uio/UioMapper.cpp b/src/fsfw_hal/linux/uio/UioMapper.cpp index 43ca2727..3d7e5987 100644 --- a/src/fsfw_hal/linux/uio/UioMapper.cpp +++ b/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -18,17 +18,17 @@ UioMapper::UioMapper(std::string uioFile, int mapNum) : uioFile(uioFile), mapNum UioMapper::~UioMapper() {} ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permissions) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; 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; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } size_t size = 0; result = getMapSize(&size); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } *address = static_cast( @@ -39,9 +39,9 @@ ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permiss sif::error << "UioMapper::getMappedAdress: Failed to map physical address of uio device " << uioFile.c_str() << " and map" << static_cast(mapNum) << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t UioMapper::getMapSize(size_t* size) { @@ -54,7 +54,7 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "UioMapper::getMapSize: Failed to open file " << namestream.str() << std::endl; #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } char hexstring[SIZE_HEX_STRING] = ""; int items = fscanf(fp, "%s", hexstring); @@ -66,7 +66,7 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) { << namestream.str() << std::endl; #endif fclose(fp); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } uint32_t sizeTmp = 0; items = sscanf(hexstring, "%x", &sizeTmp); @@ -79,8 +79,8 @@ ReturnValue_t UioMapper::getMapSize(size_t* size) { << "size of map" << mapNum << " to integer" << std::endl; #endif fclose(fp); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } fclose(fp); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp b/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp index cbf8def5..624696c8 100644 --- a/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp +++ b/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.cpp @@ -84,7 +84,7 @@ ReturnValue_t GyroL3GD20H::initialize() { spiHandle->Init.Mode = SPI_MODE_MASTER; if (HAL_SPI_Init(spiHandle) != HAL_OK) { sif::printWarning("Error initializing SPI\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } delete mspCfg; @@ -106,11 +106,11 @@ ReturnValue_t GyroL3GD20H::initialize() { return handlePollingTransferInit(); } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::performOperation() { @@ -125,10 +125,10 @@ ReturnValue_t GyroL3GD20H::performOperation() { return handleInterruptSensorRead(); } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::handleDmaTransferInit() { @@ -162,10 +162,10 @@ ReturnValue_t GyroL3GD20H::handleDmaTransferInit() { case (TransferStates::FAILURE): { sif::printWarning("Transfer failure\n"); transferState = TransferStates::FAILURE; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -194,10 +194,10 @@ ReturnValue_t GyroL3GD20H::handleDmaTransferInit() { case (TransferStates::FAILURE): { sif::printWarning("GyroL3GD20H::initialize: Configuration transfer failure\n"); transferState = TransferStates::FAILURE; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -228,13 +228,13 @@ ReturnValue_t GyroL3GD20H::handleDmaTransferInit() { case (TransferStates::FAILURE): { sif::printWarning("GyroL3GD20H::initialize: Configuration transfer failure\n"); transferState = TransferStates::FAILURE; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::handleDmaSensorRead() { @@ -259,13 +259,13 @@ ReturnValue_t GyroL3GD20H::handleDmaSensorRead() { case (TransferStates::FAILURE): { sif::printWarning("GyroL3GD20H::handleDmaSensorRead: Sensor read failure\n"); transferState = TransferStates::FAILURE; - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } HAL_StatusTypeDef GyroL3GD20H::performDmaTransfer(size_t sendSize) { @@ -298,14 +298,14 @@ ReturnValue_t GyroL3GD20H::handlePollingTransferInit() { } case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } case (HAL_ERROR): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -323,14 +323,14 @@ ReturnValue_t GyroL3GD20H::handlePollingTransferInit() { } case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } case (HAL_ERROR): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -353,17 +353,17 @@ ReturnValue_t GyroL3GD20H::handlePollingTransferInit() { } case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } case (HAL_ERROR): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::handlePollingSensorRead() { @@ -380,17 +380,17 @@ ReturnValue_t GyroL3GD20H::handlePollingSensorRead() { } case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer timeout\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } case (HAL_ERROR): { sif::printDebug("GyroL3GD20H::initialize: Polling transfer failure\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() { @@ -416,7 +416,7 @@ ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() { case (HAL_ERROR): case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Initialization failure using interrupts\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -438,7 +438,7 @@ ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() { case (HAL_ERROR): case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Initialization failure using interrupts\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -465,10 +465,10 @@ ReturnValue_t GyroL3GD20H::handleInterruptTransferInit() { case (HAL_ERROR): case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Initialization failure using interrupts\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t GyroL3GD20H::handleInterruptSensorRead() { @@ -489,10 +489,10 @@ ReturnValue_t GyroL3GD20H::handleInterruptSensorRead() { case (HAL_ERROR): case (HAL_TIMEOUT): { sif::printDebug("GyroL3GD20H::initialize: Sensor read failure using interrupts\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void GyroL3GD20H::prepareConfigRegs(uint8_t *configRegs) { diff --git a/src/fsfw_hal/stm32h7/spi/SpiComIF.cpp b/src/fsfw_hal/stm32h7/spi/SpiComIF.cpp index 49e4670d..724917bd 100644 --- a/src/fsfw_hal/stm32h7/spi/SpiComIF.cpp +++ b/src/fsfw_hal/stm32h7/spi/SpiComIF.cpp @@ -35,7 +35,7 @@ void SpiComIF::addDmaHandles(DMA_HandleTypeDef *txHandle, DMA_HandleTypeDef *rxH spi::setDmaHandles(txHandle, rxHandle); } -ReturnValue_t SpiComIF::initialize() { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SpiComIF::initialize() { return returnvalue::OK; } ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { SpiCookie *spiCookie = dynamic_cast(cookie); @@ -55,7 +55,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { spi::getDmaHandles(&txHandle, &rxHandle); if (txHandle == nullptr or rxHandle == nullptr) { sif::printError("SpiComIF::initialize: DMA handles not set!\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } // This semaphore ensures thread-safety for a given bus @@ -79,7 +79,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { static_cast(spiAddress)); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } auto gpioPin = spiCookie->getChipSelectGpioPin(); @@ -98,7 +98,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { #endif } else { printCfgError("SPI Bus Index"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } auto mspCfg = spiCookie->getMspCfg(); @@ -107,21 +107,21 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { auto typedCfg = dynamic_cast(mspCfg); if (typedCfg == nullptr) { printCfgError("Polling MSP"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } spi::setSpiPollingMspFunctions(typedCfg); } else if (transferMode == spi::TransferModes::INTERRUPT) { auto typedCfg = dynamic_cast(mspCfg); if (typedCfg == nullptr) { printCfgError("IRQ MSP"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } spi::setSpiIrqMspFunctions(typedCfg); } else if (transferMode == spi::TransferModes::DMA) { auto typedCfg = dynamic_cast(mspCfg); if (typedCfg == nullptr) { printCfgError("DMA MSP"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // Check DMA handles DMA_HandleTypeDef *txHandle = nullptr; @@ -129,7 +129,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { spi::getDmaHandles(&txHandle, &rxHandle); if (txHandle == nullptr or rxHandle == nullptr) { printCfgError("DMA Handle"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } spi::setSpiDmaMspFunctions(typedCfg); } @@ -145,12 +145,12 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { if (HAL_SPI_Init(&spiHandle) != HAL_OK) { sif::printWarning("SpiComIF::initialize: Error initializing SPI\n"); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } // The MSP configuration struct is not required anymore spiCookie->deleteMspCfg(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) { @@ -163,7 +163,7 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s auto iter = spiDeviceMap.find(spiCookie->getDeviceAddress()); if (iter == spiDeviceMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } iter->second.currentTransferLen = sendLen; @@ -176,7 +176,7 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s case (spi::TransferStates::FAILURE): case (spi::TransferStates::SUCCESS): default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } @@ -194,13 +194,13 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s sendData, sendLen); } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } -ReturnValue_t SpiComIF::getSendSuccess(CookieIF *cookie) { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SpiComIF::getSendSuccess(CookieIF *cookie) { return returnvalue::OK; } ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { @@ -212,7 +212,7 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, case (spi::TransferStates::SUCCESS): { auto iter = spiDeviceMap.find(spiCookie->getDeviceAddress()); if (iter == spiDeviceMap.end()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } *buffer = iter->second.replyBuffer.data(); *size = iter->second.currentTransferLen; @@ -228,18 +228,18 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, #endif #endif spiCookie->setTransferState(spi::TransferStates::IDLE); - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } case (spi::TransferStates::WAIT): case (spi::TransferStates::IDLE): { break; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void SpiComIF::setDefaultPollingTimeout(dur_millis_t timeout) { @@ -252,7 +252,7 @@ ReturnValue_t SpiComIF::handlePollingSendOperation(uint8_t *recvPtr, SPI_HandleT auto gpioPort = spiCookie.getChipSelectGpioPort(); auto gpioPin = spiCookie.getChipSelectGpioPin(); auto returnval = spiSemaphore->acquire(timeoutType, timeoutMs); - if (returnval != HasReturnvaluesIF::RETURN_OK) { + if (returnval != returnvalue::OK) { return returnval; } spiCookie.setTransferState(spi::TransferStates::WAIT); @@ -299,7 +299,7 @@ ReturnValue_t SpiComIF::handlePollingSendOperation(uint8_t *recvPtr, SPI_HandleT return spi::HAL_ERROR_RETVAL; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t SpiComIF::handleInterruptSendOperation(uint8_t *recvPtr, SPI_HandleTypeDef &spiHandle, @@ -318,7 +318,7 @@ ReturnValue_t SpiComIF::handleIrqSendOperation(uint8_t *recvPtr, SPI_HandleTypeD SpiCookie &spiCookie, const uint8_t *sendData, size_t sendLen) { ReturnValue_t result = genericIrqSendSetup(recvPtr, spiHandle, spiCookie, sendData, sendLen); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } // yet another HAL driver which is not const-correct.. @@ -366,7 +366,7 @@ ReturnValue_t SpiComIF::halErrorHandler(HAL_StatusTypeDef status, spi::TransferM return spi::HAL_TIMEOUT_RETVAL; } default: { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } } @@ -379,7 +379,7 @@ ReturnValue_t SpiComIF::genericIrqSendSetup(uint8_t *recvPtr, SPI_HandleTypeDef // Take the semaphore which will be released by a callback when the transfer is complete ReturnValue_t result = spiSemaphore->acquire(SemaphoreIF::TimeoutType::WAITING, timeoutMs); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { // Configuration error sif::printWarning( "SpiComIF::handleInterruptSendOperation: Semaphore " @@ -399,7 +399,7 @@ ReturnValue_t SpiComIF::genericIrqSendSetup(uint8_t *recvPtr, SPI_HandleTypeDef HAL_GPIO_WritePin(spiCookie.getChipSelectGpioPort(), spiCookie.getChipSelectGpioPin(), GPIO_PIN_RESET); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void SpiComIF::spiTransferTxCompleteCallback(SPI_HandleTypeDef *hspi, void *args) { @@ -445,7 +445,7 @@ void SpiComIF::genericIrqHandler(void *irqArgsVoid, spi::TransferStates targetSt #elif defined FSFW_OSAL_RTEMS ReturnValue_t result = comIF->spiSemaphore->release(); #endif - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { // Configuration error printf("SpiComIF::genericIrqHandler: Failure releasing Semaphore!\n"); } diff --git a/src/fsfw_tests/integration/assemblies/TestAssembly.cpp b/src/fsfw_tests/integration/assemblies/TestAssembly.cpp index a0313f96..668120c6 100644 --- a/src/fsfw_tests/integration/assemblies/TestAssembly.cpp +++ b/src/fsfw_tests/integration/assemblies/TestAssembly.cpp @@ -30,7 +30,7 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) { #else sif::printInfo("TestAssembly: Received command to go to mode %d submode %d\n", mode, submode); #endif - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; if (mode == MODE_OFF) { commandTable[0].setMode(MODE_OFF); commandTable[0].setSubmode(SUBMODE_NONE); @@ -113,14 +113,14 @@ ReturnValue_t TestAssembly::isModeCombinationValid(Mode_t mode, Submode_t submod switch (mode) { case MODE_OFF: if (submode == SUBMODE_NONE) { - return RETURN_OK; + return returnvalue::OK; } else { return INVALID_SUBMODE; } case DeviceHandlerIF::MODE_NORMAL: case MODE_ON: if (submode < 3) { - return RETURN_OK; + return returnvalue::OK; } else { return INVALID_SUBMODE; } @@ -130,24 +130,24 @@ ReturnValue_t TestAssembly::isModeCombinationValid(Mode_t mode, Submode_t submod ReturnValue_t TestAssembly::initialize() { ReturnValue_t result = AssemblyBase::initialize(); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } handler0 = ObjectManager::instance()->get(deviceHandler0Id); handler1 = ObjectManager::instance()->get(deviceHandler1Id); if ((handler0 == nullptr) or (handler1 == nullptr)) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } handler0->setParentQueue(this->getCommandQueue()); handler1->setParentQueue(this->getCommandQueue()); result = registerChild(deviceHandler0Id); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = registerChild(deviceHandler1Id); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return result; @@ -160,11 +160,11 @@ ReturnValue_t TestAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wa return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE; } } - return RETURN_OK; + return returnvalue::OK; } else if (submode == submodes::SINGLE) { for (const auto& info : childrenMap) { if (info.second.mode == wantedMode and info.second.mode != wantedSubmode) { - return RETURN_OK; + return returnvalue::OK; } } } diff --git a/src/fsfw_tests/integration/controller/TestController.cpp b/src/fsfw_tests/integration/controller/TestController.cpp index 03f24311..2ee4d5fe 100644 --- a/src/fsfw_tests/integration/controller/TestController.cpp +++ b/src/fsfw_tests/integration/controller/TestController.cpp @@ -10,7 +10,7 @@ TestController::TestController(object_id_t objectId, object_id_t parentId, size_ TestController::~TestController() {} ReturnValue_t TestController::handleCommandMessage(CommandMessage *message) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TestController::performControlOperation() {} @@ -24,7 +24,7 @@ LocalPoolDataSetBase *TestController::getDataSetHandle(sid_t sid) { return nullp ReturnValue_t TestController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestController::initializeAfterTaskCreation() { @@ -33,5 +33,5 @@ ReturnValue_t TestController::initializeAfterTaskCreation() { ReturnValue_t TestController::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp index 551e252f..f4fb323a 100644 --- a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp +++ b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp @@ -139,7 +139,7 @@ ReturnValue_t TestDevice::buildCommandFromCommand(DeviceCommandId_t deviceComman const uint8_t* commandData, size_t commandDataLen) { using namespace testdevice; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (deviceCommand) { case (TEST_NORMAL_MODE_CMD): { commandSent = true; @@ -222,7 +222,7 @@ ReturnValue_t TestDevice::buildNormalModeCommand(DeviceCommandId_t deviceCommand } /* The command is passed on in the command buffer as it is */ passOnCommand(deviceCommand, commandData, commandDataLen); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::buildTestCommand0(DeviceCommandId_t deviceCommand, @@ -248,7 +248,7 @@ ReturnValue_t TestDevice::buildTestCommand0(DeviceCommandId_t deviceCommand, /* The command is passed on in the command buffer as it is */ passOnCommand(deviceCommand, commandData, commandDataLen); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::buildTestCommand1(DeviceCommandId_t deviceCommand, @@ -277,7 +277,7 @@ ReturnValue_t TestDevice::buildTestCommand1(DeviceCommandId_t deviceCommand, size_t size = commandDataLen; ReturnValue_t result = SerializeAdapter::deSerialize(¶meter1, &commandData, &size, SerializeIF::Endianness::BIG); - if (result == HasReturnvaluesIF::RETURN_FAILED) { + if (result == returnvalue::FAILED) { return result; } @@ -299,7 +299,7 @@ ReturnValue_t TestDevice::buildTestCommand1(DeviceCommandId_t deviceCommand, memcpy(commandBuffer + 6, ¶meter2, sizeof(parameter2)); rawPacket = commandBuffer; rawPacketLen = sizeof(deviceCommand) + sizeof(parameter1) + sizeof(parameter2); - return RETURN_OK; + return returnvalue::OK; } void TestDevice::passOnCommand(DeviceCommandId_t command, const uint8_t* commandData, @@ -342,7 +342,7 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC size_t size = len; ReturnValue_t result = SerializeAdapter::deSerialize(foundId, &start, &size, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -366,7 +366,7 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC *foundLen = len; *foundId = pendingCmd; - return RETURN_OK; + return returnvalue::OK; } case (TEST_COMMAND_0): { @@ -389,7 +389,7 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC *foundLen = TEST_COMMAND_0_SIZE; *foundId = pendingCmd; - return RETURN_OK; + return returnvalue::OK; } case (TEST_COMMAND_1): { @@ -409,7 +409,7 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC *foundLen = len; *foundId = pendingCmd; - return RETURN_OK; + return returnvalue::OK; } default: @@ -418,7 +418,7 @@ ReturnValue_t TestDevice::scanForReply(const uint8_t* start, size_t len, DeviceC } ReturnValue_t TestDevice::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; switch (id) { /* Periodic replies */ case testdevice::TEST_NORMAL_MODE_CMD: { @@ -460,7 +460,7 @@ ReturnValue_t TestDevice::interpretingNormalModeReply() { dataset.testFloat3Vec.value[2] = 0.0; dataset.setValidity(false, true); } - return RETURN_OK; + return returnvalue::OK; } PoolReadGuard readHelper(&dataset); @@ -570,7 +570,7 @@ ReturnValue_t TestDevice::interpretingNormalModeReply() { } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::interpretingTestReply0(DeviceCommandId_t id, const uint8_t* packet) { @@ -589,7 +589,7 @@ ReturnValue_t TestDevice::interpretingTestReply0(DeviceCommandId_t id, const uin actionHelper.step(1, commander, id); actionHelper.finish(true, commander, id); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::interpretingTestReply1(DeviceCommandId_t id, const uint8_t* packet) { @@ -608,7 +608,7 @@ ReturnValue_t TestDevice::interpretingTestReply1(DeviceCommandId_t id, const uin ReturnValue_t result = actionHelper.reportData(commander, id, packet, testdevice::TEST_COMMAND_1_SIZE, false); - if (result != RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TestDevice" << deviceIdx << "::interpretingReply1: Sending data " @@ -620,7 +620,7 @@ ReturnValue_t TestDevice::interpretingTestReply1(DeviceCommandId_t id, const uin return result; } - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { /* Finish reply */ actionHelper.finish(true, commander, id); } else { @@ -628,7 +628,7 @@ ReturnValue_t TestDevice::interpretingTestReply1(DeviceCommandId_t id, const uin actionHelper.finish(false, commander, id, result); } - return RETURN_OK; + return returnvalue::OK; } uint32_t TestDevice::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } @@ -645,8 +645,13 @@ ReturnValue_t TestDevice::initializeLocalDataPool(localpool::DataPool& localData sid_t sid(this->getObjectId(), td::TEST_SET_ID); /* Subscribe for periodic HK packets but do not enable reporting for now. Non-diangostic with a period of one second */ +<<<<<<< HEAD poolManager.subscribeForRegularPeriodicPacket(subdp::RegularHkPeriodicParams(sid, false, 1.0)); return HasReturnvaluesIF::RETURN_OK; +======= + poolManager.subscribeForPeriodicPacket(sid, false, 1.0, false); + return returnvalue::OK; +>>>>>>> mueller/expand-retval-if } ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, @@ -658,7 +663,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, if (fullInfoPrintout) { uint32_t newValue = 0; ReturnValue_t result = newValues->getElement(&newValue, 0, 0); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx << "::getParameter: Setting parameter 0 to " @@ -677,7 +682,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, if (fullInfoPrintout) { int32_t newValue = 0; ReturnValue_t result = newValues->getElement(&newValue, 0, 0); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx << "::getParameter: Setting parameter 1 to " @@ -695,10 +700,10 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, case ParameterUniqueIds::TEST_FLOAT_VEC3_2: { if (fullInfoPrintout) { float newVector[3]; - if (newValues->getElement(newVector, 0, 0) != RETURN_OK or - newValues->getElement(newVector + 1, 0, 1) != RETURN_OK or - newValues->getElement(newVector + 2, 0, 2) != RETURN_OK) { - return HasReturnvaluesIF::RETURN_FAILED; + if (newValues->getElement(newVector, 0, 0) != returnvalue::OK or + newValues->getElement(newVector + 1, 0, 1) != returnvalue::OK or + newValues->getElement(newVector + 2, 0, 2) != returnvalue::OK) { + return returnvalue::FAILED; } #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx @@ -720,7 +725,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, if (fullInfoPrintout) { uint8_t enabled = 0; ReturnValue_t result = newValues->getElement(&enabled, 0, 0); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } char const* printout = nullptr; @@ -743,7 +748,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, case (ParameterUniqueIds::CHANGING_DATASETS): { uint8_t enabled = 0; ReturnValue_t result = newValues->getElement(&enabled, 0, 0); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (not enabled) { @@ -776,7 +781,7 @@ ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, default: return INVALID_IDENTIFIER_ID; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } LocalPoolObjectBase* TestDevice::getPoolObjectHandle(lp_id_t localPoolId) { diff --git a/src/fsfw_tests/integration/devices/TestEchoComIF.cpp b/src/fsfw_tests/integration/devices/TestEchoComIF.cpp index 727381a2..c0aa64a4 100644 --- a/src/fsfw_tests/integration/devices/TestEchoComIF.cpp +++ b/src/fsfw_tests/integration/devices/TestEchoComIF.cpp @@ -25,9 +25,9 @@ ReturnValue_t TestEchoComIF::initializeInterface(CookieIF *cookie) { auto resultPair = replyMap.emplace(dummyCookie->getAddress(), ReplyBuffer(dummyCookie->getReplyMaxLen())); if (not resultPair.second) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestEchoComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, @@ -50,17 +50,17 @@ ReturnValue_t TestEchoComIF::sendMessage(CookieIF *cookie, const uint8_t *sendDa "reply buffer length!\n", sendLen); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } replyBuffer.resize(sendLen); memcpy(replyBuffer.data(), sendData, sendLen); - return RETURN_OK; + return returnvalue::OK; } -ReturnValue_t TestEchoComIF::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } +ReturnValue_t TestEchoComIF::getSendSuccess(CookieIF *cookie) { return returnvalue::OK; } ReturnValue_t TestEchoComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestEchoComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { @@ -78,5 +78,5 @@ ReturnValue_t TestEchoComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buf // add anything that needs to be read periodically by dummy handler dummyReplyCounter = 0; } - return RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_tests/integration/task/TestTask.cpp b/src/fsfw_tests/integration/task/TestTask.cpp index a6a4a30b..a09644d2 100644 --- a/src/fsfw_tests/integration/task/TestTask.cpp +++ b/src/fsfw_tests/integration/task/TestTask.cpp @@ -15,7 +15,7 @@ TestTask::TestTask(object_id_t objectId) : SystemObject(objectId), testMode(test TestTask::~TestTask() = default; ReturnValue_t TestTask::performOperation(uint8_t operationCode) { - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; testLock->lockMutex(MutexIF::TimeoutType::WAITING, 20); if (oneShotAction) { // Add code here which should only be run once @@ -40,23 +40,23 @@ ReturnValue_t TestTask::performOperation(uint8_t operationCode) { ReturnValue_t TestTask::performOneShotAction() { /* Everything here will only be performed once. */ - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestTask::performPeriodicAction() { /* This is performed each task cycle */ - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; return result; } ReturnValue_t TestTask::performActionA() { /* This is performed each alternating task cycle */ - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; return result; } ReturnValue_t TestTask::performActionB() { /* This is performed each alternating task cycle */ - ReturnValue_t result = RETURN_OK; + ReturnValue_t result = returnvalue::OK; return result; } diff --git a/src/fsfw_tests/internal/InternalUnitTester.cpp b/src/fsfw_tests/internal/InternalUnitTester.cpp index 4e45d25b..a135359c 100644 --- a/src/fsfw_tests/internal/InternalUnitTester.cpp +++ b/src/fsfw_tests/internal/InternalUnitTester.cpp @@ -37,5 +37,5 @@ ReturnValue_t InternalUnitTester::performTests( #else sif::printInfo("Internal unit tests finished.\n"); #endif - return RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw_tests/internal/InternalUnitTester.h b/src/fsfw_tests/internal/InternalUnitTester.h index d6d7ca36..07744825 100644 --- a/src/fsfw_tests/internal/InternalUnitTester.h +++ b/src/fsfw_tests/internal/InternalUnitTester.h @@ -13,7 +13,7 @@ * which simply calls all other tests from other files manually. * Maybe there is a better way.. */ -class InternalUnitTester : public HasReturnvaluesIF { +class InternalUnitTester { public: struct TestConfig { bool testArrayPrinter = false; diff --git a/src/fsfw_tests/internal/UnittDefinitions.cpp b/src/fsfw_tests/internal/UnittDefinitions.cpp index 3322b1ad..ea562591 100644 --- a/src/fsfw_tests/internal/UnittDefinitions.cpp +++ b/src/fsfw_tests/internal/UnittDefinitions.cpp @@ -6,5 +6,5 @@ ReturnValue_t unitt::put_error(std::string errorId) { #else sif::printError("Unit Tester error: Failed at test ID %s\n", errorId.c_str()); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } diff --git a/src/fsfw_tests/internal/osal/testMq.cpp b/src/fsfw_tests/internal/osal/testMq.cpp index 3d8e1034..88082b0a 100644 --- a/src/fsfw_tests/internal/osal/testMq.cpp +++ b/src/fsfw_tests/internal/osal/testMq.cpp @@ -20,22 +20,22 @@ void testmq::testMq() { testSenderMq->setDefaultDestination(testReceiverMqId); auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - if (result != result::OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - if (result != result::OK or recvMessage.getData()[0] != 42) { + if (result != returnvalue::OK or recvMessage.getData()[0] != 42) { unitt::put_error(id); } result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - if (result != result::OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } MessageQueueId_t senderId = 0; result = testReceiverMq->receiveMessage(&recvMessage, &senderId); - if (result != result::OK or recvMessage.getData()[0] != 42) { + if (result != returnvalue::OK or recvMessage.getData()[0] != 42) { unitt::put_error(id); } if (senderId != testSenderMqId) { diff --git a/src/fsfw_tests/internal/osal/testMutex.cpp b/src/fsfw_tests/internal/osal/testMutex.cpp index 6206c31d..98c471cb 100644 --- a/src/fsfw_tests/internal/osal/testMutex.cpp +++ b/src/fsfw_tests/internal/osal/testMutex.cpp @@ -16,7 +16,7 @@ void testmutex::testMutex() { std::string id = "[testMutex]"; MutexIF* mutex = MutexFactory::instance()->createMutex(); auto result = mutex->lockMutex(MutexIF::TimeoutType::POLLING); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } // timed_mutex from the C++ library specifies undefined behaviour if @@ -35,7 +35,7 @@ void testmutex::testMutex() { } result = mutex->unlockMutex(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } diff --git a/src/fsfw_tests/internal/osal/testSemaphore.cpp b/src/fsfw_tests/internal/osal/testSemaphore.cpp index a3e4c277..df88b4ed 100644 --- a/src/fsfw_tests/internal/osal/testSemaphore.cpp +++ b/src/fsfw_tests/internal/osal/testSemaphore.cpp @@ -54,7 +54,7 @@ void testsemaph::testCountingSemaph() { // release 3 times in a row for (int i = 0; i < 3; i++) { auto result = countingSemaph->release(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } } @@ -75,7 +75,7 @@ void testsemaph::testBinSemaphoreImplementation(SemaphoreIF* binSemaph, std::str unitt::put_error(id); } result = binSemaph->acquire(SemaphoreIF::BLOCKING); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } @@ -104,7 +104,7 @@ void testsemaph::testBinSemaphoreImplementation(SemaphoreIF* binSemaph, std::str } result = binSemaph->release(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } } @@ -122,7 +122,7 @@ void testsemaph::testCountingSemaphImplementation(SemaphoreIF* countingSemaph, s // acquire 3 times in a row for (int i = 0; i < 3; i++) { result = countingSemaph->acquire(SemaphoreIF::BLOCKING); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } } @@ -144,7 +144,7 @@ void testsemaph::testCountingSemaphImplementation(SemaphoreIF* countingSemaph, s // release 3 times in a row for (int i = 0; i < 3; i++) { result = countingSemaph->release(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { unitt::put_error(id); } } diff --git a/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp b/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp index 5865f8fc..58ab05c1 100644 --- a/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp +++ b/src/fsfw_tests/internal/serialize/IntTestSerialization.cpp @@ -13,18 +13,18 @@ std::array testserialize::test_array = {0}; ReturnValue_t testserialize::test_serialization() { // Here, we test all serialization tools. First test basic cases. ReturnValue_t result = test_endianness_tools(); - if (result != result::OK) { + if (result != returnvalue::OK) { return result; } result = test_autoserialization(); - if (result != result::OK) { + if (result != returnvalue::OK) { return result; } result = test_serial_buffer_adapter(); - if (result != result::OK) { + if (result != returnvalue::OK) { return result; } - return result::OK; + return returnvalue::OK; } ReturnValue_t testserialize::test_endianness_tools() { @@ -48,7 +48,7 @@ ReturnValue_t testserialize::test_endianness_tools() { if (test_array[0] != 0 and test_array[1] != 1) { return unitt::put_error(id); } - return result::OK; + return returnvalue::OK; } ReturnValue_t testserialize::test_autoserialization() { @@ -152,7 +152,7 @@ ReturnValue_t testserialize::test_autoserialization() { } // Check overflow - return result::OK; + return returnvalue::OK; } // TODO: Also test for constant buffers. @@ -205,5 +205,5 @@ ReturnValue_t testserialize::test_serial_buffer_adapter() { if (testUint16 != 16) { return unitt::put_error(id); } - return result::OK; + return returnvalue::OK; } diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index a6eea048..77c055aa 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -20,12 +20,12 @@ TEST_CASE("Action Helper", "[ActionHelper]") { StorageManagerIF* ipcStore = tglob::getIpcStoreHandle(); REQUIRE(ipcStore != nullptr); ipcStore->addData(¶mAddress, testParams.data(), 3); - REQUIRE(actionHelper.initialize() == result::OK); + REQUIRE(actionHelper.initialize() == returnvalue::OK); SECTION("Simple tests") { ActionMessage::setCommand(&actionMessage, testActionId, paramAddress); CHECK(not testDhMock.executeActionCalled); - REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == returnvalue::OK); CHECK(testDhMock.executeActionCalled); // No message is sent if everything is alright. CHECK(not testMqMock.wasMessageSent()); @@ -58,7 +58,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { step += 1; CHECK(testMqMock.wasMessageSent()); CommandMessage testMessage; - REQUIRE(testMqMock.getNextSentMessage(testMessage) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(testMqMock.getNextSentMessage(testMessage) == returnvalue::OK); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(testMessage.getParameter() == static_cast(testActionId)); uint32_t parameter2 = ((uint32_t)step << 16) | (uint32_t)status; @@ -72,7 +72,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { actionHelper.finish(false, testMqMock.getId(), testActionId, status); CHECK(testMqMock.wasMessageSent()); CommandMessage testMessage; - REQUIRE(testMqMock.getNextSentMessage(testMessage) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(testMqMock.getNextSentMessage(testMessage) == returnvalue::OK); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::COMPLETION_FAILED)); REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId); REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(status)); @@ -81,14 +81,14 @@ TEST_CASE("Action Helper", "[ActionHelper]") { SECTION("Handle failed") { store_address_t toLongParamAddress = store_address_t::invalid(); std::array toLongData = {5, 4, 3, 2, 1}; - REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == result::OK); + REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == returnvalue::OK); ActionMessage::setCommand(&actionMessage, testActionId, toLongParamAddress); CHECK(not testDhMock.executeActionCalled); - REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == returnvalue::OK); REQUIRE(ipcStore->getData(toLongParamAddress).first == static_cast(StorageManagerIF::DATA_DOES_NOT_EXIST)); CommandMessage testMessage; - REQUIRE(testMqMock.getNextSentMessage(testMessage) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(testMqMock.getNextSentMessage(testMessage) == returnvalue::OK); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(ActionMessage::getReturnCode(&testMessage) == 0xAFFE); REQUIRE(ActionMessage::getStep(&testMessage) == 0); @@ -98,9 +98,9 @@ TEST_CASE("Action Helper", "[ActionHelper]") { SECTION("Missing IPC Data") { ActionMessage::setCommand(&actionMessage, testActionId, store_address_t::invalid()); CHECK(not testDhMock.executeActionCalled); - REQUIRE(actionHelper.handleActionMessage(&actionMessage) == result::OK); + REQUIRE(actionHelper.handleActionMessage(&actionMessage) == returnvalue::OK); CommandMessage testMessage; - REQUIRE(testMqMock.getNextSentMessage(testMessage) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(testMqMock.getNextSentMessage(testMessage) == returnvalue::OK); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(StorageManagerIF::ILLEGAL_STORAGE_ID)); diff --git a/unittests/action/TestActionHelper.h b/unittests/action/TestActionHelper.h index 75a9f3fe..bd88df80 100644 --- a/unittests/action/TestActionHelper.h +++ b/unittests/action/TestActionHelper.h @@ -26,7 +26,7 @@ class ActionHelperOwnerMockBase : public HasActionsIF { } this->size = size; memcpy(buffer, data, size); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void clearBuffer() { diff --git a/unittests/cfdp/testAckPdu.cpp b/unittests/cfdp/testAckPdu.cpp index e5668799..93d484db 100644 --- a/unittests/cfdp/testAckPdu.cpp +++ b/unittests/cfdp/testAckPdu.cpp @@ -7,7 +7,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array buf = {}; uint8_t* bufptr = buf.data(); size_t maxsz = buf.size(); @@ -20,7 +20,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { AckTransactionStatus::ACTIVE); auto ackSerializer = AckPduSerializer(ackInfo, pduConf); result = ackSerializer.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); SECTION("Serialize") { REQUIRE(buf.data()[sz - 3] == cfdp::FileDirectives::ACK); @@ -34,7 +34,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { bufptr = buf.data(); sz = 0; result = ackSerializer2.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(buf.data()[sz - 3] == cfdp::FileDirectives::ACK); REQUIRE((buf.data()[sz - 2] >> 4) == FileDirectives::FINISH); REQUIRE((buf.data()[sz - 2] & 0x0f) == 0b0001); @@ -47,7 +47,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { auto ackSerializer3 = AckPduSerializer(ackInfo, pduConf); result = ackSerializer3.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); // Invalid file directive - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); ackInfo.setAckedDirective(FileDirectives::FINISH); // buffer too small @@ -59,7 +59,7 @@ TEST_CASE("ACK PDU", "[AckPdu]") { AckInfo ackInfo; auto reader = AckPduDeserializer(buf.data(), sz, ackInfo); result = reader.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(ackInfo.getAckedDirective() == FileDirectives::EOF_DIRECTIVE); REQUIRE(ackInfo.getAckedConditionCode() == ConditionCode::NO_ERROR); REQUIRE(ackInfo.getDirectiveSubtypeCode() == 0); @@ -71,11 +71,11 @@ TEST_CASE("ACK PDU", "[AckPdu]") { bufptr = buf.data(); sz = 0; result = ackSerializer2.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); auto reader2 = AckPduDeserializer(buf.data(), sz, ackInfo); result = reader2.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(ackInfo.getAckedDirective() == FileDirectives::FINISH); REQUIRE(ackInfo.getAckedConditionCode() == ConditionCode::FILESTORE_REJECTION); REQUIRE(ackInfo.getDirectiveSubtypeCode() == 0b0001); diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index e7acab01..b18ef9a3 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -14,7 +14,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { using namespace cfdp; std::array serBuf; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; cfdp::TransactionSeqNum seqNum = TransactionSeqNum(cfdp::WidthInBytes::ONE_BYTE, 2); cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0); cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1); @@ -29,10 +29,10 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { const uint8_t** dummyPtr = nullptr; ReturnValue_t deserResult = headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK); - REQUIRE(deserResult == result::FAILED); + REQUIRE(deserResult == returnvalue::FAILED); deserResult = headerSerializer.serialize(nullptr, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(deserResult == result::FAILED); + REQUIRE(deserResult == returnvalue::FAILED); REQUIRE(seqNum.getSerializedSize() == 1); REQUIRE(headerSerializer.getPduDataFieldLen() == 0); @@ -62,7 +62,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serSize == 7); // Only version bits are set REQUIRE(serBuf[0] == 0b00100000); @@ -155,11 +155,11 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { REQUIRE(entityId == 0x00ff00ff); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); uint8_t oneByteSourceId = 32; serTarget = &oneByteSourceId; size_t deserLen = 1; @@ -197,7 +197,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { auto headerSerializer = HeaderSerializer(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); ReturnValue_t result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serBuf[1] == 0); REQUIRE(serBuf[2] == 0); // Entity and Transaction Sequence number are 1 byte large @@ -207,7 +207,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { auto headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); ReturnValue_t serResult = headerDeser.parseData(); - REQUIRE(serResult == result::OK); + REQUIRE(serResult == returnvalue::OK); REQUIRE(headerDeser.getPduDataFieldLen() == 0); REQUIRE(headerDeser.getHeaderSize() == 7); REQUIRE(headerDeser.getWholePduSize() == 7); @@ -230,11 +230,11 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { headerSerializer.setPduType(cfdp::PduType::FILE_DATA); headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); serTarget = serBuf.data(); serSize = 0; result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), @@ -242,7 +242,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { headerDeser = HeaderDeserializer(serBuf.data(), serBuf.size()); result = headerDeser.parseData(); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Everything except version bit flipped to one now REQUIRE(serBuf[0] == 0x3f); REQUIRE(serBuf[3] == 0b11001010); @@ -274,7 +274,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { serTarget = serBuf.data(); const uint8_t** serTargetConst = const_cast(&serTarget); result = headerDeser.parseData(); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); headerDeser.setData(nullptr, -1); REQUIRE(headerDeser.getHeaderSize() == 0); @@ -286,7 +286,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48); result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(headerDeser.getWholePduSize() == 8); headerDeser.setData(serBuf.data(), serBuf.size()); @@ -301,7 +301,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { serTarget = serBuf.data(); serSize = 0; result = fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Only version bits are set REQUIRE(serBuf[0] == 0b00100000); // PDU data field length is 5 (4 + Directive code octet) @@ -321,9 +321,9 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { size_t deserSize = 20; serSize = 0; REQUIRE(fdSer.deSerialize(&deserTarget, &deserSize, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); REQUIRE(fdSer.serialize(nullptr, nullptr, 85, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); for (uint8_t idx = 0; idx < 8; idx++) { serTarget = serBuf.data(); serSize = 0; @@ -338,7 +338,7 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); fdDeser.setEndianness(SerializeIF::Endianness::NETWORK); - REQUIRE(fdDeser.parseData() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(fdDeser.parseData() == returnvalue::OK); REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK); REQUIRE(fdDeser.getPduDataFieldLen() == 5); REQUIRE(fdDeser.getHeaderSize() == 8); @@ -358,11 +358,11 @@ TEST_CASE("CFDP Base", "[CfdpBase]") { fss.setFileSize(0x20, false); ReturnValue_t result = fss.serialize(&buffer, &size, fssBuf.size(), SerializeIF::Endianness::MACHINE); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); uint32_t fileSize = 0; result = SerializeAdapter::deSerialize(&fileSize, fssBuf.data(), nullptr, SerializeIF::Endianness::MACHINE); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(fileSize == 0x20); } } diff --git a/unittests/cfdp/testEofPdu.cpp b/unittests/cfdp/testEofPdu.cpp index d400af5a..b5cd801c 100644 --- a/unittests/cfdp/testEofPdu.cpp +++ b/unittests/cfdp/testEofPdu.cpp @@ -8,7 +8,7 @@ TEST_CASE("EOF PDU", "[EofPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array buf = {}; uint8_t* bufPtr = buf.data(); size_t sz = 0; @@ -25,17 +25,17 @@ TEST_CASE("EOF PDU", "[EofPdu]") { auto eofSerializer = EofPduSerializer(pduConf, eofInfo); SECTION("Serialize") { result = eofSerializer.serialize(&bufPtr, &sz, buf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(((buf[1] << 8) | buf[2]) == 10); uint32_t checksum = 0; result = SerializeAdapter::deSerialize(&checksum, buf.data() + sz - 8, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(checksum == 5); uint32_t fileSizeVal = 0; result = SerializeAdapter::deSerialize(&fileSizeVal, buf.data() + sz - 4, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(fileSizeVal == 12); REQUIRE(buf[sz - 10] == cfdp::FileDirectives::EOF_DIRECTIVE); REQUIRE(buf[sz - 9] == 0x00); @@ -50,7 +50,7 @@ TEST_CASE("EOF PDU", "[EofPdu]") { sz = 0; result = serializeWithFaultLocation.serialize(&bufPtr, &sz, buf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(sz == 28); REQUIRE(buf[10] == cfdp::FileDirectives::EOF_DIRECTIVE); REQUIRE(buf[11] >> 4 == cfdp::ConditionCode::FILESTORE_REJECTION); @@ -80,12 +80,12 @@ TEST_CASE("EOF PDU", "[EofPdu]") { SECTION("Deserialize") { result = eofSerializer.serialize(&bufPtr, &sz, buf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); EntityIdTlv tlv(destId); EofInfo emptyInfo(&tlv); auto deserializer = EofPduDeserializer(buf.data(), buf.size(), emptyInfo); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::NO_ERROR); REQUIRE(emptyInfo.getChecksum() == 5); REQUIRE(emptyInfo.getFileSize().getSize() == 12); @@ -101,7 +101,7 @@ TEST_CASE("EOF PDU", "[EofPdu]") { SerializeIF::Endianness::NETWORK); auto deserializer2 = EofPduDeserializer(buf.data(), buf.size(), emptyInfo); result = deserializer2.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::FILESTORE_REJECTION); REQUIRE(emptyInfo.getChecksum() == 5); REQUIRE(emptyInfo.getFileSize().getSize() == 0x10ffffff10); @@ -112,7 +112,7 @@ TEST_CASE("EOF PDU", "[EofPdu]") { for (size_t maxSz = 0; maxSz < deserializer2.getWholePduSize() - 1; maxSz++) { auto invalidDeser = EofPduDeserializer(buf.data(), maxSz, emptyInfo); result = invalidDeser.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } } diff --git a/unittests/cfdp/testFileData.cpp b/unittests/cfdp/testFileData.cpp index 1f6a09e9..dd8654d6 100644 --- a/unittests/cfdp/testFileData.cpp +++ b/unittests/cfdp/testFileData.cpp @@ -9,7 +9,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array fileBuffer = {}; std::array fileDataBuffer = {}; uint8_t* buffer = fileDataBuffer.data(); @@ -29,7 +29,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { FileDataSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(sz == 24); // 10 file bytes plus 4 byte offset REQUIRE(((fileDataBuffer[1] << 8) | fileDataBuffer[2]) == 14); @@ -39,7 +39,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { buffer = fileDataBuffer.data(); result = SerializeAdapter::deSerialize(&offsetRaw, buffer + 10, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(offsetRaw == 50); buffer = fileDataBuffer.data() + 14; for (size_t idx = 0; idx < 10; idx++) { @@ -62,7 +62,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { result = serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(((fileDataBuffer[1] << 8) | fileDataBuffer[2]) == 25); // First bit: Seg Ctrl is set // Bits 1 to 3 length of enitity IDs is 2 @@ -88,7 +88,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { buffer = fileDataBuffer.data(); sz = 0; result = serializer.serialize(&buffer, &invalidStartSz, sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } info.setSegmentMetadataFlag(true); @@ -105,13 +105,13 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { FileDataSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); FileSize emptyOffset; FileDataInfo emptyInfo(emptyOffset); FileDataDeserializer deserializer(fileDataBuffer.data(), fileDataBuffer.size(), emptyInfo); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserializer.getWholePduSize() == 24); REQUIRE(deserializer.getPduDataFieldLen() == 14); REQUIRE(deserializer.getSegmentationControl() == @@ -136,10 +136,10 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { sz = 0; result = serializer.serialize(&buffer, &sz, fileDataBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getOffset().getSize() == 50); REQUIRE(emptyInfo.hasSegmentMetadata() == true); @@ -164,7 +164,7 @@ TEST_CASE("File Data PDU", "[FileDataPdu]") { // Starting at 15, the file data is parsed. There is not leading file data length // field to the parser can't check whether the remaining length is valid if (invalidPduField < 15) { - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } } diff --git a/unittests/cfdp/testFinishedPdu.cpp b/unittests/cfdp/testFinishedPdu.cpp index 143eaf2a..dd04144c 100644 --- a/unittests/cfdp/testFinishedPdu.cpp +++ b/unittests/cfdp/testFinishedPdu.cpp @@ -7,7 +7,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array fnBuffer = {}; uint8_t* buffer = fnBuffer.data(); size_t sz = 0; @@ -24,7 +24,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { SECTION("Serialize") { FinishPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getSerializedSize() == 12); REQUIRE(((fnBuffer[1] << 8) | fnBuffer[2]) == 2); REQUIRE(fnBuffer[10] == cfdp::FileDirectives::FINISH); @@ -47,7 +47,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { sz = 0; buffer = fnBuffer.data(); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getSerializedSize() == 12 + 14); REQUIRE(serializer.getPduDataFieldLen() == 16); @@ -69,7 +69,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { sz = 0; buffer = fnBuffer.data(); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); info.setConditionCode(cfdp::ConditionCode::FILESTORE_REJECTION); REQUIRE(serializer.getSerializedSize() == 12 + 14 + 15 + 4); REQUIRE(sz == 12 + 14 + 15 + 4); @@ -81,7 +81,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { sz = 0; buffer = fnBuffer.data(); result = serializer.serialize(&buffer, &sz, maxSz, SerializeIF::Endianness::NETWORK); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } @@ -89,10 +89,10 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { FinishedInfo emptyInfo; FinishPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); FinishPduDeserializer deserializer(fnBuffer.data(), fnBuffer.size(), emptyInfo); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getFileStatus() == cfdp::FinishedFileStatus::DISCARDED_DELIBERATELY); REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::INACTIVITY_DETECTED); REQUIRE(emptyInfo.getDeliveryCode() == cfdp::FinishedDeliveryCode::DATA_INCOMPLETE); @@ -110,13 +110,13 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { serializer.updateDirectiveFieldLen(); REQUIRE(serializer.getPduDataFieldLen() == 16); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); FilestoreResponseTlv emptyResponse(firstNameLv, nullptr); responsePtr = &emptyResponse; emptyInfo.setFilestoreResponsesArray(&responsePtr, nullptr, &len); FinishPduDeserializer deserializer2(fnBuffer.data(), fnBuffer.size(), emptyInfo); result = deserializer2.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getFsResponsesLen() == 1); FilestoreResponseTlv** responseArray = nullptr; emptyInfo.getFilestoreResonses(&responseArray, nullptr, nullptr); @@ -145,7 +145,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { sz = 0; buffer = fnBuffer.data(); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); EntityId emptyId; EntityIdTlv emptyFaultLoc(emptyId); emptyInfo.setFaultLocation(&emptyFaultLoc); @@ -154,7 +154,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { response2.setFilestoreMessage(&emptyFsMsg); FinishPduDeserializer deserializer3(fnBuffer.data(), fnBuffer.size(), emptyInfo); result = deserializer3.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); auto& infoRef = deserializer3.getInfo(); REQUIRE(deserializer3.getWholePduSize() == 45); @@ -183,7 +183,7 @@ TEST_CASE("Finished PDU", "[FinishedPdu]") { for (size_t maxSz = 0; maxSz < 45; maxSz++) { FinishPduDeserializer faultyDeser(fnBuffer.data(), maxSz, emptyInfo); result = faultyDeser.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } } diff --git a/unittests/cfdp/testKeepAlivePdu.cpp b/unittests/cfdp/testKeepAlivePdu.cpp index 8ec8c66c..4b52a084 100644 --- a/unittests/cfdp/testKeepAlivePdu.cpp +++ b/unittests/cfdp/testKeepAlivePdu.cpp @@ -7,7 +7,7 @@ TEST_CASE("Keep Alive PDU", "[KeepAlivePdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array kaBuffer = {}; uint8_t* buffer = kaBuffer.data(); size_t sz = 0; @@ -21,12 +21,12 @@ TEST_CASE("Keep Alive PDU", "[KeepAlivePdu]") { SECTION("Serialize") { KeepAlivePduSerializer serializer(pduConf, progress); result = serializer.serialize(&buffer, &sz, kaBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(kaBuffer[10] == cfdp::FileDirectives::KEEP_ALIVE); uint32_t fsRaw = 0; result = SerializeAdapter::deSerialize(&fsRaw, kaBuffer.data() + 11, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(fsRaw == 0x50); REQUIRE(sz == 15); REQUIRE(serializer.getWholePduSize() == 15); @@ -37,33 +37,33 @@ TEST_CASE("Keep Alive PDU", "[KeepAlivePdu]") { buffer = kaBuffer.data(); sz = 0; result = serializer.serialize(&buffer, &sz, kaBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getWholePduSize() == 19); REQUIRE(serializer.getPduDataFieldLen() == 9); uint64_t fsRawLarge = 0; result = SerializeAdapter::deSerialize(&fsRawLarge, kaBuffer.data() + 11, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(fsRawLarge == 0x50); for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { buffer = kaBuffer.data(); sz = 0; result = serializer.serialize(&buffer, &sz, invalidMaxSz, SerializeIF::Endianness::NETWORK); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } SECTION("Deserialize") { KeepAlivePduSerializer serializer(pduConf, progress); result = serializer.serialize(&buffer, &sz, kaBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Set another file size progress.setFileSize(200, false); KeepAlivePduDeserializer deserializer(kaBuffer.data(), kaBuffer.size(), progress); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); auto& progRef = deserializer.getProgress(); // Should have been overwritten REQUIRE(progRef.getSize() == 0x50); @@ -73,7 +73,7 @@ TEST_CASE("Keep Alive PDU", "[KeepAlivePdu]") { for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { deserializer.setData(kaBuffer.data(), invalidMaxSz); result = deserializer.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } } diff --git a/unittests/cfdp/testMetadataPdu.cpp b/unittests/cfdp/testMetadataPdu.cpp index 331d64a9..7e90e8d3 100644 --- a/unittests/cfdp/testMetadataPdu.cpp +++ b/unittests/cfdp/testMetadataPdu.cpp @@ -10,7 +10,7 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array mdBuffer = {}; uint8_t* buffer = mdBuffer.data(); size_t sz = 0; @@ -41,7 +41,7 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { SECTION("Serialize") { MetadataPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getWholePduSize() == 27); REQUIRE(info.getSourceFileName().getSerializedSize() == 10); REQUIRE(info.getDestFileName().getSerializedSize() == 1); @@ -53,7 +53,7 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { uint32_t fileSizeRaw = 0; result = SerializeAdapter::deSerialize(&fileSizeRaw, mdBuffer.data() + 12, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(fileSizeRaw == 35); REQUIRE(mdBuffer[16] == 9); REQUIRE(mdBuffer[17] == 'h'); @@ -83,7 +83,7 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { serializer.updateDirectiveFieldLen(); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE((mdBuffer[1] << 8 | mdBuffer[2]) == 37); auto checksumType = static_cast(mdBuffer[11] & 0x0f); REQUIRE(checksumType == cfdp::ChecksumType::CRC_32C); @@ -117,16 +117,16 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { SECTION("Deserialize") { MetadataPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); MetadataPduDeserializer deserializer(mdBuffer.data(), mdBuffer.size(), info); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); size_t fullSize = deserializer.getWholePduSize(); for (size_t maxSz = 0; maxSz < fullSize; maxSz++) { MetadataPduDeserializer invalidSzDeser(mdBuffer.data(), maxSz, info); result = invalidSzDeser.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } size_t sizeOfOptions = options.size(); size_t maxSize = 4; @@ -140,11 +140,11 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { info.setSourceFileName(sourceFileName); result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); MetadataPduDeserializer deserializer2(mdBuffer.data(), mdBuffer.size(), info); result = deserializer2.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(options[0]->getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); REQUIRE(options[0]->getSerializedSize() == 14); REQUIRE(options[1]->getType() == cfdp::TlvTypes::MSG_TO_USER); @@ -162,7 +162,7 @@ TEST_CASE("Metadata PDU", "[MetadataPdu]") { } // This is the precise length where there are no options or one option if (invalidFieldLen != 17 and invalidFieldLen != 31) { - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } mdBuffer[1] = (36 >> 8) & 0xff; diff --git a/unittests/cfdp/testNakPdu.cpp b/unittests/cfdp/testNakPdu.cpp index 38b45300..0fc74c89 100644 --- a/unittests/cfdp/testNakPdu.cpp +++ b/unittests/cfdp/testNakPdu.cpp @@ -8,7 +8,7 @@ TEST_CASE("NAK PDU", "[NakPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array nakBuffer = {}; uint8_t* buffer = nakBuffer.data(); size_t sz = 0; @@ -23,7 +23,7 @@ TEST_CASE("NAK PDU", "[NakPdu]") { SECTION("Serializer") { NakPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getSerializedSize() == 19); REQUIRE(serializer.FileDirectiveSerializer::getSerializedSize() == 11); REQUIRE(sz == 19); @@ -33,11 +33,11 @@ TEST_CASE("NAK PDU", "[NakPdu]") { uint32_t scope = 0; result = SerializeAdapter::deSerialize(&scope, nakBuffer.data() + 11, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(scope == 50); result = SerializeAdapter::deSerialize(&scope, nakBuffer.data() + 15, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(scope == 1050); NakInfo::SegmentRequest segReq0(cfdp::FileSize(2020), cfdp::FileSize(2520)); @@ -50,26 +50,26 @@ TEST_CASE("NAK PDU", "[NakPdu]") { size_t sz = 0; serializer.updateDirectiveFieldLen(); result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getSerializedSize() == 35); REQUIRE(serializer.getPduDataFieldLen() == 25); REQUIRE(((nakBuffer[1] << 8) | nakBuffer[2]) == 25); uint32_t segReqScopes = 0; result = SerializeAdapter::deSerialize(&segReqScopes, nakBuffer.data() + 19, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(segReqScopes == 2020); result = SerializeAdapter::deSerialize(&segReqScopes, nakBuffer.data() + 23, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(segReqScopes == 2520); result = SerializeAdapter::deSerialize(&segReqScopes, nakBuffer.data() + 27, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(segReqScopes == 2932); result = SerializeAdapter::deSerialize(&segReqScopes, nakBuffer.data() + 31, nullptr, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(segReqScopes == 3021); for (size_t maxSz = 0; maxSz < 35; maxSz++) { @@ -89,13 +89,13 @@ TEST_CASE("NAK PDU", "[NakPdu]") { SECTION("Deserializer") { NakPduSerializer serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); info.getStartOfScope().setFileSize(0, false); info.getEndOfScope().setFileSize(0, false); NakPduDeserializer deserializer(nakBuffer.data(), nakBuffer.size(), info); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserializer.getWholePduSize() == 19); REQUIRE(info.getStartOfScope().getSize() == 50); REQUIRE(info.getEndOfScope().getSize() == 1050); @@ -110,11 +110,11 @@ TEST_CASE("NAK PDU", "[NakPdu]") { size_t sz = 0; serializer.updateDirectiveFieldLen(); result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); NakPduDeserializer deserializeWithSegReqs(nakBuffer.data(), nakBuffer.size(), info); result = deserializeWithSegReqs.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); NakInfo::SegmentRequest* segReqsPtr = nullptr; size_t readSegReqs = 0; info.getSegmentRequests(&segReqsPtr, &readSegReqs, nullptr); @@ -128,7 +128,7 @@ TEST_CASE("NAK PDU", "[NakPdu]") { for (size_t idx = 0; idx < 34; idx++) { NakPduDeserializer faultyDeserializer(nakBuffer.data(), idx, info); result = faultyDeserializer.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } for (size_t pduFieldLen = 0; pduFieldLen < 25; pduFieldLen++) { nakBuffer[1] = (pduFieldLen >> 8) & 0xff; @@ -143,7 +143,7 @@ TEST_CASE("NAK PDU", "[NakPdu]") { REQUIRE(info.getSegmentRequestsLen() == 2); } if (pduFieldLen != 9 and pduFieldLen != 17 and pduFieldLen != 25) { - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } info.setMaxSegmentRequestLen(5); diff --git a/unittests/cfdp/testPromptPdu.cpp b/unittests/cfdp/testPromptPdu.cpp index 9f406aec..80363983 100644 --- a/unittests/cfdp/testPromptPdu.cpp +++ b/unittests/cfdp/testPromptPdu.cpp @@ -7,7 +7,7 @@ TEST_CASE("Prompt PDU", "[PromptPdu]") { using namespace cfdp; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array rawBuf = {}; uint8_t* buffer = rawBuf.data(); size_t sz = 0; @@ -19,7 +19,7 @@ TEST_CASE("Prompt PDU", "[PromptPdu]") { SECTION("Serialize") { PromptPduSerializer serializer(pduConf, cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); result = serializer.serialize(&buffer, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getWholePduSize() == 12); REQUIRE(sz == 12); REQUIRE(serializer.getPduDataFieldLen() == 2); @@ -30,24 +30,24 @@ TEST_CASE("Prompt PDU", "[PromptPdu]") { uint8_t* buffer = rawBuf.data(); size_t sz = 0; result = serializer.serialize(&buffer, &sz, invalidMaxSz, SerializeIF::Endianness::NETWORK); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } for (size_t invalidSz = 1; invalidSz < sz; invalidSz++) { size_t locSz = invalidSz; uint8_t* buffer = rawBuf.data(); result = serializer.serialize(&buffer, &locSz, sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } SECTION("Deserialize") { PromptPduSerializer serializer(pduConf, cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); result = serializer.serialize(&buffer, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); PromptPduDeserializer deserializer(rawBuf.data(), rawBuf.size()); result = deserializer.parseData(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserializer.getPromptResponseRequired() == cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); sz = deserializer.getWholePduSize(); @@ -59,7 +59,7 @@ TEST_CASE("Prompt PDU", "[PromptPdu]") { for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { deserializer.setData(rawBuf.data(), invalidMaxSz); result = deserializer.parseData(); - REQUIRE(result != HasReturnvaluesIF::RETURN_OK); + REQUIRE(result != returnvalue::OK); } } } diff --git a/unittests/cfdp/testTlvsLvs.cpp b/unittests/cfdp/testTlvsLvs.cpp index c251fd15..bd5ec849 100644 --- a/unittests/cfdp/testTlvsLvs.cpp +++ b/unittests/cfdp/testTlvsLvs.cpp @@ -16,7 +16,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { using namespace cfdp; - int result = HasReturnvaluesIF::RETURN_OK; + int result = returnvalue::OK; std::array rawBuf; uint8_t* serPtr = rawBuf.data(); const uint8_t* deserPtr = rawBuf.data(); @@ -28,7 +28,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = tlvRawBuf.data(); result = sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 2); auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvRawBuf.data(), deserSize); REQUIRE(tlv.getSerializedSize() == 4); @@ -36,7 +36,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); deserSize = 0; result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 4); REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); REQUIRE(rawBuf[1] == 2); @@ -55,33 +55,32 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); deserSize = 0; result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); REQUIRE(rawBuf[1] == 4); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); serPtr = rawBuf.data(); deserSize = 0; auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, tlvRawBuf.data(), 0); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) != returnvalue::OK); tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) != returnvalue::OK); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); REQUIRE(tlvInvalid.getSerializedSize() == 0); REQUIRE(tlvInvalid.serialize(nullptr, nullptr, 0, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); REQUIRE(zeroLenField.getSerializedSize() == 2); serPtr = rawBuf.data(); deserSize = 0; REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER); REQUIRE(rawBuf[1] == 0); } @@ -100,7 +99,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { Tlv tlv; deserPtr = rawBuf.data(); result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(tlv.getSerializedSize() == 4); REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID); deserPtr = tlv.getValue(); @@ -110,8 +109,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { SerializeIF::Endianness::NETWORK); REQUIRE(entityId == 0x0ff0); - REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != returnvalue::OK); deserPtr = rawBuf.data(); deserSize = 0; REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) == @@ -120,17 +118,16 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { rawBuf[0] = TlvTypes::INVALID_TLV; deserSize = 4; REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); serPtr = rawBuf.data(); deserSize = 0; REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); deserPtr = rawBuf.data(); result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(zeroLenField.getSerializedSize() == 2); REQUIRE(deserSize == 0); } @@ -140,7 +137,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = lvRawBuf.data(); result = sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 2); auto lv = cfdp::Lv(lvRawBuf.data(), 2); auto lvCopy = cfdp::Lv(lv); @@ -150,7 +147,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); deserSize = 0; result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 3); REQUIRE(rawBuf[0] == 2); uint16_t sourceId = 0; @@ -164,7 +161,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { deserSize = 0; result = lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 1); } @@ -177,13 +174,13 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); deserSize = 0; result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); Lv uninitLv; deserPtr = rawBuf.data(); deserSize = 3; result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(uninitLv.getSerializedSize() == 3); const uint8_t* storedValue = uninitLv.getValue(nullptr); uint16_t sourceId = 0; @@ -197,15 +194,15 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { deserSize = 0; result = lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 1); deserPtr = rawBuf.data(); result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(uninitLv.getSerializedSize() == 1); REQUIRE(uninitLv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); serPtr = rawBuf.data(); deserSize = 0; REQUIRE(uninitLv.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::BIG) == @@ -233,14 +230,14 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { std::array serBuf = {}; result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); cfdp::Lv emptyMsg; cfdp::Lv emptySecondName; FilestoreResponseTlv emptyTlv(firstName, &emptyMsg); emptyTlv.setSecondFileName(&emptySecondName); result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyTlv.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); REQUIRE(emptyTlv.getStatusCode() == cfdp::FSR_SUCCESS); size_t firstNameLen = 0; @@ -274,26 +271,26 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { REQUIRE(expectedSz == 10 + 11 + 1); REQUIRE(request.getSerializedSize() == expectedSz + 2); result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(sz == expectedSz + 2); FilestoreRequestTlv emptyRequest(firstName); emptyRequest.setSecondFileName(&secondName); const uint8_t* constptr = serBuf.data(); result = emptyRequest.deSerialize(&constptr, &sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); cfdp::Tlv rawRequest; ptr = serBuf.data(); sz = 0; result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE); result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); } @@ -310,11 +307,11 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); REQUIRE(faultOverrideTlv.getSerializedSize() == 3); REQUIRE(sz == 3); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); FaultHandlerOverrideTlv emptyOverrideTlv; result = emptyOverrideTlv.deSerialize(&deserPtr, &sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); EntityId entId(cfdp::WidthInBytes::TWO_BYTES, 0x42); EntityId emptyId; @@ -322,9 +319,9 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); deserPtr = rawBuf.data(); result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); } } diff --git a/unittests/container/RingBufferTest.cpp b/unittests/container/RingBufferTest.cpp index edabfd55..efc571b4 100644 --- a/unittests/container/RingBufferTest.cpp +++ b/unittests/container/RingBufferTest.cpp @@ -12,42 +12,42 @@ TEST_CASE("Ring Buffer Test", "[RingBufferTest]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.writeData(testData, 3) == result::FAILED); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == returnvalue::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 4) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == returnvalue::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == returnvalue::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 1024) == result::FAILED); - REQUIRE(ringBuffer.writeData(nullptr, 5) == result::FAILED); + REQUIRE(ringBuffer.writeData(testData, 1024) == returnvalue::FAILED); + REQUIRE(ringBuffer.writeData(nullptr, 5) == returnvalue::FAILED); } SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 8) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == returnvalue::FAILED); REQUIRE(ringBuffer.writeTillWrap() == 2); // too many excess bytes. - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == returnvalue::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == returnvalue::OK); REQUIRE(ringBuffer.getExcessBytes() == 3); std::memcpy(testPtr, testData, 5); ringBuffer.confirmBytesWritten(5); @@ -59,19 +59,19 @@ TEST_CASE("Ring Buffer Test", "[RingBufferTest]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == returnvalue::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == returnvalue::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); } } @@ -84,21 +84,21 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == returnvalue::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 4) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == returnvalue::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == returnvalue::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } @@ -106,17 +106,17 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 8) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == returnvalue::FAILED); REQUIRE(ringBuffer.writeTillWrap() == 2); // too many excess bytes. - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == returnvalue::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == returnvalue::OK); REQUIRE(ringBuffer.getExcessBytes() == 3); std::memcpy(testPtr, testData, 5); ringBuffer.confirmBytesWritten(5); @@ -128,19 +128,19 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == returnvalue::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == returnvalue::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); } @@ -148,17 +148,17 @@ TEST_CASE("Ring Buffer Test2", "[RingBufferTest2]") { REQUIRE(ringBuffer.availableWriteSpace() == 9); // We don't allow writing of Data that is larger than the ring buffer in total REQUIRE(ringBuffer.getMaxSize() == 9); - REQUIRE(ringBuffer.writeData(testData, 13) == result::FAILED); + REQUIRE(ringBuffer.writeData(testData, 13) == returnvalue::FAILED); REQUIRE(ringBuffer.getAvailableReadData() == 0); ringBuffer.clear(); uint8_t *ptr = nullptr; // With excess Bytes 13 Bytes can be written to this Buffer - REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == returnvalue::OK); REQUIRE(ptr != nullptr); memcpy(ptr, testData, 13); ringBuffer.confirmBytesWritten(13); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 3, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 3, true) == returnvalue::OK); for (auto i = 0; i < 3; i++) { REQUIRE(readBuffer[i] == testData[i + 10]); } @@ -173,21 +173,21 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == returnvalue::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 4) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == returnvalue::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == returnvalue::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } @@ -195,19 +195,19 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 8) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == returnvalue::OK); REQUIRE(ringBuffer.getExcessBytes() == 8); REQUIRE(ringBuffer.writeTillWrap() == 2); // too many excess bytes. - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == returnvalue::FAILED); // Less Execss bytes overwrites before - REQUIRE(ringBuffer.getFreeElement(&testPtr, 3) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 3) == returnvalue::OK); REQUIRE(ringBuffer.getExcessBytes() == 1); std::memcpy(testPtr, testData, 3); ringBuffer.confirmBytesWritten(3); @@ -219,19 +219,19 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == returnvalue::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == returnvalue::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); } @@ -239,18 +239,18 @@ TEST_CASE("Ring Buffer Test3", "[RingBufferTest3]") { REQUIRE(ringBuffer.availableWriteSpace() == 9); // Writing more than the buffer is large. // This write will be rejected and is seen as a configuration mistake - REQUIRE(ringBuffer.writeData(testData, 13) == result::FAILED); + REQUIRE(ringBuffer.writeData(testData, 13) == returnvalue::FAILED); REQUIRE(ringBuffer.getAvailableReadData() == 0); ringBuffer.clear(); // Using FreeElement allows the usage of excessBytes but // should be used with caution uint8_t *ptr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&ptr, 13) == returnvalue::OK); REQUIRE(ptr != nullptr); memcpy(ptr, testData, 13); ringBuffer.confirmBytesWritten(13); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 3, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 3, true) == returnvalue::OK); for (auto i = 0; i < 3; i++) { REQUIRE(readBuffer[i] == testData[i + 10]); } @@ -264,22 +264,22 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") { SECTION("Simple Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.writeData(testData, 3) == result::FAILED); - REQUIRE(ringBuffer.readData(readBuffer, 5, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, true) == returnvalue::OK); for (uint8_t i = 0; i < 5; i++) { CHECK(readBuffer[i] == i); } REQUIRE(ringBuffer.availableWriteSpace() == 5); ringBuffer.clear(); REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 4) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 4, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 4) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 4, true) == returnvalue::OK); for (uint8_t i = 0; i < 4; i++) { CHECK(readBuffer[i] == i); } - REQUIRE(ringBuffer.writeData(testData, 9) == result::OK); - REQUIRE(ringBuffer.readData(readBuffer, 9, true) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 9) == returnvalue::OK); + REQUIRE(ringBuffer.readData(readBuffer, 9, true) == returnvalue::OK); for (uint8_t i = 0; i < 9; i++) { CHECK(readBuffer[i] == i); } @@ -287,16 +287,16 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") { SECTION("Get Free Element Test") { REQUIRE(ringBuffer.availableWriteSpace() == 9); - REQUIRE(ringBuffer.writeData(testData, 8) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 8) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 1); - REQUIRE(ringBuffer.readData(readBuffer, 8, true) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 8, true) == returnvalue::OK); REQUIRE(ringBuffer.availableWriteSpace() == 9); uint8_t *testPtr = nullptr; - REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == result::FAILED); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 10) == returnvalue::FAILED); REQUIRE(ringBuffer.writeTillWrap() == 2); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == result::OK); - REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == result::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 8) == returnvalue::OK); + REQUIRE(ringBuffer.getFreeElement(&testPtr, 5) == returnvalue::OK); REQUIRE(ringBuffer.getExcessBytes() == 3); std::memcpy(testPtr, testData, 5); ringBuffer.confirmBytesWritten(5); @@ -308,19 +308,19 @@ TEST_CASE("Ring Buffer Test4", "[RingBufferTest4]") { } SECTION("Read Remaining Test") { - REQUIRE(ringBuffer.writeData(testData, 3) == result::OK); + REQUIRE(ringBuffer.writeData(testData, 3) == returnvalue::OK); REQUIRE(ringBuffer.getAvailableReadData() == 3); - REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == result::FAILED); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, false, nullptr) == returnvalue::FAILED); size_t trueSize = 0; - REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.readData(readBuffer, 5, false, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); for (uint8_t i = 0; i < 3; i++) { CHECK(readBuffer[i] == i); } trueSize = 0; - REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == result::FAILED); + REQUIRE(ringBuffer.deleteData(5, false, &trueSize) == returnvalue::FAILED); REQUIRE(trueSize == 0); - REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == result::OK); + REQUIRE(ringBuffer.deleteData(5, true, &trueSize) == returnvalue::OK); REQUIRE(trueSize == 3); } } diff --git a/unittests/container/TestArrayList.cpp b/unittests/container/TestArrayList.cpp index 4daf59d4..851c03cf 100644 --- a/unittests/container/TestArrayList.cpp +++ b/unittests/container/TestArrayList.cpp @@ -25,7 +25,7 @@ TEST_CASE("Array List", "[ArrayListTest]") { SECTION("SimpleTest") { REQUIRE(list.maxSize() == 20); REQUIRE(list.size == 0); - REQUIRE(list.insert(10) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(list.insert(10) == static_cast(returnvalue::OK)); REQUIRE(list[0] == 10); REQUIRE(list.front() != nullptr); REQUIRE((*list.front()) == 10); @@ -41,7 +41,7 @@ TEST_CASE("Array List", "[ArrayListTest]") { // This is an invalid element but its not a nullptr REQUIRE(list.back() != nullptr); for (auto i = 0; i < 20; i++) { - REQUIRE(list.insert(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(list.insert(i) == static_cast(returnvalue::OK)); } REQUIRE(list.insert(20) == static_cast(ArrayList::FULL)); ArrayList::Iterator it = list.begin(); @@ -64,7 +64,7 @@ TEST_CASE("Array List", "[ArrayListTest]") { SECTION("Const Iterator") { ArrayList::Iterator it = list.begin(); for (auto i = 0; i < 10; i++) { - REQUIRE(list.insert(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(list.insert(i) == static_cast(returnvalue::OK)); } it++; const uint16_t* number = it.value; @@ -74,8 +74,7 @@ TEST_CASE("Array List", "[ArrayListTest]") { SECTION("Const Iterator") { ArrayList::Iterator it = complexList.begin(); for (auto i = 0; i < 10; i++) { - REQUIRE(complexList.insert(TestClass(i, i + 1)) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(complexList.insert(TestClass(i, i + 1)) == static_cast(returnvalue::OK)); } it++; const TestClass* secondTest = it.value; diff --git a/unittests/container/TestDynamicFifo.cpp b/unittests/container/TestDynamicFifo.cpp index 6769c247..1475b0dc 100644 --- a/unittests/container/TestDynamicFifo.cpp +++ b/unittests/container/TestDynamicFifo.cpp @@ -35,13 +35,13 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { REQUIRE(fifo.empty()); REQUIRE(not fifo.full()); - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.insert(structTwo) == static_cast(FIFOBase::FULL)); struct Test testptr; - REQUIRE(fifo.peek(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.peek(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == structOne; REQUIRE(equal); REQUIRE(fifo.size() == 3); @@ -52,7 +52,7 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { testptr.number1 = 0; testptr.number2 = 0; testptr.number3 = 0; - REQUIRE(fifo.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.retrieve(&testptr) == static_cast(returnvalue::OK)); equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo.size() == i); @@ -66,29 +66,29 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { REQUIRE(fifo.empty()); REQUIRE(fifo.pop() == static_cast(FIFOBase::EMPTY)); - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 1); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 2); - REQUIRE(fifo.pop() == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.pop() == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 1); testptr.number1 = 0; testptr.number2 = 0; testptr.number3 = 0; - REQUIRE(fifo.peek(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.peek(&testptr) == static_cast(returnvalue::OK)); equal = testptr == structTwo; REQUIRE(equal); - REQUIRE(fifo.pop() == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.pop() == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 0); REQUIRE(fifo.empty()); // struct Test* ptr = nullptr; - // REQUIRE(fifo.retrieve(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); - // REQUIRE(fifo.peek(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); + // REQUIRE(fifo.retrieve(ptr) == static_cast(HasReturnvaluesIF::returnvalue::FAILED)); + // REQUIRE(fifo.peek(ptr) == static_cast(HasReturnvaluesIF::returnvalue::FAILED)); }; SECTION("Copy Test") { - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 3); REQUIRE(fifo.full()); REQUIRE(not fifo.empty()); @@ -100,9 +100,9 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { }; SECTION("Assignment Test") { - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 3); REQUIRE(fifo.full()); REQUIRE(not fifo.empty()); @@ -114,7 +114,7 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { REQUIRE(not fifo2.empty()); for (size_t i = 2; i < 3; i--) { struct Test testptr = {0, 0, 0}; - REQUIRE(fifo2.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo2.retrieve(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo2.size() == i); @@ -122,9 +122,9 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { }; SECTION("Assignment Test Smaller") { - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 3); REQUIRE(fifo.full()); REQUIRE(not fifo.empty()); @@ -136,7 +136,7 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { REQUIRE(not fifo2.empty()); for (size_t i = 2; i < 3; i--) { struct Test testptr = {0, 0, 0}; - REQUIRE(fifo2.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo2.retrieve(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo2.size() == i); diff --git a/unittests/container/TestFifo.cpp b/unittests/container/TestFifo.cpp index 0b4b41af..1a3c9d8a 100644 --- a/unittests/container/TestFifo.cpp +++ b/unittests/container/TestFifo.cpp @@ -35,13 +35,13 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { REQUIRE(fifo.empty()); REQUIRE(not fifo.full()); - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.insert(structTwo) == static_cast(FIFOBase::FULL)); struct Test testptr; - REQUIRE(fifo.peek(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.peek(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == structOne; REQUIRE(equal); REQUIRE(fifo.size() == 3); @@ -52,7 +52,7 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { testptr.number1 = 0; testptr.number2 = 0; testptr.number3 = 0; - REQUIRE(fifo.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.retrieve(&testptr) == static_cast(returnvalue::OK)); equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo.size() == i); @@ -66,11 +66,11 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { REQUIRE(fifo.empty()); REQUIRE(fifo.pop() == static_cast(FIFOBase::EMPTY)); - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 1); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 2); - REQUIRE(fifo.pop() == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.pop() == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 1); testptr.number1 = 0; testptr.number2 = 0; @@ -78,20 +78,20 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { // Test that retrieve and peek will not cause a nullptr dereference struct Test* ptr = nullptr; - REQUIRE(fifo.retrieve(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); - REQUIRE(fifo.peek(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); + REQUIRE(fifo.retrieve(ptr) == static_cast(returnvalue::FAILED)); + REQUIRE(fifo.peek(ptr) == static_cast(returnvalue::FAILED)); - REQUIRE(fifo.peek(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.peek(&testptr) == static_cast(returnvalue::OK)); equal = testptr == structTwo; REQUIRE(equal); - REQUIRE(fifo.pop() == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.pop() == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 0); REQUIRE(fifo.empty()); }; SECTION("Copy Test") { - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 3); REQUIRE(fifo.full()); REQUIRE(not fifo.empty()); @@ -102,7 +102,7 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { REQUIRE(not fifo2.empty()); for (size_t i = 2; i < 3; i--) { struct Test testptr = {0, 0, 0}; - REQUIRE(fifo2.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo2.retrieve(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo2.size() == i); @@ -110,9 +110,9 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { }; SECTION("Assignment Test") { - REQUIRE(fifo.insert(structOne) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structTwo) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(fifo.insert(structThree) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structTwo) == static_cast(returnvalue::OK)); + REQUIRE(fifo.insert(structThree) == static_cast(returnvalue::OK)); REQUIRE(fifo.size() == 3); REQUIRE(fifo.full()); REQUIRE(not fifo.empty()); @@ -124,7 +124,7 @@ TEST_CASE("Static Fifo Tests", "[TestFifo]") { REQUIRE(not fifo2.empty()); for (size_t i = 2; i < 3; i--) { struct Test testptr = {0, 0, 0}; - REQUIRE(fifo2.retrieve(&testptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(fifo2.retrieve(&testptr) == static_cast(returnvalue::OK)); bool equal = testptr == list[i]; REQUIRE(equal); REQUIRE(fifo2.size() == i); diff --git a/unittests/container/TestFixedArrayList.cpp b/unittests/container/TestFixedArrayList.cpp index 6beb8d5d..b28c3166 100644 --- a/unittests/container/TestFixedArrayList.cpp +++ b/unittests/container/TestFixedArrayList.cpp @@ -10,7 +10,7 @@ TEST_CASE("FixedArrayList Tests", "[TestFixedArrayList]") { using testList = FixedArrayList; testList list; REQUIRE(list.size == 0); - REQUIRE(list.insert(10) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(list.insert(10) == static_cast(returnvalue::OK)); REQUIRE(list.size == 1); REQUIRE(list.maxSize() == 260); SECTION("Copy Constructor") { @@ -29,7 +29,7 @@ TEST_CASE("FixedArrayList Tests", "[TestFixedArrayList]") { }; SECTION("Fill") { for (auto i = 1; i < 260; i++) { - REQUIRE(list.insert(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(list.insert(i) == static_cast(returnvalue::OK)); } REQUIRE(list.insert(260) == static_cast(ArrayList::FULL)); list.clear(); diff --git a/unittests/container/TestFixedMap.cpp b/unittests/container/TestFixedMap.cpp index d3c65760..b74b8751 100644 --- a/unittests/container/TestFixedMap.cpp +++ b/unittests/container/TestFixedMap.cpp @@ -19,9 +19,8 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { SECTION("Fill and erase") { for (uint16_t i = 0; i < 30; i++) { - REQUIRE(map.insert(std::make_pair(i, i + 1)) == - static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(map.exists(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(std::make_pair(i, i + 1)) == static_cast(returnvalue::OK)); + REQUIRE(map.exists(i) == static_cast(returnvalue::OK)); REQUIRE(map.find(i)->second == i + 1); REQUIRE(not map.empty()); } @@ -32,7 +31,7 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { REQUIRE(map.full()); { uint16_t* ptr; - REQUIRE(map.find(5, &ptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.find(5, &ptr) == static_cast(returnvalue::OK)); REQUIRE(*ptr == 6); REQUIRE(*(map.findValue(6)) == 7); REQUIRE(map.find(31, &ptr) == @@ -41,7 +40,7 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { REQUIRE(map.getSerializedSize() == (sizeof(uint32_t) + 30 * (sizeof(uint32_t) + sizeof(uint16_t)))); - REQUIRE(map.erase(2) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(2) == static_cast(returnvalue::OK)); REQUIRE(map.erase(31) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); REQUIRE(map.exists(2) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); REQUIRE(map.size() == 29); @@ -60,7 +59,7 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { } for (FixedMap::Iterator it = map.begin(); it != map.end(); it++) { - REQUIRE(map.erase(&it) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(&it) == static_cast(returnvalue::OK)); } REQUIRE(map.size() == 0); @@ -73,11 +72,11 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { SECTION("Insert variants") { FixedMap::Iterator it = map.end(); - REQUIRE(map.insert(36, 37, &it) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(36, 37, &it) == static_cast(returnvalue::OK)); REQUIRE(it->first == 36); REQUIRE(it->second == 37); REQUIRE(map.size() == 1); - REQUIRE(map.insert(37, 38, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(37, 38, nullptr) == static_cast(returnvalue::OK)); REQUIRE(map.find(37)->second == 38); REQUIRE(map.size() == 2); REQUIRE(map.insert(37, 24, nullptr) == @@ -86,8 +85,8 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { REQUIRE(map.size() == 2); }; SECTION("Serialize and DeSerialize") { - REQUIRE(map.insert(36, 37, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(map.insert(37, 38, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(36, 37, nullptr) == static_cast(returnvalue::OK)); + REQUIRE(map.insert(37, 38, nullptr) == static_cast(returnvalue::OK)); uint8_t buffer[sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t))]; REQUIRE(map.getSerializedSize() == (sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t)))); @@ -97,27 +96,27 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { static_cast(SerializeIF::BUFFER_TOO_SHORT)); loc_ptr = buffer; size = 0; - REQUIRE(map.serialize( - &loc_ptr, &size, sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t)), - SerializeIF::Endianness::BIG) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.serialize(&loc_ptr, &size, + sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t)), + SerializeIF::Endianness::BIG) == static_cast(returnvalue::OK)); REQUIRE(size == 16); uint32_t internal_size = 0; const uint8_t* ptr2 = buffer; REQUIRE( SerializeAdapter::deSerialize(&internal_size, &ptr2, &size, SerializeIF::Endianness::BIG) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(internal_size == 2); for (uint8_t i = 36; i < 38; i++) { uint32_t first_element = 0; REQUIRE(SerializeAdapter::deSerialize(&first_element, &ptr2, &size, SerializeIF::Endianness::BIG) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(first_element == i); uint16_t second_element = 0; REQUIRE(SerializeAdapter::deSerialize(&second_element, &ptr2, &size, SerializeIF::Endianness::BIG) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(second_element == i + 1); } REQUIRE(size == 0); @@ -126,7 +125,7 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { size = 16; REQUIRE(map.size() == 0); REQUIRE(map.deSerialize(&constPtr, &size, SerializeIF::Endianness::BIG) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(map.size() == 2); REQUIRE(map.find(36)->second == 37); for (auto& element : map) { @@ -154,12 +153,12 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { size_t size = 0; size_t max_size = sizeof(uint32_t) + 1 * (sizeof(uint32_t) + sizeof(uint16_t)); REQUIRE(map.serialize(&ptr, &size, max_size, SerializeIF::Endianness::LITTLE) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); map.clear(); REQUIRE(map.size() == 0); const uint8_t* ptr2 = newBuffer; REQUIRE(map.deSerialize(&ptr2, &size, SerializeIF::Endianness::LITTLE) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); REQUIRE(map.size() == 1); REQUIRE(map.find(10)->second == 20); }; diff --git a/unittests/container/TestFixedOrderedMultimap.cpp b/unittests/container/TestFixedOrderedMultimap.cpp index 88b32694..d70180b1 100644 --- a/unittests/container/TestFixedOrderedMultimap.cpp +++ b/unittests/container/TestFixedOrderedMultimap.cpp @@ -14,9 +14,8 @@ TEST_CASE("FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { SECTION("Test insert, find, exists") { for (uint16_t i = 0; i < 30; i++) { - REQUIRE(map.insert(std::make_pair(i, i + 1)) == - static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(map.exists(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(std::make_pair(i, i + 1)) == static_cast(returnvalue::OK)); + REQUIRE(map.exists(i) == static_cast(returnvalue::OK)); REQUIRE(map.find(i)->second == i + 1); } REQUIRE(map.insert(0, 0) == @@ -26,12 +25,12 @@ TEST_CASE("FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { REQUIRE(map.size() == 30); { uint16_t* ptr; - REQUIRE(map.find(5, &ptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.find(5, &ptr) == static_cast(returnvalue::OK)); REQUIRE(*ptr == 6); REQUIRE(map.find(31, &ptr) == static_cast(FixedOrderedMultimap::KEY_DOES_NOT_EXIST)); } - REQUIRE(map.erase(2) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(2) == static_cast(returnvalue::OK)); REQUIRE(map.erase(31) == static_cast(FixedOrderedMultimap::KEY_DOES_NOT_EXIST)); REQUIRE(map.exists(2) == @@ -55,7 +54,7 @@ TEST_CASE("FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { { FixedOrderedMultimap::Iterator it = map.begin(); while (it != map.end()) { - REQUIRE(map.erase(&it) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(&it) == static_cast(returnvalue::OK)); } REQUIRE(map.size() == 0); } @@ -69,16 +68,16 @@ TEST_CASE("FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { SECTION("Test different insert variants") { FixedOrderedMultimap::Iterator it = map.end(); - REQUIRE(map.insert(36, 37, &it) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(36, 37, &it) == static_cast(returnvalue::OK)); REQUIRE(it->first == 36); REQUIRE(it->second == 37); REQUIRE(map.size() == 1); - REQUIRE(map.insert(37, 38, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(37, 38, nullptr) == static_cast(returnvalue::OK)); REQUIRE(map.find(37)->second == 38); REQUIRE(map.size() == 2); - REQUIRE(map.insert(37, 24, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(37, 24, nullptr) == static_cast(returnvalue::OK)); REQUIRE(map.find(37)->second == 38); - REQUIRE(map.insert(0, 1, nullptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(0, 1, nullptr) == static_cast(returnvalue::OK)); REQUIRE(map.find(0)->second == 1); REQUIRE(map.size() == 4); map.clear(); @@ -128,8 +127,8 @@ TEST_CASE("FixedOrderedMultimap Non Trivial Type", "[TestFixedOrderedMultimapNon SECTION("Test insert, find, exists") { for (uint16_t i = 0; i < 30; i++) { REQUIRE(map.insert(std::make_pair(i, TestClass(i + 1, i))) == - static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(map.exists(i) == static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); + REQUIRE(map.exists(i) == static_cast(returnvalue::OK)); bool compare = map.find(i)->second == TestClass(i + 1, i); REQUIRE(compare); } @@ -140,13 +139,13 @@ TEST_CASE("FixedOrderedMultimap Non Trivial Type", "[TestFixedOrderedMultimapNon REQUIRE(map.size() == 30); { TestClass* ptr = nullptr; - REQUIRE(map.find(5, &ptr) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.find(5, &ptr) == static_cast(returnvalue::OK)); bool compare = *ptr == TestClass(6, 5); REQUIRE(compare); REQUIRE(map.find(31, &ptr) == static_cast(FixedOrderedMultimap::KEY_DOES_NOT_EXIST)); } - REQUIRE(map.erase(2) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(2) == static_cast(returnvalue::OK)); REQUIRE(map.erase(31) == static_cast(FixedOrderedMultimap::KEY_DOES_NOT_EXIST)); REQUIRE(map.exists(2) == @@ -174,7 +173,7 @@ TEST_CASE("FixedOrderedMultimap Non Trivial Type", "[TestFixedOrderedMultimapNon { FixedOrderedMultimap::Iterator it = map.begin(); while (it != map.end()) { - REQUIRE(map.erase(&it) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.erase(&it) == static_cast(returnvalue::OK)); } REQUIRE(map.size() == 0); } @@ -188,23 +187,19 @@ TEST_CASE("FixedOrderedMultimap Non Trivial Type", "[TestFixedOrderedMultimapNon SECTION("Test different insert variants") { FixedOrderedMultimap::Iterator it = map.end(); - REQUIRE(map.insert(36, TestClass(37, 36), &it) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(36, TestClass(37, 36), &it) == static_cast(returnvalue::OK)); REQUIRE(it->first == 36); bool compare = it->second == TestClass(37, 36); REQUIRE(compare); REQUIRE(map.size() == 1); - REQUIRE(map.insert(37, TestClass(38, 37), nullptr) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(37, TestClass(38, 37), nullptr) == static_cast(returnvalue::OK)); compare = map.find(37)->second == TestClass(38, 37); REQUIRE(compare); REQUIRE(map.size() == 2); - REQUIRE(map.insert(37, TestClass(24, 37), nullptr) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(37, TestClass(24, 37), nullptr) == static_cast(returnvalue::OK)); compare = map.find(37)->second == TestClass(38, 37); REQUIRE(compare); - REQUIRE(map.insert(0, TestClass(1, 0), nullptr) == - static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(map.insert(0, TestClass(1, 0), nullptr) == static_cast(returnvalue::OK)); compare = map.find(0)->second == TestClass(1, 0); REQUIRE(compare); REQUIRE(map.size() == 4); diff --git a/unittests/container/TestPlacementFactory.cpp b/unittests/container/TestPlacementFactory.cpp index 1333567e..142f03d7 100644 --- a/unittests/container/TestPlacementFactory.cpp +++ b/unittests/container/TestPlacementFactory.cpp @@ -36,13 +36,13 @@ TEST_CASE("PlacementFactory Tests", "[TestPlacementFactory]") { static_cast(StorageManagerIF::DATA_TOO_LARGE)); uint64_t* number2 = factory.generate(12345); REQUIRE(number2 == nullptr); - REQUIRE(factory.destroy(number) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(factory.destroy(number) == static_cast(returnvalue::OK)); REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr) == - static_cast(HasReturnvaluesIF::RETURN_OK)); - REQUIRE(storagePool.deleteData(address) == static_cast(HasReturnvaluesIF::RETURN_OK)); + static_cast(returnvalue::OK)); + REQUIRE(storagePool.deleteData(address) == static_cast(returnvalue::OK)); // Check that PlacementFactory checks for nullptr ptr = nullptr; - REQUIRE(factory.destroy(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); + REQUIRE(factory.destroy(ptr) == static_cast(returnvalue::FAILED)); } } diff --git a/unittests/datapoollocal/testDataSet.cpp b/unittests/datapoollocal/testDataSet.cpp index 67e17d97..def92ac3 100644 --- a/unittests/datapoollocal/testDataSet.cpp +++ b/unittests/datapoollocal/testDataSet.cpp @@ -13,11 +13,13 @@ #include "mocks/MessageQueueMock.h" #include "tests/TestsConfig.h" +using namespace returnvalue; + TEST_CASE("DataSetTest", "[DataSetTest]") { auto queue = MessageQueueMock(1); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner.initializeHkManager() == result::OK); - REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == result::OK); + REQUIRE(poolOwner.initializeHkManager() == OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == OK); LocalPoolStaticTestDataSet localSet; SECTION("BasicTest") { @@ -36,7 +38,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Test local pool ID serialization */ CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize, - SerializeIF::Endianness::MACHINE) == result::OK); + SerializeIF::Endianness::MACHINE) == returnvalue::OK); CHECK(serSize == maxSize); CHECK(localPoolIdBuff[0] == 3); CHECK(lpIds[0] == localSet.localPoolVarUint8.getDataPoolId()); @@ -47,7 +49,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { localPoolIdBuffPtr = localPoolIdBuff; serSize = 0; CHECK(localSet.serializeLocalPoolIds(&localPoolIdBuffPtr, &serSize, maxSize, - SerializeIF::Endianness::MACHINE, false) == result::OK); + SerializeIF::Endianness::MACHINE, false) == OK); CHECK(serSize == maxSize - sizeof(uint8_t)); CHECK(lpIds[0] == localSet.localPoolVarUint8.getDataPoolId()); CHECK(lpIds[1] == localSet.localPoolVarFloat.getDataPoolId()); @@ -56,7 +58,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { { /* Test read operation. Values should be all zeros */ PoolReadGuard readHelper(&localSet); - REQUIRE(readHelper.getReadResult() == result::OK); + REQUIRE(readHelper.getReadResult() == returnvalue::OK); CHECK(not localSet.isValid()); CHECK(localSet.localPoolVarUint8.value == 0); CHECK(not localSet.localPoolVarUint8.isValid()); @@ -89,7 +91,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Now we read again and check whether our zeroed values were overwritten with the values in the pool */ PoolReadGuard readHelper(&localSet); - REQUIRE(readHelper.getReadResult() == result::OK); + REQUIRE(readHelper.getReadResult() == returnvalue::OK); CHECK(localSet.isValid()); CHECK(localSet.localPoolVarUint8.value == 232); CHECK(localSet.localPoolVarUint8.isValid()); @@ -109,7 +111,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { uint8_t buffer[maxSize + 1]; uint8_t* buffPtr = buffer; CHECK(localSet.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); uint8_t rawUint8 = buffer[0]; CHECK(rawUint8 == 232); float rawFloat = 0.0; @@ -127,7 +129,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { std::memset(buffer, 0, sizeof(buffer)); const uint8_t* constBuffPtr = buffer; CHECK(localSet.deSerialize(&constBuffPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == result::OK); + SerializeIF::Endianness::MACHINE) == returnvalue::OK); /* Check whether deserialization was successfull */ CHECK(localSet.localPoolVarUint8.value == 0); CHECK(localSet.localPoolVarFloat.value == Catch::Approx(0.0)); @@ -155,7 +157,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { serSize = 0; buffPtr = buffer; CHECK(localSet.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(rawUint8 == 232); std::memcpy(&rawFloat, buffer + sizeof(uint8_t), sizeof(float)); CHECK(rawFloat == Catch::Approx(-2324.322)); @@ -185,7 +187,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { sizeToDeserialize = maxSize; constBuffPtr = buffer; CHECK(localSet.deSerialize(&constBuffPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == result::OK); + SerializeIF::Endianness::MACHINE) == returnvalue::OK); /* Check whether deserialization was successfull */ CHECK(localSet.localPoolVarUint8.value == 0); CHECK(localSet.localPoolVarFloat.value == Catch::Approx(0.0)); @@ -212,10 +214,10 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Register same variables again to get more than 8 registered variables */ for (uint8_t idx = 0; idx < 8; idx++) { - REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == result::OK); + REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == returnvalue::OK); } - REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == result::OK); - REQUIRE(set.registerVariable(&localSet.localPoolUint16Vec) == result::OK); + REQUIRE(set.registerVariable(&localSet.localPoolVarUint8) == returnvalue::OK); + REQUIRE(set.registerVariable(&localSet.localPoolUint16Vec) == returnvalue::OK); set.setValidityBufferGeneration(true); { @@ -231,8 +233,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { /* Already reserve additional space for validity buffer, will be needed later */ uint8_t buffer[maxSize + 1]; uint8_t* buffPtr = buffer; - CHECK(set.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - result::OK); + CHECK(set.serialize(&buffPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == OK); std::array validityBuffer{}; std::memcpy(validityBuffer.data(), buffer + 9 + sizeof(uint16_t) * 3, 2); /* The first 9 variables should be valid */ @@ -250,7 +251,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { const uint8_t* constBuffPtr = buffer; size_t sizeToDeSerialize = serSize; CHECK(set.deSerialize(&constBuffPtr, &sizeToDeSerialize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(localSet.localPoolVarUint8.isValid() == false); CHECK(localSet.localPoolUint16Vec.isValid() == true); } @@ -260,11 +261,11 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { SharedLocalDataSet sharedSet(sharedSetId, &poolOwner, lpool::testSetId, 5); localSet.localPoolVarUint8.setReadWriteMode(pool_rwm_t::VAR_WRITE); localSet.localPoolUint16Vec.setReadWriteMode(pool_rwm_t::VAR_WRITE); - CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == result::OK); - CHECK(sharedSet.registerVariable(&localSet.localPoolUint16Vec) == result::OK); - CHECK(sharedSet.initialize() == result::OK); - CHECK(sharedSet.lockDataset() == result::OK); - CHECK(sharedSet.unlockDataset() == result::OK); + CHECK(sharedSet.registerVariable(&localSet.localPoolVarUint8) == returnvalue::OK); + CHECK(sharedSet.registerVariable(&localSet.localPoolUint16Vec) == returnvalue::OK); + CHECK(sharedSet.initialize() == returnvalue::OK); + CHECK(sharedSet.lockDataset() == returnvalue::OK); + CHECK(sharedSet.unlockDataset() == returnvalue::OK); { // PoolReadGuard rg(&sharedSet); @@ -273,7 +274,7 @@ TEST_CASE("DataSetTest", "[DataSetTest]") { localSet.localPoolUint16Vec.value[0] = 1; localSet.localPoolUint16Vec.value[1] = 2; localSet.localPoolUint16Vec.value[2] = 3; - CHECK(sharedSet.commit() == result::OK); + CHECK(sharedSet.commit() == returnvalue::OK); } sharedSet.setReadCommitProtectionBehaviour(true); diff --git a/unittests/datapoollocal/testLocalPoolManager.cpp b/unittests/datapoollocal/testLocalPoolManager.cpp index dfb72ec1..91cd011d 100644 --- a/unittests/datapoollocal/testLocalPoolManager.cpp +++ b/unittests/datapoollocal/testLocalPoolManager.cpp @@ -22,8 +22,8 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { auto hkReceiver = HkReceiverMock(hkDest); auto queue = MessageQueueMock(3); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner.initializeHkManager() == result::OK); - REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == result::OK); + REQUIRE(poolOwner.initializeHkManager() == returnvalue::OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == returnvalue::OK); MessageQueueMock& poolOwnerMock = poolOwner.getMockQueueHandle(); @@ -46,14 +46,14 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { CHECK(owner->getObjectId() == objects::TEST_LOCAL_POOL_OWNER_BASE); /* Subscribe for message generation on update. */ - REQUIRE(poolOwner.subscribeWrapperSetUpdate(subscriberId) == result::OK); + REQUIRE(poolOwner.subscribeWrapperSetUpdate(subscriberId) == returnvalue::OK); /* Subscribe for an update message. */ poolOwner.dataset.setChanged(true); /* Now the update message should be generated. */ - REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK); REQUIRE(poolOwnerMock.wasMessageSent()); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); @@ -62,26 +62,26 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { poolOwnerMock.clearMessages(true); /* Set changed again, result should be the same. */ poolOwner.dataset.setChanged(true); - REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK); REQUIRE(poolOwnerMock.wasMessageSent() == true); CHECK(poolOwnerMock.numberOfSentMessages() == 1); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); poolOwnerMock.clearMessages(true); /* Now subscribe for set update HK as well. */ - REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == result::OK); + REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == returnvalue::OK); poolOwner.dataset.setChanged(true); - REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK); REQUIRE(poolOwnerMock.wasMessageSent() == true); CHECK(poolOwnerMock.numberOfSentMessages() == 2); // first message sent should be the update notification - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == result::OK); + REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); /* Clear message to avoid memory leak, our mock won't do it for us (yet) */ CommandMessageCleaner::clearCommandMessage(&messageSent); @@ -91,7 +91,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Set the variables in the set to certain values. These are checked later. */ { PoolReadGuard readHelper(&poolOwner.dataset); - REQUIRE(readHelper.getReadResult() == result::OK); + REQUIRE(readHelper.getReadResult() == returnvalue::OK); poolOwner.dataset.localPoolVarUint8.value = 5; poolOwner.dataset.localPoolVarFloat.value = -12.242; poolOwner.dataset.localPoolUint16Vec.value[0] = 2; @@ -100,7 +100,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { } /* Subscribe for snapshot generation on update. */ - REQUIRE(poolOwner.subscribeWrapperSetUpdateSnapshot(subscriberId) == result::OK); + REQUIRE(poolOwner.subscribeWrapperSetUpdateSnapshot(subscriberId) == returnvalue::OK); poolOwner.dataset.setChanged(true); /* Store current time, we are going to check the (approximate) time equality later */ @@ -108,10 +108,10 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { Clock::getClock_timeval(&now); /* Trigger generation of snapshot */ - REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK); REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 1); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK); /* Check that snapshot was generated */ CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_SET)); /* Now we deserialize the snapshot into a new dataset instance */ @@ -121,7 +121,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { store_address_t storeId; HousekeepingMessage::getUpdateSnapshotSetCommand(&messageSent, &storeId); ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); - REQUIRE(accessorPair.first == result::OK); + REQUIRE(accessorPair.first == returnvalue::OK); const uint8_t* readOnlyPtr = accessorPair.second.data(); size_t sizeToDeserialize = accessorPair.second.size(); CHECK(newSet.localPoolVarFloat.value == 0); @@ -131,7 +131,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { CHECK(newSet.localPoolUint16Vec.value[2] == 0); /* Fill the dataset and timestamp */ REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == result::OK); + SerializeIF::Endianness::MACHINE) == returnvalue::OK); /* Now we check that the snapshot is actually correct */ CHECK(newSet.localPoolVarFloat.value == Catch::Approx(-12.242)); CHECK(newSet.localPoolVarUint8 == 5); @@ -142,7 +142,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Now we check that both times are equal */ timeval timeFromHK{}; auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); timeval difference = timeFromHK - now; CHECK(timevalOperations::toDouble(difference) < 1.0); } @@ -154,14 +154,14 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Subscribe for variable snapshot */ REQUIRE(poolOwner.subscribeWrapperVariableSnapshot(subscriberId, lpool::uint8VarId) == - result::OK); + returnvalue::OK); auto poolVar = dynamic_cast*>(poolOwner.getPoolObjectHandle(lpool::uint8VarId)); REQUIRE(poolVar != nullptr); { PoolReadGuard rg(poolVar); - CHECK(rg.getReadResult() == result::OK); + CHECK(rg.getReadResult() == returnvalue::OK); poolVar->value = 25; } @@ -170,7 +170,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { CCSDSTime::CDS_short timeCdsNow{}; timeval now{}; Clock::getClock_timeval(&now); - REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK); /* Check update snapshot was sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); @@ -178,7 +178,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Should have been reset. */ CHECK(poolVar->hasChanged() == false); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE)); /* Now we deserialize the snapshot into a new dataset instance */ @@ -188,19 +188,19 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { store_address_t storeId; HousekeepingMessage::getUpdateSnapshotVariableCommand(&messageSent, &storeId); ConstAccessorPair accessorPair = tglob::getIpcStoreHandle()->getData(storeId); - REQUIRE(accessorPair.first == result::OK); + REQUIRE(accessorPair.first == returnvalue::OK); const uint8_t* readOnlyPtr = accessorPair.second.data(); size_t sizeToDeserialize = accessorPair.second.size(); CHECK(varCopy.value == 0); /* Fill the dataset and timestamp */ REQUIRE(snapshot.deSerialize(&readOnlyPtr, &sizeToDeserialize, - SerializeIF::Endianness::MACHINE) == result::OK); + SerializeIF::Endianness::MACHINE) == returnvalue::OK); CHECK(varCopy.value == 25); /* Now we check that both times are equal */ timeval timeFromHK{}; auto result = CCSDSTime::convertFromCDS(&timeFromHK, &cdsShort); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); timeval difference = timeFromHK - now; CHECK(timevalOperations::toDouble(difference) < 1.0); } @@ -212,30 +212,30 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* Subscribe for variable update */ REQUIRE(poolOwner.subscribeWrapperVariableUpdate(subscriberId, lpool::uint8VarId) == - result::OK); + returnvalue::OK); auto* poolVar = dynamic_cast*>(poolOwner.getPoolObjectHandle(lpool::uint8VarId)); REQUIRE(poolVar != nullptr); poolVar->setChanged(true); REQUIRE(poolVar->hasChanged() == true); - REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK); /* Check update notification was sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 1); /* Should have been reset. */ CHECK(poolVar->hasChanged() == false); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); /* Now subscribe for the dataset update (HK and update) again with subscription interface */ REQUIRE(subscriptionIF->subscribeForSetUpdateMessage(lpool::testSetId, objects::NO_OBJECT, - subscriberId, false) == result::OK); - REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == result::OK); + subscriberId, false) == returnvalue::OK); + REQUIRE(poolOwner.subscribeWrapperSetUpdateHk(false, &hkReceiver) == returnvalue::OK); poolOwner.dataset.setChanged(true); poolOwnerMock.clearMessages(); - REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK); /* Now two messages should be sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 2); @@ -244,24 +244,23 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { poolOwner.dataset.setChanged(true); poolOwnerMock.clearMessages(true); poolVar->setChanged(true); - REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK); /* Now three messages should be sent. */ REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 3); CHECK(poolOwnerMock.numberOfSentMessagesToDest(subscriberId) == 2); CHECK(poolOwnerMock.numberOfSentMessagesToDest(hkDest) == 1); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == result::OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE)); - REQUIRE(poolOwnerMock.clearLastSentMessage(subscriberId) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE(poolOwnerMock.clearLastSentMessage(subscriberId) == returnvalue::OK); + REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::UPDATE_NOTIFICATION_SET)); - REQUIRE(poolOwnerMock.clearLastSentMessage(subscriberId) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == result::OK); + REQUIRE(poolOwnerMock.clearLastSentMessage(subscriberId) == returnvalue::OK); + REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == returnvalue::OK); CHECK(messageSent.getCommand() == static_cast(HousekeepingMessage::HK_REPORT)); - REQUIRE(poolOwnerMock.clearLastSentMessage() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(poolOwnerMock.clearLastSentMessage() == returnvalue::OK); REQUIRE(poolOwnerMock.getNextSentMessage(subscriberId, messageSent) == MessageQueueIF::EMPTY); REQUIRE(poolOwnerMock.getNextSentMessage(messageSent) == MessageQueueIF::EMPTY); } @@ -271,62 +270,62 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { the temporal behaviour correctly the HK manager should generate a HK packet immediately and the periodic helper depends on HK op function calls anyway instead of using the clock, so we could also just call performHkOperation multiple times */ - REQUIRE(poolOwner.subscribePeriodicHk(true) == result::OK); - REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); + REQUIRE(poolOwner.subscribePeriodicHk(true) == returnvalue::OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK); /* Now HK packet should be sent as message immediately. */ REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); + CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK); LocalPoolDataSetBase* setHandle = poolOwner.getDataSetHandle(lpool::testSid); REQUIRE(setHandle != nullptr); CHECK(poolOwner.poolManager.generateHousekeepingPacket(lpool::testSid, setHandle, false) == - result::OK); + returnvalue::OK); REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); + CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK); CHECK(setHandle->getReportingEnabled() == true); CommandMessage hkCmd; HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(setHandle->getReportingEnabled() == false); REQUIRE(poolOwnerMock.wasMessageSent()); CHECK(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); + CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, false); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(setHandle->getReportingEnabled() == true); REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); + CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, false); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(setHandle->getReportingEnabled() == false); REQUIRE(poolOwnerMock.wasMessageSent()); - CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); + CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, false); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); /* For non-diagnostics and a specified minimum frequency of 0.2 seconds, the resulting collection interval should be 1.0 second */ CHECK(poolOwner.dataset.getCollectionInterval() == 1.0); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); + CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); - REQUIRE(poolOwner.poolManager.performHkOperation() == result::OK); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + REQUIRE(poolOwner.poolManager.performHkOperation() == returnvalue::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); /* Now HK packet should be sent as message. */ REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, false); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); @@ -334,7 +333,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { HousekeepingMessage::setUpdateNotificationSetCommand(&hkCmd, lpool::testSid); sid_t sidToCheck; store_address_t storeId; - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(poolOwner.changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); CHECK(sidToCheck == lpool::testSid); @@ -347,7 +346,7 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* We still expect a failure message being sent */ REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); + CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, false); @@ -355,36 +354,36 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); + CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, false); CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == static_cast(LocalDataPoolManager::WRONG_HK_PACKET_TYPE)); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); - CHECK(poolOwnerMock.clearLastSentMessage() == result::OK); + CHECK(poolOwnerMock.clearLastSentMessage() == returnvalue::OK); HousekeepingMessage::setStructureReportingCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setCollectionIntervalModificationCommand(&hkCmd, lpool::testSid, 0.4, true); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, true, true); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setToggleReportingCommand(&hkCmd, lpool::testSid, false, true); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); @@ -397,26 +396,26 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { poolOwnerMock.clearMessages(); HousekeepingMessage::setOneShotReportCommand(&hkCmd, lpool::testSid, true); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); REQUIRE(poolOwnerMock.wasMessageSent()); REQUIRE(poolOwnerMock.numberOfSentMessages() == 1); poolOwnerMock.clearMessages(); HousekeepingMessage::setUpdateNotificationVariableCommand(&hkCmd, lpool::uint8VarGpid); gp_id_t gpidToCheck; - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(poolOwner.changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); CHECK(gpidToCheck == lpool::uint8VarGpid); HousekeepingMessage::setUpdateSnapshotSetCommand(&hkCmd, lpool::testSid, store_address_t::invalid()); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(poolOwner.changedDataSetCallbackWasCalled(sidToCheck, storeId) == true); CHECK(sidToCheck == lpool::testSid); HousekeepingMessage::setUpdateSnapshotVariableCommand(&hkCmd, lpool::uint8VarGpid, store_address_t::invalid()); - CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == result::OK); + CHECK(poolOwner.poolManager.handleHousekeepingMessage(&hkCmd) == returnvalue::OK); CHECK(poolOwner.changedVariableCallbackWasCalled(gpidToCheck, storeId) == true); CHECK(gpidToCheck == lpool::uint8VarGpid); @@ -425,6 +424,6 @@ TEST_CASE("Local Pool Manager Tests", "[LocManTest]") { /* we need to reset the subscription list because the pool owner is a global object. */ - CHECK(poolOwner.reset() == result::OK); + CHECK(poolOwner.reset() == returnvalue::OK); poolOwnerMock.clearMessages(true); } diff --git a/unittests/datapoollocal/testLocalPoolVariable.cpp b/unittests/datapoollocal/testLocalPoolVariable.cpp index 78b1ccde..ce125029 100644 --- a/unittests/datapoollocal/testLocalPoolVariable.cpp +++ b/unittests/datapoollocal/testLocalPoolVariable.cpp @@ -7,26 +7,28 @@ #include "mocks/LocalPoolOwnerBase.h" #include "tests/TestsConfig.h" +using namespace returnvalue; + TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { auto queue = MessageQueueMock(1); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner.initializeHkManager() == result::OK); - REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == result::OK); + REQUIRE(poolOwner.initializeHkManager() == OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == OK); SECTION("Basic Tests") { /* very basic test. */ lp_var_t testVariable = lp_var_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); - REQUIRE(testVariable.read() == result::OK); + REQUIRE(testVariable.read() == returnvalue::OK); CHECK(testVariable.value == 0); testVariable.value = 5; - REQUIRE(testVariable.commit() == result::OK); - REQUIRE(testVariable.read() == result::OK); + REQUIRE(testVariable.commit() == returnvalue::OK); + REQUIRE(testVariable.read() == returnvalue::OK); REQUIRE(testVariable.value == 5); CHECK(not testVariable.isValid()); testVariable.setValid(true); CHECK(testVariable.isValid()); - CHECK(testVariable.commit(true) == result::OK); + CHECK(testVariable.commit(true) == returnvalue::OK); testVariable.setReadWriteMode(pool_rwm_t::VAR_READ); CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ); @@ -42,7 +44,7 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); lp_var_t testVariable2 = lp_var_t(globPoolId); - REQUIRE(testVariable2.read() == result::OK); + REQUIRE(testVariable2.read() == returnvalue::OK); CHECK(testVariable2 == 5); CHECK(testVariable == testVariable2); testVariable = 10; @@ -54,12 +56,12 @@ TEST_CASE("LocalPoolVariable", "[LocPoolVarTest]") { CHECK(maxSize == 1); size_t serSize = 0; CHECK(testVariable.serialize(&varPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(variableRaw == 10); const uint8_t* varConstPtr = &variableRaw; testVariable = 5; CHECK(testVariable.deSerialize(&varConstPtr, &serSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(testVariable == 10); CHECK(testVariable != testVariable2); CHECK(testVariable2 < testVariable); diff --git a/unittests/datapoollocal/testLocalPoolVector.cpp b/unittests/datapoollocal/testLocalPoolVector.cpp index 9ebfd3a0..69014e58 100644 --- a/unittests/datapoollocal/testLocalPoolVector.cpp +++ b/unittests/datapoollocal/testLocalPoolVector.cpp @@ -7,29 +7,31 @@ #include "mocks/LocalPoolOwnerBase.h" #include "tests/TestsConfig.h" +using namespace returnvalue; + TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { auto queue = MessageQueueMock(1); LocalPoolOwnerBase poolOwner(queue, objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner.initializeHkManager() == result::OK); - REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == result::OK); + REQUIRE(poolOwner.initializeHkManager() == OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == OK); SECTION("BasicTest") { // very basic test. lp_vec_t testVector = lp_vec_t(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id); - REQUIRE(testVector.read() == result::OK); + REQUIRE(testVector.read() == returnvalue::OK); testVector.value[0] = 5; testVector.value[1] = 232; testVector.value[2] = 32023; - REQUIRE(testVector.commit(true) == result::OK); + REQUIRE(testVector.commit(true) == returnvalue::OK); CHECK(testVector.isValid()); testVector.value[0] = 0; testVector.value[1] = 0; testVector.value[2] = 0; - CHECK(testVector.read() == result::OK); + CHECK(testVector.read() == returnvalue::OK); CHECK(testVector.value[0] == 5); CHECK(testVector.value[1] == 232); CHECK(testVector.value[2] == 32023); @@ -40,7 +42,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { (we can't throw exceptions) */ testVector[4] = 12; CHECK(testVector[2] == 12); - CHECK(testVector.commit() == result::OK); + CHECK(testVector.commit() == returnvalue::OK); /* Use read-only reference. */ const lp_vec_t& roTestVec = testVector; @@ -57,7 +59,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { uint8_t* vecPtr = reinterpret_cast(serializedVector); size_t serSize = 0; REQUIRE(testVector.serialize(&vecPtr, &serSize, maxSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(serSize == 6); CHECK(serializedVector[0] == 5); @@ -74,7 +76,7 @@ TEST_CASE("LocalPoolVector", "[LocPoolVecTest]") { const uint8_t* constVecPtr = reinterpret_cast(serializedVector); REQUIRE(testVector.deSerialize(&constVecPtr, &serSize, SerializeIF::Endianness::MACHINE) == - result::OK); + returnvalue::OK); CHECK(testVector[0] == 16); CHECK(testVector[1] == 7832); CHECK(testVector[2] == 39232); diff --git a/unittests/devicehandler/DeviceHandlerCommander.cpp b/unittests/devicehandler/DeviceHandlerCommander.cpp index d38166ad..03ff992c 100644 --- a/unittests/devicehandler/DeviceHandlerCommander.cpp +++ b/unittests/devicehandler/DeviceHandlerCommander.cpp @@ -13,15 +13,15 @@ DeviceHandlerCommander::~DeviceHandlerCommander() {} ReturnValue_t DeviceHandlerCommander::performOperation(uint8_t operationCode) { readCommandQueue(); - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DeviceHandlerCommander::initialize() { ReturnValue_t result = commandActionHelper.initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } MessageQueueIF* DeviceHandlerCommander::getCommandQueuePtr() { return commandQueue; } @@ -35,7 +35,7 @@ void DeviceHandlerCommander::dataReceived(ActionId_t actionId, const uint8_t* da } void DeviceHandlerCommander::completionSuccessfulReceived(ActionId_t actionId) { - lastReplyReturnCode = RETURN_OK; + lastReplyReturnCode = returnvalue::OK; } void DeviceHandlerCommander::completionFailedReceived(ActionId_t actionId, @@ -45,11 +45,11 @@ void DeviceHandlerCommander::completionFailedReceived(ActionId_t actionId, void DeviceHandlerCommander::readCommandQueue() { CommandMessage message; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; + for (result = commandQueue->receiveMessage(&message); result == returnvalue::OK; result = commandQueue->receiveMessage(&message)) { result = commandActionHelper.handleReply(&message); - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == returnvalue::OK) { continue; } } @@ -61,4 +61,4 @@ ReturnValue_t DeviceHandlerCommander::sendCommand(object_id_t target, ActionId_t ReturnValue_t DeviceHandlerCommander::getReplyReturnCode() { return lastReplyReturnCode; } -void DeviceHandlerCommander::resetReplyReturnCode() { lastReplyReturnCode = RETURN_FAILED; } +void DeviceHandlerCommander::resetReplyReturnCode() { lastReplyReturnCode = returnvalue::FAILED; } diff --git a/unittests/devicehandler/DeviceHandlerCommander.h b/unittests/devicehandler/DeviceHandlerCommander.h index 435d0017..e90cbcee 100644 --- a/unittests/devicehandler/DeviceHandlerCommander.h +++ b/unittests/devicehandler/DeviceHandlerCommander.h @@ -9,8 +9,7 @@ class DeviceHandlerCommander : public ExecutableObjectIF, public SystemObject, - public CommandsActionsIF, - public HasReturnvaluesIF { + public CommandsActionsIF { public: DeviceHandlerCommander(object_id_t objectId); virtual ~DeviceHandlerCommander(); @@ -42,7 +41,7 @@ class DeviceHandlerCommander : public ExecutableObjectIF, CommandActionHelper commandActionHelper; - ReturnValue_t lastReplyReturnCode = RETURN_FAILED; + ReturnValue_t lastReplyReturnCode = returnvalue::FAILED; void readCommandQueue(); }; diff --git a/unittests/devicehandler/TestDeviceHandlerBase.cpp b/unittests/devicehandler/TestDeviceHandlerBase.cpp index 0a1b18fa..67c3cdaf 100644 --- a/unittests/devicehandler/TestDeviceHandlerBase.cpp +++ b/unittests/devicehandler/TestDeviceHandlerBase.cpp @@ -15,16 +15,16 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { DeviceHandlerMock deviceHandlerMock(objects::DEVICE_HANDLER_MOCK, objects::COM_IF_MOCK, cookieIFMock, &deviceFdirMock); ReturnValue_t result = deviceHandlerMock.initialize(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); DeviceHandlerCommander deviceHandlerCommander(objects::DEVICE_HANDLER_COMMANDER); result = deviceHandlerCommander.initialize(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); SECTION("Commanding nominal") { comIF.setTestCase(ComIFMock::TestCase::SIMPLE_COMMAND_NOMINAL); result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, DeviceHandlerMock::SIMPLE_COMMAND); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); @@ -34,7 +34,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { result = deviceHandlerCommander.getReplyReturnCode(); uint32_t missedReplies = deviceFdirMock.getMissedReplyCount(); REQUIRE(missedReplies == 0); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); } SECTION("Commanding missed reply") { @@ -44,7 +44,7 @@ TEST_CASE("Device Handler Base", "[DeviceHandlerBase]") { deviceHandlerMock.changeSimpleCommandReplyCountdown(0); result = deviceHandlerCommander.sendCommand(objects::DEVICE_HANDLER_MOCK, DeviceHandlerMock::SIMPLE_COMMAND); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); deviceHandlerMock.performOperation(DeviceHandlerIF::PERFORM_OPERATION); deviceHandlerMock.performOperation(DeviceHandlerIF::SEND_WRITE); deviceHandlerMock.performOperation(DeviceHandlerIF::GET_WRITE); diff --git a/unittests/globalfunctions/testDleEncoder.cpp b/unittests/globalfunctions/testDleEncoder.cpp index fc4d79bf..55e27ba4 100644 --- a/unittests/globalfunctions/testDleEncoder.cpp +++ b/unittests/globalfunctions/testDleEncoder.cpp @@ -49,7 +49,7 @@ const std::vector TEST_ARRAY_4_ENCODED_NON_ESCAPED = { TEST_CASE("DleEncoder", "[DleEncoder]") { DleEncoder dleEncoder; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = returnvalue::OK; std::array buffer; size_t encodedLen = 0; @@ -60,7 +60,7 @@ TEST_CASE("DleEncoder", "[DleEncoder]") { const std::vector& expectedVec) { result = encoder.encode(vecToEncode.data(), vecToEncode.size(), buffer.data(), buffer.size(), &encodedLen); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); for (size_t idx = 0; idx < expectedVec.size(); idx++) { REQUIRE(buffer[idx] == expectedVec[idx]); } @@ -71,7 +71,7 @@ TEST_CASE("DleEncoder", "[DleEncoder]") { const std::vector& expectedVec) { result = encoder.decode(testVecEncoded.data(), testVecEncoded.size(), &readLen, buffer.data(), buffer.size(), &decodedLen); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(readLen == testVecEncoded.size()); REQUIRE(decodedLen == expectedVec.size()); for (size_t idx = 0; idx < decodedLen; idx++) { diff --git a/unittests/hal/testCommandExecutor.cpp b/unittests/hal/testCommandExecutor.cpp index d34f67aa..04576f85 100644 --- a/unittests/hal/testCommandExecutor.cpp +++ b/unittests/hal/testCommandExecutor.cpp @@ -22,8 +22,8 @@ TEST_CASE("Command Executor", "[cmd-exec]") { REQUIRE(cmdExecutor.getCurrentState() == CommandExecutor::States::IDLE); ReturnValue_t result = cmdExecutor.load(cmd, true, true); REQUIRE(cmdExecutor.getCurrentState() == CommandExecutor::States::COMMAND_LOADED); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - REQUIRE(cmdExecutor.execute() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); + REQUIRE(cmdExecutor.execute() == returnvalue::OK); // Check that file exists with contents std::ifstream file(TEST_FILE_NAME); std::string line; @@ -38,7 +38,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { cmdExecutor.setRingBuffer(&outputBuffer, &sizesFifo); result = cmdExecutor.load("echo \"Hello World\"", false, false); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); cmdExecutor.execute(); bool bytesHaveBeenRead = false; size_t limitIdx = 0; @@ -58,7 +58,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { REQUIRE(readBytes == 12); REQUIRE(outputBuffer.getAvailableReadData() == 12); uint8_t readBuffer[32] = {}; - REQUIRE(outputBuffer.readData(readBuffer, 12) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(outputBuffer.readData(readBuffer, 12) == returnvalue::OK); std::string readString(reinterpret_cast(readBuffer)); std::string cmpString = "Hello World\n"; CHECK(readString == cmpString); @@ -69,7 +69,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { // Test more complex command result = cmdExecutor.load("ping -c 1 localhost", false, false); REQUIRE(cmdExecutor.getCurrentState() == CommandExecutor::States::COMMAND_LOADED); - REQUIRE(cmdExecutor.execute() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(cmdExecutor.execute() == returnvalue::OK); REQUIRE(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING); limitIdx = 0; while (result != CommandExecutor::EXECUTION_FINISHED) { @@ -110,11 +110,10 @@ TEST_CASE("Command Executor", "[cmd-exec]") { // Now check failing command result = cmdExecutor.load("false", false, false); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); result = cmdExecutor.execute(); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); - while (result != CommandExecutor::EXECUTION_FINISHED and - result != HasReturnvaluesIF::RETURN_FAILED) { + REQUIRE(result == returnvalue::OK); + while (result != CommandExecutor::EXECUTION_FINISHED and result != returnvalue::FAILED) { limitIdx++; result = cmdExecutor.check(bytesHaveBeenRead); REQUIRE(result != CommandExecutor::COMMAND_ERROR); @@ -122,7 +121,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { usleep(500); REQUIRE(limitIdx < 500); } - REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(result == returnvalue::FAILED); REQUIRE(cmdExecutor.getLastError() == 1); } diff --git a/unittests/internalerror/TestInternalErrorReporter.cpp b/unittests/internalerror/TestInternalErrorReporter.cpp index e2bf96e4..4562bab4 100644 --- a/unittests/internalerror/TestInternalErrorReporter.cpp +++ b/unittests/internalerror/TestInternalErrorReporter.cpp @@ -38,7 +38,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { CommandMessage message; ActionMessage::setCompletionReply(&message, 10, true); auto result = hkQueue->sendMessage(testQueue->getId(), &message); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); uint32_t queueHits = 0; uint32_t lostTm = 0; uint32_t storeHits = 0; @@ -49,7 +49,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { { CommandMessage hkMessage; result = hkQueue->receiveMessage(&hkMessage); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(hkMessage.getCommand() == HousekeepingMessage::UPDATE_SNAPSHOT_SET); store_address_t storeAddress; gp_id_t gpid = @@ -59,12 +59,12 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { InternalErrorDataset dataset(objects::INTERNAL_ERROR_REPORTER); CCSDSTime::CDS_short time{}; ConstAccessorPair data = ipcStore->getData(storeAddress); - REQUIRE(data.first == HasReturnvaluesIF::RETURN_OK); + REQUIRE(data.first == returnvalue::OK); HousekeepingSnapshot hkSnapshot(&time, &dataset); const uint8_t* buffer = data.second.data(); size_t size = data.second.size(); result = hkSnapshot.deSerialize(&buffer, &size, SerializeIF::Endianness::MACHINE); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Remember the amount of queueHits before to see the increase queueHits = dataset.queueHits.value; lostTm = dataset.tmHits.value; @@ -78,7 +78,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { internalErrorReporter->performOperation(0); CommandMessage hkMessage; result = hkQueue->receiveMessage(&hkMessage); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(hkMessage.getCommand() == HousekeepingMessage::UPDATE_SNAPSHOT_SET); store_address_t storeAddress; gp_id_t gpid = @@ -86,15 +86,15 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { REQUIRE(gpid.objectId == objects::INTERNAL_ERROR_REPORTER); ConstAccessorPair data = ipcStore->getData(storeAddress); - REQUIRE(data.first == HasReturnvaluesIF::RETURN_OK); - CCSDSTime::CDS_short time{}; + REQUIRE(data.first == returnvalue::OK); + CCSDSTime::CDS_short time; // We need the object ID of the reporter here (NO_OBJECT) InternalErrorDataset dataset(objects::INTERNAL_ERROR_REPORTER); HousekeepingSnapshot hkSnapshot(&time, &dataset); const uint8_t* buffer = data.second.data(); size_t size = data.second.size(); result = hkSnapshot.deSerialize(&buffer, &size, SerializeIF::Endianness::MACHINE); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Test that we had one more queueHit REQUIRE(dataset.queueHits.value == (queueHits + 1)); REQUIRE(dataset.tmHits.value == (lostTm + 1)); @@ -111,7 +111,7 @@ TEST_CASE("Internal Error Reporter", "[TestInternalError]") { sid_t sid(objects::INTERNAL_ERROR_REPORTER, InternalErrorDataset::ERROR_SET_ID); HousekeepingMessage::setToggleReportingCommand(&message2, sid, true, false); result = hkQueue->sendMessage(id, &message2); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); internalErrorReporter->performOperation(0); } } diff --git a/unittests/mocks/CdsShortTimestamperMock.h b/unittests/mocks/CdsShortTimestamperMock.h index d19385cd..ca7a674c 100644 --- a/unittests/mocks/CdsShortTimestamperMock.h +++ b/unittests/mocks/CdsShortTimestamperMock.h @@ -10,13 +10,13 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { public: unsigned int serializeCallCount = 0; unsigned int deserializeCallCount = 0; - ReturnValue_t lastDeserializeResult = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t lastSerializeResult = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t lastDeserializeResult = returnvalue::OK; + ReturnValue_t lastSerializeResult = returnvalue::OK; unsigned int getSizeCallCount = 0; bool nextSerFails = false; - ReturnValue_t serFailRetval = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t serFailRetval = returnvalue::FAILED; bool nextDeserFails = false; - ReturnValue_t deserFailRetval = HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t deserFailRetval = returnvalue::FAILED; std::array valueToStamp{}; CdsShortTimestamperMock() = default; @@ -36,7 +36,7 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { return lastSerializeResult; } std::copy(valueToStamp.begin(), valueToStamp.end(), *buffer); - thisNonConst.lastSerializeResult = HasReturnvaluesIF::RETURN_OK; + thisNonConst.lastSerializeResult = returnvalue::OK; *buffer += getSerializedSize(); *size += getSerializedSize(); return lastSerializeResult; @@ -69,10 +69,10 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { deserializeCallCount = 0; nextSerFails = false; nextDeserFails = false; - lastSerializeResult = HasReturnvaluesIF::RETURN_OK; - lastDeserializeResult = HasReturnvaluesIF::RETURN_OK; - deserFailRetval = HasReturnvaluesIF::RETURN_FAILED; - serFailRetval = HasReturnvaluesIF::RETURN_FAILED; + lastSerializeResult = returnvalue::OK; + lastDeserializeResult = returnvalue::OK; + deserFailRetval = returnvalue::FAILED; + serFailRetval = returnvalue::FAILED; } ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override { diff --git a/unittests/mocks/ComIFMock.cpp b/unittests/mocks/ComIFMock.cpp index 650b74bd..d51339dc 100644 --- a/unittests/mocks/ComIFMock.cpp +++ b/unittests/mocks/ComIFMock.cpp @@ -6,24 +6,24 @@ ComIFMock::ComIFMock(object_id_t objectId) : SystemObject(objectId) {} ComIFMock::~ComIFMock() {} -ReturnValue_t ComIFMock::initializeInterface(CookieIF *cookie) { return RETURN_OK; } +ReturnValue_t ComIFMock::initializeInterface(CookieIF *cookie) { return returnvalue::OK; } ReturnValue_t ComIFMock::sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) { data = *sendData; - return RETURN_OK; + return returnvalue::OK; } -ReturnValue_t ComIFMock::getSendSuccess(CookieIF *cookie) { return RETURN_OK; } +ReturnValue_t ComIFMock::getSendSuccess(CookieIF *cookie) { return returnvalue::OK; } ReturnValue_t ComIFMock::requestReceiveMessage(CookieIF *cookie, size_t requestLen) { - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) { switch (testCase) { case TestCase::MISSED_REPLY: { *size = 0; - return RETURN_OK; + return returnvalue::OK; } case TestCase::SIMPLE_COMMAND_NOMINAL: { *size = 1; @@ -40,7 +40,7 @@ ReturnValue_t ComIFMock::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, default: break; } - return RETURN_OK; + return returnvalue::OK; } void ComIFMock::setTestCase(TestCase testCase_) { testCase = testCase_; } diff --git a/unittests/mocks/DeviceHandlerMock.cpp b/unittests/mocks/DeviceHandlerMock.cpp index 1398c8e9..ef0a23d8 100644 --- a/unittests/mocks/DeviceHandlerMock.cpp +++ b/unittests/mocks/DeviceHandlerMock.cpp @@ -36,7 +36,7 @@ ReturnValue_t DeviceHandlerMock::buildCommandFromCommand(DeviceCommandId_t devic WARN("DeviceHandlerMock::buildCommandFromCommand: Invalid device command"); break; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, @@ -45,19 +45,19 @@ ReturnValue_t DeviceHandlerMock::scanForReply(const uint8_t *start, size_t len, case SIMPLE_COMMAND_DATA: { *foundId = SIMPLE_COMMAND; *foundLen = sizeof(SIMPLE_COMMAND_DATA); - return RETURN_OK; + return returnvalue::OK; break; } case PERIODIC_REPLY_DATA: { *foundId = PERIODIC_REPLY; *foundLen = sizeof(PERIODIC_REPLY_DATA); - return RETURN_OK; + return returnvalue::OK; break; } default: break; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { @@ -70,7 +70,7 @@ ReturnValue_t DeviceHandlerMock::interpretDeviceReply(DeviceCommandId_t id, cons default: break; } - return RETURN_OK; + return returnvalue::OK; } void DeviceHandlerMock::fillCommandAndReplyMap() { diff --git a/unittests/mocks/LocalPoolOwnerBase.cpp b/unittests/mocks/LocalPoolOwnerBase.cpp index df295b95..e1f2f0c5 100644 --- a/unittests/mocks/LocalPoolOwnerBase.cpp +++ b/unittests/mocks/LocalPoolOwnerBase.cpp @@ -13,7 +13,7 @@ ReturnValue_t LocalPoolOwnerBase::initializeHkManager() { initialized = true; return poolManager.initialize(&queue); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t LocalPoolOwnerBase::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, @@ -25,7 +25,7 @@ ReturnValue_t LocalPoolOwnerBase::initializeLocalDataPool(localpool::DataPool &l localDataPoolMap.emplace(lpool::uint16Vec3Id, &u16VecPoolEntry); localDataPoolMap.emplace(lpool::int64Vec2Id, &i64VecPoolEntry); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } LocalPoolObjectBase *LocalPoolOwnerBase::getPoolObjectHandle(lp_id_t localPoolId) { @@ -46,10 +46,10 @@ LocalPoolObjectBase *LocalPoolOwnerBase::getPoolObjectHandle(lp_id_t localPoolId ReturnValue_t LocalPoolOwnerBase::reset() { resetSubscriptionList(); - ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t status = returnvalue::OK; { PoolReadGuard readHelper(&dataset); - if (readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + if (readHelper.getReadResult() != returnvalue::OK) { status = readHelper.getReadResult(); } dataset.localPoolVarUint8.value = 0; @@ -62,7 +62,7 @@ ReturnValue_t LocalPoolOwnerBase::reset() { { PoolReadGuard readHelper(&testUint32); - if (readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + if (readHelper.getReadResult() != returnvalue::OK) { status = readHelper.getReadResult(); } testUint32.value = 0; @@ -71,7 +71,7 @@ ReturnValue_t LocalPoolOwnerBase::reset() { { PoolReadGuard readHelper(&testInt64Vec); - if (readHelper.getReadResult() != HasReturnvaluesIF::RETURN_OK) { + if (readHelper.getReadResult() != returnvalue::OK) { status = readHelper.getReadResult(); } testInt64Vec.value[0] = 0; @@ -116,7 +116,7 @@ ReturnValue_t LocalPoolOwnerBase::initializeHkManagerAfterTaskCreation() { initializedAfterTaskCreation = true; return poolManager.initializeAfterTaskCreation(); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void LocalPoolOwnerBase::handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId, diff --git a/unittests/mocks/MessageQueueMock.cpp b/unittests/mocks/MessageQueueMock.cpp index 215a7830..cac5a0d9 100644 --- a/unittests/mocks/MessageQueueMock.cpp +++ b/unittests/mocks/MessageQueueMock.cpp @@ -42,7 +42,7 @@ ReturnValue_t MessageQueueMock::clearLastReceivedMessage(bool clearCmdMsg) { message.clearCommandMessage(); } receivedMsgs.pop(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueueMock::receiveMessage(MessageQueueMessageIF* message) { @@ -51,16 +51,16 @@ ReturnValue_t MessageQueueMock::receiveMessage(MessageQueueMessageIF* message) { } std::memcpy(message->getBuffer(), receivedMsgs.front().getBuffer(), message->getMessageSize()); receivedMsgs.pop(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } -ReturnValue_t MessageQueueMock::flush(uint32_t* count) { return HasReturnvaluesIF::RETURN_FAILED; } +ReturnValue_t MessageQueueMock::flush(uint32_t* count) { return returnvalue::FAILED; } ReturnValue_t MessageQueueMock::sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, MessageQueueId_t sentFrom, bool ignoreFault) { if (message == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (nextSendFailsPair.first) { nextSendFailsPair.first = false; @@ -76,7 +76,7 @@ ReturnValue_t MessageQueueMock::sendMessageFrom(MessageQueueId_t sendTo, createMsgCopy(messageCopy, *message); iter->second.msgs.push(messageCopy); } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueueMock::reply(MessageQueueMessageIF* message) { @@ -121,7 +121,7 @@ ReturnValue_t MessageQueueMock::getNextSentMessage(MessageQueueId_t id, return MessageQueueIF::EMPTY; } createMsgCopy(message, iter->second.msgs.front()); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t MessageQueueMock::getNextSentMessage(MessageQueueMessageIF& message) { @@ -156,7 +156,7 @@ ReturnValue_t MessageQueueMock::clearLastSentMessage( } iter->second.msgs.pop(); iter->second.callCount--; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void MessageQueueMock::clearEmptyEntries() { for (auto it = sendMap.cbegin(); it != sendMap.cend();) { diff --git a/unittests/mocks/PeriodicTaskIFMock.h b/unittests/mocks/PeriodicTaskIFMock.h index dc0ccefc..7fbcfee1 100644 --- a/unittests/mocks/PeriodicTaskIFMock.h +++ b/unittests/mocks/PeriodicTaskIFMock.h @@ -16,10 +16,10 @@ class PeriodicTaskMock : public PeriodicTaskBase { */ virtual ReturnValue_t startTask() override { initObjsAfterTaskCreation(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; }; - virtual ReturnValue_t sleepFor(uint32_t ms) override { return HasReturnvaluesIF::RETURN_OK; }; + virtual ReturnValue_t sleepFor(uint32_t ms) override { return returnvalue::OK; }; }; #endif // FSFW_UNITTEST_TESTS_MOCKS_PERIODICTASKMOCK_H_ diff --git a/unittests/mocks/PowerSwitcherMock.cpp b/unittests/mocks/PowerSwitcherMock.cpp index 5c6935e4..b1506f6e 100644 --- a/unittests/mocks/PowerSwitcherMock.cpp +++ b/unittests/mocks/PowerSwitcherMock.cpp @@ -16,7 +16,7 @@ ReturnValue_t PowerSwitcherMock::sendSwitchCommand(power::Switch_t switchNr, Ret info.timesCalledOff++; } } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t PowerSwitcherMock::sendFuseOnCommand(uint8_t fuseNr) { @@ -26,7 +26,7 @@ ReturnValue_t PowerSwitcherMock::sendFuseOnCommand(uint8_t fuseNr) { FuseInfo& info = fuseMap.at(fuseNr); info.timesCalled++; } - return RETURN_OK; + return returnvalue::OK; } ReturnValue_t PowerSwitcherMock::getSwitchState(power::Switch_t switchNr) const { @@ -35,7 +35,7 @@ ReturnValue_t PowerSwitcherMock::getSwitchState(power::Switch_t switchNr) const SWITCH_REQUEST_UPDATE_VALUE++; return info.currentState; } - return RETURN_FAILED; + return returnvalue::FAILED; } ReturnValue_t PowerSwitcherMock::getFuseState(uint8_t fuseNr) const { @@ -44,7 +44,7 @@ ReturnValue_t PowerSwitcherMock::getFuseState(uint8_t fuseNr) const { } else { return FUSE_OFF; } - return RETURN_FAILED; + return returnvalue::FAILED; } uint32_t PowerSwitcherMock::getSwitchDelayMs(void) const { return 5000; } diff --git a/unittests/mocks/PusDistributorMock.cpp b/unittests/mocks/PusDistributorMock.cpp index cb9aed32..625dffc5 100644 --- a/unittests/mocks/PusDistributorMock.cpp +++ b/unittests/mocks/PusDistributorMock.cpp @@ -8,5 +8,5 @@ PusDistributorMock::PusDistributorMock(object_id_t registeredId) ReturnValue_t PusDistributorMock::registerService(AcceptsTelecommandsIF *service) { registerCallCount++; lastServiceArg = service; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/unittests/mocks/PusServiceBaseMock.cpp b/unittests/mocks/PusServiceBaseMock.cpp index 5c20f0a1..91e745e9 100644 --- a/unittests/mocks/PusServiceBaseMock.cpp +++ b/unittests/mocks/PusServiceBaseMock.cpp @@ -9,7 +9,7 @@ ReturnValue_t PsbMock::handleRequest(uint8_t subservice) { handleReqFailPair.first = false; return handleReqFailPair.second; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t PsbMock::performService() { @@ -18,7 +18,7 @@ ReturnValue_t PsbMock::performService() { performServiceFailPair.first = false; return performServiceFailPair.second; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void PsbMock::reset() { diff --git a/unittests/mocks/PusVerificationReporterMock.cpp b/unittests/mocks/PusVerificationReporterMock.cpp index c811d38e..07afd319 100644 --- a/unittests/mocks/PusVerificationReporterMock.cpp +++ b/unittests/mocks/PusVerificationReporterMock.cpp @@ -33,10 +33,10 @@ void PusVerificationReporterMock::popNextSuccessParams() { ReturnValue_t PusVerificationReporterMock::sendSuccessReport(VerifSuccessParams params) { successParams.push(params); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t PusVerificationReporterMock::sendFailureReport(VerifFailureParams params) { failParams.push(params); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/unittests/osal/TestClock.cpp b/unittests/osal/TestClock.cpp index 9979b28c..5d198db1 100644 --- a/unittests/osal/TestClock.cpp +++ b/unittests/osal/TestClock.cpp @@ -11,13 +11,13 @@ TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") { SECTION("Test getClock") { timeval time; ReturnValue_t result = Clock::getClock_timeval(&time); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); Clock::TimeOfDay_t timeOfDay; result = Clock::getDateAndTime(&timeOfDay); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); timeval timeOfDayAsTimeval; result = Clock::convertTimeOfDayToTimeval(&timeOfDay, &timeOfDayAsTimeval); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // We require timeOfDayAsTimeval to be larger than time as it // was request a few ns later double difference = timevalOperations::toDouble(timeOfDayAsTimeval - time); @@ -27,28 +27,28 @@ TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") { // Conversion in the other direction Clock::TimeOfDay_t timevalAsTimeOfDay; result = Clock::convertTimevalToTimeOfDay(&time, &timevalAsTimeOfDay); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); CHECK(timevalAsTimeOfDay.year <= timeOfDay.year); // TODO We should write TimeOfDay operators! } SECTION("Leap seconds") { uint16_t leapSeconds = 0; ReturnValue_t result = Clock::getLeapSeconds(&leapSeconds); - REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(result == returnvalue::FAILED); REQUIRE(leapSeconds == 0); result = Clock::setLeapSeconds(18); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); result = Clock::getLeapSeconds(&leapSeconds); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(leapSeconds == 18); } SECTION("usec Test") { timeval timeAsTimeval; ReturnValue_t result = Clock::getClock_timeval(&timeAsTimeval); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); uint64_t timeAsUsec = 0; result = Clock::getClock_usecs(&timeAsUsec); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); double timeAsUsecDouble = static_cast(timeAsUsec) / 1000000.0; timeval timeAsUsecTimeval = timevalOperations::toTimeval(timeAsUsecDouble); double difference = timevalOperations::toDouble(timeAsUsecTimeval - timeAsTimeval); @@ -66,7 +66,7 @@ TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") { time.tv_sec = 1648208539; time.tv_usec = 0; ReturnValue_t result = Clock::convertTimevalToJD2000(time, &j2000); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); double correctJ2000 = 2459663.98772 - 2451545.0; CHECK(j2000 == Catch::Approx(correctJ2000).margin(1.2 * 1e-8)); } @@ -76,9 +76,9 @@ TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") { utcTime.tv_usec = 999000; timeval tt; ReturnValue_t result = Clock::setLeapSeconds(27); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); result = Clock::convertUTCToTT(utcTime, &tt); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); CHECK(tt.tv_usec == 183000); // The plus 1 is a own forced overflow of usecs CHECK(tt.tv_sec == (1648208539 + 27 + 10 + 32 + 1)); diff --git a/unittests/osal/testMq.cpp b/unittests/osal/testMq.cpp index b1792a9c..dbab553f 100644 --- a/unittests/osal/testMq.cpp +++ b/unittests/osal/testMq.cpp @@ -19,17 +19,17 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { SECTION("Simple Tests") { auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(recvMessage.getData()[0] == 42); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); MessageQueueId_t senderId = 0; result = testReceiverMq->receiveMessage(&recvMessage, &senderId); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(recvMessage.getData()[0] == 42); CHECK(senderId == testSenderMqId); senderId = testReceiverMq->getLastPartner(); @@ -37,7 +37,7 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { } SECTION("Test Full") { auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); REQUIRE(result == MessageQueueIF::FULL); // We try another message @@ -45,12 +45,12 @@ TEST_CASE("MessageQueue Basic Test", "[TestMq]") { REQUIRE(result == MessageQueueIF::FULL); MessageQueueMessage recvMessage; result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(recvMessage.getData()[0] == 42); result = testSenderMq->sendMessage(testReceiverMqId, &testMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = testReceiverMq->receiveMessage(&recvMessage); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(recvMessage.getData()[0] == 42); } // We have to clear MQs ourself ATM diff --git a/unittests/power/testPowerSwitcher.cpp b/unittests/power/testPowerSwitcher.cpp index f6a24583..222dccf6 100644 --- a/unittests/power/testPowerSwitcher.cpp +++ b/unittests/power/testPowerSwitcher.cpp @@ -30,7 +30,7 @@ TEST_CASE("Power Switcher", "[power-switcher]") { REQUIRE(switchInfo.timesCalledOn == 1); REQUIRE(not switcher.active()); REQUIRE(mock.getAmountSwitchStatWasRequested() == 2); - REQUIRE(switcher.checkSwitchState() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(switcher.checkSwitchState() == returnvalue::OK); REQUIRE(mock.getAmountSwitchStatWasRequested() == 3); switcher.turnOff(false); REQUIRE(mock.getAmountSwitchStatWasRequested() == 3); diff --git a/unittests/serialize/testSerialBufferAdapter.cpp b/unittests/serialize/testSerialBufferAdapter.cpp index 56b16975..e5ea379e 100644 --- a/unittests/serialize/testSerialBufferAdapter.cpp +++ b/unittests/serialize/testSerialBufferAdapter.cpp @@ -102,7 +102,7 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") { size_t size = 6; auto result = tv_serial_buffer_adapter3.deSerialize(const_cast(&arrayPtr), &size, SerializeIF::Endianness::MACHINE); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(test_recv_array[0] == 1); CHECK(test_recv_array[1] == 1); CHECK(test_recv_array[2] == 1); diff --git a/unittests/serialize/testSerialLinkedPacket.cpp b/unittests/serialize/testSerialLinkedPacket.cpp index 0af5d2a1..30024248 100644 --- a/unittests/serialize/testSerialLinkedPacket.cpp +++ b/unittests/serialize/testSerialLinkedPacket.cpp @@ -40,7 +40,7 @@ TEST_CASE("Serial Linked Packet", "[SerLinkPacket]") { // Deserialize big endian packet by setting bigEndian to true. ReturnValue_t result = testClass.deSerialize(&readOnlyPointer, &packetLen, SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testClass.getHeader() == 42); // Equivalent check. // CHECK(testClass.getBuffer()[0] == 1); @@ -59,7 +59,7 @@ TEST_CASE("Serial Linked Packet", "[SerLinkPacket]") { // serialize for ground: bigEndian = true. ReturnValue_t result = testClass.serialize(&packetPointer, &serializedSize, packetMaxSize, SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Result should be big endian now. CHECK(packet[3] == 42); CHECK(packet[4] == 1); diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index 7aafe98f..30ad58e5 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -14,7 +14,7 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { SECTION("Little Endian Normal") { REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::LITTLE) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); @@ -26,8 +26,7 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { SECTION("Little Endian Simple") { size_t serLen = 0xff; REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), - SerializeIF::Endianness::LITTLE) == - HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::LITTLE) == returnvalue::OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); @@ -37,14 +36,14 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { SECTION("Big Endian Normal") { SECTION("Explicit") { REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 0") { REQUIRE(simpleSer.serialize(&ptr, &len, buf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 1") { - REQUIRE(simpleSer.serializeBe(&ptr, &len, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.serializeBe(&ptr, &len, buf.size()) == returnvalue::OK); } CHECK(buf[0] == 1); @@ -59,17 +58,16 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { size_t serLen = 0xff; SECTION("Explicit") { REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), - SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); } SECTION("Network 0") { REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 1") { REQUIRE(simpleSer.SerializeIF::serializeBe(buf.data(), serLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } CHECK(buf[0] == 1); CHECK(buf[1] == 2); @@ -85,8 +83,7 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { size_t len = buf.size(); SECTION("Little Endian Normal") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == returnvalue::OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); CHECK(ptr == buf.data() + 3); @@ -95,9 +92,8 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { SECTION("Little Endian Simple") { size_t deserLen = 0xff; - REQUIRE( - simpleSer.SerializeIF::deSerialize(ptr, deserLen, len, SerializeIF::Endianness::LITTLE) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerialize(ptr, deserLen, len, + SerializeIF::Endianness::LITTLE) == returnvalue::OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); CHECK(deserLen == 3); @@ -105,15 +101,14 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { SECTION("Big Endian Normal") { SECTION("Explicit") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == returnvalue::OK); } SECTION("Network 0") { REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 1") { - REQUIRE(simpleSer.SerializeIF::deSerializeBe(&ptr, &len) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(simpleSer.SerializeIF::deSerializeBe(&ptr, &len) == returnvalue::OK); } CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 1); @@ -125,17 +120,16 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { size_t deserLen = 0xff; SECTION("Explicit") { REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size(), - SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); } SECTION("Network 0") { REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("Network 1") { REQUIRE(simpleSer.SerializeIF::deSerializeBe(buf.data(), deserLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 1); diff --git a/unittests/storagemanager/testAccessor.cpp b/unittests/storagemanager/testAccessor.cpp index 56ab411c..d1c38f5d 100644 --- a/unittests/storagemanager/testAccessor.cpp +++ b/unittests/storagemanager/testAccessor.cpp @@ -12,7 +12,7 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { std::array testDataArray{}; std::array receptionArray{}; store_address_t testStoreId; - ReturnValue_t result = result::FAILED; + ReturnValue_t result = returnvalue::FAILED; for (size_t i = 0; i < testDataArray.size(); i++) { testDataArray[i] = i; @@ -21,9 +21,9 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { SECTION("Simple tests getter functions") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); auto resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); resultPair.second.getDataCopy(receptionArray.data(), 20); CHECK(resultPair.second.getId() == testStoreId); CHECK(resultPair.second.size() == 10); @@ -39,18 +39,18 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { { auto resultPairLoc = SimplePool.getData(testStoreId); - REQUIRE(resultPairLoc.first == result::OK); + REQUIRE(resultPairLoc.first == returnvalue::OK); // data should be deleted when accessor goes out of scope. } resultPair = SimplePool.getData(testStoreId); REQUIRE(resultPair.first == (int)StorageManagerIF::DATA_DOES_NOT_EXIST); result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); { ConstStorageAccessor constAccessor(testStoreId); result = SimplePool.getData(testStoreId, constAccessor); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); constAccessor.getDataCopy(receptionArray.data(), 20); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -63,12 +63,12 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); { resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); resultPair.second.release(); // now data should not be deleted anymore } resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); resultPair.second.getDataCopy(receptionArray.data(), 20); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -77,11 +77,11 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { SECTION("Simple tests modify functions") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); { StorageAccessor accessor(testStoreId); result = SimplePool.modifyData(testStoreId, accessor); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(accessor.getId() == testStoreId); CHECK(accessor.size() == 10); accessor.getDataCopy(receptionArray.data(), 20); @@ -98,10 +98,10 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { REQUIRE(resultPair.first == (int)StorageManagerIF::DATA_DOES_NOT_EXIST); result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); { auto resultPairLoc = SimplePool.modifyData(testStoreId); - REQUIRE(resultPairLoc.first == result::OK); + REQUIRE(resultPairLoc.first == returnvalue::OK); CHECK(resultPairLoc.second.getId() == testStoreId); CHECK(resultPairLoc.second.size() == 10); resultPairLoc.second.getDataCopy(receptionArray.data(), 20); @@ -117,22 +117,22 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { // data should not be deleted when accessor goes out of scope } resultPair = SimplePool.getData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); } SECTION("Write tests") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); { auto resultPair = SimplePool.modifyData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); testDataArray[9] = 42; resultPair.second.write(testDataArray.data(), 10, 0); // now data should not be deleted resultPair.second.release(); } auto resultConstPair = SimplePool.getData(testStoreId); - REQUIRE(resultConstPair.first == result::OK); + REQUIRE(resultConstPair.first == returnvalue::OK); resultConstPair.second.getDataCopy(receptionArray.data(), 10); for (size_t i = 0; i < size - 1; i++) { @@ -141,15 +141,15 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { CHECK(receptionArray[9] == 42); auto resultPair = SimplePool.modifyData(testStoreId); - REQUIRE(resultPair.first == result::OK); + REQUIRE(resultPair.first == returnvalue::OK); result = resultPair.second.write(testDataArray.data(), 20, 0); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); result = resultPair.second.write(testDataArray.data(), 10, 5); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); std::memset(testDataArray.data(), 42, 5); result = resultPair.second.write(testDataArray.data(), 5, 5); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); resultConstPair = SimplePool.getData(testStoreId); resultPair.second.getDataCopy(receptionArray.data(), 20); for (size_t i = 5; i < 10; i++) { @@ -159,7 +159,7 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { SECTION("Operators") { result = SimplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); { StorageAccessor accessor(testStoreId); StorageAccessor accessor2(store_address_t::invalid()); @@ -168,19 +168,19 @@ TEST_CASE("Pool Accessor", "[pool-accessor]") { std::array data; size_t size = 6; result = accessor.write(data.data(), data.size()); - REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(result == returnvalue::FAILED); result = SimplePool.modifyData(testStoreId, accessor2); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); CHECK(accessor2.getId() == testStoreId); CHECK(accessor2.size() == 10); std::array newData; - // Expect data to be invalid so this must return RETURN_FAILED + // Expect data to be invalid so this must return returnvalue::FAILED result = accessor.getDataCopy(newData.data(), newData.size()); - REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(result == returnvalue::FAILED); // Expect data to be too small result = accessor2.getDataCopy(data.data(), data.size()); - REQUIRE(result == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(result == returnvalue::FAILED); } } } diff --git a/unittests/storagemanager/testPool.cpp b/unittests/storagemanager/testPool.cpp index c3eadf1d..49a097d0 100644 --- a/unittests/storagemanager/testPool.cpp +++ b/unittests/storagemanager/testPool.cpp @@ -25,10 +25,10 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Basic tests") { REQUIRE(not simplePool.hasDataAtId(testStoreId)); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(simplePool.hasDataAtId(testStoreId)); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -36,12 +36,12 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { memset(receptionArray.data(), 0, size); result = simplePool.modifyData(testStoreId, &pointer, &size); memcpy(receptionArray.data(), pointer, size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); } result = simplePool.deleteData(testStoreId); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(not simplePool.hasDataAtId(testStoreId)); result = simplePool.addData(&testStoreId, testDataArray.data(), 15); CHECK(result == (int)StorageManagerIF::DATA_TOO_LARGE); @@ -50,12 +50,12 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Reservation Tests ") { pointer = nullptr; result = simplePool.getFreeElement(&testStoreId, size, &pointer); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); memcpy(pointer, testDataArray.data(), size); constPointer = nullptr; result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -64,21 +64,21 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Add, delete, add, add when full") { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); } result = simplePool.deleteData(testStoreId); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.getData(testStoreId, &constPointer, &size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); memcpy(receptionArray.data(), constPointer, size); for (size_t i = 0; i < size; i++) { CHECK(receptionArray[i] == i); @@ -105,20 +105,20 @@ TEST_CASE("Local Pool Simple Tests [1 Pool]", "[TestPool]") { SECTION("Initialize and clear store, delete with pointer") { result = simplePool.initialize(); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); simplePool.clearStore(); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = simplePool.modifyData(testStoreId, &pointer, &size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); store_address_t newId; result = simplePool.deleteData(pointer, size, &testStoreId); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(testStoreId.raw != (uint32_t)StorageManagerIF::INVALID_ADDRESS); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); } } @@ -144,7 +144,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { std::array testDataArray{}; std::array receptionArray{}; store_address_t testStoreId; - ReturnValue_t result = result::FAILED; + ReturnValue_t result = returnvalue::FAILED; for (size_t i = 0; i < testDataArray.size(); i++) { testDataArray[i] = i; } @@ -153,20 +153,20 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { SECTION("Basic tests") { size = 8; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Should be on second page of the pool now for 8 bytes CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == 0); size = 15; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Should be on third page of the pool now for 15 bytes CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == 0); result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Should be on third page of the pool now for 15 bytes CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == 1); @@ -177,7 +177,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 8; result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Should still work CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == 1); @@ -185,7 +185,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { // fill the rest of the pool for (uint8_t idx = 2; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } @@ -206,21 +206,21 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 5; for (uint8_t idx = 0; idx < 10; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 0); CHECK(testStoreId.packetIndex == idx); } size = 10; for (uint8_t idx = 0; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } size = 20; for (uint8_t idx = 0; idx < 2; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 2); CHECK(testStoreId.packetIndex == idx); } @@ -247,7 +247,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 5; for (uint8_t idx = 0; idx < 10; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 0); CHECK(testStoreId.packetIndex == idx); } @@ -264,7 +264,7 @@ TEST_CASE("Local Pool Extended Tests [3 Pools]", "[TestPool2]") { size = 10; for (uint8_t idx = 0; idx < 5; idx++) { result = simplePool.addData(&testStoreId, testDataArray.data(), size); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); CHECK(testStoreId.poolIndex == 1); CHECK(testStoreId.packetIndex == idx); } diff --git a/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp b/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp index 0c44f6a2..9559cca9 100644 --- a/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp +++ b/unittests/testcfg/pollingsequence/PollingSequenceFactory.cpp @@ -17,14 +17,14 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) thisSequence->addSlot(objects::TEST_DEVICE, 0.6 * length, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::TEST_DEVICE, 0.8 * length, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() == returnvalue::OK) { + return returnvalue::OK; } else { #if FSFW_CPP_OSTREAM_ENABLED sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" << std::endl; #else sif::printError("pst::pollingSequenceInitDefault: Sequence invalid!"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } diff --git a/unittests/timemanager/TestCCSDSTime.cpp b/unittests/timemanager/TestCCSDSTime.cpp index 9c457dda..0b1b602c 100644 --- a/unittests/timemanager/TestCCSDSTime.cpp +++ b/unittests/timemanager/TestCCSDSTime.cpp @@ -20,7 +20,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { time.usecond = 123456; SECTION("Test CCS Time") { auto result = CCSDSTime::convertToCcsds(&cssMilliSecconds, &time); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(cssMilliSecconds.pField == 0x52); // 0b01010010 REQUIRE(cssMilliSecconds.yearMSB == 0x07); REQUIRE(cssMilliSecconds.yearLSB == 0xe4); @@ -36,7 +36,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { const uint8_t* dataPtr = reinterpret_cast(&cssMilliSecconds); size_t length = sizeof(CCSDSTime::Ccs_mseconds); result = CCSDSTime::convertFromCCS(&timeTo, dataPtr, &length, sizeof(CCSDSTime::Ccs_mseconds)); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(cssMilliSecconds.pField == 0x52); // 0b01010010 REQUIRE(cssMilliSecconds.yearMSB == 0x07); REQUIRE(cssMilliSecconds.yearLSB == 0xe4); @@ -59,7 +59,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { size_t length = ccsDayOfYear.size(); auto result = CCSDSTime::convertFromCCS(&timeTo, ccsDayOfYear.data(), &length, ccsDayOfYear.size()); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Check constness REQUIRE(ccsDayOfYear[0] == 0b01011000); REQUIRE(ccsDayOfYear[1] == 0x07); @@ -82,7 +82,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { Clock::TimeOfDay_t timeTo; const uint8_t* timeChar = reinterpret_cast(timeAscii.c_str()); auto result = CCSDSTime::convertFromASCII(&timeTo, timeChar, timeAscii.length()); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(timeTo.year == 2022); REQUIRE(timeTo.month == 12); REQUIRE(timeTo.day == 31); @@ -95,7 +95,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { const uint8_t* timeChar2 = reinterpret_cast(timeAscii2.c_str()); Clock::TimeOfDay_t timeTo2; result = CCSDSTime::convertFromCcsds(&timeTo2, timeChar2, timeAscii2.length()); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(timeTo2.year == 2022); REQUIRE(timeTo2.month == 12); REQUIRE(timeTo2.day == 31); @@ -117,14 +117,14 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { time.usecond = 123456; timeval timeAsTimeval; auto result = Clock::convertTimeOfDayToTimeval(&time, &timeAsTimeval); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); CHECK(timeAsTimeval.tv_sec == 1582982685); CHECK(timeAsTimeval.tv_usec == 123456); // Conversion to CDS Short CCSDSTime::CDS_short cdsTime; result = CCSDSTime::convertToCcsds(&cdsTime, &timeAsTimeval); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); // Days in CCSDS Epoch 22704 (0x58B0) CHECK(cdsTime.dayMSB == 0x58); CHECK(cdsTime.dayLSB == 0xB0); @@ -138,7 +138,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { // Conversion back to timeval timeval timeReturnAsTimeval; result = CCSDSTime::convertFromCDS(&timeReturnAsTimeval, &cdsTime); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); // micro seconds precision is lost timeval difference = timeAsTimeval - timeReturnAsTimeval; CHECK(difference.tv_usec == 456); @@ -146,7 +146,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { Clock::TimeOfDay_t timeReturnAsTimeOfDay; result = CCSDSTime::convertFromCDS(&timeReturnAsTimeOfDay, &cdsTime); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); CHECK(timeReturnAsTimeOfDay.year == 2020); CHECK(timeReturnAsTimeOfDay.month == 2); CHECK(timeReturnAsTimeOfDay.day == 29); @@ -159,7 +159,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { Clock::TimeOfDay_t timeReturnAsTodFromBuffer; const uint8_t* buffer = reinterpret_cast(&cdsTime); result = CCSDSTime::convertFromCDS(&timeReturnAsTodFromBuffer, buffer, sizeof(cdsTime)); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); CHECK(timeReturnAsTodFromBuffer.year == time.year); CHECK(timeReturnAsTodFromBuffer.month == time.month); CHECK(timeReturnAsTodFromBuffer.day == time.day); @@ -170,7 +170,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { Clock::TimeOfDay_t todFromCCSDS; result = CCSDSTime::convertFromCcsds(&todFromCCSDS, buffer, sizeof(cdsTime)); - CHECK(result == HasReturnvaluesIF::RETURN_OK); + CHECK(result == returnvalue::OK); CHECK(todFromCCSDS.year == time.year); CHECK(todFromCCSDS.month == time.month); CHECK(todFromCCSDS.day == time.day); @@ -189,7 +189,7 @@ TEST_CASE("CCSDSTime Tests", "[TestCCSDSTime]") { CCSDSTime::P_FIELD_CUC_6B_CCSDS, 0x77, 0x1E, 0x96, 0x0F, 0x91, 0x27}; size_t foundLength = 0; auto result = CCSDSTime::convertFromCUC(&to, cucBuffer.data(), &foundLength, cucBuffer.size()); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(foundLength == 7); REQUIRE(to.tv_sec == 1619801999); // TAI (no leap seconds) REQUIRE(to.tv_usec == 567001); diff --git a/unittests/timemanager/TestCountdown.cpp b/unittests/timemanager/TestCountdown.cpp index d0af659d..67f4ddb2 100644 --- a/unittests/timemanager/TestCountdown.cpp +++ b/unittests/timemanager/TestCountdown.cpp @@ -8,9 +8,9 @@ TEST_CASE("Countdown Tests", "[TestCountdown]") { INFO("Countdown Tests"); Countdown count(20); REQUIRE(count.timeout == 20); - REQUIRE(count.setTimeout(100) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(count.setTimeout(100) == static_cast(returnvalue::OK)); REQUIRE(count.timeout == 100); - REQUIRE(count.setTimeout(150) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(count.setTimeout(150) == static_cast(returnvalue::OK)); REQUIRE(count.isBusy()); REQUIRE(not count.hasTimedOut()); uint32_t number = count.getRemainingMillis(); diff --git a/unittests/tmtcpacket/testCcsds.cpp b/unittests/tmtcpacket/testCcsds.cpp index 7c88c0c6..233e4ada 100644 --- a/unittests/tmtcpacket/testCcsds.cpp +++ b/unittests/tmtcpacket/testCcsds.cpp @@ -44,8 +44,7 @@ TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { packetId.packetType = ccsds::PacketType::TM; size_t serLen = 0; REQUIRE(packetId.raw() == 0x1ff); - REQUIRE(packetId.SerializeIF::serializeBe(buf.data(), serLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE(packetId.SerializeIF::serializeBe(buf.data(), serLen, buf.size()) == returnvalue::OK); CHECK(buf[0] == 0x1); CHECK(buf[1] == 0xff); } @@ -78,7 +77,7 @@ TEST_CASE("CCSDS Packet ID", "[ccsds-packet-id]") { buf[1] = 0xff; size_t deserLen = 0xff; REQUIRE(packetId.deSerialize(buf.data(), deserLen, buf.size(), - SerializeIF::Endianness::NETWORK) == HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); CHECK(packetId.apid == 0x2ff); CHECK(deserLen == 2); CHECK(packetId.packetType == ccsds::PacketType::TC); @@ -94,8 +93,7 @@ TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") { psc.seqFlags = ccsds::SequenceFlags::FIRST_SEGMENT; psc.seqCount = static_cast(std::round(std::pow(2, 14) - 1)); REQUIRE(psc.raw() == 0x7fff); - REQUIRE(psc.SerializeIF::serializeBe(buf.data(), serLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE(psc.SerializeIF::serializeBe(buf.data(), serLen, buf.size()) == returnvalue::OK); CHECK(buf[0] == 0x7f); CHECK(buf[1] == 0xff); CHECK(serLen == 2); @@ -114,7 +112,7 @@ TEST_CASE("CCSDS Packet Seq Ctrl", "[ccsds-packet-seq-ctrl]") { buf[1] = 0xfe; size_t deserLen = 0xff; REQUIRE(psc.deSerialize(buf.data(), deserLen, buf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); CHECK(psc.seqFlags == ccsds::SequenceFlags::LAST_SEGMENT); CHECK(deserLen == 2); CHECK(psc.seqCount == static_cast(std::round(std::pow(2, 14) - 2))); diff --git a/unittests/tmtcpacket/testCcsdsCreator.cpp b/unittests/tmtcpacket/testCcsdsCreator.cpp index 465e6475..2b043717 100644 --- a/unittests/tmtcpacket/testCcsdsCreator.cpp +++ b/unittests/tmtcpacket/testCcsdsCreator.cpp @@ -40,11 +40,11 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { serLen = 6; const uint8_t* readOnlyPtr = buf.data(); REQUIRE(base.deSerialize(&readOnlyPtr, &serLen, SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); } SECTION("Raw Output") { - REQUIRE(base.serializeBe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(base.serializeBe(&bufPtr, &serLen, buf.size()) == returnvalue::OK); // TC, and secondary header flag is set -> 0b0001100 -> 0x18 CHECK(buf[0] == 0x18); // APID 0x02 @@ -66,7 +66,7 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { base.setSeqFlags(ccsds::SequenceFlags::UNSEGMENTED); base.setDataLen(static_cast(std::pow(2, 16)) - 1); REQUIRE(base.isValid()); - REQUIRE(base.serializeBe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(base.serializeBe(&bufPtr, &serLen, buf.size()) == returnvalue::OK); CHECK(buf[0] == 0x1F); CHECK(buf[1] == 0xFF); CHECK(buf[2] == 0xFF); @@ -80,14 +80,14 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { ccsds::PacketType::TC, true, 0xFFFF, ccsds::SequenceFlags::FIRST_SEGMENT, 0x34, 0x16); REQUIRE(not creator.isValid()); REQUIRE(not creator); - REQUIRE(creator.serializeBe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(creator.serializeBe(&bufPtr, &serLen, buf.size()) == returnvalue::FAILED); } SECTION("Invalid Seq Count") { SpacePacketCreator invalid = SpacePacketCreator( ccsds::PacketType::TC, true, 0x02, ccsds::SequenceFlags::FIRST_SEGMENT, 0xFFFF, 0x16); REQUIRE(not invalid.isValid()); - REQUIRE(invalid.serializeBe(&bufPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(invalid.serializeBe(&bufPtr, &serLen, buf.size()) == returnvalue::FAILED); } SECTION("Invalid Buf Size 1") { diff --git a/unittests/tmtcpacket/testCcsdsReader.cpp b/unittests/tmtcpacket/testCcsdsReader.cpp index 75b4af87..519ef08b 100644 --- a/unittests/tmtcpacket/testCcsdsReader.cpp +++ b/unittests/tmtcpacket/testCcsdsReader.cpp @@ -36,12 +36,12 @@ TEST_CASE("CCSDS Reader", "[ccsds-reader]") { SECTION("Empty Reader") { REQUIRE(SpacePacketIF::getHeaderLen() == 6); REQUIRE(reader.isNull()); - REQUIRE(reader.checkSize() == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(reader.checkSize() == returnvalue::FAILED); } SECTION("Basic Read") { REQUIRE(base.serialize(&bufPtr, &serLen, buf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); SECTION("Setter") { reader.setReadOnlyData(buf.data(), SpacePacketIF::getHeaderLen()); checkReader(reader); @@ -54,8 +54,8 @@ TEST_CASE("CCSDS Reader", "[ccsds-reader]") { SECTION("Read with additional data") { REQUIRE(base.serialize(&bufPtr, &serLen, buf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); - REQUIRE(reader.setReadOnlyData(buf.data(), buf.size()) == HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); + REQUIRE(reader.setReadOnlyData(buf.data(), buf.size()) == returnvalue::OK); REQUIRE(reader.getBufSize() == buf.size()); REQUIRE(reader.getFullPacketLen() == FULL_PACKET_LEN); REQUIRE(reader.getPacketData() == buf.data() + SpacePacketIF::getHeaderLen()); diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index 5aed24a0..b18c4717 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -34,7 +34,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { } SECTION("Serialized") { - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); REQUIRE(serLen == 13); REQUIRE(buf[0] == 0x18); REQUIRE(buf[1] == 0x02); @@ -64,7 +64,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { auto& params = creator.getPusParams(); params.sourceId = 0x5ff; REQUIRE(creator.getSourceId() == 0x5ff); - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); REQUIRE(((buf[9] << 8) | buf[10]) == 0x5ff); } @@ -76,7 +76,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { REQUIRE(creator.getSerializedSize() == 13); creator.updateSpLengthField(); REQUIRE(creator.getSerializedSize() == 16); - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); REQUIRE(serLen == 16); REQUIRE(buf[11] == 1); REQUIRE(buf[12] == 2); @@ -88,7 +88,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { auto simpleSer = SimpleSerializable(); creator.setSerializableUserData(simpleSer); REQUIRE(creator.getSerializedSize() == 16); - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); REQUIRE(serLen == 16); REQUIRE(buf[11] == 1); REQUIRE(buf[12] == 2); @@ -100,7 +100,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { auto simpleSer = SimpleSerializable(); creator.setSerializableUserData(simpleSer); REQUIRE(creator.getSerializedSize() == 16); - REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == returnvalue::OK); REQUIRE(serLen == 16); REQUIRE(buf[11] == 1); REQUIRE(buf[12] == 2); @@ -112,7 +112,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { size_t deserLen = buf.size(); const uint8_t* roPtr = buf.data(); REQUIRE(deser.deSerialize(&roPtr, &deserLen, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); } SECTION("Serialize with invalid buffer length") { diff --git a/unittests/tmtcpacket/testPusTcReader.cpp b/unittests/tmtcpacket/testPusTcReader.cpp index 1c3469f2..3dbb8f81 100644 --- a/unittests/tmtcpacket/testPusTcReader.cpp +++ b/unittests/tmtcpacket/testPusTcReader.cpp @@ -16,21 +16,21 @@ TEST_CASE("PUS TC Reader", "[pus-tc-reader]") { PusTcReader reader; SECTION("State") { - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); REQUIRE(reader.isNull()); REQUIRE(not reader); PusTcReader* readerPtr = nullptr; bool callDelete = false; SECTION("Setter") { readerPtr = &reader; - REQUIRE(readerPtr->setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(readerPtr->parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(readerPtr->setReadOnlyData(buf.data(), serLen) == returnvalue::OK); + REQUIRE(readerPtr->parseDataWithCrcCheck() == returnvalue::OK); } SECTION("Directly Constructed") { callDelete = true; readerPtr = new PusTcReader(buf.data(), serLen); REQUIRE(not readerPtr->isNull()); - REQUIRE(readerPtr->parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(readerPtr->parseDataWithCrcCheck() == returnvalue::OK); } REQUIRE(not readerPtr->isNull()); REQUIRE(*readerPtr); @@ -55,26 +55,26 @@ TEST_CASE("PUS TC Reader", "[pus-tc-reader]") { } SECTION("Invalid CRC") { - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == returnvalue::OK); buf[11] = 0x00; REQUIRE(reader.parseDataWithCrcCheck() == PusIF::INVALID_CRC_16); } SECTION("Invalid CRC but no check") { - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == returnvalue::OK); buf[11] = 0x00; - REQUIRE(reader.parseDataWithoutCrcCheck() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.parseDataWithoutCrcCheck() == returnvalue::OK); } SECTION("With application data") { auto& params = creator.getPusParams(); std::array data{1, 2, 3}; creator.setRawUserData(data.data(), data.size()); - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == returnvalue::OK); + REQUIRE(reader.parseDataWithCrcCheck() == returnvalue::OK); const uint8_t* userDataPtr = reader.getUserData(); REQUIRE(userDataPtr != nullptr); REQUIRE(reader.getUserDataLen() == 3); diff --git a/unittests/tmtcpacket/testPusTmCreator.cpp b/unittests/tmtcpacket/testPusTmCreator.cpp index 4c958911..fc86dcbe 100644 --- a/unittests/tmtcpacket/testPusTmCreator.cpp +++ b/unittests/tmtcpacket/testPusTmCreator.cpp @@ -45,8 +45,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { } SECTION("Serialization") { - REQUIRE(creator.SerializeIF::serializeBe(&dataPtr, &serLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.SerializeIF::serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); REQUIRE(buf[0] == 0x08); REQUIRE(buf[1] == 0xef); // Unsegmented is the default @@ -90,7 +89,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { REQUIRE(creator.getApid() == 0x3ff); REQUIRE(creator.getDestId() == 0xfff); REQUIRE(creator.getMessageTypeCounter() == 0x313); - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); // Message Sequence Count REQUIRE(((buf[9] << 8) | buf[10]) == 0x313); // Destination ID @@ -101,14 +100,14 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { SerializeIF& deser = creator; const uint8_t* roDataPtr = nullptr; REQUIRE(deser.deSerialize(&roDataPtr, &serLen, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); } SECTION("Serialize with Raw Data") { std::array data{1, 2, 3}; creator.setRawUserData(data.data(), data.size()); REQUIRE(creator.getFullPacketLen() == 25); - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); REQUIRE(buf[20] == 1); REQUIRE(buf[21] == 2); REQUIRE(buf[22] == 3); @@ -119,7 +118,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { creator.setSerializableUserData(simpleSer); REQUIRE(creator.getFullPacketLen() == 25); REQUIRE(creator.serialize(&dataPtr, &serLen, buf.size(), SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); REQUIRE(buf[20] == 1); REQUIRE(buf[21] == 2); REQUIRE(buf[22] == 3); @@ -151,7 +150,7 @@ TEST_CASE("PUS TM Creator", "[pus-tm-creator]") { SECTION("No CRC Generation") { creator.disableCrcCalculation(); REQUIRE(not creator.crcCalculationEnabled()); - REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == returnvalue::OK); REQUIRE(serLen == 22); REQUIRE(buf[20] == 0x00); REQUIRE(buf[21] == 0x00); diff --git a/unittests/tmtcpacket/testPusTmReader.cpp b/unittests/tmtcpacket/testPusTmReader.cpp index 67659442..1180fd23 100644 --- a/unittests/tmtcpacket/testPusTmReader.cpp +++ b/unittests/tmtcpacket/testPusTmReader.cpp @@ -22,12 +22,12 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { bool deleteReader = false; dataPtr = buf.data(); serLen = 0; - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); REQUIRE(not(*readerPtr)); REQUIRE(readerPtr->isNull()); SECTION("Setter") { - REQUIRE(readerPtr->setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(readerPtr->setReadOnlyData(buf.data(), serLen) == returnvalue::OK); } SECTION("Full Construction") { readerPtr = new PusTmReader(&timeStamperAndReader, buf.data(), serLen); @@ -40,7 +40,7 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { } REQUIRE(not *readerPtr); REQUIRE(readerPtr->isNull()); - REQUIRE(readerPtr->parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(readerPtr->parseDataWithCrcCheck() == returnvalue::OK); REQUIRE(not readerPtr->isNull()); REQUIRE(readerPtr->getService() == 17); REQUIRE(readerPtr->getSubService() == 2); @@ -62,9 +62,9 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { } SECTION("Invalid CRC") { - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); buf[20] = 0; - REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == returnvalue::OK); REQUIRE(reader.parseDataWithCrcCheck() == PusIF::INVALID_CRC_16); } @@ -74,18 +74,18 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { } SECTION("Invalid CRC ignored") { - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); buf[20] = 0; - REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(reader.parseDataWithoutCrcCheck() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == returnvalue::OK); + REQUIRE(reader.parseDataWithoutCrcCheck() == returnvalue::OK); } SECTION("Read with source data") { std::array data{1, 2, 3}; creator.setRawUserData(data.data(), data.size()); - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == returnvalue::OK); + REQUIRE(reader.parseDataWithCrcCheck() == returnvalue::OK); REQUIRE(reader.getUserDataLen() == 3); const uint8_t* roData = reader.getUserData(); REQUIRE(roData[0] == 1); @@ -94,7 +94,7 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { } SECTION("Invalid stream lengths") { - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); for (size_t i = 0; i < serLen - 1; i++) { REQUIRE(reader.setReadOnlyData(buf.data(), i) == SerializeIF::STREAM_TOO_SHORT); } @@ -102,8 +102,8 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { SECTION("Reading timestamp fails") { timeStamperAndReader.nextDeserFails = true; - REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(reader.parseDataWithCrcCheck() == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(creator.serializeBe(&dataPtr, &serLen, buf.size()) == returnvalue::OK); + REQUIRE(reader.setReadOnlyData(buf.data(), serLen) == returnvalue::OK); + REQUIRE(reader.parseDataWithCrcCheck() == returnvalue::FAILED); } } \ No newline at end of file diff --git a/unittests/tmtcpacket/testZcTmWriter.cpp b/unittests/tmtcpacket/testZcTmWriter.cpp index da596250..12e88ea1 100644 --- a/unittests/tmtcpacket/testZcTmWriter.cpp +++ b/unittests/tmtcpacket/testZcTmWriter.cpp @@ -18,7 +18,7 @@ TEST_CASE("TM ZC Helper", "[tm-zc-helper]") { size_t serLen = 0; SECTION("No Crash For Uninitialized Object") { - REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == result::OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == returnvalue::OK); PusTmZeroCopyWriter writer(timeStamper, dataPtr, serLen); REQUIRE(writer.getSequenceCount() == 22); writer.setSequenceCount(23); @@ -28,9 +28,9 @@ TEST_CASE("TM ZC Helper", "[tm-zc-helper]") { } SECTION("Basic") { - REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == result::OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, buf.size()) == returnvalue::OK); PusTmZeroCopyWriter writer(timeStamper, dataPtr, serLen); - REQUIRE(writer.parseDataWithoutCrcCheck() == result::OK); + REQUIRE(writer.parseDataWithoutCrcCheck() == returnvalue::OK); REQUIRE(writer.getSequenceCount() == 22); writer.setSequenceCount(23); REQUIRE(writer.getSequenceCount() == 23); diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index 464fb3da..433a516e 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -37,7 +37,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { auto pusParams = PusTcParams(17, 1); PusTcCreator creator(spParams, pusParams); - REQUIRE(psb.initialize() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(psb.initialize() == returnvalue::OK); SECTION("State") { REQUIRE(psb.getIdentifier() == 17); @@ -49,19 +49,20 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { SECTION("Perform Service") { REQUIRE(psb.performServiceCallCnt == 0); - REQUIRE(psb.performOperation(0) == result::OK); + REQUIRE(psb.performOperation(0) == returnvalue::OK); REQUIRE(psb.performServiceCallCnt == 1); } SECTION("Send Request with Successful Handling") { REQUIRE(psb.performServiceCallCnt == 0); uint8_t* dataPtr; - REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == result::OK); + REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == + returnvalue::OK); size_t serLen = 0; - REQUIRE(creator.serializeBe(dataPtr, serLen, creator.getSerializedSize()) == result::OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, creator.getSerializedSize()) == returnvalue::OK); tmtcMsg.setStorageId(storeId); msgQueue.addReceivedMessage(tmtcMsg); - REQUIRE(psb.performOperation(0) == result::OK); + REQUIRE(psb.performOperation(0) == returnvalue::OK); uint8_t subservice = 0; REQUIRE(psb.getAndPopNextSubservice(subservice)); REQUIRE(subservice == 1); @@ -77,13 +78,14 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { SECTION("Send Request with Failed Handling") { uint8_t* dataPtr; - REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == result::OK); + REQUIRE(pool.getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == + returnvalue::OK); size_t serLen = 0; - REQUIRE(creator.serializeBe(dataPtr, serLen, creator.getSerializedSize()) == result::OK); + REQUIRE(creator.serializeBe(dataPtr, serLen, creator.getSerializedSize()) == returnvalue::OK); tmtcMsg.setStorageId(storeId); msgQueue.addReceivedMessage(tmtcMsg); psb.makeNextHandleReqCallFail(3); - REQUIRE(psb.performOperation(0) == result::OK); + REQUIRE(psb.performOperation(0) == returnvalue::OK); uint8_t subservice = 0; REQUIRE(psb.getAndPopNextSubservice(subservice)); REQUIRE(subservice == 1); @@ -100,7 +102,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { SECTION("Invalid Packet Sent") { tmtcMsg.setStorageId(store_address_t::invalid()); msgQueue.addReceivedMessage(tmtcMsg); - REQUIRE(psb.performOperation(0) == result::OK); + REQUIRE(psb.performOperation(0) == returnvalue::OK); REQUIRE(verificationReporter.failCallCount() == 1); auto verifParams = verificationReporter.getNextFailCallParams(); REQUIRE(verifParams.tcPacketId == 0); @@ -147,7 +149,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { psbParams.objectId = 1; auto mockWithOwnerQueue = PsbMock(psbParams); REQUIRE(mockWithOwnerQueue.getRequestQueue() == MessageQueueIF::NO_QUEUE); - REQUIRE(mockWithOwnerQueue.initialize() == result::OK); + REQUIRE(mockWithOwnerQueue.initialize() == returnvalue::OK); REQUIRE(mockWithOwnerQueue.getRequestQueue() != MessageQueueIF::NO_QUEUE); } @@ -190,7 +192,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { auto pusDistrib = PusDistributorMock(distributorId); PsbMock::setStaticPusDistributor(distributorId); REQUIRE(PsbMock::getStaticPusDistributor() == distributorId); - REQUIRE(psb2.initialize() == result::OK); + REQUIRE(psb2.initialize() == returnvalue::OK); REQUIRE(pusDistrib.registerCallCount == 1); REQUIRE(pusDistrib.lastServiceArg == &psb2); } @@ -203,7 +205,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { auto packetDest = AcceptsTmMock(destId, 2); PsbMock::setStaticTmDest(destId); REQUIRE(PsbMock::getStaticTmDest() == destId); - REQUIRE(psb2.initialize() == result::OK); + REQUIRE(psb2.initialize() == returnvalue::OK); auto& p = psb2.getParams(); REQUIRE(p.tmReceiver == &packetDest); } @@ -214,7 +216,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { object_id_t reporterId = objects::TC_VERIFICATOR; PusVerificationReporterMock otherReporter(reporterId); auto psb2 = PsbMock(psbParams); - REQUIRE(psb2.initialize() == result::OK); + REQUIRE(psb2.initialize() == returnvalue::OK); auto& p = psb2.getParams(); REQUIRE(p.verifReporter == &otherReporter); } @@ -224,7 +226,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { psbParams.tcPool = nullptr; psbParams.objectId = 1; auto psb2 = PsbMock(psbParams); - REQUIRE(psb2.initialize() == result::OK); + REQUIRE(psb2.initialize() == returnvalue::OK); auto& p = psb2.getParams(); REQUIRE(p.tcPool == &tcStoreGlobal); } diff --git a/unittests/tmtcservices/testSendHelper.cpp b/unittests/tmtcservices/testSendHelper.cpp index 78ca9f0e..43816835 100644 --- a/unittests/tmtcservices/testSendHelper.cpp +++ b/unittests/tmtcservices/testSendHelper.cpp @@ -44,7 +44,7 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") { REQUIRE(emptyHelper.getDefaultDestination() == MessageQueueIF::NO_QUEUE); store_address_t dummy; // basic robustness - REQUIRE(emptyHelper.sendPacket(dummy) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(emptyHelper.sendPacket(dummy) == returnvalue::FAILED); } SECTION("One Arg CTOR") { @@ -61,46 +61,46 @@ TEST_CASE("TM Send Helper", "[tm-send-helper]") { REQUIRE(helper.getMsgQueue() == &msgQueue); } SECTION("Send") { - REQUIRE(storeHelper.preparePacket(17, 2, 0) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.preparePacket(17, 2, 0) == returnvalue::OK); store_address_t storeId; SECTION("Separate Helpers") { - REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.addPacketToStore() == returnvalue::OK); storeId = storeHelper.getCurrentAddr(); - REQUIRE(sendHelper.sendPacket(storeId) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(sendHelper.sendPacket(storeId) == returnvalue::OK); } REQUIRE(msgQueue.wasMessageSent()); REQUIRE(msgQueue.numberOfSentMessagesToDefault() == 1); TmTcMessage msg; - REQUIRE(msgQueue.getNextSentMessage(msg) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(msgQueue.getNextSentMessage(msg) == returnvalue::OK); REQUIRE(msg.getStorageId() == storeId); REQUIRE(pool.hasDataAtId(msg.getStorageId())); } SECTION("Send to Non-Default") { storeHelper.preparePacket(17, 2, 0); - REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.addPacketToStore() == returnvalue::OK); store_address_t storeId = storeHelper.getCurrentAddr(); - REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == returnvalue::OK); REQUIRE(msgQueue.wasMessageSent()); REQUIRE(msgQueue.numberOfSentMessagesToDest(destId + 1) == 1); } SECTION("Sending fails, errors not ignored") { - msgQueue.makeNextSendFail(HasReturnvaluesIF::RETURN_FAILED); + msgQueue.makeNextSendFail(returnvalue::FAILED); storeHelper.preparePacket(17, 2, 0); - REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.addPacketToStore() == returnvalue::OK); store_address_t storeId = storeHelper.getCurrentAddr(); - REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == returnvalue::FAILED); REQUIRE(errReporter.lostTmCallCnt == 1); } SECTION("Sending fails, errors ignored") { - msgQueue.makeNextSendFail(HasReturnvaluesIF::RETURN_FAILED); + msgQueue.makeNextSendFail(returnvalue::FAILED); storeHelper.preparePacket(17, 2, 0); sendHelper.ignoreFaults(); - REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.addPacketToStore() == returnvalue::OK); store_address_t storeId = storeHelper.getCurrentAddr(); - REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == HasReturnvaluesIF::RETURN_FAILED); + REQUIRE(sendHelper.sendPacket(destId + 1, storeId) == returnvalue::FAILED); REQUIRE(errReporter.lostTmCallCnt == 0); } } \ No newline at end of file diff --git a/unittests/tmtcservices/testStoreAndSendHelper.cpp b/unittests/tmtcservices/testStoreAndSendHelper.cpp index 1163c33d..4e1bb4fb 100644 --- a/unittests/tmtcservices/testStoreAndSendHelper.cpp +++ b/unittests/tmtcservices/testStoreAndSendHelper.cpp @@ -34,7 +34,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { SECTION("Storage Fails") { // Too large to fit in store std::array data{}; - REQUIRE(storeHelper.setSourceDataRaw(data.data(), data.size()) == result::OK); + REQUIRE(storeHelper.setSourceDataRaw(data.data(), data.size()) == returnvalue::OK); REQUIRE(tmHelper.storeAndSendTmPacket() == StorageManagerIF::DATA_TOO_LARGE); } @@ -48,13 +48,13 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(params.dataWrapper.dataUnion.raw.data == nullptr); REQUIRE(params.dataWrapper.dataUnion.raw.len == 0); REQUIRE(tmHelper.sendCounter == 0); - REQUIRE(tmHelper.storeAndSendTmPacket() == result::OK); + REQUIRE(tmHelper.storeAndSendTmPacket() == returnvalue::OK); REQUIRE(tmHelper.sendCounter == 1); auto storeId = storeHelper.getCurrentAddr(); REQUIRE(msgQueue.wasMessageSent()); REQUIRE(msgQueue.numberOfSentMessagesToDefault() == 1); TmTcMessage msg; - REQUIRE(msgQueue.getNextSentMessage(msg) == result::OK); + REQUIRE(msgQueue.getNextSentMessage(msg) == returnvalue::OK); REQUIRE(msg.getStorageId() == storeId); REQUIRE(pool.hasDataAtId(msg.getStorageId())); storeHelper.deletePacket(); @@ -62,7 +62,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { SECTION("Raw Data Helper") { std::array data = {1, 2, 3}; - REQUIRE(tmHelper.prepareTmPacket(2, data.data(), data.size()) == result::OK); + REQUIRE(tmHelper.prepareTmPacket(2, data.data(), data.size()) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); REQUIRE(params.dataWrapper.type == ecss::DataTypes::RAW); @@ -72,7 +72,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { SECTION("Serializable Helper") { auto simpleSer = SimpleSerializable(); - REQUIRE(tmHelper.prepareTmPacket(2, simpleSer) == result::OK); + REQUIRE(tmHelper.prepareTmPacket(2, simpleSer) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); REQUIRE(params.dataWrapper.type == ecss::DataTypes::SERIALIZABLE); @@ -83,7 +83,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { uint32_t objectId = 0x01020304; std::array data = {1, 2, 3}; telemetry::DataWithObjectIdPrefix dataWithObjId(objectId, data.data(), data.size()); - REQUIRE(tmHelper.prepareTmPacket(2, dataWithObjId) == result::OK); + REQUIRE(tmHelper.prepareTmPacket(2, dataWithObjId) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); REQUIRE(params.dataWrapper.type == ecss::DataTypes::SERIALIZABLE); diff --git a/unittests/tmtcservices/testStoreHelper.cpp b/unittests/tmtcservices/testStoreHelper.cpp index 5220957a..dd73305d 100644 --- a/unittests/tmtcservices/testStoreHelper.cpp +++ b/unittests/tmtcservices/testStoreHelper.cpp @@ -16,7 +16,7 @@ TEST_CASE("TM Store Helper", "[tm-store-helper]") { REQUIRE(storeHelper.getCurrentAddr() == store_address_t::invalid()); REQUIRE(storeHelper.getTimeStamper() == &timeStamper); REQUIRE(storeHelper.getTmStore() == &pool); - REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.preparePacket(17, 1, 1) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); REQUIRE(creator.getApid() == 2); REQUIRE(creator.getService() == 17); @@ -45,51 +45,51 @@ TEST_CASE("TM Store Helper", "[tm-store-helper]") { } SECTION("Basic") { - REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.preparePacket(17, 1, 1) == returnvalue::OK); + REQUIRE(storeHelper.addPacketToStore() == returnvalue::OK); REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid()); auto accessor = pool.getData(storeHelper.getCurrentAddr()); - REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK); + REQUIRE(accessor.first == returnvalue::OK); // Not going to verify individual fields, the creator was unittested separately REQUIRE(accessor.second.size() == 22); } SECTION("Deletion") { - REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.preparePacket(17, 1, 1) == returnvalue::OK); + REQUIRE(storeHelper.addPacketToStore() == returnvalue::OK); REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid()); { auto accessor = pool.getData(storeHelper.getCurrentAddr()); - REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK); + REQUIRE(accessor.first == returnvalue::OK); REQUIRE(accessor.second.size() == 22); accessor.second.release(); } - REQUIRE(storeHelper.deletePacket() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.deletePacket() == returnvalue::OK); REQUIRE(storeHelper.getCurrentAddr() == store_address_t::invalid()); auto accessor = pool.getData(storeHelper.getCurrentAddr()); - REQUIRE(accessor.first != HasReturnvaluesIF::RETURN_OK); + REQUIRE(accessor.first != returnvalue::OK); } SECTION("With App Data Raw") { - REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.preparePacket(17, 1, 1) == returnvalue::OK); std::array data = {1, 2, 3}; - REQUIRE(storeHelper.setSourceDataRaw(data.data(), data.size()) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.setSourceDataRaw(data.data(), data.size()) == returnvalue::OK); + REQUIRE(storeHelper.addPacketToStore() == returnvalue::OK); REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid()); auto accessor = pool.getData(storeHelper.getCurrentAddr()); - REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK); + REQUIRE(accessor.first == returnvalue::OK); // Not going to verify individual fields, the creator was unittested separately REQUIRE(accessor.second.size() == 25); } SECTION("With App Data Serializable") { - REQUIRE(storeHelper.preparePacket(17, 1, 1) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.preparePacket(17, 1, 1) == returnvalue::OK); auto serializable = SimpleSerializable(); - REQUIRE(storeHelper.setSourceDataSerializable(serializable) == HasReturnvaluesIF::RETURN_OK); - REQUIRE(storeHelper.addPacketToStore() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(storeHelper.setSourceDataSerializable(serializable) == returnvalue::OK); + REQUIRE(storeHelper.addPacketToStore() == returnvalue::OK); REQUIRE(storeHelper.getCurrentAddr() != store_address_t::invalid()); auto accessor = pool.getData(storeHelper.getCurrentAddr()); - REQUIRE(accessor.first == HasReturnvaluesIF::RETURN_OK); + REQUIRE(accessor.first == returnvalue::OK); // Not going to verify individual fields, the creator was unittested separately REQUIRE(accessor.second.size() == 25); } diff --git a/unittests/util/testUnsignedByteField.cpp b/unittests/util/testUnsignedByteField.cpp index 83ffd3c6..df1ff483 100644 --- a/unittests/util/testUnsignedByteField.cpp +++ b/unittests/util/testUnsignedByteField.cpp @@ -27,29 +27,28 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { } SECTION("Serialize U32") { - CHECK(testByteField.serializeBe(buf.data(), serLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + CHECK(testByteField.serializeBe(buf.data(), serLen, buf.size()) == returnvalue::OK); CHECK(serLen == 4); CHECK(buf[0] == 0); CHECK(buf[3] == 10); } SECTION("Serialize U32 Concrete") { - CHECK(u32ByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(u32ByteField.serializeBe(buf.data(), serLen, buf.size()) == returnvalue::OK); CHECK(serLen == 4); CHECK(buf[0] == 0); CHECK(buf[3] == 10); } SECTION("Serialize U16 Concrete") { - CHECK(u16ByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(u16ByteField.serializeBe(buf.data(), serLen, buf.size()) == returnvalue::OK); CHECK(serLen == 2); CHECK(buf[0] == 0); CHECK(buf[1] == 5); } SECTION("Serialize U8 Concrete") { - CHECK(u8ByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(u8ByteField.serializeBe(buf.data(), serLen, buf.size()) == returnvalue::OK); CHECK(serLen == 1); CHECK(buf[0] == 2); } @@ -60,8 +59,7 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { buf[2] = 0x30; buf[3] = 0x20; size_t deserLen = 0; - CHECK(testByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + CHECK(testByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == returnvalue::OK); CHECK(testByteField.getValue() == 0x50403020); } @@ -69,8 +67,7 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { buf[0] = 0x50; buf[1] = 0x40; size_t deserLen = 0; - CHECK(u16ByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == - HasReturnvaluesIF::RETURN_OK); + CHECK(u16ByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == returnvalue::OK); CHECK(u16ByteField.getValue() == 0x5040); } } \ No newline at end of file From fc34d562398c1bb5db9c3fae3487340e30e528bf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 Aug 2022 01:12:50 +0200 Subject: [PATCH 237/532] cicd fix --- unittests/util/testUnsignedByteField.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/unittests/util/testUnsignedByteField.cpp b/unittests/util/testUnsignedByteField.cpp index 9a67c092..e6d91ab9 100644 --- a/unittests/util/testUnsignedByteField.cpp +++ b/unittests/util/testUnsignedByteField.cpp @@ -28,28 +28,28 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { } SECTION("Serialize U32") { - CHECK(testByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(testByteField.serializeBe(buf.data(), serLen, buf.size()) == returnvalue::OK); CHECK(serLen == 4); CHECK(buf[0] == 0); CHECK(buf[3] == 10); } SECTION("Serialize U32 Concrete") { - CHECK(u32ByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(u32ByteField.serializeBe(buf.data(), serLen, buf.size()) == returnvalue::OK); CHECK(serLen == 4); CHECK(buf[0] == 0); CHECK(buf[3] == 10); } SECTION("Serialize U16 Concrete") { - CHECK(u16ByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(u16ByteField.serializeBe(buf.data(), serLen, buf.size()) == returnvalue::OK); CHECK(serLen == 2); CHECK(buf[0] == 0); CHECK(buf[1] == 5); } SECTION("Serialize U8 Concrete") { - CHECK(u8ByteField.serializeBe(buf.data(), serLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(u8ByteField.serializeBe(buf.data(), serLen, buf.size()) == returnvalue::OK); CHECK(serLen == 1); CHECK(buf[0] == 2); } @@ -60,7 +60,7 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { buf[2] = 0x30; buf[3] = 0x20; size_t deserLen = 0; - CHECK(testByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(testByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == returnvalue::OK); CHECK(testByteField.getValue() == 0x50403020); } @@ -68,7 +68,7 @@ TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { buf[0] = 0x50; buf[1] = 0x40; size_t deserLen = 0; - CHECK(u16ByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == HasReturnvaluesIF::RETURN_OK); + CHECK(u16ByteField.deSerializeBe(buf.data(), deserLen, buf.size()) == returnvalue::OK); CHECK(u16ByteField.getValue() == 0x5040); } } \ No newline at end of file From f63f3fa5645bbdec8bd5dfd7823c9bfd0df784cb Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 16 Aug 2022 12:12:21 +0200 Subject: [PATCH 238/532] more occurences in comments --- CHANGELOG.md | 2 +- docs/README-localpools.md | 4 +-- docs/devicehandlers.rst | 12 +++---- docs/localpools.rst | 4 +-- src/fsfw/action/ActionHelper.h | 6 ++-- src/fsfw/action/HasActionsIF.h | 2 +- src/fsfw/cfdp/pdu/HeaderDeserializer.h | 2 +- src/fsfw/cfdp/tlv/Tlv.h | 4 +-- src/fsfw/container/ArrayList.h | 2 +- src/fsfw/container/FIFOBase.h | 8 ++--- src/fsfw/container/FixedOrderedMultimap.h | 12 +++---- src/fsfw/container/PlacementFactory.h | 2 +- src/fsfw/container/SimpleRingBuffer.h | 4 +-- src/fsfw/datalinklayer/DataLinkLayer.h | 12 +++---- src/fsfw/datalinklayer/Farm1StateOpen.h | 2 +- src/fsfw/datalinklayer/MapPacketExtraction.h | 4 +-- .../datalinklayer/VirtualChannelReception.h | 6 ++-- .../datalinklayer/VirtualChannelReceptionIF.h | 4 +-- src/fsfw/datapool/PoolDataSetBase.h | 8 ++--- src/fsfw/devicehandlers/AssemblyBase.h | 2 +- .../devicehandlers/DeviceCommunicationIF.h | 10 +++--- src/fsfw/devicehandlers/DeviceHandlerBase.h | 36 +++++++++---------- src/fsfw/globalfunctions/DleEncoder.h | 4 +-- src/fsfw/health/HealthHelper.h | 4 +-- src/fsfw/ipc/MessageQueueIF.h | 12 +++---- src/fsfw/objectmanager/ObjectManagerIF.h | 4 +-- src/fsfw/objectmanager/SystemObjectIF.h | 4 +-- src/fsfw/osal/freertos/BinSemaphUsingTask.h | 6 ++-- src/fsfw/osal/freertos/BinarySemaphore.h | 10 +++--- .../osal/freertos/CountingSemaphUsingTask.h | 10 +++--- src/fsfw/osal/linux/BinarySemaphore.h | 4 +-- src/fsfw/parameters/ParameterWrapper.h | 2 +- src/fsfw/pus/Service11TelecommandScheduling.h | 14 ++++---- src/fsfw/returnvalues/HasReturnvaluesIF.h | 2 +- src/fsfw/rmap/RMAPChannelIF.h | 4 +-- src/fsfw/rmap/RmapDeviceCommunicationIF.h | 10 +++--- src/fsfw/serialize/SerializeAdapter.h | 8 ++--- src/fsfw/serialize/SerializeIF.h | 4 +-- src/fsfw/storagemanager/LocalPool.h | 6 ++-- src/fsfw/storagemanager/StorageManagerIF.h | 10 +++--- src/fsfw/subsystem/SubsystemBase.cpp | 6 ++-- src/fsfw/subsystem/SubsystemBase.h | 2 +- src/fsfw/tasks/FixedSlotSequence.cpp | 2 +- src/fsfw/tasks/PeriodicTaskIF.h | 4 +-- src/fsfw/tasks/SemaphoreIF.h | 4 +-- src/fsfw/tcdistribution/CCSDSDistributorIF.h | 4 +-- src/fsfw/tcdistribution/CFDPDistributor.cpp | 6 ++-- src/fsfw/tcdistribution/CFDPDistributorIF.h | 2 +- src/fsfw/tcdistribution/PUSDistributorIF.h | 2 +- src/fsfw/tcdistribution/TcDistributor.h | 4 +-- src/fsfw/tcdistribution/TcPacketCheckIF.h | 2 +- src/fsfw/timemanager/CCSDSTime.h | 10 +++--- src/fsfw/timemanager/Clock.h | 26 +++++++------- src/fsfw/tmstorage/TmStoreFrontendIF.h | 2 +- .../tmtcpacket/RedirectableDataPointerIF.h | 2 +- src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h | 2 +- .../tmtcpacket/pus/tc/TcPacketStoredBase.h | 2 +- src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h | 2 +- .../tmtcservices/CommandingServiceBase.cpp | 2 +- src/fsfw/tmtcservices/CommandingServiceBase.h | 10 +++--- src/fsfw/tmtcservices/PusServiceBase.h | 6 ++-- src/fsfw/tmtcservices/SpacePacketParser.h | 4 +-- src/fsfw/tmtcservices/TmTcBridge.h | 4 +-- src/fsfw_hal/common/gpio/GpioIF.h | 2 +- src/fsfw_hal/linux/CommandExecutor.h | 6 ++-- src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h | 2 +- src/fsfw_hal/linux/i2c/I2cComIF.h | 2 +- .../integration/assemblies/TestAssembly.h | 2 +- 68 files changed, 195 insertions(+), 195 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22699114..1c78318c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - HAL Devicehandlers: Periodic printout is run-time configurable now - `oneShotAction` flag in the `TestTask` class is not static anymore - `SimpleRingBuffer::writeData` now checks if the amount is larger than the total size of the - Buffer and rejects such writeData calls with `HasReturnvaluesIF::RETURN_FAILED` + Buffer and rejects such writeData calls with `returnvalue::FAILED` PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/586 - Major update for version handling, using `git describe` to fetch version information with git. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/601 diff --git a/docs/README-localpools.md b/docs/README-localpools.md index 2ee75189..1770efb9 100644 --- a/docs/README-localpools.md +++ b/docs/README-localpools.md @@ -144,7 +144,7 @@ ReturnValue_t GyroHandler::initializeLocalDataPool(localpool::DataPool &localDat new PoolEntry({0})); poolManager.subscribeForPeriodicPacket(gyroData.getSid(), false, 4.0, false); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ``` @@ -154,7 +154,7 @@ in any case: ```cpp PoolReadGuard readHelper(&gyroData); -if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) { +if(readHelper.getReadResult() == returnvalue::OK) { if(not gyroData.isValid()) { gyroData.setValidity(true, true); } diff --git a/docs/devicehandlers.rst b/docs/devicehandlers.rst index 0008edb3..9c6929e8 100644 --- a/docs/devicehandlers.rst +++ b/docs/devicehandlers.rst @@ -75,11 +75,11 @@ and the respective source file with sensible default return values: void TestDeviceHandler::doShutDown() {} ReturnValue_t TestDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void TestDeviceHandler::fillCommandAndReplyMap() {} @@ -87,17 +87,17 @@ and the respective source file with sensible default return values: ReturnValue_t TestDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, size_t commandDataLen) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } uint32_t TestDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { @@ -106,5 +106,5 @@ and the respective source file with sensible default return values: ReturnValue_t TestDeviceHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/docs/localpools.rst b/docs/localpools.rst index d2afd0a0..f7e1ca47 100644 --- a/docs/localpools.rst +++ b/docs/localpools.rst @@ -150,7 +150,7 @@ with a housekeeping service command. new PoolEntry({0})); poolManager.subscribeForPeriodicPacket(gyroData.getSid(), false, 4.0, false); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } Now, if we receive some sensor data and converted them into the right format, @@ -160,7 +160,7 @@ in any case: .. code-block:: cpp PoolReadGuard readHelper(&gyroData); - if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) { + if(readHelper.getReadResult() == returnvalue::OK) { if(not gyroData.isValid()) { gyroData.setValidity(true, true); } diff --git a/src/fsfw/action/ActionHelper.h b/src/fsfw/action/ActionHelper.h index 16abb212..4bcecbae 100644 --- a/src/fsfw/action/ActionHelper.h +++ b/src/fsfw/action/ActionHelper.h @@ -45,7 +45,7 @@ class ActionHelper { * helper function * @param queueToUse_ Pointer to the messageQueue to be used, optional * if queue was set in constructor - * @return Returns RETURN_OK if successful + * @return Returns returnvalue::OK if successful */ ReturnValue_t initialize(MessageQueueIF* queueToUse_ = nullptr); /** @@ -75,7 +75,7 @@ class ActionHelper { * message to * @param replyId ID of the executed command * @param data Pointer to the data - * @return Returns RETURN_OK if successful, otherwise failure code + * @return Returns returnvalue::OK if successful, otherwise failure code */ ReturnValue_t reportData(MessageQueueId_t reportTo, ActionId_t replyId, SerializeIF* data, bool hideSender = false); @@ -86,7 +86,7 @@ class ActionHelper { * message to * @param replyId ID of the executed command * @param data Pointer to the data - * @return Returns RETURN_OK if successful, otherwise failure code + * @return Returns returnvalue::OK if successful, otherwise failure code */ ReturnValue_t reportData(MessageQueueId_t reportTo, ActionId_t replyId, const uint8_t* data, size_t dataSize, bool hideSender = false); diff --git a/src/fsfw/action/HasActionsIF.h b/src/fsfw/action/HasActionsIF.h index 89e58add..45247d1a 100644 --- a/src/fsfw/action/HasActionsIF.h +++ b/src/fsfw/action/HasActionsIF.h @@ -53,7 +53,7 @@ class HasActionsIF { * * @return * -@c EXECUTION_FINISHED Finish reply will be generated - * -@c Not RETURN_OK Step failure reply will be generated + * -@c Not returnvalue::OK Step failure reply will be generated */ virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) = 0; diff --git a/src/fsfw/cfdp/pdu/HeaderDeserializer.h b/src/fsfw/cfdp/pdu/HeaderDeserializer.h index 70a7908c..4c237117 100644 --- a/src/fsfw/cfdp/pdu/HeaderDeserializer.h +++ b/src/fsfw/cfdp/pdu/HeaderDeserializer.h @@ -36,7 +36,7 @@ class HeaderDeserializer : public RedirectableDataPointerIF, public PduHeaderIF /** * This needs to be called before accessing the PDU fields to avoid segmentation faults. * @return - * - RETURN_OK on parse success + * - returnvalue::OK on parse success * - returnvalue::FAILED Invalid raw data * - SerializeIF::BUFFER_TOO_SHORT if buffer is shorter than expected */ diff --git a/src/fsfw/cfdp/tlv/Tlv.h b/src/fsfw/cfdp/tlv/Tlv.h index a67c6dd1..dded5652 100644 --- a/src/fsfw/cfdp/tlv/Tlv.h +++ b/src/fsfw/cfdp/tlv/Tlv.h @@ -23,7 +23,7 @@ class Tlv : public TlvIF { * @param maxSize * @param streamEndianness * @return - * - RETURN_OK on success + * - returnvalue::OK on success * - INVALID_TLV_TYPE * - SerializeIF returncode on wrong serialization parameters */ @@ -37,7 +37,7 @@ class Tlv : public TlvIF { * @param buffer Raw buffer including the size field * @param size * @param streamEndianness - * - RETURN_OK on success + * - returnvalue::OK on success * - INVALID_TLV_TYPE * - SerializeIF returncode on wrong deserialization parameters */ diff --git a/src/fsfw/container/ArrayList.h b/src/fsfw/container/ArrayList.h index 522ddf3b..608e7e55 100644 --- a/src/fsfw/container/ArrayList.h +++ b/src/fsfw/container/ArrayList.h @@ -183,7 +183,7 @@ class ArrayList { * @param entry * @return * -@c FULL if the List is full - * -@c RETURN_OK else + * -@c returnvalue::OK else */ ReturnValue_t insert(T entry) { if (size >= maxSize_) { diff --git a/src/fsfw/container/FIFOBase.h b/src/fsfw/container/FIFOBase.h index 25c75515..7c51bc39 100644 --- a/src/fsfw/container/FIFOBase.h +++ b/src/fsfw/container/FIFOBase.h @@ -20,24 +20,24 @@ class FIFOBase { /** * Insert value into FIFO * @param value - * @return RETURN_OK on success, FULL if full + * @return returnvalue::OK on success, FULL if full */ ReturnValue_t insert(T value); /** * Retrieve item from FIFO. This removes the item from the FIFO. * @param value Must point to a valid T - * @return RETURN_OK on success, EMPTY if empty and FAILED if nullptr check failed + * @return returnvalue::OK on success, EMPTY if empty and FAILED if nullptr check failed */ ReturnValue_t retrieve(T* value); /** * Retrieve item from FIFO without removing it from FIFO. * @param value Must point to a valid T - * @return RETURN_OK on success, EMPTY if empty and FAILED if nullptr check failed + * @return returnvalue::OK on success, EMPTY if empty and FAILED if nullptr check failed */ ReturnValue_t peek(T* value); /** * Remove item from FIFO. - * @return RETURN_OK on success, EMPTY if empty + * @return returnvalue::OK on success, EMPTY if empty */ ReturnValue_t pop(); diff --git a/src/fsfw/container/FixedOrderedMultimap.h b/src/fsfw/container/FixedOrderedMultimap.h index f402d622..73b010ed 100644 --- a/src/fsfw/container/FixedOrderedMultimap.h +++ b/src/fsfw/container/FixedOrderedMultimap.h @@ -100,7 +100,7 @@ class FixedOrderedMultimap { * @param[in] value Value of the new element * @param[in/out] (optional) storedValue On success this points to the new value, otherwise a * nullptr - * @return RETURN_OK if insert was successful, MAP_FULL if no space is available + * @return returnvalue::OK if insert was successful, MAP_FULL if no space is available */ ReturnValue_t insert(key_t key, T value, Iterator* storedValue = nullptr); @@ -108,14 +108,14 @@ class FixedOrderedMultimap { * Used to insert new pair instead of single values * * @param pair Pair to be inserted - * @return RETURN_OK if insert was successful, MAP_FULL if no space is available + * @return returnvalue::OK if insert was successful, MAP_FULL if no space is available */ ReturnValue_t insert(std::pair pair); /*** * Can be used to check if a certain key is in the map * @param key Key to be checked - * @return RETURN_OK if the key exists KEY_DOES_NOT_EXIST otherwise + * @return returnvalue::OK if the key exists KEY_DOES_NOT_EXIST otherwise */ ReturnValue_t exists(key_t key) const; @@ -127,14 +127,14 @@ class FixedOrderedMultimap { * * @warning The iterator needs to be valid and dereferenceable * @param[in/out] iter Pointer to iterator to the element that needs to be ereased - * @return RETURN_OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this + * @return returnvalue::OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this */ ReturnValue_t erase(Iterator* iter); /*** * Used to erase by key * @param key Key to be erased - * @return RETURN_OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this + * @return returnvalue::OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this */ ReturnValue_t erase(key_t key); @@ -160,7 +160,7 @@ class FixedOrderedMultimap { * * @param key Key to search for * @param value Found value - * @return RETURN_OK if it points to the value, + * @return returnvalue::OK if it points to the value, * KEY_DOES_NOT_EXIST if the key is not in the map */ ReturnValue_t find(key_t key, T** value) const; diff --git a/src/fsfw/container/PlacementFactory.h b/src/fsfw/container/PlacementFactory.h index e59fc134..668e71b8 100644 --- a/src/fsfw/container/PlacementFactory.h +++ b/src/fsfw/container/PlacementFactory.h @@ -51,7 +51,7 @@ class PlacementFactory { * This must be called by the user. * * @param thisElement Element to be destroyed - * @return RETURN_OK if the element was destroyed, different errors on failure + * @return returnvalue::OK if the element was destroyed, different errors on failure */ template ReturnValue_t destroy(T* thisElement) { diff --git a/src/fsfw/container/SimpleRingBuffer.h b/src/fsfw/container/SimpleRingBuffer.h index 7495e31c..a9892c0c 100644 --- a/src/fsfw/container/SimpleRingBuffer.h +++ b/src/fsfw/container/SimpleRingBuffer.h @@ -47,7 +47,7 @@ class SimpleRingBuffer : public RingBufferBase<> { * Write to circular buffer and increment write pointer by amount. * @param data * @param amount - * @return -@c RETURN_OK if write operation was successful + * @return -@c returnvalue::OK if write operation was successful * -@c returnvalue::FAILED if */ ReturnValue_t writeData(const uint8_t* data, size_t amount); @@ -95,7 +95,7 @@ class SimpleRingBuffer : public RingBufferBase<> { * If readRemaining was set to true, the true amount read will be assigned * to the passed value. * @return - * - @c RETURN_OK if data was read successfully + * - @c returnvalue::OK if data was read successfully * - @c returnvalue::FAILED if not enough data was available and readRemaining * was set to false. */ diff --git a/src/fsfw/datalinklayer/DataLinkLayer.h b/src/fsfw/datalinklayer/DataLinkLayer.h index 64d33016..64d2f96b 100644 --- a/src/fsfw/datalinklayer/DataLinkLayer.h +++ b/src/fsfw/datalinklayer/DataLinkLayer.h @@ -51,7 +51,7 @@ class DataLinkLayer : public CCSDSReturnValuesIF { * This method tries to process a frame that is placed in #frameBuffer. * The procedures described in the Standard are performed. * @param length Length of the incoming frame candidate. - * @return @c RETURN_OK on successful handling, otherwise the return codes of the higher + * @return @c returnvalue::OK on successful handling, otherwise the return codes of the higher * methods. */ ReturnValue_t processFrame(uint16_t length); @@ -61,12 +61,12 @@ class DataLinkLayer : public CCSDSReturnValuesIF { * handle Frames directed to this VC. * @param virtualChannelId Id of the VC. Shall be smaller than 64. * @param object Reference to the object that handles the Frame. - * @return @c RETURN_OK on success, @c returnvalue::FAILED otherwise. + * @return @c returnvalue::OK on success, @c returnvalue::FAILED otherwise. */ ReturnValue_t addVirtualChannel(uint8_t virtualChannelId, VirtualChannelReceptionIF* object); /** * The initialization method calls the @c initialize routine of all virtual channels. - * @return The return code of the first failed VC initialization or @c RETURN_OK. + * @return The return code of the first failed VC initialization or @c returnvalue::OK. */ ReturnValue_t initialize(); @@ -91,19 +91,19 @@ class DataLinkLayer : public CCSDSReturnValuesIF { virtualChannels; //!< Map of all virtual channels assigned. /** * Method that performs all possible frame validity checks (as specified). - * @return Various error codes or @c RETURN_OK on success. + * @return Various error codes or @c returnvalue::OK on success. */ ReturnValue_t frameValidationCheck(); /** * First method to call. * Removes start sequence bytes and checks if the complete frame was received. * SHOULDDO: Maybe handling the start sequence must be done more variable. - * @return @c RETURN_OK or @c TOO_SHORT. + * @return @c returnvalue::OK or @c TOO_SHORT. */ ReturnValue_t frameDelimitingAndFillRemoval(); /** * Small helper method to check the CRC of the Frame. - * @return @c RETURN_OK or @c CRC_FAILED. + * @return @c returnvalue::OK or @c CRC_FAILED. */ ReturnValue_t frameCheckCRC(); /** diff --git a/src/fsfw/datalinklayer/Farm1StateOpen.h b/src/fsfw/datalinklayer/Farm1StateOpen.h index 0bca931d..f0a8ad40 100644 --- a/src/fsfw/datalinklayer/Farm1StateOpen.h +++ b/src/fsfw/datalinklayer/Farm1StateOpen.h @@ -37,7 +37,7 @@ class Farm1StateOpen : public Farm1StateIF { * change to Farm1StateLockout. * @param frame The frame to handle. * @param clcw Any changes to the CLCW shall be done with the help of this interface. - * @return If the Sequence Number is ok, it returns #RETURN_OK. Otherwise either #NS_POSITIVE_W, + * @return If the Sequence Number is ok, it returns returnvalue::OK. Otherwise either #NS_POSITIVE_W, * #NS_NEGATIVE_W or NS_LOCKOUT is returned. */ ReturnValue_t handleADFrame(TcTransferFrame* frame, ClcwIF* clcw); diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.h b/src/fsfw/datalinklayer/MapPacketExtraction.h index 54faaf04..6586722c 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.h +++ b/src/fsfw/datalinklayer/MapPacketExtraction.h @@ -36,7 +36,7 @@ class MapPacketExtraction : public MapPacketExtractionIF { * Method that is called if the segmentation flag is @c NO_SEGMENTATION. * The method extracts one or more packets within the frame and forwards them to the OBSW. * @param frame The TC Transfer Frame to work on. - * @return @c RETURN_OK if all Packets were extracted. If something is entirely wrong, + * @return @c returnvalue::OK if all Packets were extracted. If something is entirely wrong, * @c DATA_CORRUPTED is returned, if some bytes are left over @c RESIDUAL_DATA. */ ReturnValue_t unpackBlockingPackets(TcTransferFrame* frame); @@ -63,7 +63,7 @@ class MapPacketExtraction : public MapPacketExtractionIF { ReturnValue_t extractPackets(TcTransferFrame* frame); /** * The #packetStore and the default destination of #tcQueue are initialized here. - * @return @c RETURN_OK on success, @c returnvalue::FAILED otherwise. + * @return @c returnvalue::OK on success, @c returnvalue::FAILED otherwise. */ ReturnValue_t initialize(); /** diff --git a/src/fsfw/datalinklayer/VirtualChannelReception.h b/src/fsfw/datalinklayer/VirtualChannelReception.h index d425123a..88ec6886 100644 --- a/src/fsfw/datalinklayer/VirtualChannelReception.h +++ b/src/fsfw/datalinklayer/VirtualChannelReception.h @@ -77,7 +77,7 @@ class VirtualChannelReception : public VirtualChannelReceptionIF, public CCSDSRe * required. * @param frame The Tc Transfer Frame to handle. * @param clcw Any changes on the CLCW shall be done with this method. - * @return Always returns @c RETURN_OK. + * @return Always returns @c returnvalue::OK. */ ReturnValue_t handleBDFrame(TcTransferFrame* frame, ClcwIF* clcw); /** @@ -102,13 +102,13 @@ class VirtualChannelReception : public VirtualChannelReceptionIF, public CCSDSRe * Helper method to simplify adding a mapChannel during construction. * @param mapId The mapId of the object to add. * @param object Pointer to the MapPacketExtraction object itself. - * @return @c RETURN_OK if the channel was successfully inserted, @c returnvalue::FAILED otherwise. + * @return @c returnvalue::OK if the channel was successfully inserted, @c returnvalue::FAILED otherwise. */ ReturnValue_t addMapChannel(uint8_t mapId, MapPacketExtractionIF* object); /** * The initialization routine checks the set #slidingWindowWidth and initializes all MAP * channels. - * @return @c RETURN_OK on successful initialization, @c returnvalue::FAILED otherwise. + * @return @c returnvalue::OK on successful initialization, @c returnvalue::FAILED otherwise. */ ReturnValue_t initialize(); /** diff --git a/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h b/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h index 3426f21c..8874909b 100644 --- a/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h +++ b/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h @@ -33,13 +33,13 @@ class VirtualChannelReceptionIF { * Handling the Frame includes forwarding to higher-level procedures. * @param frame The Tc Transfer Frame that was received and checked. * @param clcw Any changes to the CLCW value are forwarded by using this parameter. - * @return The return Value shall indicate successful processing with @c RETURN_OK. + * @return The return Value shall indicate successful processing with @c returnvalue::OK. */ virtual ReturnValue_t frameAcceptanceAndReportingMechanism(TcTransferFrame* frame, ClcwIF* clcw) = 0; /** * If any other System Objects are required for operation they shall be initialized here. - * @return @c RETURN_OK for successful initialization. + * @return @c returnvalue::OK for successful initialization. */ virtual ReturnValue_t initialize() = 0; /** diff --git a/src/fsfw/datapool/PoolDataSetBase.h b/src/fsfw/datapool/PoolDataSetBase.h index 79a1095b..3e7e30c5 100644 --- a/src/fsfw/datapool/PoolDataSetBase.h +++ b/src/fsfw/datapool/PoolDataSetBase.h @@ -58,7 +58,7 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF { * freed afterwards. It is mandatory to call commit after a read call, * even if the read operation is not successful! * @return - * - @c RETURN_OK if all variables were read successfully. + * - @c returnvalue::OK if all variables were read successfully. * - @c INVALID_PARAMETER_DEFINITION if a pool entry does not exist or there * is a type conflict. * - @c SET_WAS_ALREADY_READ if read() is called twice without calling @@ -80,7 +80,7 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF { * commit() can only be called after read(). If the set only contains * variables which are write only, commit() can be called without a * preceding read() call. Every read call must be followed by a commit call! - * @return - @c RETURN_OK if all variables were read successfully. + * @return - @c returnvalue::OK if all variables were read successfully. * - @c COMMITING_WITHOUT_READING if set was not read yet and * contains non write-only variables */ @@ -97,7 +97,7 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF { /** * Provides the means to lock the underlying data structure to ensure * thread-safety. Default implementation is empty - * @return Always returns -@c RETURN_OK + * @return Always returns -@c returnvalue::OK */ virtual ReturnValue_t lockDataPool( MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, @@ -105,7 +105,7 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF { /** * Provides the means to unlock the underlying data structure to ensure * thread-safety. Default implementation is empty - * @return Always returns -@c RETURN_OK + * @return Always returns -@c returnvalue::OK */ virtual ReturnValue_t unlockDataPool() override; diff --git a/src/fsfw/devicehandlers/AssemblyBase.h b/src/fsfw/devicehandlers/AssemblyBase.h index 92feb6ae..ec0847f1 100644 --- a/src/fsfw/devicehandlers/AssemblyBase.h +++ b/src/fsfw/devicehandlers/AssemblyBase.h @@ -53,7 +53,7 @@ class AssemblyBase : public SubsystemBase { * @param mode * @param submode * @return - * - @c RETURN_OK if ok + * - @c returnvalue::OK if ok * - @c NEED_SECOND_STEP if children need to be commanded again */ virtual ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) = 0; diff --git a/src/fsfw/devicehandlers/DeviceCommunicationIF.h b/src/fsfw/devicehandlers/DeviceCommunicationIF.h index 5af3f3f0..cf00a8e2 100644 --- a/src/fsfw/devicehandlers/DeviceCommunicationIF.h +++ b/src/fsfw/devicehandlers/DeviceCommunicationIF.h @@ -61,7 +61,7 @@ class DeviceCommunicationIF { * initialization. * @param cookie * @return - * - @c RETURN_OK if initialization was successfull + * - @c returnvalue::OK if initialization was successfull * - Everything else triggers failure event with returnvalue as parameter 1 */ virtual ReturnValue_t initializeInterface(CookieIF *cookie) = 0; @@ -74,7 +74,7 @@ class DeviceCommunicationIF { * @param data * @param len If this is 0, nothing shall be sent. * @return - * - @c RETURN_OK for successfull send + * - @c returnvalue::OK for successfull send * - Everything else triggers failure event with returnvalue as parameter 1 */ virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen) = 0; @@ -84,7 +84,7 @@ class DeviceCommunicationIF { * Get send confirmation that the data in sendMessage() was sent successfully. * @param cookie * @return - * - @c RETURN_OK if data was sent successfully but a reply is expected + * - @c returnvalue::OK if data was sent successfully but a reply is expected * - NO_REPLY_EXPECTED if data was sent successfully and no reply is expected * - Everything else to indicate failure */ @@ -99,7 +99,7 @@ class DeviceCommunicationIF { * * @param cookie * @param requestLen Size of data to read - * @return - @c RETURN_OK to confirm the request for data has been sent. + * @return - @c returnvalue::OK to confirm the request for data has been sent. * - Everything else triggers failure event with * returnvalue as parameter 1 */ @@ -113,7 +113,7 @@ class DeviceCommunicationIF { * @param buffer [out] Set reply here (by using *buffer = ...) * @param size [out] size pointer to set (by using *size = ...). * Set to 0 if no reply was received - * @return - @c RETURN_OK for successfull receive + * @return - @c returnvalue::OK for successfull receive * - @c NO_REPLY_RECEIVED if not reply was received. Setting size to * 0 has the same effect * - Everything else triggers failure event with diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 35a33eab..a37a4740 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -144,7 +144,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * 4. Decrements counter for timeout of replies by calling * decrementDeviceReplyMap() * 5. Performs FDIR check for failures - * 6. If the device mode is MODE_OFF, return RETURN_OK. + * 6. If the device mode is MODE_OFF, return returnvalue::OK. * Otherwise, perform the Action property and performs depending * on value specified by input value counter (incremented in PST). * The child class tells base class what to do by setting this value. @@ -160,7 +160,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * - GET_READ: Access requested reading data by calling doGetRead() * which calls readReceivedMessage of #communicationInterface * @param counter Specifies which Action to perform - * @return RETURN_OK for successful execution + * @return returnvalue::OK for successful execution */ virtual ReturnValue_t performOperation(uint8_t counter) override; @@ -281,7 +281,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * * @param[out] id the device command id that has been built * @return - * - @c RETURN_OK to send command after setting #rawPacket and + * - @c returnvalue::OK to send command after setting #rawPacket and * #rawPacketLen. * - @c NOTHING_TO_SEND when no command is to be sent. * - Anything else triggers an even with the returnvalue as a parameter. @@ -305,7 +305,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * * @param[out] id the device command id built * @return - * - @c RETURN_OK when a command is to be sent + * - @c returnvalue::OK when a command is to be sent * - @c NOTHING_TO_SEND when no command is to be sent * - Anything else triggers an even with the returnvalue as a parameter */ @@ -327,7 +327,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param commandData Pointer to the data from the direct command * @param commandDataLen Length of commandData * @return - * - @c RETURN_OK to send command after #rawPacket and #rawPacketLen + * - @c returnvalue::OK to send command after #rawPacket and #rawPacketLen * have been set. * - @c HasActionsIF::EXECUTION_COMPLETE to generate a finish reply immediately. This can * be used if no reply is expected @@ -357,7 +357,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param[out] foundLen length of the data found. Is to be set in function, * buffer is scanned at previous position + foundLen. * @return - * - @c RETURN_OK a valid packet was found at @c start, @c foundLen is valid + * - @c returnvalue::OK a valid packet was found at @c start, @c foundLen is valid * - @c returnvalue::FAILED no reply could be found starting at @c start, * implies @c foundLen is not valid, base class will call scanForReply() * again with ++start @@ -387,7 +387,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param id the id found by scanForReply() * @param packet * @return - * - @c RETURN_OK when the reply was interpreted. + * - @c returnvalue::OK when the reply was interpreted. * - @c IGNORE_REPLY_DATA Ignore the reply and don't reset reply cycle * counter. * - @c returnvalue::FAILED when the reply could not be interpreted, @@ -450,7 +450,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param countdown Instead of using maxDelayCycles to timeout a device reply it is also possible * to provide a pointer to a Countdown object which will signal the timeout * when expired - * @return - @c RETURN_OK when the command was successfully inserted, + * @return - @c returnvalue::OK when the command was successfully inserted, * - @c returnvalue::FAILED else. */ ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, @@ -471,7 +471,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param countdown Instead of using maxDelayCycles to timeout a device reply it is also possible * to provide a pointer to a Countdown object which will signal the timeout * when expired - * @return - @c RETURN_OK when the command was successfully inserted, + * @return - @c returnvalue::OK when the command was successfully inserted, * - @c returnvalue::FAILED else. */ ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, @@ -481,7 +481,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, /** * @brief A simple command to add a command to the commandList. * @param deviceCommand The command to add - * @return - @c RETURN_OK when the command was successfully inserted, + * @return - @c returnvalue::OK when the command was successfully inserted, * - @c returnvalue::FAILED else. */ ReturnValue_t insertInCommandMap(DeviceCommandId_t deviceCommand, @@ -518,7 +518,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param periodic Indicates if the command is periodic (i.e. it is sent * by the device repeatedly without request) or not. Default is aperiodic (0). * Warning: The setting always overrides the value that was entered in the map. - * @return - @c RETURN_OK when the command was successfully inserted, + * @return - @c returnvalue::OK when the command was successfully inserted, * - @c returnvalue::FAILED else. */ ReturnValue_t updateReplyMapEntry(DeviceCommandId_t deviceReply, uint16_t delayCycles, @@ -602,7 +602,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param mode * @param submode * @return - * - @c RETURN_OK if valid + * - @c returnvalue::OK if valid * - @c returnvalue::FAILED if invalid */ virtual ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode); @@ -622,7 +622,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param[out] switches pointer to an array of switches * @param[out] numberOfSwitches length of returned array * @return - * - @c RETURN_OK if the parameters were set + * - @c returnvalue::OK if the parameters were set * - @c returnvalue::FAILED if no switches exist */ virtual ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches); @@ -977,7 +977,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * - A failure code may be returned if something went fundamentally wrong. * * @param deviceCommand - * @return - RETURN_OK if a reply was activated. + * @return - returnvalue::OK if a reply was activated. * - NO_REPLY_EXPECTED if there was no reply found. This is not an * error case as many commands do not expect a reply. */ @@ -1004,7 +1004,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * * @param[out] id the device command id built * @return - * - @c RETURN_OK when a command is to be sent + * - @c returnvalue::OK when a command is to be sent * - not @c NOTHING_TO_SEND when no command is to be sent */ virtual ReturnValue_t buildChildRawCommand(); @@ -1085,7 +1085,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, /** * Checks if current handler state allows reception of external device commands. * Default implementation allows commands only in plain MODE_ON and MODE_NORMAL. - * @return RETURN_OK if commands are accepted, anything else otherwise. + * @return returnvalue::OK if commands are accepted, anything else otherwise. */ virtual ReturnValue_t acceptExternalDeviceCommands(); @@ -1273,9 +1273,9 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param[out] data * @param[out] len * @return - * - @c RETURN_OK @c data is valid + * - @c returnvalue::OK @c data is valid * - @c returnvalue::FAILED IPCStore is nullptr - * - the return value from the IPCStore if it was not @c RETURN_OK + * - the return value from the IPCStore if it was not @c returnvalue::OK */ ReturnValue_t getStorageData(store_address_t storageAddress, uint8_t **data, size_t *len); diff --git a/src/fsfw/globalfunctions/DleEncoder.h b/src/fsfw/globalfunctions/DleEncoder.h index a18527fb..85656b37 100644 --- a/src/fsfw/globalfunctions/DleEncoder.h +++ b/src/fsfw/globalfunctions/DleEncoder.h @@ -72,7 +72,7 @@ class DleEncoder { * @param addStxEtx Adding STX start marker and ETX end marker can be omitted, * if they are added manually * @return - * - RETURN_OK for successful encoding operation + * - returnvalue::OK for successful encoding operation * - STREAM_TOO_SHORT if the destination stream is too short */ ReturnValue_t encode(const uint8_t *sourceStream, size_t sourceLen, uint8_t *destStream, @@ -87,7 +87,7 @@ class DleEncoder { * @param maxDestStreamlen * @param decodedLen * @return - * - RETURN_OK for successful decode operation + * - returnvalue::OK for successful decode operation * - DECODE_ERROR if the source stream is invalid * - STREAM_TOO_SHORT if the destination stream is too short */ diff --git a/src/fsfw/health/HealthHelper.h b/src/fsfw/health/HealthHelper.h index 0b9a9c78..84985559 100644 --- a/src/fsfw/health/HealthHelper.h +++ b/src/fsfw/health/HealthHelper.h @@ -55,7 +55,7 @@ class HealthHelper { * * @param message * @return - * -@c RETURN_OK if the message was handled + * -@c returnvalue::OK if the message was handled * -@c returnvalue::FAILED if the message could not be handled * (ie it was not a @c HEALTH_SET or @c HEALTH_READ message) */ @@ -88,7 +88,7 @@ class HealthHelper { * @param parentQueue The queue ID of the parent object. * Set to 0 if no parent present * @return - * -@c RETURN_OK if the Health Table was found and the object + * -@c returnvalue::OK if the Health Table was found and the object * could be registered * -@c returnvalue::FAILED else */ diff --git a/src/fsfw/ipc/MessageQueueIF.h b/src/fsfw/ipc/MessageQueueIF.h index 9532b2d6..b229747e 100644 --- a/src/fsfw/ipc/MessageQueueIF.h +++ b/src/fsfw/ipc/MessageQueueIF.h @@ -40,7 +40,7 @@ class MessageQueueIF { * @param message * A pointer to a previously created message, which is sent. * @return - * -@c RETURN_OK if ok + * -@c returnvalue::OK if ok * -@c NO_REPLY_PARTNER Should return NO_REPLY_PARTNER if partner was found. */ virtual ReturnValue_t reply(MessageQueueMessageIF* message) = 0; @@ -69,14 +69,14 @@ class MessageQueueIF { * function returns immediately. * @param message * A pointer to a message in which the received data is stored. - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c MessageQueueIF::EMPTY if queue is empty */ virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) = 0; /** * Deletes all pending messages in the queue. * @param count The number of flushed messages. - * @return RETURN_OK on success. + * @return returnvalue::OK on success. */ virtual ReturnValue_t flush(uint32_t* count) = 0; /** @@ -104,7 +104,7 @@ class MessageQueueIF { * @param ignoreFault * If set to true, the internal software fault counter is not incremented * if queue is full (if implemented). - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c MessageQueueIF::FULL if queue is full */ virtual ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message, @@ -136,7 +136,7 @@ class MessageQueueIF { * @param sentFrom * The sentFrom information can be set to inject the sender's queue id * into the message. This variable is set to zero by default. - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c MessageQueueIF::FULL if queue is full */ virtual ReturnValue_t sendToDefaultFrom(MessageQueueMessageIF* message, MessageQueueId_t sentFrom, @@ -148,7 +148,7 @@ class MessageQueueIF { * call of the Implementation class and adds its queue id as * "sentFrom" information. * @param message A pointer to a previously created message, which is sent. - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c MessageQueueIF::FULL if queue is full */ virtual ReturnValue_t sendToDefault(MessageQueueMessageIF* message) = 0; diff --git a/src/fsfw/objectmanager/ObjectManagerIF.h b/src/fsfw/objectmanager/ObjectManagerIF.h index 58ee9ab4..eae35319 100644 --- a/src/fsfw/objectmanager/ObjectManagerIF.h +++ b/src/fsfw/objectmanager/ObjectManagerIF.h @@ -48,14 +48,14 @@ class ObjectManagerIF { * @param id The new id to be added to the list. * @param object A pointer to the object to be added. * @return @li INSERTION_FAILED in case the object could not be inserted. - * @li RETURN_OK in case the object was successfully inserted + * @li returnvalue::OK in case the object was successfully inserted */ virtual ReturnValue_t insert(object_id_t id, SystemObjectIF* object) = 0; /** * @brief With this call, an object is removed from the list. * @param id The object id of the object to be removed. * @return @li NOT_FOUND in case the object was not found - * @li RETURN_OK in case the object was successfully removed + * @li returnvalue::OK in case the object was successfully removed */ virtual ReturnValue_t remove(object_id_t id) = 0; virtual void initialize() = 0; diff --git a/src/fsfw/objectmanager/SystemObjectIF.h b/src/fsfw/objectmanager/SystemObjectIF.h index 02f24837..25065662 100644 --- a/src/fsfw/objectmanager/SystemObjectIF.h +++ b/src/fsfw/objectmanager/SystemObjectIF.h @@ -45,7 +45,7 @@ class SystemObjectIF : public EventReportingProxyIF { * which might not have been built yet. * Therefore, a two-step initialization resolves this problem and prevents * circular dependencies of not-fully initialized objects on start up. - * @return - @c RETURN_OK in case the initialization was successful + * @return - @c returnvalue::OK in case the initialization was successful * - @c returnvalue::FAILED otherwise */ virtual ReturnValue_t initialize() = 0; @@ -54,7 +54,7 @@ class SystemObjectIF : public EventReportingProxyIF { * for operation. * Some objects need certain other objects (or a certain number), to be * registered as children. These checks can be done in this method. - * @return - @c RETURN_OK in case the check was successful + * @return - @c returnvalue::OK in case the check was successful * - @c any other code otherwise */ virtual ReturnValue_t checkObjectConnections() = 0; diff --git a/src/fsfw/osal/freertos/BinSemaphUsingTask.h b/src/fsfw/osal/freertos/BinSemaphUsingTask.h index a88863c9..b29ecdc9 100644 --- a/src/fsfw/osal/freertos/BinSemaphUsingTask.h +++ b/src/fsfw/osal/freertos/BinSemaphUsingTask.h @@ -50,7 +50,7 @@ class BinarySemaphoreUsingTask : public SemaphoreIF, public HasReturnvaluesIF { /** * Same as acquire() with timeout in FreeRTOS ticks. * @param timeoutTicks - * @return - @c RETURN_OK on success + * @return - @c returnvalue::OK on success * - @c returnvalue::FAILED on failure */ ReturnValue_t acquireWithTickTimeout(TimeoutType timeoutType = TimeoutType::BLOCKING, @@ -65,7 +65,7 @@ class BinarySemaphoreUsingTask : public SemaphoreIF, public HasReturnvaluesIF { /** * Wrapper function to give back semaphore from handle * @param semaphore - * @return - @c RETURN_OK on success + * @return - @c returnvalue::OK on success * - @c returnvalue::FAILED on failure */ static ReturnValue_t release(TaskHandle_t taskToNotify); @@ -76,7 +76,7 @@ class BinarySemaphoreUsingTask : public SemaphoreIF, public HasReturnvaluesIF { * @param higherPriorityTaskWoken This will be set to pdPASS if a task with * a higher priority was unblocked. A context switch should be requested * from an ISR if this is the case (see TaskManagement functions) - * @return - @c RETURN_OK on success + * @return - @c returnvalue::OK on success * - @c returnvalue::FAILED on failure */ static ReturnValue_t releaseFromISR(TaskHandle_t taskToNotify, diff --git a/src/fsfw/osal/freertos/BinarySemaphore.h b/src/fsfw/osal/freertos/BinarySemaphore.h index e2ca3c9d..d7fbf351 100644 --- a/src/fsfw/osal/freertos/BinarySemaphore.h +++ b/src/fsfw/osal/freertos/BinarySemaphore.h @@ -47,7 +47,7 @@ class BinarySemaphore : public SemaphoreIF, public HasReturnvaluesIF { * for a maximum of #timeoutMs or until the semaphore is given back, * for example by an ISR or another task. * @param timeoutMs - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_TIMEOUT on timeout */ ReturnValue_t acquire(TimeoutType timeoutType = TimeoutType::BLOCKING, @@ -56,7 +56,7 @@ class BinarySemaphore : public SemaphoreIF, public HasReturnvaluesIF { /** * Same as lockBinarySemaphore() with timeout in FreeRTOS ticks. * @param timeoutTicks - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_TIMEOUT on timeout */ ReturnValue_t acquireWithTickTimeout(TimeoutType timeoutType = TimeoutType::BLOCKING, @@ -64,7 +64,7 @@ class BinarySemaphore : public SemaphoreIF, public HasReturnvaluesIF { /** * Release the binary semaphore. - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_NOT_OWNED if the semaphores is * already available. */ @@ -79,7 +79,7 @@ class BinarySemaphore : public SemaphoreIF, public HasReturnvaluesIF { /** * Wrapper function to give back semaphore from handle * @param semaphore - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_NOT_OWNED if the semaphores is * already available. */ @@ -91,7 +91,7 @@ class BinarySemaphore : public SemaphoreIF, public HasReturnvaluesIF { * @param higherPriorityTaskWoken This will be set to pdPASS if a task with * a higher priority was unblocked. A context switch from an ISR should * then be requested (see TaskManagement functions) - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_NOT_OWNED if the semaphores is * already available. */ diff --git a/src/fsfw/osal/freertos/CountingSemaphUsingTask.h b/src/fsfw/osal/freertos/CountingSemaphUsingTask.h index 86b27267..4426f29b 100644 --- a/src/fsfw/osal/freertos/CountingSemaphUsingTask.h +++ b/src/fsfw/osal/freertos/CountingSemaphUsingTask.h @@ -30,7 +30,7 @@ class CountingSemaphoreUsingTask : public SemaphoreIF { * for a maximum of #timeoutMs or until one is given back, * for example by an ISR or another task. * @param timeoutMs - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_TIMEOUT on timeout */ ReturnValue_t acquire(TimeoutType timeoutType = TimeoutType::BLOCKING, @@ -39,7 +39,7 @@ class CountingSemaphoreUsingTask : public SemaphoreIF { /** * Release a semaphore, increasing the number of available counting * semaphores up to the #maxCount value. - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_NOT_OWNED if #maxCount semaphores are * already available. */ @@ -59,7 +59,7 @@ class CountingSemaphoreUsingTask : public SemaphoreIF { /** * Acquire with a timeout value in ticks * @param timeoutTicks - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_TIMEOUT on timeout */ ReturnValue_t acquireWithTickTimeout(TimeoutType timeoutType = TimeoutType::BLOCKING, @@ -74,7 +74,7 @@ class CountingSemaphoreUsingTask : public SemaphoreIF { /** * Release semaphore of task by supplying task handle * @param taskToNotify - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_NOT_OWNED if #maxCount semaphores are * already available. */ @@ -85,7 +85,7 @@ class CountingSemaphoreUsingTask : public SemaphoreIF { * @param higherPriorityTaskWoken This will be set to pdPASS if a task with * a higher priority was unblocked. A context switch should be requested * from an ISR if this is the case (see TaskManagement functions) - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_NOT_OWNED if #maxCount semaphores are * already available. */ diff --git a/src/fsfw/osal/linux/BinarySemaphore.h b/src/fsfw/osal/linux/BinarySemaphore.h index f75618a6..c7289712 100644 --- a/src/fsfw/osal/linux/BinarySemaphore.h +++ b/src/fsfw/osal/linux/BinarySemaphore.h @@ -45,7 +45,7 @@ class BinarySemaphore : public SemaphoreIF, public HasReturnvaluesIF { * for a maximum of #timeoutMs or until the semaphore is given back, * for example by an ISR or another task. * @param timeoutMs - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_TIMEOUT on timeout */ ReturnValue_t acquire(TimeoutType timeoutType = TimeoutType::BLOCKING, @@ -53,7 +53,7 @@ class BinarySemaphore : public SemaphoreIF, public HasReturnvaluesIF { /** * Release the binary semaphore. - * @return -@c RETURN_OK on success + * @return -@c returnvalue::OK on success * -@c SemaphoreIF::SEMAPHORE_NOT_OWNED if the semaphores is * already available. */ diff --git a/src/fsfw/parameters/ParameterWrapper.h b/src/fsfw/parameters/ParameterWrapper.h index 3b04199a..5a8e20a4 100644 --- a/src/fsfw/parameters/ParameterWrapper.h +++ b/src/fsfw/parameters/ParameterWrapper.h @@ -58,7 +58,7 @@ class ParameterWrapper : public SerializeIF { * @param row * @param column * @return - * -@c RETURN_OK if element was retrieved successfully + * -@c returnvalue::OK if element was retrieved successfully * -@c NOT_SET data has not been set yet * -@c DATATYPE_MISSMATCH Invalid supplied type * -@c OUT_OF_BOUNDS Invalid row and/or column. diff --git a/src/fsfw/pus/Service11TelecommandScheduling.h b/src/fsfw/pus/Service11TelecommandScheduling.h index 0fed8bca..35ae59e0 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.h +++ b/src/fsfw/pus/Service11TelecommandScheduling.h @@ -123,31 +123,31 @@ class Service11TelecommandScheduling final : public PusServiceBase { ReturnValue_t handleResetCommand(); /** * @brief Logic to be performed on an incoming TC[11,4]. - * @return RETURN_OK if successful + * @return returnvalue::OK if successful */ ReturnValue_t doInsertActivity(const uint8_t* data, size_t size); /** * @brief Logic to be performed on an incoming TC[11,5]. - * @return RETURN_OK if successful + * @return returnvalue::OK if successful */ ReturnValue_t doDeleteActivity(const uint8_t* data, size_t size); /** * @brief Logic to be performed on an incoming TC[11,6]. - * @return RETURN_OK if successful + * @return returnvalue::OK if successful */ ReturnValue_t doFilterDeleteActivity(const uint8_t* data, size_t size); /** * @brief Logic to be performed on an incoming TC[11,7]. - * @return RETURN_OK if successful + * @return returnvalue::OK if successful */ ReturnValue_t doTimeshiftActivity(const uint8_t* data, size_t size); /** * @brief Logic to be performed on an incoming TC[11,8]. - * @return RETURN_OK if successful + * @return returnvalue::OK if successful */ ReturnValue_t doFilterTimeshiftActivity(const uint8_t* data, size_t size); @@ -167,7 +167,7 @@ class Service11TelecommandScheduling final : public PusServiceBase { * @param data Pointer to first byte described data * @param dataSize Remaining size of data NOTE: non-const, this is modified by the function * @param [out] requestId Request ID - * @return RETURN_OK if successful + * @return returnvalue::OK if successful */ ReturnValue_t getRequestIdFromData(const uint8_t*& data, size_t& dataSize, uint64_t& requestId); @@ -186,7 +186,7 @@ class Service11TelecommandScheduling final : public PusServiceBase { * @param dataSize TC data size * @param [out] itBegin Begin of filter range * @param [out] itEnd End of filter range - * @return RETURN_OK if successful + * @return returnvalue::OK if successful */ ReturnValue_t getMapFilterFromData(const uint8_t*& data, size_t& size, TcMapIter& itBegin, TcMapIter& itEnd); diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/HasReturnvaluesIF.h index 45574056..79a0d9bd 100644 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ b/src/fsfw/returnvalues/HasReturnvaluesIF.h @@ -17,7 +17,7 @@ namespace returnvalue { /** * It is discouraged to use the input parameters 0,0 and 0,1 as this - * will generate the RETURN_OK and returnvalue::FAILED returnvalues. + * will generate the returnvalue::OK and returnvalue::FAILED returnvalues. * @param interfaceId * @param number * @return diff --git a/src/fsfw/rmap/RMAPChannelIF.h b/src/fsfw/rmap/RMAPChannelIF.h index 9e666dfb..aea08c86 100644 --- a/src/fsfw/rmap/RMAPChannelIF.h +++ b/src/fsfw/rmap/RMAPChannelIF.h @@ -21,7 +21,7 @@ class RMAPChannelIF { * @return * - @c LINK_DOWN when the link is down and all replies were missed * - @c COMMAND_CHANNEL_DEACTIVATED if the channel's port is NULL - * - @c RETURN_OK else + * - @c returnvalue::OK else */ virtual ReturnValue_t reset() = 0; @@ -72,7 +72,7 @@ class RMAPChannelIF { * @param data data to be sent * @param datalen length of data * @return - * - @c RETURN_OK + * - @c returnvalue::OK * - @c COMMAND_NO_DESCRIPTORS_AVAILABLE no descriptors available for sending * command; command was not sent * - @c COMMAND_BUFFER_FULL no receiver buffer available for diff --git a/src/fsfw/rmap/RmapDeviceCommunicationIF.h b/src/fsfw/rmap/RmapDeviceCommunicationIF.h index abe94685..9bbf8466 100644 --- a/src/fsfw/rmap/RmapDeviceCommunicationIF.h +++ b/src/fsfw/rmap/RmapDeviceCommunicationIF.h @@ -25,7 +25,7 @@ class RmapDeviceCommunicationIF : public DeviceCommunicationIF { * this can be performed in this function, which is called on device handler * initialization. * @param cookie - * @return -@c RETURN_OK if initialization was successfull + * @return -@c returnvalue::OK if initialization was successfull * - Everything else triggers failure event with returnvalue as parameter 1 */ virtual ReturnValue_t initializeInterface(CookieIF *cookie) = 0; @@ -37,7 +37,7 @@ class RmapDeviceCommunicationIF : public DeviceCommunicationIF { * @param cookie * @param data * @param len - * @return -@c RETURN_OK for successfull send + * @return -@c returnvalue::OK for successfull send * - Everything else triggers failure event with returnvalue as parameter 1 */ virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t *sendData, size_t sendLen); @@ -46,7 +46,7 @@ class RmapDeviceCommunicationIF : public DeviceCommunicationIF { * Called by DHB in the GET_WRITE doGetWrite(). * Get send confirmation that the data in sendMessage() was sent successfully. * @param cookie - * @return -@c RETURN_OK if data was sent successfull + * @return -@c returnvalue::OK if data was sent successfull * - Everything else triggers falure event with returnvalue as parameter 1 */ virtual ReturnValue_t getSendSuccess(CookieIF *cookie); @@ -57,7 +57,7 @@ class RmapDeviceCommunicationIF : public DeviceCommunicationIF { * from a device. * * @param cookie - * @return -@c RETURN_OK to confirm the request for data has been sent. + * @return -@c returnvalue::OK to confirm the request for data has been sent. * -@c NO_READ_REQUEST if no request shall be made. readReceivedMessage() * will not be called in the respective communication cycle. * - Everything else triggers failure event with returnvalue as parameter 1 @@ -71,7 +71,7 @@ class RmapDeviceCommunicationIF : public DeviceCommunicationIF { * @param cookie * @param data * @param len - * @return @c RETURN_OK for successfull receive + * @return @c returnvalue::OK for successfull receive * - Everything else triggers failure event with returnvalue as parameter 1 */ virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size); diff --git a/src/fsfw/serialize/SerializeAdapter.h b/src/fsfw/serialize/SerializeAdapter.h index 31259b0f..cc06aa80 100644 --- a/src/fsfw/serialize/SerializeAdapter.h +++ b/src/fsfw/serialize/SerializeAdapter.h @@ -40,7 +40,7 @@ class SerializeAdapter { * @return * - @c BUFFER_TOO_SHORT The given buffer in is too short * - @c returnvalue::FAILED Generic Error - * - @c RETURN_OK Successful serialization + * - @c returnvalue::OK Successful serialization */ template static ReturnValue_t serialize(const T *object, uint8_t **buffer, size_t *size, size_t maxSize, @@ -65,7 +65,7 @@ class SerializeAdapter { * @return * - @c BUFFER_TOO_SHORT The given buffer in is too short * - @c returnvalue::FAILED Generic Error - * - @c RETURN_OK Successful serialization + * - @c returnvalue::OK Successful serialization */ template static ReturnValue_t serialize(const T *object, uint8_t *const buffer, size_t *serSize, @@ -114,7 +114,7 @@ class SerializeAdapter { * - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object * - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected * - @c returnvalue::FAILED Generic Error - * - @c RETURN_OK Successful deserialization + * - @c returnvalue::OK Successful deserialization */ template static ReturnValue_t deSerialize(T *object, const uint8_t **buffer, size_t *size, @@ -137,7 +137,7 @@ class SerializeAdapter { * - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object * - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected * - @c returnvalue::FAILED Generic Error - * - @c RETURN_OK Successful deserialization + * - @c returnvalue::OK Successful deserialization */ template static ReturnValue_t deSerialize(T *object, const uint8_t *buffer, size_t *deserSize, diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index a02b5f9e..0e9840eb 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -57,7 +57,7 @@ class SerializeIF { * @return * - @c BUFFER_TOO_SHORT The given buffer in is too short * - @c returnvalue::FAILED Generic error - * - @c RETURN_OK Successful serialization + * - @c returnvalue::OK Successful serialization */ [[nodiscard]] virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const = 0; @@ -93,7 +93,7 @@ class SerializeIF { * - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object * - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected * - @c returnvalue::FAILED Generic Error - * - @c RETURN_OK Successful deserialization + * - @c returnvalue::OK Successful deserialization */ virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) = 0; diff --git a/src/fsfw/storagemanager/LocalPool.h b/src/fsfw/storagemanager/LocalPool.h index 01706e9c..ebdcba9f 100644 --- a/src/fsfw/storagemanager/LocalPool.h +++ b/src/fsfw/storagemanager/LocalPool.h @@ -138,7 +138,7 @@ class LocalPool : public SystemObject, public StorageManagerIF { * With this helper method, a free element of @c size is reserved. * @param size The minimum packet size that shall be reserved. * @param[out] address Storage ID of the reserved data. - * @return - #RETURN_OK on success, + * @return - returnvalue::OK on success, * - the return codes of #getPoolIndex or #findEmpty otherwise. */ virtual ReturnValue_t reserveSpace(const size_t size, store_address_t* address, bool ignoreFault); @@ -210,7 +210,7 @@ class LocalPool : public SystemObject, public StorageManagerIF { * fits is used. * @param packet_size The size of the data to be stored. * @param[out] poolIndex The fitting pool index found. - * @return - @c RETURN_OK on success, + * @return - @c returnvalue::OK on success, * - @c DATA_TOO_LARGE otherwise. */ ReturnValue_t getSubPoolIndex(size_t packetSize, uint16_t* subpoolIndex, @@ -230,7 +230,7 @@ class LocalPool : public SystemObject, public StorageManagerIF { * duration grows with the fill level of the pool. * @param pool_index The pool in which the search is performed. * @param[out] element The first found element in the pool. - * @return - #RETURN_OK on success, + * @return - returnvalue::OK on success, * - #DATA_STORAGE_FULL if the store is full */ ReturnValue_t findEmpty(n_pool_elem_t poolIndex, uint16_t* element); diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index 24ef2e45..66002ca9 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -63,7 +63,7 @@ class StorageManagerIF { * @param storageId A pointer to the storageId to retrieve. * @param data The data to be stored in the StorageManager. * @param size The amount of data to be stored. - * @return Returns @li RETURN_OK if data was added. + * @return Returns @li returnvalue::OK if data was added. * @li returnvalue::FAILED if data could not be added. * storageId is unchanged then. */ @@ -73,7 +73,7 @@ class StorageManagerIF { * @brief With deleteData, the storageManager frees the memory region * identified by packet_id. * @param packet_id The identifier of the memory region to be freed. - * @return @li RETURN_OK on success. + * @return @li returnvalue::OK on success. * @li returnvalue::FAILED if deletion did not work * (e.g. an illegal packet_id was passed). */ @@ -84,7 +84,7 @@ class StorageManagerIF { * @param buffer Pointer to the data. * @param size Size of data to be stored. * @param storeId Store id of the deleted element (optional) - * @return @li RETURN_OK on success. + * @return @li returnvalue::OK on success. * @li failure code if deletion did not work */ virtual ReturnValue_t deleteData(uint8_t* buffer, size_t size, @@ -116,7 +116,7 @@ class StorageManagerIF { * @param packet_ptr The passed pointer address is set to the the memory * position * @param size The exact size of the stored data is returned here. - * @return @li RETURN_OK on success. + * @return @li returnvalue::OK on success. * @li returnvalue::FAILED if fetching data did not work * (e.g. an illegal packet_id was passed). */ @@ -156,7 +156,7 @@ class StorageManagerIF { * @param storageId A pointer to the storageId to retrieve. * @param size The size of the space to be reserved. * @param p_data A pointer to the element data is returned here. - * @return Returns @li RETURN_OK if data was added. + * @return Returns @li returnvalue::OK if data was added. * @li returnvalue::FAILED if data could not be added. * storageId is unchanged then. */ diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 17bbdf46..86ee251a 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -223,14 +223,14 @@ ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) { return returnvalue::OK; // case ModeMessage::CMD_MODE_COMMAND: // handleCommandedMode(message); - // return RETURN_OK; + // return returnvalue::OK; // case ModeMessage::CMD_MODE_ANNOUNCE: // triggerEvent(MODE_INFO, mode, submode); - // return RETURN_OK; + // return returnvalue::OK; // case ModeMessage::CMD_MODE_ANNOUNCE_RECURSIVELY: // triggerEvent(MODE_INFO, mode, submode); // commandAllChildren(message); - // return RETURN_OK; + // return returnvalue::OK; default: return returnvalue::FAILED; } diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index ad341b80..f61340ac 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -42,7 +42,7 @@ class SubsystemBase : public SystemObject, * Also adds them to the internal childrenMap. * * @param objectId - * @return RETURN_OK if successful + * @return returnvalue::OK if successful * CHILD_DOESNT_HAVE_MODES if Child is no HasHealthIF and no HasModesIF * COULD_NOT_INSERT_CHILD If the Child could not be added to the ChildrenMap */ diff --git a/src/fsfw/tasks/FixedSlotSequence.cpp b/src/fsfw/tasks/FixedSlotSequence.cpp index e538c9fc..cba7a87a 100644 --- a/src/fsfw/tasks/FixedSlotSequence.cpp +++ b/src/fsfw/tasks/FixedSlotSequence.cpp @@ -16,7 +16,7 @@ FixedSlotSequence::~FixedSlotSequence() { void FixedSlotSequence::executeAndAdvance() { current->executableObject->performOperation(current->opcode); - // if (returnValue != RETURN_OK) { + // if (returnValue != returnvalue::OK) { // this->sendErrorMessage( returnValue ); // } // Increment the polling Sequence iterator diff --git a/src/fsfw/tasks/PeriodicTaskIF.h b/src/fsfw/tasks/PeriodicTaskIF.h index 04415533..d1bbf456 100644 --- a/src/fsfw/tasks/PeriodicTaskIF.h +++ b/src/fsfw/tasks/PeriodicTaskIF.h @@ -29,7 +29,7 @@ class PeriodicTaskIF { * The objects are executed in the order added. The object needs to implement * ExecutableObjectIF * @param object Id of the object to add. - * @return RETURN_OK on success, returnvalue::FAILED if the object could not be added. + * @return returnvalue::OK on success, returnvalue::FAILED if the object could not be added. */ virtual ReturnValue_t addComponent(object_id_t object, uint8_t opCode) = 0; virtual ReturnValue_t addComponent(object_id_t object) { return addComponent(object, 0); }; @@ -38,7 +38,7 @@ class PeriodicTaskIF { * Adds an object to the list of objects to be executed. * The objects are executed in the order added. * @param object pointer to the object to add. - * @return RETURN_OK on success, returnvalue::FAILED if the object could not be added. + * @return returnvalue::OK on success, returnvalue::FAILED if the object could not be added. */ virtual ReturnValue_t addComponent(ExecutableObjectIF* object, uint8_t opCode) = 0; virtual ReturnValue_t addComponent(ExecutableObjectIF* object) { return addComponent(object, 0); } diff --git a/src/fsfw/tasks/SemaphoreIF.h b/src/fsfw/tasks/SemaphoreIF.h index 3f544de8..37275529 100644 --- a/src/fsfw/tasks/SemaphoreIF.h +++ b/src/fsfw/tasks/SemaphoreIF.h @@ -46,14 +46,14 @@ class SemaphoreIF { * for a maximum of timeoutMs while trying to acquire the semaphore. * This can be used to achieve task synchrnization. * @param timeoutMs - * @return - c RETURN_OK for successfull acquisition + * @return - c returnvalue::OK for successfull acquisition */ virtual ReturnValue_t acquire(TimeoutType timeoutType = TimeoutType::BLOCKING, uint32_t timeoutMs = 0) = 0; /** * Corrensponding call to release a semaphore. - * @return -@c RETURN_OK for successfull release + * @return -@c returnvalue::OK for successfull release */ virtual ReturnValue_t release() = 0; diff --git a/src/fsfw/tcdistribution/CCSDSDistributorIF.h b/src/fsfw/tcdistribution/CCSDSDistributorIF.h index a57379ea..9d512549 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributorIF.h +++ b/src/fsfw/tcdistribution/CCSDSDistributorIF.h @@ -17,7 +17,7 @@ class CCSDSDistributorIF { * With this call, a class implementing the CCSDSApplicationIF can register * at the distributor. * @param application A pointer to the Application to register. - * @return - @c RETURN_OK on success, + * @return - @c returnvalue::OK on success, * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerApplication(AcceptsTelecommandsIF* application) = 0; @@ -27,7 +27,7 @@ class CCSDSDistributorIF { * @param apid The APID to register. * @param id The MessageQueueId of the message queue to send the * TC Packets to. - * @return - @c RETURN_OK on success, + * @return - @c returnvalue::OK on success, * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerApplication(uint16_t apid, MessageQueueId_t id) = 0; diff --git a/src/fsfw/tcdistribution/CFDPDistributor.cpp b/src/fsfw/tcdistribution/CFDPDistributor.cpp index 20edc0f4..5f5f3904 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.cpp +++ b/src/fsfw/tcdistribution/CFDPDistributor.cpp @@ -101,10 +101,10 @@ ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) { MessageQueueId_t CFDPDistributor::getRequestQueue() { return tcQueue->getId(); } // ReturnValue_t CFDPDistributor::callbackAfterSending(ReturnValue_t queueStatus) { -// if (queueStatus != RETURN_OK) { +// if (queueStatus != returnvalue::OK) { // tcStatus = queueStatus; // } -// if (tcStatus != RETURN_OK) { +// if (tcStatus != returnvalue::OK) { // this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, // currentPacket, tcStatus); // // A failed packet is deleted immediately after reporting, @@ -114,7 +114,7 @@ MessageQueueId_t CFDPDistributor::getRequestQueue() { return tcQueue->getId(); } // } else { // this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, // currentPacket); -// return RETURN_OK; +// return returnvalue::OK; // } // } diff --git a/src/fsfw/tcdistribution/CFDPDistributorIF.h b/src/fsfw/tcdistribution/CFDPDistributorIF.h index 57cf9fde..8ee5568f 100644 --- a/src/fsfw/tcdistribution/CFDPDistributorIF.h +++ b/src/fsfw/tcdistribution/CFDPDistributorIF.h @@ -17,7 +17,7 @@ class CFDPDistributorIF { /** * With this method, Handlers can register themselves at the CFDP Distributor. * @param handler A pointer to the registering Handler. - * @return - @c RETURN_OK on success, + * @return - @c returnvalue::OK on success, * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) = 0; diff --git a/src/fsfw/tcdistribution/PUSDistributorIF.h b/src/fsfw/tcdistribution/PUSDistributorIF.h index 85619fee..e3bff93f 100644 --- a/src/fsfw/tcdistribution/PUSDistributorIF.h +++ b/src/fsfw/tcdistribution/PUSDistributorIF.h @@ -17,7 +17,7 @@ class PUSDistributorIF { /** * With this method, Services can register themselves at the PUS Distributor. * @param service A pointer to the registering Service. - * @return - @c RETURN_OK on success, + * @return - @c returnvalue::OK on success, * - @c returnvalue::FAILED on failure. */ virtual ReturnValue_t registerService(AcceptsTelecommandsIF* service) = 0; diff --git a/src/fsfw/tcdistribution/TcDistributor.h b/src/fsfw/tcdistribution/TcDistributor.h index 7c7e539c..62cd5dc9 100644 --- a/src/fsfw/tcdistribution/TcDistributor.h +++ b/src/fsfw/tcdistribution/TcDistributor.h @@ -101,10 +101,10 @@ class TcDistributor : public SystemObject, public ExecutableObjectIF { * This method gives the child class a chance to perform some kind of * operation after the parent tried to forward the message. * A typically application would be sending success/failure messages. - * The default implementation just returns @c RETURN_OK. + * The default implementation just returns @c returnvalue::OK. * @param queueStatus The status of the message queue after an attempt * to send the TC. - * @return - @c RETURN_OK on success + * @return - @c returnvalue::OK on success * - @c returnvalue::FAILED on failure */ virtual ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus); diff --git a/src/fsfw/tcdistribution/TcPacketCheckIF.h b/src/fsfw/tcdistribution/TcPacketCheckIF.h index 858c3093..4846195a 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckIF.h +++ b/src/fsfw/tcdistribution/TcPacketCheckIF.h @@ -20,7 +20,7 @@ class TcPacketCheckIF { * This is the actual method to formally check a certain Packet. * The packet's Application Data can not be checked here. * @param current_packet The packet to check - * @return - @c RETURN_OK on success. + * @return - @c returnvalue::OK on success. * - @c INCORRECT_CHECKSUM if checksum is invalid. * - @c ILLEGAL_APID if APID does not match. */ diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index c0db1d6e..622f42ec 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -105,7 +105,7 @@ class CCSDSTime { * @param to pointer to a CCS struct * @param from pointer to a TimeOfDay Struct * @return - * - @c RETURN_OK if OK + * - @c returnvalue::OK if OK * - @c INVALID_TIMECODE if not OK */ static ReturnValue_t convertToCcsds(Ccs_seconds *to, Clock::TimeOfDay_t const *from); @@ -115,7 +115,7 @@ class CCSDSTime { * @param to pointer to the CDS struct to generate * @param from pointer to a timeval struct which comprises a time of day since UNIX epoch. * @return - * - @c RETURN_OK as it assumes a valid timeval. + * - @c returnvalue::OK as it assumes a valid timeval. */ static ReturnValue_t convertToCcsds(CDS_short *to, timeval const *from); @@ -129,7 +129,7 @@ class CCSDSTime { * @param to pointer to a CCS struct * @param from pointer to a TimeOfDay Struct * @return - * - @c RETURN_OK if OK + * - @c returnvalue::OK if OK * - @c INVALID_TIMECODE if not OK */ static ReturnValue_t convertToCcsds(Ccs_mseconds *to, Clock::TimeOfDay_t const *from); @@ -145,7 +145,7 @@ class CCSDSTime { * @param from pointer to an CCSDS Time code * @param length length of the Time code * @return - * - @c RETURN_OK if successful + * - @c returnvalue::OK if successful * - @c UNSUPPORTED_TIME_FORMAT if a (possibly valid) time code is not supported * - @c LENGTH_MISMATCH if the length does not match the P Field * - @c INVALID_TIME_FORMAT if the format or a value is invalid @@ -182,7 +182,7 @@ class CCSDSTime { * @param from Buffer to read from * @param foundLength Length found by this function (can be nullptr if unused) * @param maxLength Max length of the buffer to be read - * @return ReturnValue_t - RETURN_OK if successful + * @return ReturnValue_t - returnvalue::OK if successful * - LENGTH_MISMATCH if expected length is larger than maxLength */ static ReturnValue_t convertFromCUC(timeval *to, uint8_t const *from, size_t *foundLength, diff --git a/src/fsfw/timemanager/Clock.h b/src/fsfw/timemanager/Clock.h index 6df6e12b..f27c2211 100644 --- a/src/fsfw/timemanager/Clock.h +++ b/src/fsfw/timemanager/Clock.h @@ -38,7 +38,7 @@ class Clock { * This system call sets the system time. * To set the time, it uses a TimeOfDay_t struct. * @param time The struct with the time settings to set. - * @return -@c RETURN_OK on success. Otherwise, the OS failure code + * @return -@c returnvalue::OK on success. Otherwise, the OS failure code * is returned. */ static ReturnValue_t setClock(const TimeOfDay_t *time); @@ -46,7 +46,7 @@ class Clock { * This system call sets the system time. * To set the time, it uses a timeval struct. * @param time The struct with the time settings to set. - * @return -@c RETURN_OK on success. Otherwise, the OS failure code is returned. + * @return -@c returnvalue::OK on success. Otherwise, the OS failure code is returned. */ static ReturnValue_t setClock(const timeval *time); /** @@ -54,7 +54,7 @@ class Clock { * The timval format has the fields @c tv_sec with seconds and @c tv_usec with * microseconds since an OS-defined epoch. * @param time A pointer to a timeval struct where the current time is stored. - * @return @c RETURN_OK on success. Otherwise, the OS failure code is returned. + * @return @c returnvalue::OK on success. Otherwise, the OS failure code is returned. */ static ReturnValue_t getClock_timeval(timeval *time); @@ -62,7 +62,7 @@ class Clock { * Get the time since boot in a timeval struct * * @param[out] time A pointer to a timeval struct where the uptime is stored. - * @return @c RETURN_OK on success. Otherwise, the OS failure code is returned. + * @return @c returnvalue::OK on success. Otherwise, the OS failure code is returned. * * @deprecated, I do not think this should be able to fail, use timeval getUptime() */ @@ -77,7 +77,7 @@ class Clock { * between two calls up to 49 days by always using uint32_t in the calculation * * @param ms uptime in ms - * @return RETURN_OK on success. Otherwise, the OS failure code is returned. + * @return returnvalue::OK on success. Otherwise, the OS failure code is returned. */ static ReturnValue_t getUptime(uint32_t *uptimeMs); @@ -86,7 +86,7 @@ class Clock { * The time is returned in a 64 bit unsigned integer. * @param time A pointer to a 64 bit unisigned integer where the data is stored. * @return - * - @c RETURN_OK on success. + * - @c returnvalue::OK on success. * - Otherwise, the OS failure code is returned. */ static ReturnValue_t getClock_usecs(uint64_t *time); @@ -94,7 +94,7 @@ class Clock { * Returns the time in a TimeOfDay_t struct. * @param time A pointer to a TimeOfDay_t struct. * @return - * - @c RETURN_OK on success. + * - @c returnvalue::OK on success. * - Otherwise, the OS failure code is returned. */ static ReturnValue_t getDateAndTime(TimeOfDay_t *time); @@ -111,7 +111,7 @@ class Clock { * @param time The time of day as input * @param timeval The corresponding seconds since the epoch. * @return - * - @c RETURN_OK on success. + * - @c returnvalue::OK on success. * - Otherwise, the OS failure code is returned. */ static ReturnValue_t convertTimeOfDayToTimeval(const TimeOfDay_t *from, timeval *to); @@ -122,7 +122,7 @@ class Clock { * * @param time seconds since unix epoch * @param[out] JD2000 days since J2000 - * @return @c RETURN_OK + * @return @c returnvalue::OK */ static ReturnValue_t convertTimevalToJD2000(timeval time, double *JD2000); @@ -136,7 +136,7 @@ class Clock { * @param utc timeval, corresponding to UTC time * @param[out] tt timeval, corresponding to Terrestial Time * @return - * - @c RETURN_OK on success + * - @c returnvalue::OK on success * - @c returnvalue::FAILED if leapSeconds are not set */ static ReturnValue_t convertUTCToTT(timeval utc, timeval *tt); @@ -146,7 +146,7 @@ class Clock { * * @param leapSeconds_ * @return - * - @c RETURN_OK on success. + * - @c returnvalue::OK on success. */ static ReturnValue_t setLeapSeconds(const uint16_t leapSeconds_); @@ -157,7 +157,7 @@ class Clock { * * @param[out] leapSeconds_ * @return - * - @c RETURN_OK on success. + * - @c returnvalue::OK on success. * - @c returnvalue::FAILED on error */ static ReturnValue_t getLeapSeconds(uint16_t *leapSeconds_); @@ -166,7 +166,7 @@ class Clock { /** * Function to check and create the Mutex for the clock * @return - * - @c RETURN_OK on success. + * - @c returnvalue::OK on success. * - Otherwise @c returnvalue::FAILED if not able to create one */ static ReturnValue_t checkOrCreateClockMutex(); diff --git a/src/fsfw/tmstorage/TmStoreFrontendIF.h b/src/fsfw/tmstorage/TmStoreFrontendIF.h index 3ab93ba1..4665a299 100644 --- a/src/fsfw/tmstorage/TmStoreFrontendIF.h +++ b/src/fsfw/tmstorage/TmStoreFrontendIF.h @@ -28,7 +28,7 @@ class TmStoreFrontendIF { * @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, RETURN_OK must be returned. + * @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; diff --git a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h index a1fc77e8..1a74e63d 100644 --- a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h +++ b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h @@ -22,7 +22,7 @@ class RedirectableDataPointerIF { * large enough * @param args Any additional user arguments required to set the data pointer * @return - * - RETURN_OK if the pointer was set successfully + * - returnvalue::OK if the pointer was set successfully * - returnvalue::FAILED on general error of if the maximum size is too small */ virtual ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) = 0; diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h index f9c73bdd..329b62ff 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h @@ -25,7 +25,7 @@ class CFDPPacketStored : public CFDPPacket, public TcPacketStoredBase { * Getter function for the raw data. * @param dataPtr [out] Pointer to the data pointer to set * @param dataSize [out] Address of size to set. - * @return -@c RETURN_OK if data was retrieved successfully. + * @return -@c returnvalue::OK if data was retrieved successfully. */ ReturnValue_t getData(const uint8_t** dataPtr, size_t* dataSize); diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h index ece0e482..6602eeca 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h @@ -34,7 +34,7 @@ class TcPacketStoredBase : public TcPacketStoredIF { * Getter function for the raw data. * @param dataPtr [out] Pointer to the data pointer to set * @param dataSize [out] Address of size to set. - * @return -@c RETURN_OK if data was retrieved successfully. + * @return -@c returnvalue::OK if data was retrieved successfully. */ ReturnValue_t getData(const uint8_t** dataPtr, size_t* dataSize) override; diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h index 7ac8c331..e7c4f9f0 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h @@ -25,7 +25,7 @@ class TcPacketStoredIF { * Getter function for the raw data. * @param dataPtr [out] Pointer to the data pointer to set * @param dataSize [out] Address of size to set. - * @return -@c RETURN_OK if data was retrieved successfully. + * @return -@c returnvalue::OK if data was retrieved successfully. */ virtual ReturnValue_t getData(const uint8_t** dataPtr, size_t* dataSize) = 0; }; diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 4cecf53b..d61bf77f 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -184,7 +184,7 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, Comma // In case a new command is to be sent immediately, this is performed here. // If no new command is sent, only analyse reply result by initializing - // sendResult as RETURN_OK + // sendResult as returnvalue::OK ReturnValue_t sendResult = returnvalue::OK; if (nextCommand->getCommand() != CommandMessage::CMD_NONE) { sendResult = commandQueue->sendMessage(reply->getSender(), nextCommand); diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 73b42259..1de1f977 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -90,7 +90,7 @@ class CommandingServiceBase : public SystemObject, * Handle request queue for external commands. * Handle command Queue for internal commands. * @param opCode is unused here at the moment - * @return RETURN_OK + * @return returnvalue::OK */ virtual ReturnValue_t performOperation(uint8_t opCode) override; @@ -128,7 +128,7 @@ class CommandingServiceBase : public SystemObject, * Check the target subservice * @param subservice[in] * @return - * -@c RETURN_OK Subservice valid, continue message handling + * -@c returnvalue::OK Subservice valid, continue message handling * -@c INVALID_SUBSERVICE if service is not known, rejects packet. */ virtual ReturnValue_t isValidSubservice(uint8_t subservice) = 0; @@ -143,7 +143,7 @@ class CommandingServiceBase : public SystemObject, * @param id MessageQueue ID is stored here * @param objectId Object ID is extracted and stored here * @return - * - @c RETURN_OK Cotinue message handling + * - @c returnvalue::OK Cotinue message handling * - @c returnvalue::FAILED Reject the packet and generates a start failure * verification */ @@ -164,7 +164,7 @@ class CommandingServiceBase : public SystemObject, * communication * @param objectId Target object ID * @return - * - @c RETURN_OK to generate a verification start message + * - @c returnvalue::OK to generate a verification start message * - @c EXECUTION_COMPLETE Fire-and-forget command. Generate a completion * verification message. * - @c Anything else rejects the packets and generates a start failure @@ -189,7 +189,7 @@ class CommandingServiceBase : public SystemObject, * @param objectId Source object ID * @param isStep Flag value to mark steps of command execution * @return - * - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to + * - @c returnvalue::OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to * generate TC verification success * - @c INVALID_REPLY Calls handleUnrequestedReply * - Anything else triggers a TC verification failure. If returnvalue::FAILED or diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 6271f267..97351994 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -75,14 +75,14 @@ class PusServiceBase : public ExecutableObjectIF, * * @return The returned status_code is directly taken as main error code * in the Verification Report. - * On success, RETURN_OK shall be returned. + * On success, returnvalue::OK shall be returned. */ virtual ReturnValue_t handleRequest(uint8_t subservice) = 0; /** * In performService, implementations can handle periodic, * non-TC-triggered activities. * The performService method is always called. - * @return Currently, everything other that RETURN_OK only triggers + * @return Currently, everything other that returnvalue::OK only triggers * diagnostic output. */ virtual ReturnValue_t performService() = 0; @@ -92,7 +92,7 @@ class PusServiceBase : public ExecutableObjectIF, * completion verification messages and deletes * the TC requests afterwards. * performService is always executed afterwards. - * @return @c RETURN_OK if the periodic performService was successful. + * @return @c returnvalue::OK if the periodic performService was successful. * @c returnvalue::FAILED else. */ ReturnValue_t performOperation(uint8_t opCode) override; diff --git a/src/fsfw/tmtcservices/SpacePacketParser.h b/src/fsfw/tmtcservices/SpacePacketParser.h index f0a9e8e2..93f90afe 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.h +++ b/src/fsfw/tmtcservices/SpacePacketParser.h @@ -51,7 +51,7 @@ class SpacePacketParser { * will be set to the detected packet size and startIndex will be set to the start of the * detected packet. buffer and read length will not be incremented but the found length * will be assigned. - * -@c RETURN_OK if a packet was found + * -@c returnvalue::OK if a packet was found */ ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, size_t& startIndex, size_t& foundSize, size_t& readLen); @@ -67,7 +67,7 @@ class SpacePacketParser { * -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. foundSize * will be set to the detected packet size and startIndex will be set to the start of the * detected packet - * -@c RETURN_OK if a packet was found + * -@c returnvalue::OK if a packet was found */ ReturnValue_t parseSpacePackets(const uint8_t* buffer, const size_t maxSize, size_t& startIndex, size_t& foundSize); diff --git a/src/fsfw/tmtcservices/TmTcBridge.h b/src/fsfw/tmtcservices/TmTcBridge.h index 3ebdac95..e2e5bfa5 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.h +++ b/src/fsfw/tmtcservices/TmTcBridge.h @@ -30,7 +30,7 @@ class TmTcBridge : public AcceptsTelemetryIF, * Set number of packets sent per performOperation().Please note that this * value must be smaller than MAX_STORED_DATA_SENT_PER_CYCLE * @param sentPacketsPerCycle - * @return -@c RETURN_OK if value was set successfully + * @return -@c returnvalue::OK if value was set successfully * -@c returnvalue::FAILED otherwise, stored value stays the same */ ReturnValue_t setNumberOfSentPacketsPerCycle(uint8_t sentPacketsPerCycle); @@ -39,7 +39,7 @@ class TmTcBridge : public AcceptsTelemetryIF, * Set number of packets sent per performOperation().Please note that this * value must be smaller than MAX_DOWNLINK_PACKETS_STORED * @param sentPacketsPerCycle - * @return -@c RETURN_OK if value was set successfully + * @return -@c returnvalue::OK if value was set successfully * -@c returnvalue::FAILED otherwise, stored value stays the same */ ReturnValue_t setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored); diff --git a/src/fsfw_hal/common/gpio/GpioIF.h b/src/fsfw_hal/common/gpio/GpioIF.h index feb356f4..3e947b84 100644 --- a/src/fsfw_hal/common/gpio/GpioIF.h +++ b/src/fsfw_hal/common/gpio/GpioIF.h @@ -29,7 +29,7 @@ class GpioIF { * functionality to pull a certain GPIO to high logic level. * * @param gpioId A unique number which specifies the GPIO to drive. - * @return Returns RETURN_OK for success. This should never return returnvalue::FAILED. + * @return Returns returnvalue::OK for success. This should never return returnvalue::FAILED. */ virtual ReturnValue_t pullHigh(gpioId_t gpioId) = 0; diff --git a/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h index f817b0c2..11b8ccbb 100644 --- a/src/fsfw_hal/linux/CommandExecutor.h +++ b/src/fsfw_hal/linux/CommandExecutor.h @@ -68,7 +68,7 @@ class CommandExecutor { * the result of the system call was not 0. The error value can be accessed using * getLastError * - In non-blocking mode, this call will start - * the execution and then return RETURN_OK + * the execution and then return returnvalue::OK */ ReturnValue_t execute(); /** @@ -77,7 +77,7 @@ class CommandExecutor { * @return * - BYTES_READ if bytes have been read from the executing process. It is recommended to call * check again after this - * - RETURN_OK execution is pending, but no bytes have been read from the executing process + * - returnvalue::OK execution is pending, but no bytes have been read from the executing process * - returnvalue::FAILED if execution has failed, error value can be accessed using getLastError * - EXECUTION_FINISHED if the process was executed successfully * - NO_COMMAND_LOADED_OR_PENDING self-explanatory @@ -87,7 +87,7 @@ class CommandExecutor { /** * Abort the current command. Should normally not be necessary, check can be used to find * out whether command execution was successful - * @return RETURN_OK + * @return returnvalue::OK */ ReturnValue_t close(); diff --git a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h index f9ba680b..fff7e3c2 100644 --- a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h +++ b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h @@ -71,7 +71,7 @@ class LinuxLibgpioIF : public GpioIF, public SystemObject { * * @param mapToAdd The GPIOs which shall be added to the gpioMap. * - * @return RETURN_OK if successful, otherwise returnvalue::FAILED + * @return returnvalue::OK if successful, otherwise returnvalue::FAILED */ ReturnValue_t checkForConflicts(GpioMap& mapToAdd); diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.h b/src/fsfw_hal/linux/i2c/I2cComIF.h index 7101b9b6..0a15c3a4 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.h +++ b/src/fsfw_hal/linux/i2c/I2cComIF.h @@ -49,7 +49,7 @@ class I2cComIF : public DeviceCommunicationIF, public SystemObject { * @param deviceFile The name of the device file. E.g. i2c-0 * @param i2cAddress The address of the i2c slave device. * @param fileDescriptor Pointer to device descriptor. - * @return RETURN_OK if successful, otherwise returnvalue::FAILED. + * @return returnvalue::OK if successful, otherwise returnvalue::FAILED. */ ReturnValue_t openDevice(std::string deviceFile, address_t i2cAddress, int *fileDescriptor); }; diff --git a/src/fsfw_tests/integration/assemblies/TestAssembly.h b/src/fsfw_tests/integration/assemblies/TestAssembly.h index 6042f54e..91ffbf60 100644 --- a/src/fsfw_tests/integration/assemblies/TestAssembly.h +++ b/src/fsfw_tests/integration/assemblies/TestAssembly.h @@ -22,7 +22,7 @@ class TestAssembly : public AssemblyBase { * @param mode * @param submode * @return - * - @c RETURN_OK if ok + * - @c returnvalue::OK if ok * - @c NEED_SECOND_STEP if children need to be commanded again */ ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) override; From d2ac3603a5857d4f08c7238b24fb195d8d1f0f3f Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 16 Aug 2022 12:29:53 +0200 Subject: [PATCH 239/532] some more occurences --- docs/README-highlevel.md | 2 +- docs/highlevel.rst | 2 +- src/fsfw/osal/linux/Clock.cpp | 2 +- src/fsfw/pus/Service11TelecommandScheduling.h | 6 +++--- src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h | 12 ++++++------ src/fsfw_hal/linux/spi/SpiComIF.h | 6 +++--- src/fsfw_hal/linux/uart/UartComIF.h | 6 +++--- src/fsfw_hal/stm32h7/spi/spiDefinitions.h | 6 +++--- unittests/container/TestDynamicFifo.cpp | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md index 262138a7..9005af8d 100644 --- a/docs/README-highlevel.md +++ b/docs/README-highlevel.md @@ -14,7 +14,7 @@ FSFW to achieve that. The fsfw uses run-time type information but exceptions are # Failure Handling Functions should return a defined `ReturnValue_t` to signal to the caller that something has -gone wrong. Returnvalues must be unique. For this the function `HasReturnvaluesIF::makeReturnCode` +gone wrong. Returnvalues must be unique. For this the function `returnvalue::makeCode` or the macro `MAKE_RETURN` can be used. The `CLASS_ID` is a unique id for that type of object. See `returnvalues/FwClassIds` folder. The user can add custom `CLASS_ID`s via the `fsfwconfig` folder. diff --git a/docs/highlevel.rst b/docs/highlevel.rst index 04eb5e7b..3c9baae2 100644 --- a/docs/highlevel.rst +++ b/docs/highlevel.rst @@ -18,7 +18,7 @@ Failure Handling ----------------- Functions should return a defined :cpp:type:`ReturnValue_t` to signal to the caller that something has -gone wrong. Returnvalues must be unique. For this the function :cpp:func:`HasReturnvaluesIF::makeReturnCode` +gone wrong. Returnvalues must be unique. For this the function :cpp:func:`returnvalue::makeCode` or the :ref:`macro MAKE_RETURN_CODE ` can be used. The ``CLASS_ID`` is a unique ID for that type of object. See the :ref:`FSFW Class IDs file `. The user can add custom ``CLASS_ID``\s via the ``fsfwconfig`` folder. diff --git a/src/fsfw/osal/linux/Clock.cpp b/src/fsfw/osal/linux/Clock.cpp index 2b914f75..a2b6f5bf 100644 --- a/src/fsfw/osal/linux/Clock.cpp +++ b/src/fsfw/osal/linux/Clock.cpp @@ -93,7 +93,7 @@ ReturnValue_t Clock::getUptime(timeval* uptime) { // struct sysinfo sysInfo; // int result = sysinfo(&sysInfo); // if(result != 0){ -// return HasReturnvaluesIF::returnvalue::FAILED; +// return returnvalue::FAILED; // } // return sysInfo.uptime; //} diff --git a/src/fsfw/pus/Service11TelecommandScheduling.h b/src/fsfw/pus/Service11TelecommandScheduling.h index 35ae59e0..2ceacbf7 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.h +++ b/src/fsfw/pus/Service11TelecommandScheduling.h @@ -38,11 +38,11 @@ class Service11TelecommandScheduling final : public PusServiceBase { static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_11; static constexpr ReturnValue_t INVALID_TYPE_TIME_WINDOW = - HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1); + returnvalue::makeCode(CLASS_ID, 1); static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = - HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2); + returnvalue::makeCode(CLASS_ID, 2); static constexpr ReturnValue_t INVALID_RELATIVE_TIME = - HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); + returnvalue::makeCode(CLASS_ID, 3); static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_11; diff --git a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h index fff7e3c2..49b15b83 100644 --- a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h +++ b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h @@ -20,17 +20,17 @@ class LinuxLibgpioIF : public GpioIF, public SystemObject { static const uint8_t gpioRetvalId = CLASS_ID::HAL_GPIO; static constexpr ReturnValue_t UNKNOWN_GPIO_ID = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 1); + returnvalue::makeCode(gpioRetvalId, 1); static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 2); + returnvalue::makeCode(gpioRetvalId, 2); static constexpr ReturnValue_t GPIO_TYPE_FAILURE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 3); + returnvalue::makeCode(gpioRetvalId, 3); static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 4); + returnvalue::makeCode(gpioRetvalId, 4); static constexpr ReturnValue_t GPIO_DUPLICATE_DETECTED = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 5); + returnvalue::makeCode(gpioRetvalId, 5); static constexpr ReturnValue_t GPIO_INIT_FAILED = - HasReturnvaluesIF::makeReturnCode(gpioRetvalId, 6); + returnvalue::makeCode(gpioRetvalId, 6); LinuxLibgpioIF(object_id_t objectId); virtual ~LinuxLibgpioIF(); diff --git a/src/fsfw_hal/linux/spi/SpiComIF.h b/src/fsfw_hal/linux/spi/SpiComIF.h index 357afa2f..d3b361a9 100644 --- a/src/fsfw_hal/linux/spi/SpiComIF.h +++ b/src/fsfw_hal/linux/spi/SpiComIF.h @@ -24,13 +24,13 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject { public: static constexpr uint8_t spiRetvalId = CLASS_ID::HAL_SPI; static constexpr ReturnValue_t OPENING_FILE_FAILED = - HasReturnvaluesIF::makeReturnCode(spiRetvalId, 0); + returnvalue::makeCode(spiRetvalId, 0); /* Full duplex (ioctl) transfer failure */ static constexpr ReturnValue_t FULL_DUPLEX_TRANSFER_FAILED = - HasReturnvaluesIF::makeReturnCode(spiRetvalId, 1); + returnvalue::makeCode(spiRetvalId, 1); /* Half duplex (read/write) transfer failure */ static constexpr ReturnValue_t HALF_DUPLEX_TRANSFER_FAILED = - HasReturnvaluesIF::makeReturnCode(spiRetvalId, 2); + returnvalue::makeCode(spiRetvalId, 2); SpiComIF(object_id_t objectId, GpioIF* gpioComIF); diff --git a/src/fsfw_hal/linux/uart/UartComIF.h b/src/fsfw_hal/linux/uart/UartComIF.h index 224f1e77..870d02c5 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.h +++ b/src/fsfw_hal/linux/uart/UartComIF.h @@ -23,11 +23,11 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject { static constexpr uint8_t uartRetvalId = CLASS_ID::HAL_UART; static constexpr ReturnValue_t UART_READ_FAILURE = - HasReturnvaluesIF::makeReturnCode(uartRetvalId, 1); + returnvalue::makeCode(uartRetvalId, 1); static constexpr ReturnValue_t UART_READ_SIZE_MISSMATCH = - HasReturnvaluesIF::makeReturnCode(uartRetvalId, 2); + returnvalue::makeCode(uartRetvalId, 2); static constexpr ReturnValue_t UART_RX_BUFFER_TOO_SMALL = - HasReturnvaluesIF::makeReturnCode(uartRetvalId, 3); + returnvalue::makeCode(uartRetvalId, 3); UartComIF(object_id_t objectId); diff --git a/src/fsfw_hal/stm32h7/spi/spiDefinitions.h b/src/fsfw_hal/stm32h7/spi/spiDefinitions.h index 12c3bf4e..809f5c74 100644 --- a/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +++ b/src/fsfw_hal/stm32h7/spi/spiDefinitions.h @@ -11,9 +11,9 @@ namespace spi { static constexpr uint8_t HAL_SPI_ID = CLASS_ID::HAL_SPI; static constexpr ReturnValue_t HAL_TIMEOUT_RETVAL = - HasReturnvaluesIF::makeReturnCode(HAL_SPI_ID, 0); -static constexpr ReturnValue_t HAL_BUSY_RETVAL = HasReturnvaluesIF::makeReturnCode(HAL_SPI_ID, 1); -static constexpr ReturnValue_t HAL_ERROR_RETVAL = HasReturnvaluesIF::makeReturnCode(HAL_SPI_ID, 2); + returnvalue::makeCode(HAL_SPI_ID, 0); +static constexpr ReturnValue_t HAL_BUSY_RETVAL = returnvalue::makeCode(HAL_SPI_ID, 1); +static constexpr ReturnValue_t HAL_ERROR_RETVAL = returnvalue::makeCode(HAL_SPI_ID, 2); enum class TransferStates { IDLE, WAIT, SUCCESS, FAILURE }; diff --git a/unittests/container/TestDynamicFifo.cpp b/unittests/container/TestDynamicFifo.cpp index 1475b0dc..a3347215 100644 --- a/unittests/container/TestDynamicFifo.cpp +++ b/unittests/container/TestDynamicFifo.cpp @@ -82,8 +82,8 @@ TEST_CASE("Dynamic Fifo Tests", "[TestDynamicFifo]") { REQUIRE(fifo.size() == 0); REQUIRE(fifo.empty()); // struct Test* ptr = nullptr; - // REQUIRE(fifo.retrieve(ptr) == static_cast(HasReturnvaluesIF::returnvalue::FAILED)); - // REQUIRE(fifo.peek(ptr) == static_cast(HasReturnvaluesIF::returnvalue::FAILED)); + // REQUIRE(fifo.retrieve(ptr) == static_cast(returnvalue::FAILED)); + // REQUIRE(fifo.peek(ptr) == static_cast(returnvalue::FAILED)); }; SECTION("Copy Test") { REQUIRE(fifo.insert(structOne) == static_cast(returnvalue::OK)); From 217276d50c0248c88485811ff6bb0ed0fb71a4c1 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 16 Aug 2022 12:48:22 +0200 Subject: [PATCH 240/532] renamed returnvalue header --- docs/api/returnvalue.rst | 2 +- .../fsfwconfig/pollingsequence/PollingSequenceFactory.h | 2 +- src/fsfw/action/CommandActionHelper.h | 2 +- src/fsfw/action/CommandsActionsIF.h | 2 +- src/fsfw/action/HasActionsIF.h | 2 +- src/fsfw/cfdp/CFDPHandler.h | 2 +- src/fsfw/cfdp/definitions.h | 2 +- src/fsfw/container/ArrayList.h | 2 +- src/fsfw/container/FIFOBase.h | 2 +- src/fsfw/container/FixedMap.h | 2 +- src/fsfw/container/IndexedRingMemoryArray.h | 2 +- src/fsfw/container/RingBufferBase.h | 2 +- src/fsfw/coordinates/Sgp4Propagator.h | 2 +- src/fsfw/datalinklayer/CCSDSReturnValuesIF.h | 4 ++-- src/fsfw/datalinklayer/MapPacketExtraction.h | 2 +- src/fsfw/datalinklayer/VirtualChannelReceptionIF.h | 2 +- src/fsfw/datapool/DataSetIF.h | 2 +- src/fsfw/datapool/PoolVariableIF.h | 2 +- src/fsfw/datapool/ReadCommitIF.h | 2 +- src/fsfw/datapool/ReadCommitIFAttorney.h | 2 +- src/fsfw/datapoollocal/LocalPoolObjectBase.h | 2 +- src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h | 2 +- src/fsfw/devicehandlers/DeviceCommunicationIF.h | 2 +- src/fsfw/devicehandlers/DeviceHandlerBase.h | 2 +- src/fsfw/events/eventmatching/EventMatchTree.h | 2 +- src/fsfw/fdir/ConfirmsFailuresIF.h | 2 +- src/fsfw/fdir/FailureIsolationBase.h | 2 +- src/fsfw/globalfunctions/AsciiConverter.h | 2 +- src/fsfw/globalfunctions/DleEncoder.h | 2 +- src/fsfw/globalfunctions/Type.h | 2 +- src/fsfw/health/HasHealthIF.h | 2 +- src/fsfw/health/HealthHelper.h | 2 +- src/fsfw/health/HealthTableIF.h | 2 +- src/fsfw/ipc/CommandMessageIF.h | 2 +- src/fsfw/ipc/MessageQueueIF.h | 2 +- src/fsfw/ipc/MutexIF.h | 2 +- src/fsfw/memory/HasFileSystemIF.h | 2 +- src/fsfw/memory/HasMemoryIF.h | 2 +- src/fsfw/memory/MemoryHelper.h | 2 +- src/fsfw/modes/HasModesIF.h | 2 +- src/fsfw/modes/ModeHelper.h | 2 +- src/fsfw/monitoring/LimitViolationReporter.h | 2 +- src/fsfw/objectmanager/ObjectManagerIF.h | 2 +- src/fsfw/objectmanager/SystemObjectIF.h | 2 +- src/fsfw/osal/InternalErrorCodes.h | 2 +- src/fsfw/osal/common/TcpIpBase.h | 2 +- src/fsfw/osal/freertos/BinSemaphUsingTask.h | 4 ++-- src/fsfw/osal/freertos/BinarySemaphore.h | 4 ++-- src/fsfw/osal/freertos/TaskFactory.cpp | 2 +- src/fsfw/osal/freertos/TaskManagement.h | 2 +- src/fsfw/osal/host/TaskFactory.cpp | 2 +- src/fsfw/osal/host/taskHelpers.h | 2 +- src/fsfw/osal/linux/BinarySemaphore.h | 4 ++-- src/fsfw/osal/linux/PosixThread.h | 2 +- src/fsfw/osal/linux/TaskFactory.cpp | 2 +- src/fsfw/osal/rtems/FixedTimeslotTask.cpp | 2 +- src/fsfw/osal/rtems/RtemsBasic.h | 2 +- src/fsfw/osal/rtems/TaskFactory.cpp | 2 +- src/fsfw/parameters/HasParametersIF.h | 2 +- src/fsfw/parameters/ParameterWrapper.h | 2 +- src/fsfw/power/Fuse.h | 2 +- src/fsfw/power/PowerSwitchIF.h | 4 ++-- src/fsfw/power/PowerSwitcher.h | 2 +- src/fsfw/pus/Service1TelecommandVerification.h | 2 +- .../returnvalues/{HasReturnvaluesIF.h => returnvalue.h} | 6 +++--- src/fsfw/rmap/RMAP.h | 4 ++-- src/fsfw/rmap/RMAPChannelIF.h | 2 +- src/fsfw/serialize/SerializeAdapter.h | 2 +- src/fsfw/serialize/SerializeIF.h | 2 +- src/fsfw/serviceinterface/ServiceInterfaceBuffer.h | 2 +- src/fsfw/storagemanager/ConstStorageAccessor.h | 2 +- src/fsfw/storagemanager/StorageManagerIF.h | 2 +- src/fsfw/subsystem/SubsystemBase.h | 2 +- src/fsfw/subsystem/modes/ModeStoreIF.h | 2 +- src/fsfw/tasks/ExecutableObjectIF.h | 2 +- src/fsfw/tasks/SemaphoreIF.h | 2 +- src/fsfw/tcdistribution/CFDPDistributor.h | 2 +- src/fsfw/tcdistribution/PUSDistributor.h | 2 +- src/fsfw/tcdistribution/TcDistributor.h | 2 +- src/fsfw/tcdistribution/TcPacketCheckIF.h | 2 +- src/fsfw/tcdistribution/TcPacketCheckPUS.h | 2 +- src/fsfw/thermal/Heater.h | 2 +- src/fsfw/thermal/ThermalComponentIF.h | 2 +- src/fsfw/timemanager/CCSDSTime.h | 2 +- src/fsfw/timemanager/Clock.h | 2 +- src/fsfw/timemanager/TimeStamperIF.h | 2 +- src/fsfw/tmstorage/TmStoreBackendIF.h | 2 +- src/fsfw/tmstorage/TmStoreFrontendIF.h | 2 +- src/fsfw/tmtcpacket/RedirectableDataPointerIF.h | 2 +- src/fsfw/tmtcpacket/SpacePacketBase.h | 2 +- src/fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h | 2 +- src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h | 2 +- src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h | 2 +- src/fsfw/tmtcservices/PusServiceBase.h | 2 +- src/fsfw/tmtcservices/PusVerificationReport.h | 2 +- src/fsfw_hal/common/gpio/GpioCookie.h | 2 +- src/fsfw_hal/common/gpio/GpioIF.h | 2 +- src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp | 2 +- src/fsfw_hal/linux/CommandExecutor.h | 2 +- src/fsfw_hal/linux/UnixFileGuard.h | 2 +- src/fsfw_hal/linux/rpi/GpioRPi.h | 2 +- src/fsfw_hal/linux/spi/spiDefinitions.h | 2 +- src/fsfw_hal/linux/uio/UioMapper.h | 2 +- src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h | 2 +- src/fsfw_hal/stm32h7/spi/spiDefinitions.h | 2 +- src/fsfw_tests/integration/task/TestTask.h | 2 +- src/fsfw_tests/internal/InternalUnitTester.h | 2 +- src/fsfw_tests/internal/UnittDefinitions.h | 2 +- src/fsfw_tests/internal/serialize/IntTestSerialization.h | 2 +- unittests/CatchDefinitions.h | 2 +- unittests/container/TestArrayList.cpp | 2 +- unittests/container/TestDynamicFifo.cpp | 2 +- unittests/container/TestFifo.cpp | 2 +- unittests/container/TestFixedArrayList.cpp | 2 +- unittests/container/TestFixedMap.cpp | 2 +- unittests/container/TestFixedOrderedMultimap.cpp | 2 +- unittests/container/TestPlacementFactory.cpp | 2 +- unittests/devicehandler/DeviceHandlerCommander.h | 2 +- unittests/testcfg/pollingsequence/PollingSequenceFactory.h | 2 +- 119 files changed, 127 insertions(+), 127 deletions(-) rename src/fsfw/returnvalues/{HasReturnvaluesIF.h => returnvalue.h} (81%) diff --git a/docs/api/returnvalue.rst b/docs/api/returnvalue.rst index b0d43916..da65c141 100644 --- a/docs/api/returnvalue.rst +++ b/docs/api/returnvalue.rst @@ -3,7 +3,7 @@ Returnvalue API ================== -.. doxygenfile:: HasReturnvaluesIF.h +.. doxygenfile:: returnvalue.h .. _fwclassids: diff --git a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.h b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.h index c5d41b7d..622cc49a 100644 --- a/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.h +++ b/misc/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.h @@ -1,7 +1,7 @@ #ifndef POLLINGSEQUENCEFACTORY_H_ #define POLLINGSEQUENCEFACTORY_H_ -#include +#include class FixedTimeslotTaskIF; diff --git a/src/fsfw/action/CommandActionHelper.h b/src/fsfw/action/CommandActionHelper.h index a6ec0ca7..55176e09 100644 --- a/src/fsfw/action/CommandActionHelper.h +++ b/src/fsfw/action/CommandActionHelper.h @@ -4,7 +4,7 @@ #include "ActionMessage.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/objectmanager/ObjectManagerIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/serialize/SerializeIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" diff --git a/src/fsfw/action/CommandsActionsIF.h b/src/fsfw/action/CommandsActionsIF.h index 94d9a7c4..a183051d 100644 --- a/src/fsfw/action/CommandsActionsIF.h +++ b/src/fsfw/action/CommandsActionsIF.h @@ -3,7 +3,7 @@ #include "CommandActionHelper.h" #include "fsfw/ipc/MessageQueueIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" /** * Interface to separate commanding actions of other objects. diff --git a/src/fsfw/action/HasActionsIF.h b/src/fsfw/action/HasActionsIF.h index 45247d1a..29e267a0 100644 --- a/src/fsfw/action/HasActionsIF.h +++ b/src/fsfw/action/HasActionsIF.h @@ -5,7 +5,7 @@ #include "ActionMessage.h" #include "SimpleActionHelper.h" #include "fsfw/ipc/MessageQueueIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" /** * @brief diff --git a/src/fsfw/cfdp/CFDPHandler.h b/src/fsfw/cfdp/CFDPHandler.h index 6888f9d7..53a8a009 100644 --- a/src/fsfw/cfdp/CFDPHandler.h +++ b/src/fsfw/cfdp/CFDPHandler.h @@ -3,7 +3,7 @@ #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tcdistribution/CFDPDistributor.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index b8827f63..7aad21e7 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -7,7 +7,7 @@ #include #include "fsfw/returnvalues/FwClassIds.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" namespace cfdp { diff --git a/src/fsfw/container/ArrayList.h b/src/fsfw/container/ArrayList.h index 608e7e55..f5f74cf1 100644 --- a/src/fsfw/container/ArrayList.h +++ b/src/fsfw/container/ArrayList.h @@ -1,7 +1,7 @@ #ifndef FSFW_CONTAINER_ARRAYLIST_H_ #define FSFW_CONTAINER_ARRAYLIST_H_ -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeIF.h" diff --git a/src/fsfw/container/FIFOBase.h b/src/fsfw/container/FIFOBase.h index 7c51bc39..bb92790c 100644 --- a/src/fsfw/container/FIFOBase.h +++ b/src/fsfw/container/FIFOBase.h @@ -4,7 +4,7 @@ #include #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" template class FIFOBase { diff --git a/src/fsfw/container/FixedMap.h b/src/fsfw/container/FixedMap.h index c6b2c9b5..def219d1 100644 --- a/src/fsfw/container/FixedMap.h +++ b/src/fsfw/container/FixedMap.h @@ -4,7 +4,7 @@ #include #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "ArrayList.h" /** diff --git a/src/fsfw/container/IndexedRingMemoryArray.h b/src/fsfw/container/IndexedRingMemoryArray.h index 4ad72592..127ed5d7 100644 --- a/src/fsfw/container/IndexedRingMemoryArray.h +++ b/src/fsfw/container/IndexedRingMemoryArray.h @@ -4,7 +4,7 @@ #include #include "../globalfunctions/CRC.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "../serialize/SerialArrayListAdapter.h" #include "../serviceinterface/ServiceInterfaceStream.h" #include "ArrayList.h" diff --git a/src/fsfw/container/RingBufferBase.h b/src/fsfw/container/RingBufferBase.h index 77a0583b..e86f0ee1 100644 --- a/src/fsfw/container/RingBufferBase.h +++ b/src/fsfw/container/RingBufferBase.h @@ -3,7 +3,7 @@ #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" template class RingBufferBase { diff --git a/src/fsfw/coordinates/Sgp4Propagator.h b/src/fsfw/coordinates/Sgp4Propagator.h index 0edaf459..5cbeb3f2 100644 --- a/src/fsfw/coordinates/Sgp4Propagator.h +++ b/src/fsfw/coordinates/Sgp4Propagator.h @@ -7,7 +7,7 @@ #ifndef PLATFORM_WIN #include #endif -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw_contrib/sgp4/sgp4unit.h" class Sgp4Propagator { diff --git a/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h b/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h index 22ff12e4..71d14e60 100644 --- a/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h +++ b/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h @@ -9,12 +9,12 @@ #define CCSDSRETURNVALUESIF_H_ #include "dllConf.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" /** * This is a helper class to collect special return values that come up during CCSDS Handling. * @ingroup ccsds_handling */ -class CCSDSReturnValuesIF : public HasReturnvaluesIF { +class CCSDSReturnValuesIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_HANDLER_IF; //!< Basic ID of the interface. diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.h b/src/fsfw/datalinklayer/MapPacketExtraction.h index 6586722c..fab7f3c3 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.h +++ b/src/fsfw/datalinklayer/MapPacketExtraction.h @@ -5,7 +5,7 @@ #include "dllConf.h" #include "fsfw/ipc/MessageQueueSenderIF.h" #include "fsfw/objectmanager/ObjectManagerIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" class StorageManagerIF; diff --git a/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h b/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h index 8874909b..9239ee0e 100644 --- a/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h +++ b/src/fsfw/datalinklayer/VirtualChannelReceptionIF.h @@ -11,7 +11,7 @@ #include "ClcwIF.h" #include "TcTransferFrame.h" #include "dllConf.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" /** * This is the interface for Virtual Channel reception classes. diff --git a/src/fsfw/datapool/DataSetIF.h b/src/fsfw/datapool/DataSetIF.h index 492bcf29..3d4be351 100644 --- a/src/fsfw/datapool/DataSetIF.h +++ b/src/fsfw/datapool/DataSetIF.h @@ -1,7 +1,7 @@ #ifndef FSFW_DATAPOOL_DATASETIF_H_ #define FSFW_DATAPOOL_DATASETIF_H_ -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "../timemanager/Clock.h" class PoolVariableIF; diff --git a/src/fsfw/datapool/PoolVariableIF.h b/src/fsfw/datapool/PoolVariableIF.h index 95cf898e..69074310 100644 --- a/src/fsfw/datapool/PoolVariableIF.h +++ b/src/fsfw/datapool/PoolVariableIF.h @@ -1,7 +1,7 @@ #ifndef FSFW_DATAPOOL_POOLVARIABLEIF_H_ #define FSFW_DATAPOOL_POOLVARIABLEIF_H_ -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "../serialize/SerializeIF.h" #include "ReadCommitIF.h" diff --git a/src/fsfw/datapool/ReadCommitIF.h b/src/fsfw/datapool/ReadCommitIF.h index 08554be1..ca074dec 100644 --- a/src/fsfw/datapool/ReadCommitIF.h +++ b/src/fsfw/datapool/ReadCommitIF.h @@ -2,7 +2,7 @@ #define FSFW_DATAPOOL_READCOMMITIF_H_ #include "../ipc/MutexIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" /** * @brief Common interface for all software objects which employ read-commit diff --git a/src/fsfw/datapool/ReadCommitIFAttorney.h b/src/fsfw/datapool/ReadCommitIFAttorney.h index 361ac6e4..cca76c97 100644 --- a/src/fsfw/datapool/ReadCommitIFAttorney.h +++ b/src/fsfw/datapool/ReadCommitIFAttorney.h @@ -2,7 +2,7 @@ #define FSFW_DATAPOOL_READCOMMITIFATTORNEY_H_ #include -#include +#include /** * @brief This class determines which members are allowed to access protected members diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.h b/src/fsfw/datapoollocal/LocalPoolObjectBase.h index f454fea3..a4ecbd55 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.h +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.h @@ -4,7 +4,7 @@ #include "MarkChangedIF.h" #include "fsfw/datapool/PoolVariableIF.h" #include "fsfw/objectmanager/SystemObjectIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "localPoolDefinitions.h" class LocalDataPoolManager; diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index 1f13a09d..eb4e55b7 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -2,7 +2,7 @@ #define FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_ #include "../ipc/messageQueueDefinitions.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "localPoolDefinitions.h" class ProvidesDataPoolSubscriptionIF { diff --git a/src/fsfw/devicehandlers/DeviceCommunicationIF.h b/src/fsfw/devicehandlers/DeviceCommunicationIF.h index cf00a8e2..a5546a36 100644 --- a/src/fsfw/devicehandlers/DeviceCommunicationIF.h +++ b/src/fsfw/devicehandlers/DeviceCommunicationIF.h @@ -1,7 +1,7 @@ #ifndef FSFW_DEVICES_DEVICECOMMUNICATIONIF_H_ #define FSFW_DEVICES_DEVICECOMMUNICATIONIF_H_ -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "CookieIF.h" #include "DeviceHandlerIF.h" /** diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index a37a4740..a20eae0c 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -18,7 +18,7 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/parameters/ParameterHelper.h" #include "fsfw/power/PowerSwitchIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/serviceInterfaceDefintions.h" #include "fsfw/tasks/ExecutableObjectIF.h" diff --git a/src/fsfw/events/eventmatching/EventMatchTree.h b/src/fsfw/events/eventmatching/EventMatchTree.h index 7561e27d..0d06f0c2 100644 --- a/src/fsfw/events/eventmatching/EventMatchTree.h +++ b/src/fsfw/events/eventmatching/EventMatchTree.h @@ -4,7 +4,7 @@ #include "../../container/PlacementFactory.h" #include "../../events/EventMessage.h" #include "../../globalfunctions/matching/MatchTree.h" -#include "../../returnvalues/HasReturnvaluesIF.h" +#include "../../returnvalues/returnvalue.h" class StorageManagerIF; class EventMatchTree : public MatchTree { diff --git a/src/fsfw/fdir/ConfirmsFailuresIF.h b/src/fsfw/fdir/ConfirmsFailuresIF.h index e4d26907..4424747e 100644 --- a/src/fsfw/fdir/ConfirmsFailuresIF.h +++ b/src/fsfw/fdir/ConfirmsFailuresIF.h @@ -2,7 +2,7 @@ #define FRAMEWORK_FDIR_CONFIRMSFAILURESIF_H_ #include "../ipc/MessageQueueSenderIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" class ConfirmsFailuresIF { public: diff --git a/src/fsfw/fdir/FailureIsolationBase.h b/src/fsfw/fdir/FailureIsolationBase.h index 543d9fca..7ebfa9af 100644 --- a/src/fsfw/fdir/FailureIsolationBase.h +++ b/src/fsfw/fdir/FailureIsolationBase.h @@ -5,7 +5,7 @@ #include "../health/HealthMessage.h" #include "../ipc/MessageQueueIF.h" #include "../parameters/HasParametersIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "ConfirmsFailuresIF.h" #include "FaultCounter.h" diff --git a/src/fsfw/globalfunctions/AsciiConverter.h b/src/fsfw/globalfunctions/AsciiConverter.h index 7eb28882..e6cd60a7 100644 --- a/src/fsfw/globalfunctions/AsciiConverter.h +++ b/src/fsfw/globalfunctions/AsciiConverter.h @@ -1,7 +1,7 @@ #ifndef ASCIICONVERTER_H_ #define ASCIICONVERTER_H_ -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" class AsciiConverter { public: diff --git a/src/fsfw/globalfunctions/DleEncoder.h b/src/fsfw/globalfunctions/DleEncoder.h index 85656b37..b7242ebe 100644 --- a/src/fsfw/globalfunctions/DleEncoder.h +++ b/src/fsfw/globalfunctions/DleEncoder.h @@ -3,7 +3,7 @@ #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" /** * @brief This DLE Encoder (Data Link Encoder) can be used to encode and diff --git a/src/fsfw/globalfunctions/Type.h b/src/fsfw/globalfunctions/Type.h index 385d7219..918ba4e8 100644 --- a/src/fsfw/globalfunctions/Type.h +++ b/src/fsfw/globalfunctions/Type.h @@ -3,7 +3,7 @@ #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/serialize/SerializeIF.h" /** diff --git a/src/fsfw/health/HasHealthIF.h b/src/fsfw/health/HasHealthIF.h index 41abeef3..77a1c12f 100644 --- a/src/fsfw/health/HasHealthIF.h +++ b/src/fsfw/health/HasHealthIF.h @@ -3,7 +3,7 @@ #include "../events/Event.h" #include "../ipc/MessageQueueSenderIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" class HasHealthIF { public: diff --git a/src/fsfw/health/HealthHelper.h b/src/fsfw/health/HealthHelper.h index 84985559..6b550f90 100644 --- a/src/fsfw/health/HealthHelper.h +++ b/src/fsfw/health/HealthHelper.h @@ -5,7 +5,7 @@ #include "../events/EventReportingProxyIF.h" #include "../ipc/MessageQueueIF.h" #include "../objectmanager/ObjectManagerIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "HasHealthIF.h" #include "HealthMessage.h" #include "HealthTableIF.h" diff --git a/src/fsfw/health/HealthTableIF.h b/src/fsfw/health/HealthTableIF.h index aab3f0eb..0b993691 100644 --- a/src/fsfw/health/HealthTableIF.h +++ b/src/fsfw/health/HealthTableIF.h @@ -4,7 +4,7 @@ #include #include "../objectmanager/ObjectManagerIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "ManagesHealthIF.h" class HealthTableIF : public ManagesHealthIF { diff --git a/src/fsfw/ipc/CommandMessageIF.h b/src/fsfw/ipc/CommandMessageIF.h index aea08203..dc8f7109 100644 --- a/src/fsfw/ipc/CommandMessageIF.h +++ b/src/fsfw/ipc/CommandMessageIF.h @@ -1,7 +1,7 @@ #ifndef FSFW_IPC_COMMANDMESSAGEIF_H_ #define FSFW_IPC_COMMANDMESSAGEIF_H_ -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "FwMessageTypes.h" #include "MessageQueueMessageIF.h" diff --git a/src/fsfw/ipc/MessageQueueIF.h b/src/fsfw/ipc/MessageQueueIF.h index b229747e..4fe8a63b 100644 --- a/src/fsfw/ipc/MessageQueueIF.h +++ b/src/fsfw/ipc/MessageQueueIF.h @@ -5,7 +5,7 @@ #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "MessageQueueMessageIF.h" #include "messageQueueDefinitions.h" diff --git a/src/fsfw/ipc/MutexIF.h b/src/fsfw/ipc/MutexIF.h index 0bdfa1f4..30992f7b 100644 --- a/src/fsfw/ipc/MutexIF.h +++ b/src/fsfw/ipc/MutexIF.h @@ -1,7 +1,7 @@ #ifndef FRAMEWORK_IPC_MUTEXIF_H_ #define FRAMEWORK_IPC_MUTEXIF_H_ -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" /** * @brief Common interface for OS Mutex objects which provide MUTual EXclusion. diff --git a/src/fsfw/memory/HasFileSystemIF.h b/src/fsfw/memory/HasFileSystemIF.h index 88a7db83..4c081e26 100644 --- a/src/fsfw/memory/HasFileSystemIF.h +++ b/src/fsfw/memory/HasFileSystemIF.h @@ -6,7 +6,7 @@ #include "FileSystemArgsIF.h" #include "fsfw/ipc/messageQueueDefinitions.h" #include "fsfw/returnvalues/FwClassIds.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" /** * @brief Generic interface for objects which expose a file system to enable diff --git a/src/fsfw/memory/HasMemoryIF.h b/src/fsfw/memory/HasMemoryIF.h index 342f7115..b39032af 100644 --- a/src/fsfw/memory/HasMemoryIF.h +++ b/src/fsfw/memory/HasMemoryIF.h @@ -1,7 +1,7 @@ #ifndef HASMEMORYIF_H_ #define HASMEMORYIF_H_ -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" class HasMemoryIF { public: diff --git a/src/fsfw/memory/MemoryHelper.h b/src/fsfw/memory/MemoryHelper.h index 3a51f7dc..095b366f 100644 --- a/src/fsfw/memory/MemoryHelper.h +++ b/src/fsfw/memory/MemoryHelper.h @@ -3,7 +3,7 @@ #include "../ipc/CommandMessage.h" #include "../ipc/MessageQueueIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "../storagemanager/StorageManagerIF.h" #include "AcceptsMemoryMessagesIF.h" diff --git a/src/fsfw/modes/HasModesIF.h b/src/fsfw/modes/HasModesIF.h index 03cc45bf..599975f8 100644 --- a/src/fsfw/modes/HasModesIF.h +++ b/src/fsfw/modes/HasModesIF.h @@ -4,7 +4,7 @@ #include #include "../events/Event.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "ModeHelper.h" #include "ModeMessage.h" diff --git a/src/fsfw/modes/ModeHelper.h b/src/fsfw/modes/ModeHelper.h index 4d0479db..a84408a2 100644 --- a/src/fsfw/modes/ModeHelper.h +++ b/src/fsfw/modes/ModeHelper.h @@ -3,7 +3,7 @@ #include "ModeMessage.h" #include "fsfw/ipc/MessageQueueIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/timemanager/Countdown.h" class HasModesIF; diff --git a/src/fsfw/monitoring/LimitViolationReporter.h b/src/fsfw/monitoring/LimitViolationReporter.h index 06b3ba74..12747725 100644 --- a/src/fsfw/monitoring/LimitViolationReporter.h +++ b/src/fsfw/monitoring/LimitViolationReporter.h @@ -8,7 +8,7 @@ #define LIMITVIOLATIONREPORTER_H_ #include "../ipc/MessageQueueSenderIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "../serialize/SerializeIF.h" #include "../storagemanager/StorageManagerIF.h" #include "monitoringConf.h" diff --git a/src/fsfw/objectmanager/ObjectManagerIF.h b/src/fsfw/objectmanager/ObjectManagerIF.h index eae35319..81ddd95a 100644 --- a/src/fsfw/objectmanager/ObjectManagerIF.h +++ b/src/fsfw/objectmanager/ObjectManagerIF.h @@ -1,7 +1,7 @@ #ifndef FSFW_OBJECTMANAGER_OBJECTMANAGERIF_H_ #define FSFW_OBJECTMANAGER_OBJECTMANAGERIF_H_ -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "../serviceinterface/ServiceInterface.h" #include "SystemObjectIF.h" #include "frameworkObjects.h" diff --git a/src/fsfw/objectmanager/SystemObjectIF.h b/src/fsfw/objectmanager/SystemObjectIF.h index 25065662..490de20b 100644 --- a/src/fsfw/objectmanager/SystemObjectIF.h +++ b/src/fsfw/objectmanager/SystemObjectIF.h @@ -4,7 +4,7 @@ #include #include "../events/EventReportingProxyIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" /** * @defgroup system_objects Software System Object Management * The classes to create System Objects and classes to manage these are diff --git a/src/fsfw/osal/InternalErrorCodes.h b/src/fsfw/osal/InternalErrorCodes.h index 5924d4c9..abec460f 100644 --- a/src/fsfw/osal/InternalErrorCodes.h +++ b/src/fsfw/osal/InternalErrorCodes.h @@ -1,7 +1,7 @@ #ifndef INTERNALERRORCODES_H_ #define INTERNALERRORCODES_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" class InternalErrorCodes { public: diff --git a/src/fsfw/osal/common/TcpIpBase.h b/src/fsfw/osal/common/TcpIpBase.h index ccbd12ca..6cc71fbf 100644 --- a/src/fsfw/osal/common/TcpIpBase.h +++ b/src/fsfw/osal/common/TcpIpBase.h @@ -2,7 +2,7 @@ #define FSFW_OSAL_COMMON_TCPIPIF_H_ #include "../../platform.h" -#include "../../returnvalues/HasReturnvaluesIF.h" +#include "../../returnvalues/returnvalue.h" #ifdef PLATFORM_WIN #include diff --git a/src/fsfw/osal/freertos/BinSemaphUsingTask.h b/src/fsfw/osal/freertos/BinSemaphUsingTask.h index b29ecdc9..480296ee 100644 --- a/src/fsfw/osal/freertos/BinSemaphUsingTask.h +++ b/src/fsfw/osal/freertos/BinSemaphUsingTask.h @@ -2,7 +2,7 @@ #define FSFW_OSAL_FREERTOS_BINSEMAPHUSINGTASK_H_ #include "FreeRTOS.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tasks/SemaphoreIF.h" #include "task.h" @@ -20,7 +20,7 @@ * (for example in the initializeAfterTaskCreation() function) or * by calling refreshTaskHandle() with the correct executing task. */ -class BinarySemaphoreUsingTask : public SemaphoreIF, public HasReturnvaluesIF { +class BinarySemaphoreUsingTask : public SemaphoreIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::SEMAPHORE_IF; diff --git a/src/fsfw/osal/freertos/BinarySemaphore.h b/src/fsfw/osal/freertos/BinarySemaphore.h index d7fbf351..bd1148ec 100644 --- a/src/fsfw/osal/freertos/BinarySemaphore.h +++ b/src/fsfw/osal/freertos/BinarySemaphore.h @@ -2,7 +2,7 @@ #define FSFW_OSAL_FREERTOS_BINARYSEMPAHORE_H_ #include "FreeRTOS.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tasks/SemaphoreIF.h" #include "semphr.h" @@ -22,7 +22,7 @@ * @author R. Mueller * @ingroup osal */ -class BinarySemaphore : public SemaphoreIF, public HasReturnvaluesIF { +class BinarySemaphore : public SemaphoreIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::SEMAPHORE_IF; diff --git a/src/fsfw/osal/freertos/TaskFactory.cpp b/src/fsfw/osal/freertos/TaskFactory.cpp index c79a6cf1..688069cf 100644 --- a/src/fsfw/osal/freertos/TaskFactory.cpp +++ b/src/fsfw/osal/freertos/TaskFactory.cpp @@ -2,7 +2,7 @@ #include "fsfw/osal/freertos/FixedTimeslotTask.h" #include "fsfw/osal/freertos/PeriodicTask.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" TaskFactory* TaskFactory::factoryInstance = new TaskFactory(); diff --git a/src/fsfw/osal/freertos/TaskManagement.h b/src/fsfw/osal/freertos/TaskManagement.h index 825d8865..6dec15cc 100644 --- a/src/fsfw/osal/freertos/TaskManagement.h +++ b/src/fsfw/osal/freertos/TaskManagement.h @@ -3,7 +3,7 @@ #include -#include "../../returnvalues/HasReturnvaluesIF.h" +#include "../../returnvalues/returnvalue.h" #include "FreeRTOS.h" #include "task.h" diff --git a/src/fsfw/osal/host/TaskFactory.cpp b/src/fsfw/osal/host/TaskFactory.cpp index e9415f5a..0a27241b 100644 --- a/src/fsfw/osal/host/TaskFactory.cpp +++ b/src/fsfw/osal/host/TaskFactory.cpp @@ -5,7 +5,7 @@ #include "fsfw/osal/host/FixedTimeslotTask.h" #include "fsfw/osal/host/PeriodicTask.h" #include "fsfw/osal/host/taskHelpers.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tasks/PeriodicTaskIF.h" diff --git a/src/fsfw/osal/host/taskHelpers.h b/src/fsfw/osal/host/taskHelpers.h index 13a71d16..7d9ff33c 100644 --- a/src/fsfw/osal/host/taskHelpers.h +++ b/src/fsfw/osal/host/taskHelpers.h @@ -1,7 +1,7 @@ #ifndef FSFW_OSAL_HOST_TASKHELPERS_H_ #define FSFW_OSAL_HOST_TASKHELPERS_H_ -#include +#include #include diff --git a/src/fsfw/osal/linux/BinarySemaphore.h b/src/fsfw/osal/linux/BinarySemaphore.h index c7289712..fe2c0db0 100644 --- a/src/fsfw/osal/linux/BinarySemaphore.h +++ b/src/fsfw/osal/linux/BinarySemaphore.h @@ -1,7 +1,7 @@ #ifndef FRAMEWORK_OSAL_LINUX_BINARYSEMPAHORE_H_ #define FRAMEWORK_OSAL_LINUX_BINARYSEMPAHORE_H_ -#include "../../returnvalues/HasReturnvaluesIF.h" +#include "../../returnvalues/returnvalue.h" #include "../../tasks/SemaphoreIF.h" extern "C" { @@ -17,7 +17,7 @@ extern "C" { * @author R. Mueller * @ingroup osal */ -class BinarySemaphore : public SemaphoreIF, public HasReturnvaluesIF { +class BinarySemaphore : public SemaphoreIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::SEMAPHORE_IF; diff --git a/src/fsfw/osal/linux/PosixThread.h b/src/fsfw/osal/linux/PosixThread.h index 78fdfa2b..add41bf6 100644 --- a/src/fsfw/osal/linux/PosixThread.h +++ b/src/fsfw/osal/linux/PosixThread.h @@ -7,7 +7,7 @@ #include -#include "../../returnvalues/HasReturnvaluesIF.h" +#include "../../returnvalues/returnvalue.h" class PosixThread { public: diff --git a/src/fsfw/osal/linux/TaskFactory.cpp b/src/fsfw/osal/linux/TaskFactory.cpp index 2cd4fd67..bacc4311 100644 --- a/src/fsfw/osal/linux/TaskFactory.cpp +++ b/src/fsfw/osal/linux/TaskFactory.cpp @@ -2,7 +2,7 @@ #include "fsfw/osal/linux/FixedTimeslotTask.h" #include "fsfw/osal/linux/PeriodicPosixTask.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/serviceinterface/ServiceInterface.h" // TODO: Different variant than the lazy loading in QueueFactory. What's better and why? diff --git a/src/fsfw/osal/rtems/FixedTimeslotTask.cpp b/src/fsfw/osal/rtems/FixedTimeslotTask.cpp index 77582d75..c1cc4460 100644 --- a/src/fsfw/osal/rtems/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/rtems/FixedTimeslotTask.cpp @@ -6,7 +6,7 @@ #include #include "fsfw/osal/rtems/RtemsBasic.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/serviceinterface/ServiceInterface.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/osal/rtems/RtemsBasic.h b/src/fsfw/osal/rtems/RtemsBasic.h index 3525799c..ea97c3af 100644 --- a/src/fsfw/osal/rtems/RtemsBasic.h +++ b/src/fsfw/osal/rtems/RtemsBasic.h @@ -8,7 +8,7 @@ #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" class RtemsBasic { public: diff --git a/src/fsfw/osal/rtems/TaskFactory.cpp b/src/fsfw/osal/rtems/TaskFactory.cpp index f10e5cf3..4dbd254e 100644 --- a/src/fsfw/osal/rtems/TaskFactory.cpp +++ b/src/fsfw/osal/rtems/TaskFactory.cpp @@ -3,7 +3,7 @@ #include "fsfw/osal/rtems/FixedTimeslotTask.h" #include "fsfw/osal/rtems/PeriodicTask.h" #include "fsfw/osal/rtems/RtemsBasic.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" // TODO: Different variant than the lazy loading in QueueFactory. What's better and why? TaskFactory* TaskFactory::factoryInstance = new TaskFactory(); diff --git a/src/fsfw/parameters/HasParametersIF.h b/src/fsfw/parameters/HasParametersIF.h index 48557b4a..d586ceba 100644 --- a/src/fsfw/parameters/HasParametersIF.h +++ b/src/fsfw/parameters/HasParametersIF.h @@ -3,7 +3,7 @@ #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "ParameterWrapper.h" /** diff --git a/src/fsfw/parameters/ParameterWrapper.h b/src/fsfw/parameters/ParameterWrapper.h index 5a8e20a4..7767255e 100644 --- a/src/fsfw/parameters/ParameterWrapper.h +++ b/src/fsfw/parameters/ParameterWrapper.h @@ -4,7 +4,7 @@ #include #include "../globalfunctions/Type.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeIF.h" diff --git a/src/fsfw/power/Fuse.h b/src/fsfw/power/Fuse.h index 1f880f3a..e8b86cfd 100644 --- a/src/fsfw/power/Fuse.h +++ b/src/fsfw/power/Fuse.h @@ -7,7 +7,7 @@ #include "../devicehandlers/HealthDevice.h" #include "../monitoring/AbsLimitMonitor.h" #include "../parameters/ParameterHelper.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "PowerComponentIF.h" #include "PowerSwitchIF.h" namespace Factory { diff --git a/src/fsfw/power/PowerSwitchIF.h b/src/fsfw/power/PowerSwitchIF.h index 054923f4..e8c9aff4 100644 --- a/src/fsfw/power/PowerSwitchIF.h +++ b/src/fsfw/power/PowerSwitchIF.h @@ -2,7 +2,7 @@ #define FSFW_POWER_POWERSWITCHIF_H_ #include "../events/Event.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "definitions.h" /** * @@ -20,7 +20,7 @@ class PowerSwitchIF { */ virtual ~PowerSwitchIF() {} /** - * The Returnvalues id of this class, required by HasReturnvaluesIF + * The Returnvalues id of this class */ static const uint8_t INTERFACE_ID = CLASS_ID::POWER_SWITCH_IF; static const ReturnValue_t SWITCH_ON = MAKE_RETURN_CODE(1); diff --git a/src/fsfw/power/PowerSwitcher.h b/src/fsfw/power/PowerSwitcher.h index 7aa60494..7a38336c 100644 --- a/src/fsfw/power/PowerSwitcher.h +++ b/src/fsfw/power/PowerSwitcher.h @@ -2,7 +2,7 @@ #define FSFW_POWER_POWERSWITCHER_H_ #include "../objectmanager/SystemObjectIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "../timemanager/Countdown.h" #include "PowerSwitchIF.h" diff --git a/src/fsfw/pus/Service1TelecommandVerification.h b/src/fsfw/pus/Service1TelecommandVerification.h index 02a5e513..d921b48c 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.h +++ b/src/fsfw/pus/Service1TelecommandVerification.h @@ -3,7 +3,7 @@ #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" diff --git a/src/fsfw/returnvalues/HasReturnvaluesIF.h b/src/fsfw/returnvalues/returnvalue.h similarity index 81% rename from src/fsfw/returnvalues/HasReturnvaluesIF.h rename to src/fsfw/returnvalues/returnvalue.h index 79a0d9bd..c7927a8d 100644 --- a/src/fsfw/returnvalues/HasReturnvaluesIF.h +++ b/src/fsfw/returnvalues/returnvalue.h @@ -1,5 +1,5 @@ -#ifndef FSFW_RETURNVALUES_HASRETURNVALUESIF_H_ -#define FSFW_RETURNVALUES_HASRETURNVALUESIF_H_ +#ifndef FSFW_RETURNVALUES_RETURNVALUE_H_ +#define FSFW_RETURNVALUES_RETURNVALUE_H_ #include @@ -29,4 +29,4 @@ static constexpr ReturnValue_t makeCode( } -#endif /* FSFW_RETURNVALUES_HASRETURNVALUESIF_H_ */ +#endif /* FSFW_RETURNVALUES_RETURNVALUE_H_ */ diff --git a/src/fsfw/rmap/RMAP.h b/src/fsfw/rmap/RMAP.h index d274fb15..df6eaf5e 100644 --- a/src/fsfw/rmap/RMAP.h +++ b/src/fsfw/rmap/RMAP.h @@ -1,7 +1,7 @@ #ifndef FSFW_RMAP_RMAP_H_ #define FSFW_RMAP_RMAP_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/rmap/RMAPCookie.h" #include "rmapConf.h" @@ -36,7 +36,7 @@ * assignment can be changed at runtime to allow for example redundancy switching. This API is * static as the information which channel to use is contained within the cookie. */ -class RMAP : public HasReturnvaluesIF { +class RMAP { public: static const uint8_t INTERFACE_ID = CLASS_ID::RMAP_CHANNEL; diff --git a/src/fsfw/rmap/RMAPChannelIF.h b/src/fsfw/rmap/RMAPChannelIF.h index aea08c86..60d439d0 100644 --- a/src/fsfw/rmap/RMAPChannelIF.h +++ b/src/fsfw/rmap/RMAPChannelIF.h @@ -4,7 +4,7 @@ #include #include "RMAPCookie.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "rmapConf.h" class RMAPChannelIF { diff --git a/src/fsfw/serialize/SerializeAdapter.h b/src/fsfw/serialize/SerializeAdapter.h index cc06aa80..bca0e637 100644 --- a/src/fsfw/serialize/SerializeAdapter.h +++ b/src/fsfw/serialize/SerializeAdapter.h @@ -4,7 +4,7 @@ #include #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "EndianConverter.h" #include "SerializeIF.h" diff --git a/src/fsfw/serialize/SerializeIF.h b/src/fsfw/serialize/SerializeIF.h index 0e9840eb..85c29827 100644 --- a/src/fsfw/serialize/SerializeIF.h +++ b/src/fsfw/serialize/SerializeIF.h @@ -3,7 +3,7 @@ #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" /** * @defgroup serialize Serialization diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h index 9cda75c6..2ecf88d8 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h @@ -3,7 +3,7 @@ #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/storagemanager/ConstStorageAccessor.h b/src/fsfw/storagemanager/ConstStorageAccessor.h index a2ddad6c..9cad346c 100644 --- a/src/fsfw/storagemanager/ConstStorageAccessor.h +++ b/src/fsfw/storagemanager/ConstStorageAccessor.h @@ -3,7 +3,7 @@ #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "storeAddress.h" class StorageManagerIF; diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index 66002ca9..4041c84b 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -5,7 +5,7 @@ #include #include "../events/Event.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "StorageAccessor.h" #include "storeAddress.h" diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index f61340ac..6db9efa5 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -9,7 +9,7 @@ #include "../ipc/MessageQueueIF.h" #include "../modes/HasModesIF.h" #include "../objectmanager/SystemObject.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "../tasks/ExecutableObjectIF.h" #include "modes/HasModeSequenceIF.h" diff --git a/src/fsfw/subsystem/modes/ModeStoreIF.h b/src/fsfw/subsystem/modes/ModeStoreIF.h index 79215971..3d56f992 100644 --- a/src/fsfw/subsystem/modes/ModeStoreIF.h +++ b/src/fsfw/subsystem/modes/ModeStoreIF.h @@ -7,7 +7,7 @@ #include "../../container/ArrayList.h" #include "../../container/SinglyLinkedList.h" -#include "../../returnvalues/HasReturnvaluesIF.h" +#include "../../returnvalues/returnvalue.h" #include "ModeDefinitions.h" class ModeStoreIF { diff --git a/src/fsfw/tasks/ExecutableObjectIF.h b/src/fsfw/tasks/ExecutableObjectIF.h index 60f38259..1e3f19e4 100644 --- a/src/fsfw/tasks/ExecutableObjectIF.h +++ b/src/fsfw/tasks/ExecutableObjectIF.h @@ -5,7 +5,7 @@ class PeriodicTaskIF; #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" /** * @brief The interface provides a method to execute objects within a task. * @details The performOperation method, that is required by the interface is diff --git a/src/fsfw/tasks/SemaphoreIF.h b/src/fsfw/tasks/SemaphoreIF.h index 37275529..9a692e9b 100644 --- a/src/fsfw/tasks/SemaphoreIF.h +++ b/src/fsfw/tasks/SemaphoreIF.h @@ -3,7 +3,7 @@ #include #include "../returnvalues/FwClassIds.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" /** * @brief Generic interface for semaphores, which can be used to achieve diff --git a/src/fsfw/tcdistribution/CFDPDistributor.h b/src/fsfw/tcdistribution/CFDPDistributor.h index 2a901021..18c139ff 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.h +++ b/src/fsfw/tcdistribution/CFDPDistributor.h @@ -3,7 +3,7 @@ #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "../tmtcpacket/cfdp/CFDPPacketStored.h" #include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../tmtcservices/VerificationReporter.h" diff --git a/src/fsfw/tcdistribution/PUSDistributor.h b/src/fsfw/tcdistribution/PUSDistributor.h index c069c81b..8cef0f46 100644 --- a/src/fsfw/tcdistribution/PUSDistributor.h +++ b/src/fsfw/tcdistribution/PUSDistributor.h @@ -4,7 +4,7 @@ #include "PUSDistributorIF.h" #include "TcDistributor.h" #include "TcPacketCheckPUS.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tmtcpacket/pus/tc.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/VerificationReporter.h" diff --git a/src/fsfw/tcdistribution/TcDistributor.h b/src/fsfw/tcdistribution/TcDistributor.h index 62cd5dc9..d018cad4 100644 --- a/src/fsfw/tcdistribution/TcDistributor.h +++ b/src/fsfw/tcdistribution/TcDistributor.h @@ -6,7 +6,7 @@ #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/objectmanager/ObjectManagerIF.h" #include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tmtcservices/TmTcMessage.h" diff --git a/src/fsfw/tcdistribution/TcPacketCheckIF.h b/src/fsfw/tcdistribution/TcPacketCheckIF.h index 4846195a..e583cb0f 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckIF.h +++ b/src/fsfw/tcdistribution/TcPacketCheckIF.h @@ -1,7 +1,7 @@ #ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ #define FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" class SpacePacketBase; diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.h b/src/fsfw/tcdistribution/TcPacketCheckPUS.h index 5b02bbc0..1ecd1007 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.h +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.h @@ -3,7 +3,7 @@ #include "TcPacketCheckIF.h" #include "fsfw/FSFW.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tmtcservices/PusVerificationReport.h" class TcPacketStoredBase; diff --git a/src/fsfw/thermal/Heater.h b/src/fsfw/thermal/Heater.h index 61d3776f..d535f54a 100644 --- a/src/fsfw/thermal/Heater.h +++ b/src/fsfw/thermal/Heater.h @@ -6,7 +6,7 @@ #include "fsfw/devicehandlers/HealthDevice.h" #include "fsfw/parameters/ParameterHelper.h" #include "fsfw/power/PowerSwitchIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/timemanager/Countdown.h" class Heater : public HealthDevice, public ReceivesParameterMessagesIF { diff --git a/src/fsfw/thermal/ThermalComponentIF.h b/src/fsfw/thermal/ThermalComponentIF.h index 0c50fbad..0ab22d85 100644 --- a/src/fsfw/thermal/ThermalComponentIF.h +++ b/src/fsfw/thermal/ThermalComponentIF.h @@ -4,7 +4,7 @@ #include "../events/Event.h" #include "../objectmanager/SystemObjectIF.h" #include "../parameters/HasParametersIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" class ThermalComponentIF : public HasParametersIF { public: diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index 622f42ec..c52d7e87 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -6,7 +6,7 @@ #include #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" #include "Clock.h" #include "clockDefinitions.h" diff --git a/src/fsfw/timemanager/Clock.h b/src/fsfw/timemanager/Clock.h index f27c2211..88436b8b 100644 --- a/src/fsfw/timemanager/Clock.h +++ b/src/fsfw/timemanager/Clock.h @@ -6,7 +6,7 @@ #include "clockDefinitions.h" #include "fsfw/globalfunctions/timevalOperations.h" #include "fsfw/ipc/MutexFactory.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #ifdef WIN32 #include diff --git a/src/fsfw/timemanager/TimeStamperIF.h b/src/fsfw/timemanager/TimeStamperIF.h index 5c3880ea..92577943 100644 --- a/src/fsfw/timemanager/TimeStamperIF.h +++ b/src/fsfw/timemanager/TimeStamperIF.h @@ -3,7 +3,7 @@ #include -#include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/returnvalue.h" /** * A class implementing this IF provides facilities to add a time stamp to the diff --git a/src/fsfw/tmstorage/TmStoreBackendIF.h b/src/fsfw/tmstorage/TmStoreBackendIF.h index d9f1a17b..84c94f77 100644 --- a/src/fsfw/tmstorage/TmStoreBackendIF.h +++ b/src/fsfw/tmstorage/TmStoreBackendIF.h @@ -3,7 +3,7 @@ #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/parameters/HasParametersIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/timemanager/Clock.h" #include "tmStorageConf.h" diff --git a/src/fsfw/tmstorage/TmStoreFrontendIF.h b/src/fsfw/tmstorage/TmStoreFrontendIF.h index 4665a299..56bcd7fa 100644 --- a/src/fsfw/tmstorage/TmStoreFrontendIF.h +++ b/src/fsfw/tmstorage/TmStoreFrontendIF.h @@ -3,7 +3,7 @@ #include "TmStorePackets.h" #include "fsfw/ipc/MessageQueueSenderIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "tmStorageConf.h" class TmPacketMinimal; diff --git a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h index 1a74e63d..13eec711 100644 --- a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h +++ b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h @@ -3,7 +3,7 @@ #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" /** * @brief This interface can be used for classes which store a reference to data. It allows diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.h b/src/fsfw/tmtcpacket/SpacePacketBase.h index d9ee2b83..f3d3dbc6 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.h +++ b/src/fsfw/tmtcpacket/SpacePacketBase.h @@ -6,7 +6,7 @@ #include #include "ccsds_header.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" /** * @defgroup tmtcpackets Space Packets diff --git a/src/fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h b/src/fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h index 340f7825..87517fb6 100644 --- a/src/fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h +++ b/src/fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h @@ -1,7 +1,7 @@ #ifndef FSFW_TMTCPACKET_PUS_PACKETTIMESTAMPINTERPRETERIF_H_ #define FSFW_TMTCPACKET_PUS_PACKETTIMESTAMPINTERPRETERIF_H_ -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" class TmPacketMinimal; diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h index e7c4f9f0..3cfba870 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredIF.h @@ -4,7 +4,7 @@ #include #include "TcPacketPusBase.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/storagemanager/storeAddress.h" class TcPacketStoredIF { diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h index dc9c33ae..581d5dfa 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h @@ -1,7 +1,7 @@ #ifndef FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_ #define FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_ -#include "../../../returnvalues/HasReturnvaluesIF.h" +#include "../../../returnvalues/returnvalue.h" #include "../../SpacePacketBase.h" struct timeval; diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 97351994..d7a2ee47 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -7,7 +7,7 @@ #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/objectmanager/ObjectManagerIF.h" #include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tmtcpacket/pus/tc.h" diff --git a/src/fsfw/tmtcservices/PusVerificationReport.h b/src/fsfw/tmtcservices/PusVerificationReport.h index 60c01d55..4f5302f1 100644 --- a/src/fsfw/tmtcservices/PusVerificationReport.h +++ b/src/fsfw/tmtcservices/PusVerificationReport.h @@ -3,7 +3,7 @@ #include "VerificationCodes.h" #include "fsfw/ipc/MessageQueueMessage.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h" class PusVerificationMessage : public MessageQueueMessage { diff --git a/src/fsfw_hal/common/gpio/GpioCookie.h b/src/fsfw_hal/common/gpio/GpioCookie.h index cf836eae..709af9a5 100644 --- a/src/fsfw_hal/common/gpio/GpioCookie.h +++ b/src/fsfw_hal/common/gpio/GpioCookie.h @@ -2,7 +2,7 @@ #define COMMON_GPIO_GPIOCOOKIE_H_ #include -#include +#include #include "GpioIF.h" #include "gpioDefinitions.h" diff --git a/src/fsfw_hal/common/gpio/GpioIF.h b/src/fsfw_hal/common/gpio/GpioIF.h index 3e947b84..a8abb126 100644 --- a/src/fsfw_hal/common/gpio/GpioIF.h +++ b/src/fsfw_hal/common/gpio/GpioIF.h @@ -2,7 +2,7 @@ #define COMMON_GPIO_GPIOIF_H_ #include -#include +#include #include "gpioDefinitions.h" diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index 24e90c9f..86c6e888 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -4,7 +4,7 @@ #include "fsfw/devicehandlers/DeviceHandlerMessage.h" #include "fsfw/globalfunctions/bitutility.h" #include "fsfw/objectmanager/SystemObjectIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" MgmRM3100Handler::MgmRM3100Handler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, uint32_t transitionDelay) diff --git a/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h index 11b8ccbb..fea2ef0a 100644 --- a/src/fsfw_hal/linux/CommandExecutor.h +++ b/src/fsfw_hal/linux/CommandExecutor.h @@ -7,7 +7,7 @@ #include #include "fsfw/returnvalues/FwClassIds.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" class SimpleRingBuffer; template diff --git a/src/fsfw_hal/linux/UnixFileGuard.h b/src/fsfw_hal/linux/UnixFileGuard.h index 1fe47116..3e4ddca8 100644 --- a/src/fsfw_hal/linux/UnixFileGuard.h +++ b/src/fsfw_hal/linux/UnixFileGuard.h @@ -2,7 +2,7 @@ #define LINUX_UTILITY_UNIXFILEGUARD_H_ #include -#include +#include #include #include diff --git a/src/fsfw_hal/linux/rpi/GpioRPi.h b/src/fsfw_hal/linux/rpi/GpioRPi.h index 8ca7065a..bec4c33d 100644 --- a/src/fsfw_hal/linux/rpi/GpioRPi.h +++ b/src/fsfw_hal/linux/rpi/GpioRPi.h @@ -1,7 +1,7 @@ #ifndef BSP_RPI_GPIO_GPIORPI_H_ #define BSP_RPI_GPIO_GPIORPI_H_ -#include +#include #include "../../common/gpio/gpioDefinitions.h" diff --git a/src/fsfw_hal/linux/spi/spiDefinitions.h b/src/fsfw_hal/linux/spi/spiDefinitions.h index b4bae3c2..113f6551 100644 --- a/src/fsfw_hal/linux/spi/spiDefinitions.h +++ b/src/fsfw_hal/linux/spi/spiDefinitions.h @@ -7,7 +7,7 @@ #include "../../common/gpio/gpioDefinitions.h" #include "../../common/spi/spiCommon.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" class SpiCookie; class SpiComIF; diff --git a/src/fsfw_hal/linux/uio/UioMapper.h b/src/fsfw_hal/linux/uio/UioMapper.h index 20c90b4d..89c2c66a 100644 --- a/src/fsfw_hal/linux/uio/UioMapper.h +++ b/src/fsfw_hal/linux/uio/UioMapper.h @@ -5,7 +5,7 @@ #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" /** * @brief Class to help opening uio device files and mapping the physical addresses into the user diff --git a/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h b/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h index a0c3748a..f967c8d1 100644 --- a/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h +++ b/src/fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h @@ -6,7 +6,7 @@ #include "../spi/mspInit.h" #include "../spi/spiDefinitions.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "stm32h7xx_hal.h" #include "stm32h7xx_hal_spi.h" diff --git a/src/fsfw_hal/stm32h7/spi/spiDefinitions.h b/src/fsfw_hal/stm32h7/spi/spiDefinitions.h index 809f5c74..55a74e7a 100644 --- a/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +++ b/src/fsfw_hal/stm32h7/spi/spiDefinitions.h @@ -3,7 +3,7 @@ #include "../../common/spi/spiCommon.h" #include "fsfw/returnvalues/FwClassIds.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "stm32h7xx_hal.h" #include "stm32h7xx_hal_spi.h" diff --git a/src/fsfw_tests/integration/task/TestTask.h b/src/fsfw_tests/integration/task/TestTask.h index 038355c3..40eb4afd 100644 --- a/src/fsfw_tests/integration/task/TestTask.h +++ b/src/fsfw_tests/integration/task/TestTask.h @@ -11,7 +11,7 @@ * @details * Should not be used for board specific tests. Instead, a derived board test class should be used. */ -class TestTask : public SystemObject, public ExecutableObjectIF, public HasReturnvaluesIF { +class TestTask : public SystemObject, public ExecutableObjectIF { public: explicit TestTask(object_id_t objectId); ~TestTask() override; diff --git a/src/fsfw_tests/internal/InternalUnitTester.h b/src/fsfw_tests/internal/InternalUnitTester.h index 07744825..89bac368 100644 --- a/src/fsfw_tests/internal/InternalUnitTester.h +++ b/src/fsfw_tests/internal/InternalUnitTester.h @@ -2,7 +2,7 @@ #define FRAMEWORK_TEST_UNITTESTCLASS_H_ #include "UnittDefinitions.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" /** * @brief Can be used for internal testing, for example for hardware specific diff --git a/src/fsfw_tests/internal/UnittDefinitions.h b/src/fsfw_tests/internal/UnittDefinitions.h index 11e83d22..4517d94e 100644 --- a/src/fsfw_tests/internal/UnittDefinitions.h +++ b/src/fsfw_tests/internal/UnittDefinitions.h @@ -5,7 +5,7 @@ #include #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/serviceinterface/ServiceInterface.h" namespace tv { diff --git a/src/fsfw_tests/internal/serialize/IntTestSerialization.h b/src/fsfw_tests/internal/serialize/IntTestSerialization.h index 2f1786d4..939b6614 100644 --- a/src/fsfw_tests/internal/serialize/IntTestSerialization.h +++ b/src/fsfw_tests/internal/serialize/IntTestSerialization.h @@ -3,7 +3,7 @@ #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" namespace testserialize { ReturnValue_t test_serialization(); diff --git a/unittests/CatchDefinitions.h b/unittests/CatchDefinitions.h index dbe3848b..64a72f57 100644 --- a/unittests/CatchDefinitions.h +++ b/unittests/CatchDefinitions.h @@ -2,7 +2,7 @@ #define FSFW_UNITTEST_CORE_CATCHDEFINITIONS_H_ #include -#include +#include #include namespace tconst { diff --git a/unittests/container/TestArrayList.cpp b/unittests/container/TestArrayList.cpp index e2f14e47..3056c288 100644 --- a/unittests/container/TestArrayList.cpp +++ b/unittests/container/TestArrayList.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include diff --git a/unittests/container/TestDynamicFifo.cpp b/unittests/container/TestDynamicFifo.cpp index a3347215..445d3d91 100644 --- a/unittests/container/TestDynamicFifo.cpp +++ b/unittests/container/TestDynamicFifo.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include diff --git a/unittests/container/TestFifo.cpp b/unittests/container/TestFifo.cpp index 1a3c9d8a..9fc9ee93 100644 --- a/unittests/container/TestFifo.cpp +++ b/unittests/container/TestFifo.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include diff --git a/unittests/container/TestFixedArrayList.cpp b/unittests/container/TestFixedArrayList.cpp index b28c3166..0a8de39f 100644 --- a/unittests/container/TestFixedArrayList.cpp +++ b/unittests/container/TestFixedArrayList.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include diff --git a/unittests/container/TestFixedMap.cpp b/unittests/container/TestFixedMap.cpp index d17cc55b..dae40d2d 100644 --- a/unittests/container/TestFixedMap.cpp +++ b/unittests/container/TestFixedMap.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include diff --git a/unittests/container/TestFixedOrderedMultimap.cpp b/unittests/container/TestFixedOrderedMultimap.cpp index 153144cd..9bfd2b09 100644 --- a/unittests/container/TestFixedOrderedMultimap.cpp +++ b/unittests/container/TestFixedOrderedMultimap.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include diff --git a/unittests/container/TestPlacementFactory.cpp b/unittests/container/TestPlacementFactory.cpp index 142f03d7..a898f4c1 100644 --- a/unittests/container/TestPlacementFactory.cpp +++ b/unittests/container/TestPlacementFactory.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/unittests/devicehandler/DeviceHandlerCommander.h b/unittests/devicehandler/DeviceHandlerCommander.h index e90cbcee..62713d54 100644 --- a/unittests/devicehandler/DeviceHandlerCommander.h +++ b/unittests/devicehandler/DeviceHandlerCommander.h @@ -4,7 +4,7 @@ #include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/CommandsActionsIF.h" #include "fsfw/objectmanager/SystemObject.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tasks/ExecutableObjectIF.h" class DeviceHandlerCommander : public ExecutableObjectIF, diff --git a/unittests/testcfg/pollingsequence/PollingSequenceFactory.h b/unittests/testcfg/pollingsequence/PollingSequenceFactory.h index fc9891b2..daba33a8 100644 --- a/unittests/testcfg/pollingsequence/PollingSequenceFactory.h +++ b/unittests/testcfg/pollingsequence/PollingSequenceFactory.h @@ -1,7 +1,7 @@ #ifndef POLLINGSEQUENCEFACTORY_H_ #define POLLINGSEQUENCEFACTORY_H_ -#include +#include class FixedTimeslotTaskIF; From 8fd8a37f59a9b596c36064576b920db5e8f21992 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 Aug 2022 17:10:48 +0200 Subject: [PATCH 241/532] flip verif reporter ctor arguments --- src/fsfw/tmtcservices/VerificationReporter.cpp | 2 +- src/fsfw/tmtcservices/VerificationReporter.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 2eb0c771..cce8f95d 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -7,7 +7,7 @@ object_id_t VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION; object_id_t VerificationReporter::DEFAULT_REPORTER = objects::TC_VERIFICATOR; -VerificationReporter::VerificationReporter(AcceptsVerifyMessageIF* receiver, object_id_t objectId) +VerificationReporter::VerificationReporter(object_id_t objectId, AcceptsVerifyMessageIF* receiver) : SystemObject(objectId) { if (receiver != nullptr) { acknowledgeQueue = receiver->getVerificationQueue(); diff --git a/src/fsfw/tmtcservices/VerificationReporter.h b/src/fsfw/tmtcservices/VerificationReporter.h index 78c60962..5fb67f74 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.h +++ b/src/fsfw/tmtcservices/VerificationReporter.h @@ -27,8 +27,8 @@ class VerificationReporter : public SystemObject, public VerificationReporterIF friend void Factory::setStaticFrameworkObjectIds(); public: - explicit VerificationReporter(AcceptsVerifyMessageIF* receiver, - object_id_t objectId = DEFAULT_REPORTER); + explicit VerificationReporter(object_id_t objectId = DEFAULT_REPORTER, + AcceptsVerifyMessageIF* receiver = nullptr); ~VerificationReporter() override; void setReceiver(AcceptsVerifyMessageIF& receiver); From 875174c4ad9524b9d1da0b9ed365e820646673ae Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 Aug 2022 17:17:45 +0200 Subject: [PATCH 242/532] better name for global object --- src/fsfw/objectmanager/frameworkObjects.h | 2 +- src/fsfw/tcdistribution/PusDistributor.cpp | 2 +- src/fsfw/tmtcservices/CommandingServiceBase.cpp | 2 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 2 +- src/fsfw/tmtcservices/VerificationReporter.cpp | 2 +- unittests/tmtcservices/testPsb.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fsfw/objectmanager/frameworkObjects.h b/src/fsfw/objectmanager/frameworkObjects.h index be664621..9487147d 100644 --- a/src/fsfw/objectmanager/frameworkObjects.h +++ b/src/fsfw/objectmanager/frameworkObjects.h @@ -33,7 +33,7 @@ enum framework_objects : object_id_t { TC_STORE = 0x534f0100, TM_STORE = 0x534f0200, TIME_STAMPER = 0x53500010, - TC_VERIFICATOR = 0x53500020, + VERIFICATION_REPORTER = 0x53500020, FSFW_OBJECTS_END = 0x53ffffff, NO_OBJECT = 0xFFFFFFFF diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index ade49201..bb8708cd 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -137,7 +137,7 @@ ReturnValue_t PusDistributor::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } if (verifyChannel == nullptr) { - verifyChannel = ObjectManager::instance()->get(objects::TC_VERIFICATOR); + verifyChannel = ObjectManager::instance()->get(objects::VERIFICATION_REPORTER); if (verifyChannel == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index d7e3b514..7856abd0 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -124,7 +124,7 @@ ReturnValue_t CommandingServiceBase::initialize() { if (verificationReporter == nullptr) { verificationReporter = - ObjectManager::instance()->get(objects::TC_VERIFICATOR); + ObjectManager::instance()->get(objects::VERIFICATION_REPORTER); if (verificationReporter == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index b555449b..0319652d 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -126,7 +126,7 @@ ReturnValue_t PusServiceBase::initialize() { if (psbParams.verifReporter == nullptr) { psbParams.verifReporter = - ObjectManager::instance()->get(objects::TC_VERIFICATOR); + ObjectManager::instance()->get(objects::VERIFICATION_REPORTER); if (psbParams.verifReporter == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index cce8f95d..46d3eba1 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -5,7 +5,7 @@ #include "fsfw/tmtcservices/PusVerificationReport.h" object_id_t VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION; -object_id_t VerificationReporter::DEFAULT_REPORTER = objects::TC_VERIFICATOR; +object_id_t VerificationReporter::DEFAULT_REPORTER = objects::VERIFICATION_REPORTER; VerificationReporter::VerificationReporter(object_id_t objectId, AcceptsVerifyMessageIF* receiver) : SystemObject(objectId) { diff --git a/unittests/tmtcservices/testPsb.cpp b/unittests/tmtcservices/testPsb.cpp index 464fb3da..7f33c0dc 100644 --- a/unittests/tmtcservices/testPsb.cpp +++ b/unittests/tmtcservices/testPsb.cpp @@ -211,7 +211,7 @@ TEST_CASE("Pus Service Base", "[pus-service-base]") { SECTION("Auto Initialize Verification Reporter") { psbParams.verifReporter = nullptr; psbParams.objectId = 1; - object_id_t reporterId = objects::TC_VERIFICATOR; + object_id_t reporterId = objects::VERIFICATION_REPORTER; PusVerificationReporterMock otherReporter(reporterId); auto psb2 = PsbMock(psbParams); REQUIRE(psb2.initialize() == result::OK); From 239d053562d87da5b68bd10538a3ebe9171cd71d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 Aug 2022 17:23:10 +0200 Subject: [PATCH 243/532] update changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf50b683..bfca814b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +# [v6.0.0] + ## Added - Add new `UnsignedByteField` class +## Changes + +- Overhaul of the TMTC stack, including various changes and improvements + for other modules + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/655 + which also includes a migration guide + # [v5.0.0] 25.07.2022 ## Changes From 23f514039aa4587d4dd49065ad00308297dc707e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 Aug 2022 11:39:15 +0200 Subject: [PATCH 244/532] host filesystem continued --- src/fsfw/filesystem/HasFileSystemIF.h | 8 ++--- src/fsfw/tcdistribution/PusDistributor.cpp | 3 +- src/fsfw_hal/host/HostFilesystem.cpp | 12 ++++---- unittests/hal/testHostFilesystem.cpp | 36 ++++++++++++++++++++-- unittests/util/CMakeLists.txt | 4 +-- 5 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index 2f262285..078de7c0 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -19,13 +19,9 @@ struct FilesystemParams { struct FileOpParams { FileOpParams(const char* path, size_t size) : fsParams(path), size(size) {} - [[nodiscard]] const char* path() const { - return fsParams.path; - } + [[nodiscard]] const char* path() const { return fsParams.path; } - [[nodiscard]] FileSystemArgsIF* args() const { - return fsParams.args; - } + [[nodiscard]] FileSystemArgsIF* args() const { return fsParams.args; } FilesystemParams fsParams; size_t size; diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index d827d5b6..982a99bf 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -134,7 +134,8 @@ ReturnValue_t PusDistributor::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } if (verifyChannel == nullptr) { - verifyChannel = ObjectManager::instance()->get(objects::VERIFICATION_REPORTER); + verifyChannel = + ObjectManager::instance()->get(objects::VERIFICATION_REPORTER); if (verifyChannel == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp index 72cff2ed..ebe60444 100644 --- a/src/fsfw_hal/host/HostFilesystem.cpp +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -40,14 +40,14 @@ ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer if (file.fail()) { return HasFileSystemIF::GENERIC_FILE_ERROR; } - auto readLen = static_cast(params.offset); - file.seekg(readLen); - if (readSize + params.size > maxSize) { + auto sizeToRead = static_cast(params.size); + file.seekg(static_cast(params.offset)); + if (readSize + sizeToRead > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } - file.read(reinterpret_cast(*buffer), readLen); - readSize += readLen; - *buffer += readLen; + file.read(reinterpret_cast(*buffer), sizeToRead); + readSize += sizeToRead; + *buffer += sizeToRead; return HasReturnvaluesIF::RETURN_OK; } diff --git a/unittests/hal/testHostFilesystem.cpp b/unittests/hal/testHostFilesystem.cpp index ba3b1338..bf2d49d5 100644 --- a/unittests/hal/testHostFilesystem.cpp +++ b/unittests/hal/testHostFilesystem.cpp @@ -1,10 +1,13 @@ #include #include +#include #include "fsfw_hal/host/HostFilesystem.h" +using namespace std; + TEST_CASE("Host Filesystem", "[hal][host]") { - namespace fs = std::filesystem; + namespace fs = filesystem; auto hostFs = HostFilesystem(); auto tmpDir = fs::temp_directory_path(); fs::path file0 = tmpDir / "hello.txt"; @@ -62,8 +65,35 @@ TEST_CASE("Host Filesystem", "[hal][host]") { REQUIRE(hostFs.createFile(params.fsParams) == result::OK); CHECK(fs::is_regular_file(file0)); REQUIRE(fs::exists(file0)); - hostFs.writeToFile(params, reinterpret_cast(data.c_str())); - // TODO: Read back file and verify content + CHECK(hostFs.writeToFile(params, reinterpret_cast(data.c_str())) == + HasReturnvaluesIF::RETURN_OK); + CHECK(fs::file_size(file0) == data.size()); + ifstream ifile(file0); + char readBuf[524]{}; + ifile.read(readBuf, sizeof(readBuf)); + std::string readBackString(readBuf); + CHECK(data == readBackString); + REQUIRE_NOTHROW(fs::remove(file1)); + } + + SECTION("Read From File") { + std::string data = "hello world!"; + FileOpParams params(file0.c_str(), data.size()); + REQUIRE(hostFs.createFile(params.fsParams) == result::OK); + CHECK(fs::is_regular_file(file0)); + ofstream of(file0); + of.write(data.c_str(), static_cast(data.size())); + of.close(); + CHECK(fs::file_size(file0) == data.size()); + REQUIRE(fs::exists(file0)); + std::array readBuf{}; + uint8_t* readPtr = readBuf.data(); + size_t readSize = 0; + CHECK(hostFs.readFromFile(params, &readPtr, readSize, readBuf.size()) == + HasReturnvaluesIF::RETURN_OK); + std::string readBackString(reinterpret_cast(readBuf.data())); + CHECK(readSize == data.size()); + CHECK(data == readBackString); REQUIRE_NOTHROW(fs::remove(file1)); } diff --git a/unittests/util/CMakeLists.txt b/unittests/util/CMakeLists.txt index d4caa4d5..fb660d54 100644 --- a/unittests/util/CMakeLists.txt +++ b/unittests/util/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testUnsignedByteField.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE testUnsignedByteField.cpp) From 12c452e7cef8caeb725d473cd56e11d812471174 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 Aug 2022 16:10:52 +0200 Subject: [PATCH 245/532] finished host FS unittests --- src/fsfw_hal/host/HostFilesystem.cpp | 4 +- unittests/hal/testHostFilesystem.cpp | 112 +++++++++++++++++++++++++-- 2 files changed, 106 insertions(+), 10 deletions(-) diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp index ebe60444..7ebe5df8 100644 --- a/src/fsfw_hal/host/HostFilesystem.cpp +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -90,9 +90,7 @@ ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool crea if (exists(dirPath)) { return HasFileSystemIF::DIRECTORY_ALREADY_EXISTS; } - if (is_regular_file(dirPath)) { - return HasFileSystemIF::NOT_A_DIRECTORY; - } + if (createParentDirs) { if (create_directories(dirPath, errorCode)) { return HasReturnvaluesIF::RETURN_OK; diff --git a/unittests/hal/testHostFilesystem.cpp b/unittests/hal/testHostFilesystem.cpp index bf2d49d5..2da185da 100644 --- a/unittests/hal/testHostFilesystem.cpp +++ b/unittests/hal/testHostFilesystem.cpp @@ -2,6 +2,7 @@ #include #include +#include "fsfw/serialize/SerializeIF.h" #include "fsfw_hal/host/HostFilesystem.h" using namespace std; @@ -13,16 +14,18 @@ TEST_CASE("Host Filesystem", "[hal][host]") { fs::path file0 = tmpDir / "hello.txt"; fs::path file1 = tmpDir / "hello2.txt"; fs::path dir0 = tmpDir / "test_dir"; + fs::path fileInDir0 = dir0 / "hello.txt"; + fs::path dirWithParent = dir0 / "test_dir"; + REQUIRE_NOTHROW(fs::remove(file0)); REQUIRE_NOTHROW(fs::remove(file1)); - REQUIRE_NOTHROW(fs::remove(dir0)); + REQUIRE_NOTHROW(fs::remove_all(dir0)); SECTION("Create file") { FilesystemParams params(file0.c_str()); REQUIRE(hostFs.createFile(params) == result::OK); CHECK(fs::is_regular_file(file0)); REQUIRE(fs::exists(file0)); - REQUIRE_NOTHROW(fs::remove(file0)); } SECTION("Remove File") { @@ -39,7 +42,6 @@ TEST_CASE("Host Filesystem", "[hal][host]") { REQUIRE(hostFs.createDirectory(params) == result::OK); CHECK(fs::is_directory(dir0)); REQUIRE(fs::exists(dir0)); - REQUIRE_NOTHROW(fs::remove(dir0)); } SECTION("Remove Directory") { @@ -56,7 +58,6 @@ TEST_CASE("Host Filesystem", "[hal][host]") { CHECK(fs::is_regular_file(file0)); REQUIRE(fs::exists(file0)); REQUIRE(hostFs.rename(file0.c_str(), file1.c_str()) == result::OK); - REQUIRE_NOTHROW(fs::remove(file1)); } SECTION("Write To File") { @@ -73,7 +74,6 @@ TEST_CASE("Host Filesystem", "[hal][host]") { ifile.read(readBuf, sizeof(readBuf)); std::string readBackString(readBuf); CHECK(data == readBackString); - REQUIRE_NOTHROW(fs::remove(file1)); } SECTION("Read From File") { @@ -94,10 +94,108 @@ TEST_CASE("Host Filesystem", "[hal][host]") { std::string readBackString(reinterpret_cast(readBuf.data())); CHECK(readSize == data.size()); CHECK(data == readBackString); - REQUIRE_NOTHROW(fs::remove(file1)); + } + + SECTION("Invalid Input does not crash") { + FileOpParams params(nullptr, 10); + REQUIRE(hostFs.createFile(params.fsParams) != result::OK); + REQUIRE(hostFs.createDirectory(params.fsParams) != result::OK); + REQUIRE(hostFs.createFile(params.fsParams) != result::OK); + REQUIRE(hostFs.removeDirectory(params.fsParams) != result::OK); + REQUIRE(hostFs.removeFile(nullptr) != result::OK); + REQUIRE(hostFs.rename(nullptr, nullptr) != result::OK); + REQUIRE(hostFs.writeToFile(params, nullptr) != result::OK); + size_t readLen = 0; + REQUIRE(hostFs.readFromFile(params, nullptr, readLen, 20) != result::OK); + } + + SECTION("Create File but already exists") { + FilesystemParams params(file0.c_str()); + REQUIRE(hostFs.createFile(params) == result::OK); + REQUIRE(hostFs.createFile(params) == HasFileSystemIF::FILE_ALREADY_EXISTS); + } + + SECTION("Remove File but does not exist") { + REQUIRE(hostFs.removeFile(file0.c_str()) == HasFileSystemIF::FILE_DOES_NOT_EXIST); + } + + SECTION("Create Directory but already exists") { + FileOpParams params(file0.c_str(), 12); + REQUIRE(hostFs.createDirectory(params.fsParams) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(hostFs.createDirectory(params.fsParams) == HasFileSystemIF::DIRECTORY_ALREADY_EXISTS); + } + + SECTION("Remove Directory but does not exist") { + FilesystemParams params(dir0.c_str()); + REQUIRE(hostFs.removeDirectory(params) == HasFileSystemIF::DIRECTORY_DOES_NOT_EXIST); + } + + SECTION("Remove Directory but is file") { + ofstream of(file0); + FilesystemParams params(file0.c_str()); + REQUIRE(hostFs.removeDirectory(params) == HasFileSystemIF::NOT_A_DIRECTORY); + } + + SECTION("Read from file but does not exist") { + std::string data = "hello world!"; + FileOpParams params(file0.c_str(), data.size()); + std::array readBuf{}; + uint8_t* readPtr = readBuf.data(); + size_t readSize = 0; + CHECK(hostFs.readFromFile(params, &readPtr, readSize, readBuf.size()) == + HasFileSystemIF::FILE_DOES_NOT_EXIST); + } + + SECTION("Write to file but does not exist") { + std::string data = "hello world!"; + FileOpParams params(file0.c_str(), data.size()); + CHECK(hostFs.writeToFile(params, reinterpret_cast(data.c_str())) == + HasFileSystemIF::FILE_DOES_NOT_EXIST); + } + + SECTION("Remove recursively") { + fs::create_directory(dir0.c_str()); + ofstream of(fileInDir0); + CHECK(fs::is_directory(dir0)); + CHECK(fs::is_regular_file(fileInDir0)); + REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0.c_str()), true) == result::OK); + CHECK(not fs::is_directory(dir0)); + CHECK(not fs::is_regular_file(fileInDir0)); + } + + SECTION("Non-Recursive Removal Fails") { + fs::create_directory(dir0.c_str()); + ofstream of(fileInDir0); + CHECK(fs::is_directory(dir0)); + CHECK(fs::is_regular_file(fileInDir0)); + REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0.c_str())) == + HasFileSystemIF::DIRECTORY_NOT_EMPTY); + } + + SECTION("Create directory with parent directory") { + CHECK(hostFs.createDirectory(FilesystemParams(dirWithParent.c_str()), true) == result::OK); + CHECK(fs::is_directory(dir0)); + CHECK(fs::is_directory(dirWithParent)); + } + + SECTION("Read but provided buffer too small") { + std::string data = "hello world!"; + FileOpParams params(file0.c_str(), data.size()); + ofstream of(file0); + of.write(data.c_str(), static_cast(data.size())); + of.close(); + CHECK(fs::file_size(file0) == data.size()); + REQUIRE(fs::exists(file0)); + std::array readBuf{}; + uint8_t* readPtr = readBuf.data(); + size_t readSize = 0; + CHECK(hostFs.readFromFile(params, &readPtr, readSize, 5) == SerializeIF::BUFFER_TOO_SHORT); + readSize = 10; + CHECK(hostFs.readFromFile(params, &readPtr, readSize, readBuf.size()) == + SerializeIF::BUFFER_TOO_SHORT); } REQUIRE_NOTHROW(fs::remove(file0)); REQUIRE_NOTHROW(fs::remove(file1)); - REQUIRE_NOTHROW(fs::remove(dir0)); + REQUIRE_NOTHROW(fs::remove_all(dir0)); } \ No newline at end of file From 0bb82e0da290418cad3d860ade67ae9c630ced15 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 Aug 2022 16:47:46 +0200 Subject: [PATCH 246/532] add fs mock feed function --- unittests/hal/CMakeLists.txt | 2 +- unittests/hal/testFsMock.cpp | 49 ++++++++++++++++++++++++++++++ unittests/mocks/FilesystemMock.cpp | 20 +++++++++++- unittests/mocks/FilesystemMock.h | 6 ++++ 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 unittests/hal/testFsMock.cpp diff --git a/unittests/hal/CMakeLists.txt b/unittests/hal/CMakeLists.txt index 5e2887b2..5d1c7846 100644 --- a/unittests/hal/CMakeLists.txt +++ b/unittests/hal/CMakeLists.txt @@ -1,2 +1,2 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testCommandExecutor.cpp - testHostFilesystem.cpp) + testHostFilesystem.cpp testFsMock.cpp) diff --git a/unittests/hal/testFsMock.cpp b/unittests/hal/testFsMock.cpp new file mode 100644 index 00000000..7040e734 --- /dev/null +++ b/unittests/hal/testFsMock.cpp @@ -0,0 +1,49 @@ +#include + +#include "fsfw/serialize/SerializeIF.h" +#include "mocks/FilesystemMock.h" + +using namespace std; + +TEST_CASE("Filesystem Mock", "[mocks]") { + auto fsMock = FilesystemMock(); + + SECTION("Create File") { + FilesystemParams params("hello.txt"); + CHECK(fsMock.createFile(params) == result::OK); + auto iter = fsMock.fileMap.find("hello.txt"); + REQUIRE(iter != fsMock.fileMap.end()); + FilesystemMock::FileInfo &stats = iter->second; + CHECK(stats.fileSegQueue.empty()); + CHECK(stats.fileRaw.empty()); + } + + SECTION("Write to File") { + std::string testData = "test data"; + FileOpParams params("hello.txt", testData.size()); + CHECK(fsMock.writeToFile(params, reinterpret_cast(testData.data())) == + HasReturnvaluesIF::RETURN_OK); + auto iter = fsMock.fileMap.find("hello.txt"); + REQUIRE(iter != fsMock.fileMap.end()); + FilesystemMock::FileInfo &stats = iter->second; + CHECK(not stats.fileSegQueue.empty()); + CHECK(not stats.fileRaw.empty()); + auto &segment = stats.fileSegQueue.back(); + CHECK(segment.offset == 0); + CHECK(std::string(reinterpret_cast(segment.data.data()), segment.data.size()) == + testData); + CHECK(std::string(reinterpret_cast(stats.fileRaw.data()), segment.data.size()) == + testData); + } + + SECTION("Create Directory") { + FilesystemParams params("hello"); + CHECK(fsMock.createDirectory(params) == result::OK); + REQUIRE(not fsMock.dirMap.empty()); + auto iter = fsMock.dirMap.find("hello"); + REQUIRE(iter != fsMock.dirMap.end()); + auto &dirInfo = iter->second; + CHECK(dirInfo.createCallCount == 1); + CHECK(dirInfo.delCallCount == 0); + } +} \ No newline at end of file diff --git a/unittests/mocks/FilesystemMock.cpp b/unittests/mocks/FilesystemMock.cpp index 02620fd5..8f9e3f8f 100644 --- a/unittests/mocks/FilesystemMock.cpp +++ b/unittests/mocks/FilesystemMock.cpp @@ -1,7 +1,21 @@ #include "FilesystemMock.h" +#include + #include "fsfw/serialize/SerializeIF.h" +ReturnValue_t FilesystemMock::feedFile(const std::string &filename, std::ifstream &file) { + if (not std::filesystem::exists(filename)) { + return HasReturnvaluesIF::RETURN_FAILED; + } + size_t fileSize = std::filesystem::file_size(filename); + FileOpParams params(filename.c_str(), fileSize); + std::vector rawData(fileSize); + file.read(reinterpret_cast(rawData.data()), static_cast(rawData.size())); + createOrAddToFile(params, rawData.data()); + return HasReturnvaluesIF::RETURN_OK; +} + ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *data) { createOrAddToFile(params, data); return HasReturnvaluesIF::RETURN_OK; @@ -75,7 +89,9 @@ void FilesystemMock::createOrAddToFile(FileOpParams params, const uint8_t *data) auto iter = fileMap.find(filename); if (iter == fileMap.end()) { FileSegmentQueue queue; - queue.push(FileWriteInfo(filename, params.offset, data, params.size)); + if (params.size > 0) { + queue.push(FileWriteInfo(filename, params.offset, data, params.size)); + } FileInfo info; info.fileSegQueue = queue; if (data != nullptr) { @@ -105,4 +121,6 @@ void FilesystemMock::createOrAddToFile(FileOpParams params, const uint8_t *data) void FilesystemMock::reset() { fileMap.clear(); dirMap.clear(); + std::queue empty; + std::swap(renameQueue, empty); } diff --git a/unittests/mocks/FilesystemMock.h b/unittests/mocks/FilesystemMock.h index f7c53eda..19d4d38c 100644 --- a/unittests/mocks/FilesystemMock.h +++ b/unittests/mocks/FilesystemMock.h @@ -1,6 +1,7 @@ #ifndef FSFW_MOCKS_FILESYSTEMMOCK_H #define FSFW_MOCKS_FILESYSTEMMOCK_H +#include #include #include #include @@ -53,6 +54,7 @@ class FilesystemMock : public HasFileSystemIF { }; std::queue renameQueue; + ReturnValue_t feedFile(const std::string &filename, std::ifstream &file); ReturnValue_t writeToFile(FileOpParams params, const uint8_t *data) override; ReturnValue_t readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, size_t maxSize) override; @@ -64,6 +66,10 @@ class FilesystemMock : public HasFileSystemIF { void reset(); + using HasFileSystemIF::createDirectory; + using HasFileSystemIF::createFile; + using HasFileSystemIF::readFromFile; + private: void createOrAddToFile(FileOpParams params, const uint8_t *data); }; From 6930656d4e5bc52c429bfdd9669e052cf18aaec1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 Aug 2022 17:09:39 +0200 Subject: [PATCH 247/532] added some more basic tests --- src/fsfw/cfdp/handler/RemoteConfigTableIF.h | 2 +- unittests/cfdp/handler/testDestHandler.cpp | 7 ++++++- unittests/mocks/cfdp/RemoteConfigTableMock.cpp | 15 ++++++++++++--- unittests/mocks/cfdp/RemoteConfigTableMock.h | 7 ++++++- unittests/mocks/cfdp/UserMock.h | 2 +- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/fsfw/cfdp/handler/RemoteConfigTableIF.h b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h index 767492d5..1cd1ec1d 100644 --- a/src/fsfw/cfdp/handler/RemoteConfigTableIF.h +++ b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h @@ -8,7 +8,7 @@ namespace cfdp { class RemoteConfigTableIF { public: virtual ~RemoteConfigTableIF() = default; - virtual bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg* cfg) = 0; + virtual bool getRemoteCfg(const cfdp::EntityId& remoteId, cfdp::RemoteEntityCfg** cfg) = 0; }; } // namespace cfdp diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 0d9fe9f5..8189096d 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -1,7 +1,9 @@ #include #include "fsfw/cfdp.h" +#include "mocks/FilesystemMock.h" #include "mocks/cfdp/FaultHandlerMock.h" +#include "mocks/cfdp/RemoteConfigTableMock.h" #include "mocks/cfdp/UserMock.h" TEST_CASE("CFDP Dest Handler", "[cfdp]") { @@ -9,7 +11,10 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { EntityId localId = EntityId(UnsignedByteField(2)); auto fhMock = FaultHandlerMock(); auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock); - // auto userMock = UserMock(); + auto fsMock = FilesystemMock(); + auto userMock = UserMock(fsMock); + auto remoteCfgTableMock = RemoteConfigTableMock(); + auto destHandler = DestHandler(localEntityCfg, userMock, remoteCfgTableMock); SECTION("State") {} } \ No newline at end of file diff --git a/unittests/mocks/cfdp/RemoteConfigTableMock.cpp b/unittests/mocks/cfdp/RemoteConfigTableMock.cpp index 83827a36..9cb0b77c 100644 --- a/unittests/mocks/cfdp/RemoteConfigTableMock.cpp +++ b/unittests/mocks/cfdp/RemoteConfigTableMock.cpp @@ -1,6 +1,15 @@ #include "RemoteConfigTableMock.h" -bool cfdp::RemoteConfigTableMock::getRemoteCfg(cfdp::EntityId remoteId, - cfdp::RemoteEntityCfg *cfg) { - return false; +void cfdp::RemoteConfigTableMock::addRemoteConfig(const cfdp::RemoteEntityCfg& cfg) { + remoteCfgTable.emplace(cfg.remoteId, cfg); +} + +bool cfdp::RemoteConfigTableMock::getRemoteCfg(const cfdp::EntityId& remoteId, + cfdp::RemoteEntityCfg** cfg) { + auto iter = remoteCfgTable.find(remoteId); + if (iter == remoteCfgTable.end()) { + return false; + } + *cfg = &iter->second; + return true; } diff --git a/unittests/mocks/cfdp/RemoteConfigTableMock.h b/unittests/mocks/cfdp/RemoteConfigTableMock.h index e3e954e4..70891836 100644 --- a/unittests/mocks/cfdp/RemoteConfigTableMock.h +++ b/unittests/mocks/cfdp/RemoteConfigTableMock.h @@ -1,13 +1,18 @@ #ifndef FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H #define FSFW_TESTS_CFDP_REMOTCONFIGTABLEMOCK_H +#include + #include "fsfw/cfdp/handler/RemoteConfigTableIF.h" namespace cfdp { class RemoteConfigTableMock : public RemoteConfigTableIF { public: - bool getRemoteCfg(EntityId remoteId, RemoteEntityCfg *cfg) override; + void addRemoteConfig(const RemoteEntityCfg& cfg); + bool getRemoteCfg(const cfdp::EntityId& remoteId, cfdp::RemoteEntityCfg** cfg) override; + + std::map remoteCfgTable; }; } // namespace cfdp diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mocks/cfdp/UserMock.h index 7106a844..d9d05336 100644 --- a/unittests/mocks/cfdp/UserMock.h +++ b/unittests/mocks/cfdp/UserMock.h @@ -5,9 +5,9 @@ namespace cfdp { class UserMock : public UserBase { + public: explicit UserMock(HasFileSystemIF& vfs); - public: void transactionIndication(TransactionId id) override; void eofSentIndication(TransactionId id) override; void abandonedIndication(TransactionId id, ConditionCode code, size_t progress) override; From 11a699c3ced6717a39e45ef53bdd287f3015c21a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 Aug 2022 18:49:51 +0200 Subject: [PATCH 248/532] a list should do the job --- src/fsfw/cfdp/handler/DestHandler.cpp | 51 ++++++++++++++++-- src/fsfw/cfdp/handler/DestHandler.h | 60 ++++++++++++++++++++-- src/fsfw/container/DynamicFIFO.h | 3 +- src/fsfw/container/FIFOBase.h | 4 +- unittests/cfdp/handler/testDestHandler.cpp | 2 +- 5 files changed, 109 insertions(+), 11 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index d2b672c9..f04a4b12 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -2,6 +2,51 @@ #include -cfdp::DestHandler::DestHandler(LocalEntityCfg cfg, UserBase& user, - RemoteConfigTableIF& remoteCfgTable) - : cfg(std::move(cfg)), user(user), remoteCfgTable(remoteCfgTable) {} +#include "fsfw/objectmanager.h" + +cfdp::DestHandler::DestHandler(DestHandlerParams params) : p(std::move(params)) {} + +ReturnValue_t cfdp::DestHandler::performStateMachine() { + switch (step) { + case TransactionStep::IDLE: { + for (const auto& info : p.packetListRef) { + } + } + case TransactionStep::TRANSACTION_START: + break; + case TransactionStep::RECEIVING_FILE_DATA_PDUS: + break; + case TransactionStep::SENDING_ACK_PDU: + break; + case TransactionStep::TRANSFER_COMPLETION: + break; + case TransactionStep::SENDING_FINISHED_PDU: + break; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) { + if (p.packetListRef.full()) { + return HasReturnvaluesIF::RETURN_FAILED; + } + p.packetListRef.push_back(packet); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t cfdp::DestHandler::initialize() { + if (p.tmStore == nullptr) { + p.tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (p.tmStore == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + } + + if (p.tcStore == nullptr) { + p.tcStore = ObjectManager::instance()->get(objects::TC_STORE); + if (p.tcStore == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + } + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 0032c7b8..c3e30721 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -1,21 +1,73 @@ #ifndef FSFW_CFDP_CFDPDESTHANDLER_H #define FSFW_CFDP_CFDPDESTHANDLER_H +#include + +#include + #include "RemoteConfigTableIF.h" #include "UserBase.h" #include "fsfw/cfdp/handler/mib.h" #include "fsfw/cfdp/pdu/PduConfig.h" +#include "fsfw/container/DynamicFIFO.h" +#include "fsfw/storagemanager/StorageManagerIF.h" +#include "fsfw/storagemanager/storeAddress.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" namespace cfdp { -class DestHandler { - public: - DestHandler(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable); +struct PacketInfo { + PacketInfo(PduType type, FileDirectives directive, store_address_t storeId) + : pduType(type), directiveType(directive), storeId(storeId) {} + + PduType pduType = PduType::FILE_DATA; + FileDirectives directiveType = FileDirectives::INVALID_DIRECTIVE; + store_address_t storeId = store_address_t::invalid(); + PacketInfo() = default; +}; + +struct DestHandlerParams { + DestHandlerParams(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable, + AcceptsTelemetryIF& packetDest, MessageQueueIF& msgQueue, + etl::ilist& packetList) + : cfg(std::move(cfg)), + user(user), + remoteCfgTable(remoteCfgTable), + packetDest(packetDest), + msgQueue(msgQueue), + packetListRef(packetList) {} - private: LocalEntityCfg cfg; UserBase& user; RemoteConfigTableIF& remoteCfgTable; + AcceptsTelemetryIF& packetDest; + MessageQueueIF& msgQueue; + StorageManagerIF* tcStore = nullptr; + StorageManagerIF* tmStore = nullptr; + etl::ilist& packetListRef; +}; + +class DestHandler { + public: + explicit DestHandler(DestHandlerParams params); + + ReturnValue_t performStateMachine(); + + ReturnValue_t passPacket(PacketInfo packet); + + ReturnValue_t initialize(); + + private: + DestHandlerParams p; + enum class TransactionStep { + IDLE = 0, + TRANSACTION_START = 1, + RECEIVING_FILE_DATA_PDUS = 2, + SENDING_ACK_PDU = 3, + TRANSFER_COMPLETION = 4, + SENDING_FINISHED_PDU = 5 + }; + TransactionStep step = TransactionStep::IDLE; }; } // namespace cfdp diff --git a/src/fsfw/container/DynamicFIFO.h b/src/fsfw/container/DynamicFIFO.h index 96f55938..5d1d46e7 100644 --- a/src/fsfw/container/DynamicFIFO.h +++ b/src/fsfw/container/DynamicFIFO.h @@ -18,7 +18,8 @@ template class DynamicFIFO : public FIFOBase { public: - DynamicFIFO(size_t maxCapacity) : FIFOBase(nullptr, maxCapacity), fifoVector(maxCapacity) { + explicit DynamicFIFO(size_t maxCapacity) + : FIFOBase(nullptr, maxCapacity), fifoVector(maxCapacity) { // trying to pass the pointer of the uninitialized vector // to the FIFOBase constructor directly lead to a super evil bug. // So we do it like this now. diff --git a/src/fsfw/container/FIFOBase.h b/src/fsfw/container/FIFOBase.h index 25c75515..db98a3f1 100644 --- a/src/fsfw/container/FIFOBase.h +++ b/src/fsfw/container/FIFOBase.h @@ -15,7 +15,7 @@ class FIFOBase { /** Default ctor, takes pointer to first entry of underlying container * and maximum capacity */ - FIFOBase(T* values, const size_t maxCapacity); + FIFOBase(T* values, size_t maxCapacity); /** * Insert value into FIFO @@ -60,7 +60,7 @@ class FIFOBase { * Get maximal capacity of fifo * @return size_t with max capacity of this fifo */ - size_t getMaxCapacity() const; + [[nodiscard]] size_t getMaxCapacity() const; protected: void setContainer(T* data); diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 8189096d..1b2de95e 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -14,7 +14,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { auto fsMock = FilesystemMock(); auto userMock = UserMock(fsMock); auto remoteCfgTableMock = RemoteConfigTableMock(); - auto destHandler = DestHandler(localEntityCfg, userMock, remoteCfgTableMock); + // auto destHandler = DestHandler(localEntityCfg, userMock, remoteCfgTableMock); SECTION("State") {} } \ No newline at end of file From ff6de8e378ee8444f4773763167c3e5daee1f961 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 18 Aug 2022 11:19:42 +0200 Subject: [PATCH 249/532] important bugfix for verif reporter --- src/fsfw/tcdistribution/PusDistributor.cpp | 5 ++--- src/fsfw/tmtcservices/VerificationReporter.h | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index bb8708cd..0ae36c88 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -105,14 +105,13 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { tcStatus = queueStatus; } if (tcStatus != RETURN_OK) { - verifyChannel->sendFailureReport( - VerifFailureParams(tcverif::ACCEPTANCE_FAILURE, reader, tcStatus)); + verifyChannel->sendFailureReport({tcverif::ACCEPTANCE_FAILURE, reader, tcStatus}); // A failed packet is deleted immediately after reporting, // otherwise it will block memory. store->deleteData(currentMessage.getStorageId()); return RETURN_FAILED; } else { - verifyChannel->sendSuccessReport(VerifSuccessParams(tcverif::ACCEPTANCE_SUCCESS, reader)); + verifyChannel->sendSuccessReport({tcverif::ACCEPTANCE_SUCCESS, reader}); return RETURN_OK; } } diff --git a/src/fsfw/tmtcservices/VerificationReporter.h b/src/fsfw/tmtcservices/VerificationReporter.h index 5fb67f74..f6152614 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.h +++ b/src/fsfw/tmtcservices/VerificationReporter.h @@ -33,10 +33,7 @@ class VerificationReporter : public SystemObject, public VerificationReporterIF void setReceiver(AcceptsVerifyMessageIF& receiver); - // TODO: The API is a little bit bloated. It might be better to group all the parameters - // into a dedicated struct ReturnValue_t sendSuccessReport(VerifSuccessParams params) override; - ReturnValue_t sendFailureReport(VerifFailureParams params) override; static object_id_t DEFAULT_REPORTER; @@ -44,7 +41,7 @@ class VerificationReporter : public SystemObject, public VerificationReporterIF ReturnValue_t initialize() override; private: - MessageQueueId_t acknowledgeQueue; + MessageQueueId_t acknowledgeQueue = MessageQueueIF::NO_QUEUE; }; #endif /* FSFW_TMTCSERVICES_VERIFICATIONREPORTER_H_ */ From 8c8d1cfa84c5f3e855c7d9158c24f92a1b16fccf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 Aug 2022 15:02:16 +0200 Subject: [PATCH 250/532] apply auto-formatter --- src/fsfw/cfdp/CFDPHandler.h | 4 +-- src/fsfw/cfdp/definitions.h | 12 +++---- src/fsfw/datalinklayer/Farm1StateOpen.h | 4 +-- .../datalinklayer/VirtualChannelReception.h | 3 +- .../datapoollocal/LocalDataPoolManager.cpp | 14 ++++---- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 8 ++--- src/fsfw/fdir/FailureIsolationBase.h | 3 +- src/fsfw/memory/HasMemoryIF.h | 4 +-- src/fsfw/osal/common/TcpTmTcBridge.cpp | 3 +- src/fsfw/pus/Service11TelecommandScheduling.h | 9 ++--- src/fsfw/returnvalues/returnvalue.h | 9 +++-- src/fsfw/subsystem/Subsystem.cpp | 4 ++- src/fsfw/tcdistribution/TcDistributor.cpp | 4 ++- src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp | 4 ++- src/fsfw/thermal/Heater.cpp | 4 +-- .../tmtcservices/CommandingServiceBase.cpp | 3 +- src/fsfw/tmtcservices/TmTcBridge.cpp | 3 +- src/fsfw/util/UnsignedByteField.h | 35 ++++++++----------- src/fsfw_hal/linux/CommandExecutor.h | 6 ++-- src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h | 18 ++++------ src/fsfw_hal/linux/spi/SpiComIF.h | 3 +- src/fsfw_hal/linux/uart/UartComIF.h | 9 ++--- src/fsfw_hal/stm32h7/spi/spiDefinitions.h | 3 +- unittests/action/TestActionHelper.cpp | 12 +++---- unittests/cfdp/testTlvsLvs.cpp | 9 ++--- unittests/container/TestArrayList.cpp | 3 +- unittests/container/TestFixedMap.cpp | 9 +++-- .../container/TestFixedOrderedMultimap.cpp | 15 +++----- unittests/hal/testCommandExecutor.cpp | 3 +- unittests/mocks/SimpleSerializable.h | 2 +- unittests/serialize/testSerializeIF.cpp | 20 ++++------- unittests/util/testUnsignedByteField.cpp | 3 +- 32 files changed, 98 insertions(+), 147 deletions(-) diff --git a/src/fsfw/cfdp/CFDPHandler.h b/src/fsfw/cfdp/CFDPHandler.h index 53a8a009..0078f748 100644 --- a/src/fsfw/cfdp/CFDPHandler.h +++ b/src/fsfw/cfdp/CFDPHandler.h @@ -12,9 +12,7 @@ namespace Factory { void setStaticFrameworkObjectIds(); } -class CFDPHandler : public ExecutableObjectIF, - public AcceptsTelecommandsIF, - public SystemObject { +class CFDPHandler : public ExecutableObjectIF, public AcceptsTelecommandsIF, public SystemObject { friend void(Factory::setStaticFrameworkObjectIds)(); public: diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 7aad21e7..53022432 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -15,20 +15,16 @@ static constexpr uint8_t VERSION_BITS = 0b00100000; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; -static constexpr ReturnValue_t INVALID_TLV_TYPE = - returnvalue::makeCode(CFDP_CLASS_ID, 1); -static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = - returnvalue::makeCode(CFDP_CLASS_ID, 2); -static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = - returnvalue::makeCode(CFDP_CLASS_ID, 3); +static constexpr ReturnValue_t INVALID_TLV_TYPE = returnvalue::makeCode(CFDP_CLASS_ID, 1); +static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = returnvalue::makeCode(CFDP_CLASS_ID, 2); +static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = returnvalue::makeCode(CFDP_CLASS_ID, 3); static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = returnvalue::makeCode(CFDP_CLASS_ID, 4); //! Can not parse options. This can also occur because there are options //! available but the user did not pass a valid options array static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = returnvalue::makeCode(CFDP_CLASS_ID, 5); -static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = - returnvalue::makeCode(CFDP_CLASS_ID, 6); +static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = returnvalue::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES = returnvalue::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = diff --git a/src/fsfw/datalinklayer/Farm1StateOpen.h b/src/fsfw/datalinklayer/Farm1StateOpen.h index f0a8ad40..a1c553ff 100644 --- a/src/fsfw/datalinklayer/Farm1StateOpen.h +++ b/src/fsfw/datalinklayer/Farm1StateOpen.h @@ -37,8 +37,8 @@ class Farm1StateOpen : public Farm1StateIF { * change to Farm1StateLockout. * @param frame The frame to handle. * @param clcw Any changes to the CLCW shall be done with the help of this interface. - * @return If the Sequence Number is ok, it returns returnvalue::OK. Otherwise either #NS_POSITIVE_W, - * #NS_NEGATIVE_W or NS_LOCKOUT is returned. + * @return If the Sequence Number is ok, it returns returnvalue::OK. Otherwise either + * #NS_POSITIVE_W, #NS_NEGATIVE_W or NS_LOCKOUT is returned. */ ReturnValue_t handleADFrame(TcTransferFrame* frame, ClcwIF* clcw); /** diff --git a/src/fsfw/datalinklayer/VirtualChannelReception.h b/src/fsfw/datalinklayer/VirtualChannelReception.h index 88ec6886..429ae9de 100644 --- a/src/fsfw/datalinklayer/VirtualChannelReception.h +++ b/src/fsfw/datalinklayer/VirtualChannelReception.h @@ -102,7 +102,8 @@ class VirtualChannelReception : public VirtualChannelReceptionIF, public CCSDSRe * Helper method to simplify adding a mapChannel during construction. * @param mapId The mapId of the object to add. * @param object Pointer to the MapPacketExtraction object itself. - * @return @c returnvalue::OK if the channel was successfully inserted, @c returnvalue::FAILED otherwise. + * @return @c returnvalue::OK if the channel was successfully inserted, @c returnvalue::FAILED + * otherwise. */ ReturnValue_t addMapChannel(uint8_t mapId, MapPacketExtractionIF* object); /** diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index 497e4ef3..d25791a7 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -21,15 +21,15 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQue bool appendValidityBuffer) : appendValidityBuffer(appendValidityBuffer) { if (owner == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_WARNING, "LocalDataPoolManager", - returnvalue::FAILED, "Invalid supplied owner"); + printWarningOrError(sif::OutputTypes::OUT_WARNING, "LocalDataPoolManager", returnvalue::FAILED, + "Invalid supplied owner"); return; } this->owner = owner; mutex = MutexFactory::instance()->createMutex(); if (mutex == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "LocalDataPoolManager", - returnvalue::FAILED, "Could not create mutex"); + printWarningOrError(sif::OutputTypes::OUT_ERROR, "LocalDataPoolManager", returnvalue::FAILED, + "Could not create mutex"); } hkQueue = queueToUse; @@ -780,8 +780,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i ReturnValue_t result = ipcStore->getFreeElement(&storeId, expectedSize, &storePtr); if (result != returnvalue::OK) { printWarningOrError(sif::OutputTypes::OUT_ERROR, "generateSetStructurePacket", - returnvalue::FAILED, - "Could not get free element from IPC store."); + returnvalue::FAILED, "Could not get free element from IPC store."); return result; } @@ -794,8 +793,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool i } if (expectedSize != size) { printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateSetStructurePacket", - returnvalue::FAILED, - "Expected size is not equal to serialized size"); + returnvalue::FAILED, "Expected size is not equal to serialized size"); } // Send structure reporting reply. diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index a93aca0d..525a3dcc 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -45,8 +45,8 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device cookieInfo.state = COOKIE_UNUSED; cookieInfo.pendingCommand = deviceCommandMap.end(); if (comCookie == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "DeviceHandlerBase", - returnvalue::FAILED, "Invalid cookie"); + printWarningOrError(sif::OutputTypes::OUT_ERROR, "DeviceHandlerBase", returnvalue::FAILED, + "Invalid cookie"); } if (this->fdirInstance == nullptr) { this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId, defaultFdirParentId); @@ -634,8 +634,8 @@ void DeviceHandlerBase::replyToReply(const DeviceCommandId_t command, DeviceRepl } DeviceCommandInfo* info = &replyInfo.command->second; if (info == nullptr) { - printWarningOrError(sif::OutputTypes::OUT_ERROR, "replyToReply", - returnvalue::FAILED, "Command pointer not found"); + printWarningOrError(sif::OutputTypes::OUT_ERROR, "replyToReply", returnvalue::FAILED, + "Command pointer not found"); return; } diff --git a/src/fsfw/fdir/FailureIsolationBase.h b/src/fsfw/fdir/FailureIsolationBase.h index 7ebfa9af..543ad6cc 100644 --- a/src/fsfw/fdir/FailureIsolationBase.h +++ b/src/fsfw/fdir/FailureIsolationBase.h @@ -9,8 +9,7 @@ #include "ConfirmsFailuresIF.h" #include "FaultCounter.h" -class FailureIsolationBase : public ConfirmsFailuresIF, - public HasParametersIF { +class FailureIsolationBase : public ConfirmsFailuresIF, public HasParametersIF { public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FDIR_1; static const Event FDIR_CHANGED_STATE = diff --git a/src/fsfw/memory/HasMemoryIF.h b/src/fsfw/memory/HasMemoryIF.h index b39032af..fe5c1fc8 100644 --- a/src/fsfw/memory/HasMemoryIF.h +++ b/src/fsfw/memory/HasMemoryIF.h @@ -30,9 +30,7 @@ class HasMemoryIF { * Sets the address of the memory, if possible. * startAddress is a proposal for an address, or the base address if multiple addresses are set. */ - virtual ReturnValue_t setAddress(uint32_t* startAddress) { - return returnvalue::FAILED; - } + virtual ReturnValue_t setAddress(uint32_t* startAddress) { return returnvalue::FAILED; } static bool memAccessWasSuccessful(ReturnValue_t result) { switch (result) { case DO_IT_MYSELF: diff --git a/src/fsfw/osal/common/TcpTmTcBridge.cpp b/src/fsfw/osal/common/TcpTmTcBridge.cpp index b57e48c0..6b3561ba 100644 --- a/src/fsfw/osal/common/TcpTmTcBridge.cpp +++ b/src/fsfw/osal/common/TcpTmTcBridge.cpp @@ -50,8 +50,7 @@ ReturnValue_t TcpTmTcBridge::handleTm() { TmTcMessage message; ReturnValue_t status = returnvalue::OK; for (ReturnValue_t result = tmTcReceptionQueue->receiveMessage(&message); - result == returnvalue::OK; - result = tmTcReceptionQueue->receiveMessage(&message)) { + result == returnvalue::OK; result = tmTcReceptionQueue->receiveMessage(&message)) { status = storeDownlinkData(&message); if (status != returnvalue::OK) { break; diff --git a/src/fsfw/pus/Service11TelecommandScheduling.h b/src/fsfw/pus/Service11TelecommandScheduling.h index 2ceacbf7..2a14401b 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.h +++ b/src/fsfw/pus/Service11TelecommandScheduling.h @@ -37,12 +37,9 @@ class Service11TelecommandScheduling final : public PusServiceBase { public: static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_11; - static constexpr ReturnValue_t INVALID_TYPE_TIME_WINDOW = - returnvalue::makeCode(CLASS_ID, 1); - static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = - returnvalue::makeCode(CLASS_ID, 2); - static constexpr ReturnValue_t INVALID_RELATIVE_TIME = - returnvalue::makeCode(CLASS_ID, 3); + static constexpr ReturnValue_t INVALID_TYPE_TIME_WINDOW = returnvalue::makeCode(CLASS_ID, 1); + static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = returnvalue::makeCode(CLASS_ID, 2); + static constexpr ReturnValue_t INVALID_RELATIVE_TIME = returnvalue::makeCode(CLASS_ID, 3); static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_11; diff --git a/src/fsfw/returnvalues/returnvalue.h b/src/fsfw/returnvalues/returnvalue.h index c7927a8d..4f9fc092 100644 --- a/src/fsfw/returnvalues/returnvalue.h +++ b/src/fsfw/returnvalues/returnvalue.h @@ -12,8 +12,8 @@ typedef uint16_t ReturnValue_t; namespace returnvalue { - static const ReturnValue_t OK = 0; - static const ReturnValue_t FAILED = 1; +static const ReturnValue_t OK = 0; +static const ReturnValue_t FAILED = 1; /** * It is discouraged to use the input parameters 0,0 and 0,1 as this @@ -22,11 +22,10 @@ namespace returnvalue { * @param number * @return */ -static constexpr ReturnValue_t makeCode( - uint8_t classId, uint8_t number) { +static constexpr ReturnValue_t makeCode(uint8_t classId, uint8_t number) { return (static_cast(classId) << 8) + number; } -} +} // namespace returnvalue #endif /* FSFW_RETURNVALUES_RETURNVALUE_H_ */ diff --git a/src/fsfw/subsystem/Subsystem.cpp b/src/fsfw/subsystem/Subsystem.cpp index 9495323d..b2af5ac3 100644 --- a/src/fsfw/subsystem/Subsystem.cpp +++ b/src/fsfw/subsystem/Subsystem.cpp @@ -55,7 +55,9 @@ ReturnValue_t Subsystem::checkSequence(Mode_t sequence) { return checkSequence(iter, getFallbackSequence(sequence)); } -bool Subsystem::existsModeSequence(Mode_t id) { return modeSequences.exists(id) == returnvalue::OK; } +bool Subsystem::existsModeSequence(Mode_t id) { + return modeSequences.exists(id) == returnvalue::OK; +} bool Subsystem::existsModeTable(Mode_t id) { return modeTables.exists(id) == returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index d7fbd0f8..e26ba2ff 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -43,4 +43,6 @@ void TcDistributor::print() { #endif } -ReturnValue_t TcDistributor::callbackAfterSending(ReturnValue_t queueStatus) { return returnvalue::OK; } +ReturnValue_t TcDistributor::callbackAfterSending(ReturnValue_t queueStatus) { + return returnvalue::OK; +} diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp index 012c2d1a..3d6899a5 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp @@ -4,6 +4,8 @@ TcPacketCheckCFDP::TcPacketCheckCFDP(uint16_t setApid) : apid(setApid) {} -ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketBase* currentPacket) { return returnvalue::OK; } +ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketBase* currentPacket) { + return returnvalue::OK; +} uint16_t TcPacketCheckCFDP::getApid() const { return apid; } diff --git a/src/fsfw/thermal/Heater.cpp b/src/fsfw/thermal/Heater.cpp index 2ad988bd..64348106 100644 --- a/src/fsfw/thermal/Heater.cpp +++ b/src/fsfw/thermal/Heater.cpp @@ -291,8 +291,8 @@ ReturnValue_t Heater::getParameter(uint8_t domainId, uint8_t uniqueId, void Heater::handleEventQueue() { EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); - result == returnvalue::OK; result = eventQueue->receiveMessage(&event)) { + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK; + result = eventQueue->receiveMessage(&event)) { switch (event.getMessageId()) { case EventMessage::EVENT_MESSAGE: switch (event.getEvent()) { diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index d61bf77f..5a4c05b5 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -234,7 +234,8 @@ void CommandingServiceBase::handleRequestQueue() { address = message.getStorageId(); packet.setStoreAddress(address, &packet); - if ((packet.getSubService() == 0) or (isValidSubservice(packet.getSubService()) != returnvalue::OK)) { + if ((packet.getSubService() == 0) or + (isValidSubservice(packet.getSubService()) != returnvalue::OK)) { rejectPacket(tc_verification::START_FAILURE, &packet, INVALID_SUBSERVICE); continue; } diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index 0d50ebe2..87869a52 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -133,8 +133,7 @@ ReturnValue_t TmTcBridge::handleTmQueue() { size_t size = 0; ReturnValue_t status = returnvalue::OK; for (ReturnValue_t result = tmTcReceptionQueue->receiveMessage(&message); - result == returnvalue::OK; - result = tmTcReceptionQueue->receiveMessage(&message)) { + result == returnvalue::OK; result = tmTcReceptionQueue->receiveMessage(&message)) { #if FSFW_VERBOSE_LEVEL >= 3 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "Sent packet counter: " << static_cast(packetSentCounter) << std::endl; diff --git a/src/fsfw/util/UnsignedByteField.h b/src/fsfw/util/UnsignedByteField.h index b02e8b3a..3f4ee791 100644 --- a/src/fsfw/util/UnsignedByteField.h +++ b/src/fsfw/util/UnsignedByteField.h @@ -3,50 +3,45 @@ #include "fsfw/serialize.h" -template -class UnsignedByteField: public SerializeIF { +template +class UnsignedByteField : public SerializeIF { public: static_assert(std::is_unsigned::value); - explicit UnsignedByteField(T value): value(value) {} + explicit UnsignedByteField(T value) : value(value) {} [[nodiscard]] ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const override { + Endianness streamEndianness) const override { return SerializeAdapter::serialize(&value, buffer, size, maxSize, streamEndianness); } ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, - Endianness streamEndianness) override { + Endianness streamEndianness) override { return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness); } - [[nodiscard]] size_t getSerializedSize() const override { - return sizeof(T); - } + [[nodiscard]] size_t getSerializedSize() const override { return sizeof(T); } - [[nodiscard]] T getValue() const { - return value; - } + [[nodiscard]] T getValue() const { return value; } + + void setValue(T value_) { value = value_; } - void setValue(T value_) { - value = value_; - } private: T value; }; -class U32ByteField: public UnsignedByteField { +class U32ByteField : public UnsignedByteField { public: - explicit U32ByteField(uint32_t value): UnsignedByteField(value) {} + explicit U32ByteField(uint32_t value) : UnsignedByteField(value) {} }; -class U16ByteField: public UnsignedByteField { +class U16ByteField : public UnsignedByteField { public: - explicit U16ByteField(uint16_t value): UnsignedByteField(value) {} + explicit U16ByteField(uint16_t value) : UnsignedByteField(value) {} }; -class U8ByteField: public UnsignedByteField { +class U8ByteField : public UnsignedByteField { public: - explicit U8ByteField(uint8_t value): UnsignedByteField(value) {} + explicit U8ByteField(uint8_t value) : UnsignedByteField(value) {} }; #endif // FSFW_UTIL_UNSIGNEDBYTEFIELD_H diff --git a/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h index fea2ef0a..70cb071e 100644 --- a/src/fsfw_hal/linux/CommandExecutor.h +++ b/src/fsfw_hal/linux/CommandExecutor.h @@ -31,8 +31,7 @@ class CommandExecutor { static constexpr uint8_t CLASS_ID = CLASS_ID::LINUX_OSAL; //! [EXPORT] : [COMMENT] Execution of the current command has finished - static constexpr ReturnValue_t EXECUTION_FINISHED = - returnvalue::makeCode(CLASS_ID, 0); + static constexpr ReturnValue_t EXECUTION_FINISHED = returnvalue::makeCode(CLASS_ID, 0); //! [EXPORT] : [COMMENT] Command is pending. This will also be returned if the user tries //! to load another command but a command is still pending @@ -42,8 +41,7 @@ class CommandExecutor { //! [EXPORT] : [COMMENT] Command execution failed static constexpr ReturnValue_t COMMAND_ERROR = returnvalue::makeCode(CLASS_ID, 3); //! [EXPORT] : [COMMENT] - static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = - returnvalue::makeCode(CLASS_ID, 4); + static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = returnvalue::makeCode(CLASS_ID, 4); static constexpr ReturnValue_t PCLOSE_CALL_ERROR = returnvalue::makeCode(CLASS_ID, 6); /** diff --git a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h index 49b15b83..bb8e890d 100644 --- a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h +++ b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h @@ -19,18 +19,12 @@ class LinuxLibgpioIF : public GpioIF, public SystemObject { public: static const uint8_t gpioRetvalId = CLASS_ID::HAL_GPIO; - static constexpr ReturnValue_t UNKNOWN_GPIO_ID = - returnvalue::makeCode(gpioRetvalId, 1); - static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = - returnvalue::makeCode(gpioRetvalId, 2); - static constexpr ReturnValue_t GPIO_TYPE_FAILURE = - returnvalue::makeCode(gpioRetvalId, 3); - static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = - returnvalue::makeCode(gpioRetvalId, 4); - static constexpr ReturnValue_t GPIO_DUPLICATE_DETECTED = - returnvalue::makeCode(gpioRetvalId, 5); - static constexpr ReturnValue_t GPIO_INIT_FAILED = - returnvalue::makeCode(gpioRetvalId, 6); + static constexpr ReturnValue_t UNKNOWN_GPIO_ID = returnvalue::makeCode(gpioRetvalId, 1); + static constexpr ReturnValue_t DRIVE_GPIO_FAILURE = returnvalue::makeCode(gpioRetvalId, 2); + static constexpr ReturnValue_t GPIO_TYPE_FAILURE = returnvalue::makeCode(gpioRetvalId, 3); + static constexpr ReturnValue_t GPIO_INVALID_INSTANCE = returnvalue::makeCode(gpioRetvalId, 4); + static constexpr ReturnValue_t GPIO_DUPLICATE_DETECTED = returnvalue::makeCode(gpioRetvalId, 5); + static constexpr ReturnValue_t GPIO_INIT_FAILED = returnvalue::makeCode(gpioRetvalId, 6); LinuxLibgpioIF(object_id_t objectId); virtual ~LinuxLibgpioIF(); diff --git a/src/fsfw_hal/linux/spi/SpiComIF.h b/src/fsfw_hal/linux/spi/SpiComIF.h index d3b361a9..11defdce 100644 --- a/src/fsfw_hal/linux/spi/SpiComIF.h +++ b/src/fsfw_hal/linux/spi/SpiComIF.h @@ -23,8 +23,7 @@ class SpiCookie; class SpiComIF : public DeviceCommunicationIF, public SystemObject { public: static constexpr uint8_t spiRetvalId = CLASS_ID::HAL_SPI; - static constexpr ReturnValue_t OPENING_FILE_FAILED = - returnvalue::makeCode(spiRetvalId, 0); + static constexpr ReturnValue_t OPENING_FILE_FAILED = returnvalue::makeCode(spiRetvalId, 0); /* Full duplex (ioctl) transfer failure */ static constexpr ReturnValue_t FULL_DUPLEX_TRANSFER_FAILED = returnvalue::makeCode(spiRetvalId, 1); diff --git a/src/fsfw_hal/linux/uart/UartComIF.h b/src/fsfw_hal/linux/uart/UartComIF.h index 870d02c5..77318166 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.h +++ b/src/fsfw_hal/linux/uart/UartComIF.h @@ -22,12 +22,9 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject { public: static constexpr uint8_t uartRetvalId = CLASS_ID::HAL_UART; - static constexpr ReturnValue_t UART_READ_FAILURE = - returnvalue::makeCode(uartRetvalId, 1); - static constexpr ReturnValue_t UART_READ_SIZE_MISSMATCH = - returnvalue::makeCode(uartRetvalId, 2); - static constexpr ReturnValue_t UART_RX_BUFFER_TOO_SMALL = - returnvalue::makeCode(uartRetvalId, 3); + static constexpr ReturnValue_t UART_READ_FAILURE = returnvalue::makeCode(uartRetvalId, 1); + static constexpr ReturnValue_t UART_READ_SIZE_MISSMATCH = returnvalue::makeCode(uartRetvalId, 2); + static constexpr ReturnValue_t UART_RX_BUFFER_TOO_SMALL = returnvalue::makeCode(uartRetvalId, 3); UartComIF(object_id_t objectId); diff --git a/src/fsfw_hal/stm32h7/spi/spiDefinitions.h b/src/fsfw_hal/stm32h7/spi/spiDefinitions.h index 55a74e7a..cf05d986 100644 --- a/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +++ b/src/fsfw_hal/stm32h7/spi/spiDefinitions.h @@ -10,8 +10,7 @@ namespace spi { static constexpr uint8_t HAL_SPI_ID = CLASS_ID::HAL_SPI; -static constexpr ReturnValue_t HAL_TIMEOUT_RETVAL = - returnvalue::makeCode(HAL_SPI_ID, 0); +static constexpr ReturnValue_t HAL_TIMEOUT_RETVAL = returnvalue::makeCode(HAL_SPI_ID, 0); static constexpr ReturnValue_t HAL_BUSY_RETVAL = returnvalue::makeCode(HAL_SPI_ID, 1); static constexpr ReturnValue_t HAL_ERROR_RETVAL = returnvalue::makeCode(HAL_SPI_ID, 2); diff --git a/unittests/action/TestActionHelper.cpp b/unittests/action/TestActionHelper.cpp index fdb8aad6..823d873d 100644 --- a/unittests/action/TestActionHelper.cpp +++ b/unittests/action/TestActionHelper.cpp @@ -57,8 +57,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { step += 1; CHECK(testMqMock.wasMessageSent()); CommandMessage testMessage; - REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(returnvalue::OK)); + REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(returnvalue::OK)); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(testMessage.getParameter() == static_cast(testActionId)); uint32_t parameter2 = ((uint32_t)step << 16) | (uint32_t)status; @@ -72,8 +71,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { actionHelper.finish(false, testMqMock.getId(), testActionId, status); CHECK(testMqMock.wasMessageSent()); CommandMessage testMessage; - REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(returnvalue::OK)); + REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(returnvalue::OK)); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::COMPLETION_FAILED)); REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId); REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(status)); @@ -89,8 +87,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { REQUIRE(ipcStore->getData(toLongParamAddress).first == static_cast(StorageManagerIF::DATA_DOES_NOT_EXIST)); CommandMessage testMessage; - REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(returnvalue::OK)); + REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(returnvalue::OK)); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(ActionMessage::getReturnCode(&testMessage) == 0xAFFE); REQUIRE(ActionMessage::getStep(&testMessage) == 0); @@ -102,8 +99,7 @@ TEST_CASE("Action Helper", "[ActionHelper]") { CHECK(not testDhMock.executeActionCalled); REQUIRE(actionHelper.handleActionMessage(&actionMessage) == returnvalue::OK); CommandMessage testMessage; - REQUIRE(testMqMock.receiveMessage(&testMessage) == - static_cast(returnvalue::OK)); + REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast(returnvalue::OK)); REQUIRE(testMessage.getCommand() == static_cast(ActionMessage::STEP_FAILED)); REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast(StorageManagerIF::ILLEGAL_STORAGE_ID)); diff --git a/unittests/cfdp/testTlvsLvs.cpp b/unittests/cfdp/testTlvsLvs.cpp index 3bfd3a6b..bd5ec849 100644 --- a/unittests/cfdp/testTlvsLvs.cpp +++ b/unittests/cfdp/testTlvsLvs.cpp @@ -80,8 +80,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); deserSize = 0; REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == - returnvalue::OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER); REQUIRE(rawBuf[1] == 0); } @@ -110,8 +109,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { SerializeIF::Endianness::NETWORK); REQUIRE(entityId == 0x0ff0); - REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != - returnvalue::OK); + REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != returnvalue::OK); deserPtr = rawBuf.data(); deserSize = 0; REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) == @@ -126,8 +124,7 @@ TEST_CASE("CFDP TLV LV", "[CfdpTlvLv]") { serPtr = rawBuf.data(); deserSize = 0; REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == - returnvalue::OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); deserPtr = rawBuf.data(); result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); diff --git a/unittests/container/TestArrayList.cpp b/unittests/container/TestArrayList.cpp index 3056c288..04560cef 100644 --- a/unittests/container/TestArrayList.cpp +++ b/unittests/container/TestArrayList.cpp @@ -74,8 +74,7 @@ TEST_CASE("Array List", "[ArrayListTest]") { SECTION("Const Iterator") { ArrayList::Iterator it = complexList.begin(); for (auto i = 0; i < 10; i++) { - REQUIRE(complexList.insert(TestClass(i, i + 1)) == - static_cast(returnvalue::OK)); + REQUIRE(complexList.insert(TestClass(i, i + 1)) == static_cast(returnvalue::OK)); } it++; const TestClass* secondTest = it.value; diff --git a/unittests/container/TestFixedMap.cpp b/unittests/container/TestFixedMap.cpp index dae40d2d..f8479899 100644 --- a/unittests/container/TestFixedMap.cpp +++ b/unittests/container/TestFixedMap.cpp @@ -19,8 +19,7 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { SECTION("Fill and erase") { for (uint16_t i = 0; i < 30; i++) { - REQUIRE(map.insert(std::make_pair(i, i + 1)) == - static_cast(returnvalue::OK)); + REQUIRE(map.insert(std::make_pair(i, i + 1)) == static_cast(returnvalue::OK)); REQUIRE(map.exists(i) == static_cast(returnvalue::OK)); REQUIRE(map.find(i)->second == i + 1); REQUIRE(not map.empty()); @@ -97,9 +96,9 @@ TEST_CASE("FixedMap Tests", "[TestFixedMap]") { static_cast(SerializeIF::BUFFER_TOO_SHORT)); loc_ptr = buffer; size = 0; - REQUIRE(map.serialize( - &loc_ptr, &size, sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t)), - SerializeIF::Endianness::BIG) == static_cast(returnvalue::OK)); + REQUIRE(map.serialize(&loc_ptr, &size, + sizeof(uint32_t) + 2 * (sizeof(uint32_t) + sizeof(uint16_t)), + SerializeIF::Endianness::BIG) == static_cast(returnvalue::OK)); REQUIRE(size == 16); uint32_t internal_size = 0; diff --git a/unittests/container/TestFixedOrderedMultimap.cpp b/unittests/container/TestFixedOrderedMultimap.cpp index 9bfd2b09..4d90a0cf 100644 --- a/unittests/container/TestFixedOrderedMultimap.cpp +++ b/unittests/container/TestFixedOrderedMultimap.cpp @@ -14,8 +14,7 @@ TEST_CASE("FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") { SECTION("Test insert, find, exists") { for (uint16_t i = 0; i < 30; i++) { - REQUIRE(map.insert(std::make_pair(i, i + 1)) == - static_cast(returnvalue::OK)); + REQUIRE(map.insert(std::make_pair(i, i + 1)) == static_cast(returnvalue::OK)); REQUIRE(map.exists(i) == static_cast(returnvalue::OK)); REQUIRE(map.find(i)->second == i + 1); } @@ -188,23 +187,19 @@ TEST_CASE("FixedOrderedMultimap Non Trivial Type", "[TestFixedOrderedMultimapNon SECTION("Test different insert variants") { FixedOrderedMultimap::Iterator it = map.end(); - REQUIRE(map.insert(36, TestClass(37, 36), &it) == - static_cast(returnvalue::OK)); + REQUIRE(map.insert(36, TestClass(37, 36), &it) == static_cast(returnvalue::OK)); REQUIRE(it->first == 36); bool compare = it->second == TestClass(37, 36); REQUIRE(compare); REQUIRE(map.size() == 1); - REQUIRE(map.insert(37, TestClass(38, 37), nullptr) == - static_cast(returnvalue::OK)); + REQUIRE(map.insert(37, TestClass(38, 37), nullptr) == static_cast(returnvalue::OK)); compare = map.find(37)->second == TestClass(38, 37); REQUIRE(compare); REQUIRE(map.size() == 2); - REQUIRE(map.insert(37, TestClass(24, 37), nullptr) == - static_cast(returnvalue::OK)); + REQUIRE(map.insert(37, TestClass(24, 37), nullptr) == static_cast(returnvalue::OK)); compare = map.find(37)->second == TestClass(38, 37); REQUIRE(compare); - REQUIRE(map.insert(0, TestClass(1, 0), nullptr) == - static_cast(returnvalue::OK)); + REQUIRE(map.insert(0, TestClass(1, 0), nullptr) == static_cast(returnvalue::OK)); compare = map.find(0)->second == TestClass(1, 0); REQUIRE(compare); REQUIRE(map.size() == 4); diff --git a/unittests/hal/testCommandExecutor.cpp b/unittests/hal/testCommandExecutor.cpp index e6f1ae88..04576f85 100644 --- a/unittests/hal/testCommandExecutor.cpp +++ b/unittests/hal/testCommandExecutor.cpp @@ -113,8 +113,7 @@ TEST_CASE("Command Executor", "[cmd-exec]") { REQUIRE(result == returnvalue::OK); result = cmdExecutor.execute(); REQUIRE(result == returnvalue::OK); - while (result != CommandExecutor::EXECUTION_FINISHED and - result != returnvalue::FAILED) { + while (result != CommandExecutor::EXECUTION_FINISHED and result != returnvalue::FAILED) { limitIdx++; result = cmdExecutor.check(bytesHaveBeenRead); REQUIRE(result != CommandExecutor::COMMAND_ERROR); diff --git a/unittests/mocks/SimpleSerializable.h b/unittests/mocks/SimpleSerializable.h index 5c28a09a..222f1729 100644 --- a/unittests/mocks/SimpleSerializable.h +++ b/unittests/mocks/SimpleSerializable.h @@ -1,8 +1,8 @@ #ifndef FSFW_TESTS_SIMPLESERIALIZABLE_H #define FSFW_TESTS_SIMPLESERIALIZABLE_H -#include "fsfw/serialize.h" #include "fsfw/osal/Endiness.h" +#include "fsfw/serialize.h" class SimpleSerializable : public SerializeIF { public: diff --git a/unittests/serialize/testSerializeIF.cpp b/unittests/serialize/testSerializeIF.cpp index 99878eb6..30ad58e5 100644 --- a/unittests/serialize/testSerializeIF.cpp +++ b/unittests/serialize/testSerializeIF.cpp @@ -26,8 +26,7 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { SECTION("Little Endian Simple") { size_t serLen = 0xff; REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), - SerializeIF::Endianness::LITTLE) == - returnvalue::OK); + SerializeIF::Endianness::LITTLE) == returnvalue::OK); CHECK(buf[0] == 1); CHECK(buf[1] == 3); CHECK(buf[2] == 2); @@ -59,8 +58,7 @@ TEST_CASE("Serialize IF Serialize", "[serialize-if-ser]") { size_t serLen = 0xff; SECTION("Explicit") { REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), - SerializeIF::Endianness::BIG) == - returnvalue::OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); } SECTION("Network 0") { REQUIRE(simpleSer.SerializeIF::serialize(buf.data(), serLen, buf.size(), @@ -85,8 +83,7 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { size_t len = buf.size(); SECTION("Little Endian Normal") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == - returnvalue::OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::LITTLE) == returnvalue::OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); CHECK(ptr == buf.data() + 3); @@ -95,9 +92,8 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { SECTION("Little Endian Simple") { size_t deserLen = 0xff; - REQUIRE( - simpleSer.SerializeIF::deSerialize(ptr, deserLen, len, SerializeIF::Endianness::LITTLE) == - returnvalue::OK); + REQUIRE(simpleSer.SerializeIF::deSerialize(ptr, deserLen, len, + SerializeIF::Endianness::LITTLE) == returnvalue::OK); CHECK(simpleSer.getU8() == 5); CHECK(simpleSer.getU16() == 0x0100); CHECK(deserLen == 3); @@ -105,8 +101,7 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { SECTION("Big Endian Normal") { SECTION("Explicit") { - REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == - returnvalue::OK); + REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::BIG) == returnvalue::OK); } SECTION("Network 0") { REQUIRE(simpleSer.deSerialize(&ptr, &len, SerializeIF::Endianness::NETWORK) == @@ -125,8 +120,7 @@ TEST_CASE("SerializeIF Deserialize", "[serialize-if-de]") { size_t deserLen = 0xff; SECTION("Explicit") { REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size(), - SerializeIF::Endianness::BIG) == - returnvalue::OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); } SECTION("Network 0") { REQUIRE(simpleSer.SerializeIF::deSerialize(buf.data(), deserLen, buf.size(), diff --git a/unittests/util/testUnsignedByteField.cpp b/unittests/util/testUnsignedByteField.cpp index e6d91ab9..df1ff483 100644 --- a/unittests/util/testUnsignedByteField.cpp +++ b/unittests/util/testUnsignedByteField.cpp @@ -1,10 +1,9 @@ +#include #include #include "fsfw/util/UnsignedByteField.h" -#include - TEST_CASE("Unsigned Byte Field", "[unsigned-byte-field]") { auto testByteField = UnsignedByteField(10); auto u32ByteField = U32ByteField(10); From dab1b1d067961387cc004c08bda959201646f1be Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 Aug 2022 15:02:53 +0200 Subject: [PATCH 251/532] apply auto-formatter --- src/fsfw/tcdistribution/PusDistributor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 42531fcd..a2d3e321 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -135,7 +135,8 @@ ReturnValue_t PusDistributor::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } if (verifyChannel == nullptr) { - verifyChannel = ObjectManager::instance()->get(objects::VERIFICATION_REPORTER); + verifyChannel = + ObjectManager::instance()->get(objects::VERIFICATION_REPORTER); if (verifyChannel == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } From ba5c6410d6def39634721335ba72d3751cab0192 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 Aug 2022 16:23:36 +0200 Subject: [PATCH 252/532] tests running again --- src/fsfw/cfdp/CfdpHandler.cpp | 1 - src/fsfw/tcdistribution/CFDPDistributor.h | 1 - src/fsfw/tcdistribution/CcsdsPacketCheckIF.h | 6 +----- src/fsfw/tcdistribution/PusDistributor.cpp | 4 ++-- src/fsfw/tcdistribution/PusPacketChecker.h | 2 +- src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp | 1 - src/fsfw/tcdistribution/definitions.h | 2 +- src/fsfw/timemanager/TimeReaderIF.h | 2 +- src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h | 2 +- src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h | 4 ---- src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h | 2 +- src/fsfw/tmtcservices/TmSendHelper.h | 2 +- src/fsfw/tmtcservices/tcHelpers.h | 2 +- 13 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/fsfw/cfdp/CfdpHandler.cpp b/src/fsfw/cfdp/CfdpHandler.cpp index b9c8b580..cfe423e3 100644 --- a/src/fsfw/cfdp/CfdpHandler.cpp +++ b/src/fsfw/cfdp/CfdpHandler.cpp @@ -3,7 +3,6 @@ #include "fsfw/cfdp/CfdpMessage.h" #include "fsfw/ipc/CommandMessage.h" #include "fsfw/ipc/QueueFactory.h" -#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/storagemanager/storeAddress.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" diff --git a/src/fsfw/tcdistribution/CFDPDistributor.h b/src/fsfw/tcdistribution/CFDPDistributor.h index 1d0e4238..17e79ff3 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.h +++ b/src/fsfw/tcdistribution/CFDPDistributor.h @@ -5,7 +5,6 @@ #include "../returnvalues/returnvalue.h" #include "../tmtcpacket/cfdp/CfdpPacketStored.h" - #include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../tmtcservices/VerificationReporter.h" #include "CFDPDistributorIF.h" diff --git a/src/fsfw/tcdistribution/CcsdsPacketCheckIF.h b/src/fsfw/tcdistribution/CcsdsPacketCheckIF.h index 1406bc36..251203d4 100644 --- a/src/fsfw/tcdistribution/CcsdsPacketCheckIF.h +++ b/src/fsfw/tcdistribution/CcsdsPacketCheckIF.h @@ -1,13 +1,9 @@ #ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ #define FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ -<<<<<<< HEAD:src/fsfw/tcdistribution/CcsdsPacketCheckIF.h #include -======= -#include "../returnvalues/returnvalue.h" ->>>>>>> origin/development:src/fsfw/tcdistribution/TcPacketCheckIF.h -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" class SpacePacketReader; diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index a2d3e321..c94d5736 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -103,7 +103,7 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { if (queueStatus != returnvalue::OK) { tcStatus = queueStatus; } - if (tcStatus != RETURN_OK) { + if (tcStatus != returnvalue::OK) { verifyChannel->sendFailureReport({tcverif::ACCEPTANCE_FAILURE, reader, tcStatus}); // A failed packet is deleted immediately after reporting, // otherwise it will block memory. @@ -111,7 +111,7 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { return returnvalue::FAILED; } else { verifyChannel->sendSuccessReport({tcverif::ACCEPTANCE_SUCCESS, reader}); - return RETURN_OK; + return returnvalue::OK; } } diff --git a/src/fsfw/tcdistribution/PusPacketChecker.h b/src/fsfw/tcdistribution/PusPacketChecker.h index ee56e1f8..249221bb 100644 --- a/src/fsfw/tcdistribution/PusPacketChecker.h +++ b/src/fsfw/tcdistribution/PusPacketChecker.h @@ -2,7 +2,7 @@ #define FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ #include "fsfw/FSFW.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tmtcpacket/pus/defs.h" #include "fsfw/tmtcservices/PusVerificationReport.h" diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp index 504306c6..8171a392 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp @@ -9,4 +9,3 @@ ReturnValue_t CfdpPacketChecker::checkPacket(const SpacePacketReader& currentPac } uint16_t CfdpPacketChecker::getApid() const { return apid; } - diff --git a/src/fsfw/tcdistribution/definitions.h b/src/fsfw/tcdistribution/definitions.h index ce640308..3d455077 100644 --- a/src/fsfw/tcdistribution/definitions.h +++ b/src/fsfw/tcdistribution/definitions.h @@ -4,7 +4,7 @@ #include #include "fsfw/returnvalues/FwClassIds.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" namespace tcdistrib { static const uint8_t INTERFACE_ID = CLASS_ID::PACKET_CHECK; diff --git a/src/fsfw/timemanager/TimeReaderIF.h b/src/fsfw/timemanager/TimeReaderIF.h index 289a0058..a3343e1c 100644 --- a/src/fsfw/timemanager/TimeReaderIF.h +++ b/src/fsfw/timemanager/TimeReaderIF.h @@ -4,7 +4,7 @@ #include #include "TimeStampIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" class TimeReaderIF : public TimeStampIF { public: diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h index dbffa7bf..ff22510c 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h @@ -3,7 +3,7 @@ #include -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tmtcpacket/ReadablePacketIF.h" #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" #include "fsfw/tmtcpacket/ccsds/defs.h" diff --git a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h index 6accb66f..b9d03f1d 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h +++ b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.h @@ -7,11 +7,7 @@ #include "fsfw/tmtcpacket/pus/tm/PusTmIF.h" #include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h" -<<<<<<< HEAD class PacketMatchTree : public MatchTree { -======= -class PacketMatchTree : public MatchTree { ->>>>>>> origin/development public: explicit PacketMatchTree(Node* root); explicit PacketMatchTree(iterator root); diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h index 7bfae4f2..3b2e7600 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmMinimal.h @@ -2,7 +2,7 @@ #define FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_ #include "PusTmIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" #include "fsfw/tmtcpacket/pus/RawUserDataReaderIF.h" diff --git a/src/fsfw/tmtcservices/TmSendHelper.h b/src/fsfw/tmtcservices/TmSendHelper.h index 5d39d5d1..9fee84c4 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.h +++ b/src/fsfw/tmtcservices/TmSendHelper.h @@ -5,7 +5,7 @@ #include "fsfw/internalerror/InternalErrorReporterIF.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/messageQueueDefinitions.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" class TmSendHelper { public: diff --git a/src/fsfw/tmtcservices/tcHelpers.h b/src/fsfw/tmtcservices/tcHelpers.h index e2bbf509..9b1e1fdb 100644 --- a/src/fsfw/tmtcservices/tcHelpers.h +++ b/src/fsfw/tmtcservices/tcHelpers.h @@ -1,7 +1,7 @@ #ifndef FSFW_TMTCSERVICES_TCHELPERS_H #define FSFW_TMTCSERVICES_TCHELPERS_H -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/tmtcpacket/pus/tc.h" From d12c59c8acd9f7a59dfdfea04dbfe76dcae41836 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 Aug 2022 16:35:53 +0200 Subject: [PATCH 253/532] all retval replacements --- src/fsfw/cfdp/CfdpDistributor.cpp | 12 ++--- src/fsfw/cfdp/CfdpDistributor.h | 6 +-- src/fsfw/cfdp/CfdpHandler.h | 1 - src/fsfw/cfdp/handler/DestHandler.cpp | 12 ++--- src/fsfw/cfdp/pdu/AckPduDeserializer.cpp | 1 + src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp | 6 +-- src/fsfw/cfdp/pdu/FileDirectiveReader.cpp | 4 +- src/fsfw/cfdp/pdu/HeaderCreator.cpp | 12 ++--- src/fsfw/cfdp/pdu/HeaderReader.cpp | 8 +-- src/fsfw/filesystem/HasFileSystemIF.h | 2 +- src/fsfw/tcdistribution/CcsdsDistributor.cpp | 20 ++++---- src/fsfw/tcdistribution/PusDistributor.cpp | 4 +- src/fsfw/tcdistribution/TcDistributorBase.cpp | 10 ++-- src/fsfw/tcdistribution/definitions.h | 2 +- src/fsfw_hal/host/HostFilesystem.cpp | 32 ++++++------ unittests/cfdp/handler/testDistributor.cpp | 32 ++++++------ unittests/cfdp/pdu/testCfdpHeader.cpp | 36 +++++++------- unittests/cfdp/pdu/testFileDirective.cpp | 10 ++-- unittests/cfdp/testLvs.cpp | 26 +++++----- unittests/cfdp/testOtherTlvs.cpp | 20 ++++---- unittests/cfdp/testTlv.cpp | 37 +++++++------- unittests/hal/testFsMock.cpp | 6 +-- unittests/hal/testHostFilesystem.cpp | 49 +++++++++---------- unittests/mocks/CcsdsCheckerMock.h | 2 +- unittests/mocks/FilesystemMock.cpp | 20 ++++---- unittests/mocks/StorageManagerMock.cpp | 8 +-- .../tcdistributor/testCcsdsDistributor.cpp | 33 +++++++------ 27 files changed, 204 insertions(+), 207 deletions(-) diff --git a/src/fsfw/cfdp/CfdpDistributor.cpp b/src/fsfw/cfdp/CfdpDistributor.cpp index e2377024..d0237959 100644 --- a/src/fsfw/cfdp/CfdpDistributor.cpp +++ b/src/fsfw/cfdp/CfdpDistributor.cpp @@ -9,24 +9,24 @@ ReturnValue_t CfdpDistributor::registerTcDestination(const cfdp::EntityId& addre AcceptsTelecommandsIF& tcDest) { for (const auto& dest : tcDestinations) { if (dest.id == address) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } tcDestinations.emplace_back(address, tcDest.getName(), tcDest.getRequestQueue()); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { auto accessorPair = cfg.tcStore.getData(currentMessage.getStorageId()); - if (accessorPair.first != HasReturnvaluesIF::RETURN_OK) { + if (accessorPair.first != returnvalue::OK) { return accessorPair.first; } ReturnValue_t result = pduReader.setData(accessorPair.second.data(), accessorPair.second.size()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = pduReader.parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } cfdp::EntityId foundId; @@ -44,7 +44,7 @@ ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { } // Packet was forwarded successfully, so do not delete it. accessorPair.second.release(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } const char* CfdpDistributor::getName() const { return "CFDP Distributor"; } diff --git a/src/fsfw/cfdp/CfdpDistributor.h b/src/fsfw/cfdp/CfdpDistributor.h index 64c5ca9f..39ce0d27 100644 --- a/src/fsfw/cfdp/CfdpDistributor.h +++ b/src/fsfw/cfdp/CfdpDistributor.h @@ -5,7 +5,7 @@ #include #include "fsfw/cfdp/pdu/HeaderReader.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tcdistribution/CfdpPacketChecker.h" #include "fsfw/tcdistribution/TcDistributorBase.h" #include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h" @@ -61,8 +61,8 @@ class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF { MessageQueueId_t queueId; }; HeaderReader pduReader; - ReturnValue_t lastTcError = HasReturnvaluesIF::RETURN_OK; - ReturnValue_t lastTmError = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t lastTcError = returnvalue::OK; + ReturnValue_t lastTmError = returnvalue::OK; // I don't think a regular OBSW will have more than 1 or 2 of these destinations, so I think // it is okay to accept the overhead here std::vector tcDestinations; diff --git a/src/fsfw/cfdp/CfdpHandler.h b/src/fsfw/cfdp/CfdpHandler.h index c81a6cf7..8c2827ec 100644 --- a/src/fsfw/cfdp/CfdpHandler.h +++ b/src/fsfw/cfdp/CfdpHandler.h @@ -61,4 +61,3 @@ //}; // //#endif /* FSFW_CFDP_CFDPHANDLER_H_ */ - diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index f04a4b12..85ef03f4 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -23,30 +23,30 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { case TransactionStep::SENDING_FINISHED_PDU: break; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) { if (p.packetListRef.full()) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } p.packetListRef.push_back(packet); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t cfdp::DestHandler::initialize() { if (p.tmStore == nullptr) { p.tmStore = ObjectManager::instance()->get(objects::TM_STORE); if (p.tmStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } if (p.tcStore == nullptr) { p.tcStore = ObjectManager::instance()->get(objects::TC_STORE); if (p.tcStore == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp index 7e92ef9a..f09db97e 100644 --- a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp @@ -6,6 +6,7 @@ AckPduDeserializer::AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, Ac ReturnValue_t AckPduDeserializer::parseData() { ReturnValue_t result = FileDirectiveReader::parseData(); if (result != returnvalue::OK) { + return result; } size_t currentIdx = FileDirectiveReader::getHeaderSize(); if (currentIdx + 2 > this->maxSize) { diff --git a/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp index 169c2d5f..86c1ad92 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp @@ -12,13 +12,13 @@ size_t FileDirectiveCreator::getSerializedSize() const { ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (FileDirectiveCreator::getWholePduSize() > maxSize) { return BUFFER_TOO_SHORT; } ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } @@ -28,7 +28,7 @@ ReturnValue_t FileDirectiveCreator::serialize(uint8_t **buffer, size_t *size, si **buffer = directiveCode; *buffer += 1; *size += 1; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) { diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp index bc06a9d7..4099efd9 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp @@ -7,7 +7,7 @@ cfdp::FileDirectives FileDirectiveReader::getFileDirective() const { return file ReturnValue_t FileDirectiveReader::parseData() { ReturnValue_t result = HeaderReader::parseData(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (this->getPduDataFieldLen() < 1) { @@ -21,7 +21,7 @@ ReturnValue_t FileDirectiveReader::parseData() { return cfdp::INVALID_DIRECTIVE_FIELDS; } setFileDirective(static_cast(pointers.rawPtr[currentIdx])); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t FileDirectiveReader::getHeaderSize() const { diff --git a/src/fsfw/cfdp/pdu/HeaderCreator.cpp b/src/fsfw/cfdp/pdu/HeaderCreator.cpp index 1a7afe0d..e64f8481 100644 --- a/src/fsfw/cfdp/pdu/HeaderCreator.cpp +++ b/src/fsfw/cfdp/pdu/HeaderCreator.cpp @@ -12,7 +12,7 @@ HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t i ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const { if (buffer == nullptr or size == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (maxSize < this->getSerializedSize()) { return BUFFER_TOO_SHORT; @@ -29,19 +29,19 @@ ReturnValue_t HeaderCreator::serialize(uint8_t **buffer, size_t *size, size_t ma *buffer += 1; *size += 4; ReturnValue_t result = pduConf.sourceId.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = pduConf.seqNum.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } result = pduConf.destId.serialize(buffer, size, maxSize, streamEndianness); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t HeaderCreator::getSerializedSize() const { @@ -51,7 +51,7 @@ size_t HeaderCreator::getSerializedSize() const { ReturnValue_t HeaderCreator::deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) { // We could implement this, but I prefer dedicated classes - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } size_t HeaderCreator::getWholePduSize() const { diff --git a/src/fsfw/cfdp/pdu/HeaderReader.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp index 1fd40b78..f220ccd3 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.cpp +++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp @@ -8,7 +8,7 @@ HeaderReader::HeaderReader(const uint8_t *pduBuf, size_t maxSize) { setData(pduB ReturnValue_t HeaderReader::parseData() { if (pointers.rawPtr == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (maxSize < 7) { return SerializeIF::STREAM_TOO_SHORT; @@ -20,19 +20,19 @@ ReturnValue_t HeaderReader::parseData() { cfdp::WidthInBytes widthSeqNum = getLenSeqNum(); seqNumRaw = static_cast(sourceIdRaw) + static_cast(widthEntityIds); destIdRaw = static_cast(seqNumRaw) + static_cast(widthSeqNum); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) { if (dataPtr == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } if (maxSize_ < 7) { return SerializeIF::STREAM_TOO_SHORT; } pointers.rawPtr = dataPtr; maxSize = maxSize_; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } size_t HeaderReader::getHeaderSize() const { diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index 078de7c0..e7e2a529 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -7,7 +7,7 @@ #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/messageQueueDefinitions.h" #include "fsfw/returnvalues/FwClassIds.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" struct FilesystemParams { explicit FilesystemParams(const char* path) : path(path) {} diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp index a2080ea8..4668a3bc 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -36,7 +36,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { #endif auto accessorPair = tcStore->getData(currentMessage.getStorageId()); ReturnValue_t result = accessorPair.first; - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CCSDSDistributor::selectDestination: Getting data from" @@ -64,7 +64,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { } SpacePacketReader currentPacket(accessorPair.second.data(), accessorPair.second.size()); result = packetChecker->checkPacket(currentPacket, accessorPair.second.size()); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { handlePacketCheckFailure(result); return result; } @@ -90,7 +90,7 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { return handleCcsdsHeaderRemoval(accessorPair.second); } accessorPair.second.release(); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) { @@ -116,10 +116,10 @@ void CcsdsDistributor::handlePacketCheckFailure(ReturnValue_t result) { MessageQueueId_t CcsdsDistributor::getRequestQueue() const { return tcQueue->getId(); } ReturnValue_t CcsdsDistributor::registerApplication(DestInfo info) { - ReturnValue_t returnValue = RETURN_OK; + ReturnValue_t returnValue = returnvalue::OK; auto insertPair = receiverMap.emplace(info.apid, info); if (not insertPair.second) { - returnValue = RETURN_FAILED; + returnValue = returnvalue::FAILED; } return returnValue; } @@ -128,7 +128,7 @@ uint32_t CcsdsDistributor::getIdentifier() const { return 0; } ReturnValue_t CcsdsDistributor::initialize() { ReturnValue_t result = TcDistributorBase::initialize(); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } if (packetChecker == nullptr) { @@ -156,10 +156,10 @@ ReturnValue_t CcsdsDistributor::initialize() { } ReturnValue_t CcsdsDistributor::callbackAfterSending(ReturnValue_t queueStatus) { - if (queueStatus != RETURN_OK) { + if (queueStatus != returnvalue::OK) { tcStore->deleteData(currentMessage.getStorageId()); } - return RETURN_OK; + return returnvalue::OK; } void CcsdsDistributor::print() { @@ -180,7 +180,7 @@ ReturnValue_t CcsdsDistributor::handleCcsdsHeaderRemoval(ConstStorageAccessor& a store_address_t newStoreId; ReturnValue_t result = tcStore->addData(&newStoreId, accessor.data() + ccsds::HEADER_LEN, accessor.size() - ccsds::HEADER_LEN); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << __func__ << ": TC store full" << std::endl; #else @@ -190,5 +190,5 @@ ReturnValue_t CcsdsDistributor::handleCcsdsHeaderRemoval(ConstStorageAccessor& a } currentMessage.setStorageId(newStoreId); // The const accessor will delete the old data automatically - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 352e32ff..7599114b 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -27,8 +27,8 @@ ReturnValue_t PusDistributor::selectDestination(MessageQueueId_t& destId) { // TODO: Need to set the data const uint8_t* packetPtr = nullptr; size_t packetLen = 0; - ReturnValue_t result = store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != - returnvalue::OK; + ReturnValue_t result = + store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != returnvalue::OK; if (result != returnvalue::OK) { tcStatus = PACKET_LOST; return result; diff --git a/src/fsfw/tcdistribution/TcDistributorBase.cpp b/src/fsfw/tcdistribution/TcDistributorBase.cpp index 230c97fb..f87993f8 100644 --- a/src/fsfw/tcdistribution/TcDistributorBase.cpp +++ b/src/fsfw/tcdistribution/TcDistributorBase.cpp @@ -20,11 +20,11 @@ TcDistributorBase::~TcDistributorBase() { ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) { ReturnValue_t status; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - for (status = tcQueue->receiveMessage(¤tMessage); status == RETURN_OK; + ReturnValue_t result = returnvalue::OK; + for (status = tcQueue->receiveMessage(¤tMessage); status == returnvalue::OK; status = tcQueue->receiveMessage(¤tMessage)) { ReturnValue_t packetResult = handlePacket(); - if (packetResult != HasReturnvaluesIF::RETURN_OK) { + if (packetResult != returnvalue::OK) { result = packetResult; triggerEvent(tmtcdistrib::HANDLE_PACKET_FAILED, packetResult, 1); } @@ -38,12 +38,12 @@ ReturnValue_t TcDistributorBase::performOperation(uint8_t opCode) { ReturnValue_t TcDistributorBase::handlePacket() { MessageQueueId_t destId; ReturnValue_t result = selectDestination(destId); - if (result != HasReturnvaluesIF::RETURN_OK) { + if (result != returnvalue::OK) { return result; } return callbackAfterSending(tcQueue->sendMessage(destId, ¤tMessage)); } ReturnValue_t TcDistributorBase::callbackAfterSending(ReturnValue_t queueStatus) { - return RETURN_OK; + return returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/definitions.h b/src/fsfw/tcdistribution/definitions.h index d28f9d40..01fc3085 100644 --- a/src/fsfw/tcdistribution/definitions.h +++ b/src/fsfw/tcdistribution/definitions.h @@ -10,7 +10,7 @@ namespace tmtcdistrib { static const uint8_t INTERFACE_ID = CLASS_ID::TMTC_DISTRIBUTION; -static constexpr ReturnValue_t NO_DESTINATION_FOUND = result::makeCode(INTERFACE_ID, 0); +static constexpr ReturnValue_t NO_DESTINATION_FOUND = returnvalue::makeCode(INTERFACE_ID, 0); static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(1); static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(2); static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(3); diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp index 7ebe5df8..20678a8c 100644 --- a/src/fsfw_hal/host/HostFilesystem.cpp +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -12,7 +12,7 @@ HostFilesystem::HostFilesystem() = default; ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *data) { if (params.path() == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path path(params.path()); if (not exists(path)) { @@ -24,13 +24,13 @@ ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *da } file.seekp(static_cast(params.offset)); file.write(reinterpret_cast(data), static_cast(params.size)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, size_t maxSize) { if (params.path() == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path path(params.path()); if (not exists(path)) { @@ -48,13 +48,13 @@ ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer file.read(reinterpret_cast(*buffer), sizeToRead); readSize += sizeToRead; *buffer += sizeToRead; - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t HostFilesystem::createFile(FilesystemParams params, const uint8_t *data, size_t size) { if (params.path == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path path(params.path); if (exists(path)) { @@ -64,26 +64,26 @@ ReturnValue_t HostFilesystem::createFile(FilesystemParams params, const uint8_t if (file.fail()) { return HasFileSystemIF::GENERIC_FILE_ERROR; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t HostFilesystem::removeFile(const char *path_, FileSystemArgsIF *args) { if (path_ == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path path(path_); if (not exists(path)) { return HasFileSystemIF::FILE_DOES_NOT_EXIST; } if (remove(path, errorCode)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return HasFileSystemIF::GENERIC_FILE_ERROR; } ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool createParentDirs) { if (params.path == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path dirPath(params.path); @@ -93,19 +93,19 @@ ReturnValue_t HostFilesystem::createDirectory(FilesystemParams params, bool crea if (createParentDirs) { if (create_directories(dirPath, errorCode)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return HasFileSystemIF::GENERIC_DIR_ERROR; } if (create_directory(dirPath, errorCode)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } return HasFileSystemIF::GENERIC_DIR_ERROR; } ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool deleteRecurively) { if (params.path == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path dirPath(params.path); if (not exists(dirPath)) { @@ -116,11 +116,11 @@ ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool dele } if (deleteRecurively) { if (remove_all(dirPath, errorCode)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } else { if (remove(dirPath, errorCode)) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } // Error handling @@ -133,7 +133,7 @@ ReturnValue_t HostFilesystem::removeDirectory(FilesystemParams params, bool dele ReturnValue_t HostFilesystem::rename(const char *oldPath_, const char *newPath_, FileSystemArgsIF *args) { if (oldPath_ == nullptr or newPath_ == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } path oldPath(oldPath_); path newPath(newPath_); @@ -142,5 +142,5 @@ ReturnValue_t HostFilesystem::rename(const char *oldPath_, const char *newPath_, if (errorCode) { return HasFileSystemIF::GENERIC_RENAME_ERROR; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } diff --git a/unittests/cfdp/handler/testDistributor.cpp b/unittests/cfdp/handler/testDistributor.cpp index 161e21cc..368ca9c0 100644 --- a/unittests/cfdp/handler/testDistributor.cpp +++ b/unittests/cfdp/handler/testDistributor.cpp @@ -36,41 +36,41 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { uint8_t* dataPtr = nullptr; SECTION("State") { - CHECK(distributor.initialize() == result::OK); + CHECK(distributor.initialize() == returnvalue::OK); CHECK(std::strcmp(distributor.getName(), "CFDP Distributor") == 0); CHECK(distributor.getIdentifier() == 0); CHECK(distributor.getRequestQueue() == queue.getId()); } SECTION("Packet Forwarding") { - CHECK(distributor.initialize() == result::OK); - CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); + CHECK(distributor.initialize() == returnvalue::OK); + CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::OK); size_t serLen = 0; store_address_t storeId; CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == - result::OK); + returnvalue::OK); REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == - result::OK); + returnvalue::OK); TmTcMessage msg(storeId); queue.addReceivedMessage(msg); - CHECK(distributor.performOperation(0) == result::OK); + CHECK(distributor.performOperation(0) == returnvalue::OK); CHECK(queue.wasMessageSent()); CHECK(queue.numberOfSentMessages() == 1); // The packet is forwarded, with no need to delete the data CHECK(pool.hasDataAtId(storeId)); TmTcMessage sentMsg; - CHECK(queue.getNextSentMessage(receiverQueueId, sentMsg) == result::OK); + CHECK(queue.getNextSentMessage(receiverQueueId, sentMsg) == returnvalue::OK); CHECK(sentMsg.getStorageId() == storeId); } SECTION("No Destination found") { - CHECK(distributor.initialize() == result::OK); + CHECK(distributor.initialize() == returnvalue::OK); size_t serLen = 0; store_address_t storeId; CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == - result::OK); + returnvalue::OK); REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == - result::OK); + returnvalue::OK); TmTcMessage msg(storeId); queue.addReceivedMessage(msg); CHECK(distributor.performOperation(0) == tmtcdistrib::NO_DESTINATION_FOUND); @@ -81,19 +81,19 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { pool.nextModifyDataCallFails.second = StorageManagerIF::DATA_DOES_NOT_EXIST; size_t serLen = 0; store_address_t storeId; - CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); + CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::OK); CHECK(pool.LocalPool::getFreeElement(&storeId, creator.getSerializedSize(), &dataPtr) == - result::OK); + returnvalue::OK); REQUIRE(creator.SerializeIF::serializeBe(dataPtr, serLen, creator.getSerializedSize()) == - result::OK); + returnvalue::OK); TmTcMessage msg(storeId); queue.addReceivedMessage(msg); CHECK(distributor.performOperation(0) == StorageManagerIF::DATA_DOES_NOT_EXIST); } SECTION("Duplicate registration") { - CHECK(distributor.initialize() == result::OK); - CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::OK); - CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == result::FAILED); + CHECK(distributor.initialize() == returnvalue::OK); + CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::OK); + CHECK(distributor.registerTcDestination(obswEntityId, tcAcceptor) == returnvalue::FAILED); } } \ No newline at end of file diff --git a/unittests/cfdp/pdu/testCfdpHeader.cpp b/unittests/cfdp/pdu/testCfdpHeader.cpp index a01325fa..99a0c470 100644 --- a/unittests/cfdp/pdu/testCfdpHeader.cpp +++ b/unittests/cfdp/pdu/testCfdpHeader.cpp @@ -3,7 +3,7 @@ #include "fsfw/cfdp/pdu/HeaderCreator.h" #include "fsfw/cfdp/pdu/HeaderReader.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/returnvalue.h" TEST_CASE("CFDP Header", "[cfdp]") { using namespace cfdp; @@ -49,12 +49,12 @@ TEST_CASE("CFDP Header", "[cfdp]") { SECTION("Deserialization fails") { const uint8_t** dummyPtr = nullptr; REQUIRE(headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK) == - result::FAILED); + returnvalue::FAILED); } SECTION("Serialization fails") { REQUIRE(headerSerializer.serialize(nullptr, &serSize, serBuf.size(), - SerializeIF::Endianness::NETWORK) == result::FAILED); + SerializeIF::Endianness::NETWORK) == returnvalue::FAILED); } SECTION("Buffer Too Short") { @@ -93,7 +93,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { SECTION("Regular") { // Everything except version bit flipped to one now REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG) == result::OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); CHECK(serBuf[0] == 0x3f); CHECK(serBuf[3] == 0x99); REQUIRE(headerSerializer.getCrcFlag() == true); @@ -114,7 +114,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(pduConf.sourceId.getSerializedSize() == 4); REQUIRE(headerSerializer.getSerializedSize() == 14); REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG) == result::OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); REQUIRE(headerSerializer.getCrcFlag() == true); REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER); REQUIRE(headerSerializer.getLargeFileFlag() == true); @@ -157,17 +157,17 @@ TEST_CASE("CFDP Header", "[cfdp]") { SECTION("Invalid Variable Sized Fields") { result = pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 0xfff); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::TWO_BYTES, 0xfffff); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xfffffffff); - REQUIRE(result == result::FAILED); + REQUIRE(result == returnvalue::FAILED); } SECTION("Header Serialization") { result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(serSize == 7); // Only version bits are set REQUIRE(serBuf[0] == 0b00100000); @@ -216,7 +216,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { SECTION("Header Deserialization") { REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG) == result::OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); REQUIRE(serBuf[1] == 0); REQUIRE(serBuf[2] == 0); // Entity and Transaction Sequence number are 1 byte large @@ -226,7 +226,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { auto headerDeser = HeaderReader(serBuf.data(), serBuf.size()); ReturnValue_t serResult = headerDeser.parseData(); - REQUIRE(serResult == result::OK); + REQUIRE(serResult == returnvalue::OK); REQUIRE(headerDeser.getPduDataFieldLen() == 0); REQUIRE(headerDeser.getHeaderSize() == 7); REQUIRE(headerDeser.getWholePduSize() == 7); @@ -249,11 +249,11 @@ TEST_CASE("CFDP Header", "[cfdp]") { headerSerializer.setPduType(cfdp::PduType::FILE_DATA); headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); result = pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); serTarget = serBuf.data(); serSize = 0; result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), @@ -261,7 +261,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { headerDeser = HeaderReader(serBuf.data(), serBuf.size()); result = headerDeser.parseData(); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); // Everything except version bit flipped to one now REQUIRE(serBuf[0] == 0x3f); REQUIRE(serBuf[3] == 0b11001010); @@ -293,9 +293,9 @@ TEST_CASE("CFDP Header", "[cfdp]") { serTarget = serBuf.data(); const auto** serTargetConst = const_cast(&serTarget); result = headerDeser.parseData(); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); - CHECK(headerDeser.setData(nullptr, -1) != result::OK); + CHECK(headerDeser.setData(nullptr, -1) != returnvalue::OK); REQUIRE(headerDeser.getHeaderSize() == 14); headerDeser.setData(serBuf.data(), serBuf.size()); @@ -305,7 +305,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48); result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); - REQUIRE(result == result::OK); + REQUIRE(result == returnvalue::OK); REQUIRE(headerDeser.getWholePduSize() == 8); headerDeser.setData(serBuf.data(), serBuf.size()); diff --git a/unittests/cfdp/pdu/testFileDirective.cpp b/unittests/cfdp/pdu/testFileDirective.cpp index 3dfaaa57..3af8b966 100644 --- a/unittests/cfdp/pdu/testFileDirective.cpp +++ b/unittests/cfdp/pdu/testFileDirective.cpp @@ -23,7 +23,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { serTarget = serBuf.data(); serSize = 0; result = fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); // Only version bits are set REQUIRE(serBuf[0] == 0b00100000); // PDU data field length is 5 (4 + Directive code octet) @@ -42,7 +42,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { SECTION("Serialization fails") { REQUIRE(fdSer.serialize(nullptr, nullptr, 85, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); } SECTION("Buffer Too Short") { @@ -56,11 +56,11 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { SECTION("Deserialize") { CHECK(fdSer.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK) == - result::OK); + returnvalue::OK); serTarget = serBuf.data(); REQUIRE(fdSer.deSerialize(&deserTarget, &serSize, SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); deserTarget = serBuf.data(); CHECK(serSize == 8); auto fdDeser = FileDirectiveReader(deserTarget, serBuf.size()); @@ -70,7 +70,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { fdDeser.setEndianness(SerializeIF::Endianness::MACHINE); REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); fdDeser.setEndianness(SerializeIF::Endianness::NETWORK); - REQUIRE(fdDeser.parseData() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(fdDeser.parseData() == returnvalue::OK); REQUIRE(not fdDeser.isNull()); REQUIRE(fdDeser); REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK); diff --git a/unittests/cfdp/testLvs.cpp b/unittests/cfdp/testLvs.cpp index 2adc84b8..062281e5 100644 --- a/unittests/cfdp/testLvs.cpp +++ b/unittests/cfdp/testLvs.cpp @@ -5,7 +5,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { using namespace cfdp; - ReturnValue_t result = result::OK; + ReturnValue_t result = returnvalue::OK; std::array rawBuf{}; uint8_t* serPtr = rawBuf.data(); const uint8_t* deserPtr = rawBuf.data(); @@ -16,7 +16,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { std::array lvRawBuf{}; serPtr = lvRawBuf.data(); REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), - SerializeIF::Endianness::NETWORK) == result::OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); REQUIRE(deserSize == 2); auto lv = cfdp::Lv(lvRawBuf.data(), 2); @@ -31,12 +31,12 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { serPtr = rawBuf.data(); deserSize = 0; REQUIRE(lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == - result::OK); + returnvalue::OK); REQUIRE(deserSize == 3); REQUIRE(rawBuf[0] == 2); uint16_t sourceIdRaw = 0; REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, rawBuf.data() + 1, &deserSize, - SerializeIF::Endianness::BIG) == result::OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); REQUIRE(sourceIdRaw == 0x0ff0); } @@ -47,11 +47,11 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { deserSize = 0; result = lvEmpty.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(deserSize == 1); deserPtr = rawBuf.data(); result = lvEmpty.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(lvEmpty.getSerializedSize() == 1); } @@ -59,29 +59,29 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { std::array lvRawBuf{}; serPtr = lvRawBuf.data(); REQUIRE(sourceId.serialize(&serPtr, &deserSize, lvRawBuf.size(), - SerializeIF::Endianness::NETWORK) == result::OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); auto lv = cfdp::Lv(lvRawBuf.data(), 2); serPtr = rawBuf.data(); deserSize = 0; result = lv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); Lv uninitLv; deserPtr = rawBuf.data(); deserSize = 3; result = uninitLv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::BIG); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(uninitLv.getSerializedSize() == 3); const uint8_t* storedValue = uninitLv.getValue(nullptr); uint16_t sourceIdRaw = 0; REQUIRE(SerializeAdapter::deSerialize(&sourceIdRaw, storedValue, &deserSize, - SerializeIF::Endianness::BIG) == result::OK); + SerializeIF::Endianness::BIG) == returnvalue::OK); REQUIRE(sourceIdRaw == 0x0ff0); } SECTION("Invalid Input") { Lv uninitLv; REQUIRE(uninitLv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::BIG) == - HasReturnvaluesIF::RETURN_FAILED); + returnvalue::FAILED); serPtr = rawBuf.data(); deserSize = 0; REQUIRE(uninitLv.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::BIG) == @@ -96,7 +96,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { std::string filename = "hello.txt"; StringLv sourceFileName(filename); REQUIRE(sourceFileName.getSerializedSize() == 1 + filename.size()); - REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == result::OK); + REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == returnvalue::OK); REQUIRE(rawBuf[0] == filename.size()); std::string filenameFromRaw(reinterpret_cast(rawBuf.data() + 1), filename.size()); REQUIRE(filenameFromRaw == filename); @@ -106,7 +106,7 @@ TEST_CASE("CFDP LV", "[cfdp][lv]") { const char filename[] = "hello.txt"; StringLv sourceFileName(filename, sizeof(filename) - 1); REQUIRE(sourceFileName.getSerializedSize() == 1 + sizeof(filename) - 1); - REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == result::OK); + REQUIRE(sourceFileName.serializeBe(rawBuf.data(), deserSize, rawBuf.size()) == returnvalue::OK); REQUIRE(rawBuf[0] == sizeof(filename) - 1); rawBuf[deserSize] = '\0'; const char* filenameFromRaw = reinterpret_cast(rawBuf.data() + 1); diff --git a/unittests/cfdp/testOtherTlvs.cpp b/unittests/cfdp/testOtherTlvs.cpp index 6393c230..4eb51a7c 100644 --- a/unittests/cfdp/testOtherTlvs.cpp +++ b/unittests/cfdp/testOtherTlvs.cpp @@ -40,14 +40,14 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { std::array serBuf = {}; result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); cfdp::StringLv emptyMsg; cfdp::StringLv emptySecondName; FilestoreResponseTlv emptyTlv(firstName, &emptyMsg); emptyTlv.setSecondFileName(&emptySecondName); result = emptyTlv.deSerialize(rawResponse, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyTlv.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); REQUIRE(emptyTlv.getStatusCode() == cfdp::FSR_SUCCESS); size_t firstNameLen = 0; @@ -81,26 +81,26 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { REQUIRE(expectedSz == 10 + 11 + 1); REQUIRE(request.getSerializedSize() == expectedSz + 2); result = request.serialize(&ptr, &sz, serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(sz == expectedSz + 2); FilestoreRequestTlv emptyRequest(firstName); emptyRequest.setSecondFileName(&secondName); const uint8_t* constptr = serBuf.data(); result = emptyRequest.deSerialize(&constptr, &sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); cfdp::Tlv rawRequest; ptr = serBuf.data(); sz = 0; result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE); result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); } @@ -117,11 +117,11 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); REQUIRE(faultOverrideTlv.getSerializedSize() == 3); REQUIRE(sz == 3); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); FaultHandlerOverrideTlv emptyOverrideTlv; result = emptyOverrideTlv.deSerialize(&deserPtr, &sz, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); EntityId entId(cfdp::WidthInBytes::TWO_BYTES, 0x42); EntityId emptyId; @@ -129,9 +129,9 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { serPtr = rawBuf.data(); result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); deserPtr = rawBuf.data(); result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); } } diff --git a/unittests/cfdp/testTlv.cpp b/unittests/cfdp/testTlv.cpp index 5b6e0a63..3e7435cd 100644 --- a/unittests/cfdp/testTlv.cpp +++ b/unittests/cfdp/testTlv.cpp @@ -14,25 +14,25 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { SECTION("Entity ID Serialization") { REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == result::OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); REQUIRE(deserSize == 2); } SECTION("TLV Serialization") { std::array tlvBuf{}; - REQUIRE(sourceId.serializeBe(tlvBuf.data(), deserSize, tlvBuf.size()) == result::OK); + REQUIRE(sourceId.serializeBe(tlvBuf.data(), deserSize, tlvBuf.size()) == returnvalue::OK); auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvBuf.data(), deserSize); REQUIRE(tlv.getSerializedSize() == 4); REQUIRE(tlv.getLengthField() == 2); deserSize = 0; REQUIRE(tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == - result::OK); + returnvalue::OK); REQUIRE(deserSize == 4); REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); REQUIRE(rawBuf[1] == 2); uint16_t entityId = 0; REQUIRE(SerializeAdapter::deSerialize(&entityId, rawBuf.data() + 2, &deserSize, - SerializeIF::Endianness::NETWORK) == result::OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); REQUIRE(entityId == 0x0ff0); } @@ -41,30 +41,30 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { // Set new value sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 12); REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == result::OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); tlv.setValue(rawBuf.data(), cfdp::WidthInBytes::FOUR_BYTES); serPtr = rawBuf.data(); deserSize = 0; result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); REQUIRE(rawBuf[1] == 4); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); } SECTION("TLV Invalid") { auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, rawBuf.data(), 0); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) != returnvalue::OK); tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) != HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) != returnvalue::OK); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); REQUIRE(tlvInvalid.getSerializedSize() == 0); REQUIRE(tlvInvalid.serialize(nullptr, nullptr, 0, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); } SECTION("TLV Zero Length Field") { @@ -73,8 +73,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { serPtr = rawBuf.data(); deserSize = 0; REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER); REQUIRE(rawBuf[1] == 0); } @@ -93,7 +92,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { Tlv tlv; deserPtr = rawBuf.data(); result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(tlv.getSerializedSize() == 4); REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID); deserPtr = tlv.getValue(); @@ -103,8 +102,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { SerializeIF::Endianness::NETWORK); REQUIRE(entityId == 0x0ff0); - REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + REQUIRE(tlv.deSerialize(nullptr, nullptr, SerializeIF::Endianness::NETWORK) != returnvalue::OK); deserPtr = rawBuf.data(); deserSize = 0; REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) == @@ -113,17 +111,16 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { rawBuf[0] = TlvTypes::INVALID_TLV; deserSize = 4; REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) != - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); serPtr = rawBuf.data(); deserSize = 0; REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), - SerializeIF::Endianness::NETWORK) == - HasReturnvaluesIF::RETURN_OK); + SerializeIF::Endianness::NETWORK) == returnvalue::OK); deserPtr = rawBuf.data(); result = zeroLenField.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); - REQUIRE(result == HasReturnvaluesIF::RETURN_OK); + REQUIRE(result == returnvalue::OK); REQUIRE(zeroLenField.getSerializedSize() == 2); REQUIRE(deserSize == 0); } diff --git a/unittests/hal/testFsMock.cpp b/unittests/hal/testFsMock.cpp index 7040e734..2ebcd231 100644 --- a/unittests/hal/testFsMock.cpp +++ b/unittests/hal/testFsMock.cpp @@ -10,7 +10,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") { SECTION("Create File") { FilesystemParams params("hello.txt"); - CHECK(fsMock.createFile(params) == result::OK); + CHECK(fsMock.createFile(params) == returnvalue::OK); auto iter = fsMock.fileMap.find("hello.txt"); REQUIRE(iter != fsMock.fileMap.end()); FilesystemMock::FileInfo &stats = iter->second; @@ -22,7 +22,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") { std::string testData = "test data"; FileOpParams params("hello.txt", testData.size()); CHECK(fsMock.writeToFile(params, reinterpret_cast(testData.data())) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); auto iter = fsMock.fileMap.find("hello.txt"); REQUIRE(iter != fsMock.fileMap.end()); FilesystemMock::FileInfo &stats = iter->second; @@ -38,7 +38,7 @@ TEST_CASE("Filesystem Mock", "[mocks]") { SECTION("Create Directory") { FilesystemParams params("hello"); - CHECK(fsMock.createDirectory(params) == result::OK); + CHECK(fsMock.createDirectory(params) == returnvalue::OK); REQUIRE(not fsMock.dirMap.empty()); auto iter = fsMock.dirMap.find("hello"); REQUIRE(iter != fsMock.dirMap.end()); diff --git a/unittests/hal/testHostFilesystem.cpp b/unittests/hal/testHostFilesystem.cpp index 2da185da..3873d5e9 100644 --- a/unittests/hal/testHostFilesystem.cpp +++ b/unittests/hal/testHostFilesystem.cpp @@ -23,51 +23,51 @@ TEST_CASE("Host Filesystem", "[hal][host]") { SECTION("Create file") { FilesystemParams params(file0.c_str()); - REQUIRE(hostFs.createFile(params) == result::OK); + REQUIRE(hostFs.createFile(params) == returnvalue::OK); CHECK(fs::is_regular_file(file0)); REQUIRE(fs::exists(file0)); } SECTION("Remove File") { FilesystemParams params(file0.c_str()); - REQUIRE(hostFs.createFile(params) == result::OK); + REQUIRE(hostFs.createFile(params) == returnvalue::OK); CHECK(fs::is_regular_file(file0)); REQUIRE(fs::exists(file0)); - REQUIRE(hostFs.removeFile(file0.c_str()) == result::OK); + REQUIRE(hostFs.removeFile(file0.c_str()) == returnvalue::OK); REQUIRE(not fs::exists(file0)); } SECTION("Create Directory") { FilesystemParams params(dir0.c_str()); - REQUIRE(hostFs.createDirectory(params) == result::OK); + REQUIRE(hostFs.createDirectory(params) == returnvalue::OK); CHECK(fs::is_directory(dir0)); REQUIRE(fs::exists(dir0)); } SECTION("Remove Directory") { FilesystemParams params(dir0.c_str()); - REQUIRE(hostFs.createDirectory(params) == result::OK); + REQUIRE(hostFs.createDirectory(params) == returnvalue::OK); REQUIRE(fs::exists(dir0)); - REQUIRE(hostFs.removeDirectory(params) == result::OK); + REQUIRE(hostFs.removeDirectory(params) == returnvalue::OK); REQUIRE(not fs::exists(dir0)); } SECTION("Rename File") { FilesystemParams params(file0.c_str()); - REQUIRE(hostFs.createFile(params) == result::OK); + REQUIRE(hostFs.createFile(params) == returnvalue::OK); CHECK(fs::is_regular_file(file0)); REQUIRE(fs::exists(file0)); - REQUIRE(hostFs.rename(file0.c_str(), file1.c_str()) == result::OK); + REQUIRE(hostFs.rename(file0.c_str(), file1.c_str()) == returnvalue::OK); } SECTION("Write To File") { std::string data = "hello world!"; FileOpParams params(file0.c_str(), data.size()); - REQUIRE(hostFs.createFile(params.fsParams) == result::OK); + REQUIRE(hostFs.createFile(params.fsParams) == returnvalue::OK); CHECK(fs::is_regular_file(file0)); REQUIRE(fs::exists(file0)); CHECK(hostFs.writeToFile(params, reinterpret_cast(data.c_str())) == - HasReturnvaluesIF::RETURN_OK); + returnvalue::OK); CHECK(fs::file_size(file0) == data.size()); ifstream ifile(file0); char readBuf[524]{}; @@ -79,7 +79,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") { SECTION("Read From File") { std::string data = "hello world!"; FileOpParams params(file0.c_str(), data.size()); - REQUIRE(hostFs.createFile(params.fsParams) == result::OK); + REQUIRE(hostFs.createFile(params.fsParams) == returnvalue::OK); CHECK(fs::is_regular_file(file0)); ofstream of(file0); of.write(data.c_str(), static_cast(data.size())); @@ -89,8 +89,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") { std::array readBuf{}; uint8_t* readPtr = readBuf.data(); size_t readSize = 0; - CHECK(hostFs.readFromFile(params, &readPtr, readSize, readBuf.size()) == - HasReturnvaluesIF::RETURN_OK); + CHECK(hostFs.readFromFile(params, &readPtr, readSize, readBuf.size()) == returnvalue::OK); std::string readBackString(reinterpret_cast(readBuf.data())); CHECK(readSize == data.size()); CHECK(data == readBackString); @@ -98,20 +97,20 @@ TEST_CASE("Host Filesystem", "[hal][host]") { SECTION("Invalid Input does not crash") { FileOpParams params(nullptr, 10); - REQUIRE(hostFs.createFile(params.fsParams) != result::OK); - REQUIRE(hostFs.createDirectory(params.fsParams) != result::OK); - REQUIRE(hostFs.createFile(params.fsParams) != result::OK); - REQUIRE(hostFs.removeDirectory(params.fsParams) != result::OK); - REQUIRE(hostFs.removeFile(nullptr) != result::OK); - REQUIRE(hostFs.rename(nullptr, nullptr) != result::OK); - REQUIRE(hostFs.writeToFile(params, nullptr) != result::OK); + REQUIRE(hostFs.createFile(params.fsParams) != returnvalue::OK); + REQUIRE(hostFs.createDirectory(params.fsParams) != returnvalue::OK); + REQUIRE(hostFs.createFile(params.fsParams) != returnvalue::OK); + REQUIRE(hostFs.removeDirectory(params.fsParams) != returnvalue::OK); + REQUIRE(hostFs.removeFile(nullptr) != returnvalue::OK); + REQUIRE(hostFs.rename(nullptr, nullptr) != returnvalue::OK); + REQUIRE(hostFs.writeToFile(params, nullptr) != returnvalue::OK); size_t readLen = 0; - REQUIRE(hostFs.readFromFile(params, nullptr, readLen, 20) != result::OK); + REQUIRE(hostFs.readFromFile(params, nullptr, readLen, 20) != returnvalue::OK); } SECTION("Create File but already exists") { FilesystemParams params(file0.c_str()); - REQUIRE(hostFs.createFile(params) == result::OK); + REQUIRE(hostFs.createFile(params) == returnvalue::OK); REQUIRE(hostFs.createFile(params) == HasFileSystemIF::FILE_ALREADY_EXISTS); } @@ -121,7 +120,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") { SECTION("Create Directory but already exists") { FileOpParams params(file0.c_str(), 12); - REQUIRE(hostFs.createDirectory(params.fsParams) == HasReturnvaluesIF::RETURN_OK); + REQUIRE(hostFs.createDirectory(params.fsParams) == returnvalue::OK); REQUIRE(hostFs.createDirectory(params.fsParams) == HasFileSystemIF::DIRECTORY_ALREADY_EXISTS); } @@ -158,7 +157,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") { ofstream of(fileInDir0); CHECK(fs::is_directory(dir0)); CHECK(fs::is_regular_file(fileInDir0)); - REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0.c_str()), true) == result::OK); + REQUIRE(hostFs.removeDirectory(FilesystemParams(dir0.c_str()), true) == returnvalue::OK); CHECK(not fs::is_directory(dir0)); CHECK(not fs::is_regular_file(fileInDir0)); } @@ -173,7 +172,7 @@ TEST_CASE("Host Filesystem", "[hal][host]") { } SECTION("Create directory with parent directory") { - CHECK(hostFs.createDirectory(FilesystemParams(dirWithParent.c_str()), true) == result::OK); + CHECK(hostFs.createDirectory(FilesystemParams(dirWithParent.c_str()), true) == returnvalue::OK); CHECK(fs::is_directory(dir0)); CHECK(fs::is_directory(dirWithParent)); } diff --git a/unittests/mocks/CcsdsCheckerMock.h b/unittests/mocks/CcsdsCheckerMock.h index a9388ae5..bdcd491a 100644 --- a/unittests/mocks/CcsdsCheckerMock.h +++ b/unittests/mocks/CcsdsCheckerMock.h @@ -7,7 +7,7 @@ class CcsdsCheckerMock : public CcsdsPacketCheckIF { CcsdsCheckerMock(); unsigned int checkCallCount = 0; size_t checkedPacketLen = 0; - ReturnValue_t nextResult = HasReturnvaluesIF::RETURN_OK; + ReturnValue_t nextResult = returnvalue::OK; ReturnValue_t checkPacket(const SpacePacketReader& currentPacket, size_t packetLen) override; private: diff --git a/unittests/mocks/FilesystemMock.cpp b/unittests/mocks/FilesystemMock.cpp index 8f9e3f8f..3d18e3cb 100644 --- a/unittests/mocks/FilesystemMock.cpp +++ b/unittests/mocks/FilesystemMock.cpp @@ -6,19 +6,19 @@ ReturnValue_t FilesystemMock::feedFile(const std::string &filename, std::ifstream &file) { if (not std::filesystem::exists(filename)) { - return HasReturnvaluesIF::RETURN_FAILED; + return returnvalue::FAILED; } size_t fileSize = std::filesystem::file_size(filename); FileOpParams params(filename.c_str(), fileSize); std::vector rawData(fileSize); file.read(reinterpret_cast(rawData.data()), static_cast(rawData.size())); createOrAddToFile(params, rawData.data()); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *data) { createOrAddToFile(params, data); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, @@ -32,7 +32,7 @@ ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer size_t readLen = params.size; if (params.offset + params.size > info.fileRaw.size()) { if (params.offset > info.fileRaw.size()) { - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } readLen = info.fileRaw.size() - params.offset; } @@ -43,14 +43,14 @@ ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer *buffer += readLen; readSize += readLen; } - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilesystemMock::createFile(FilesystemParams params, const uint8_t *data, size_t size) { FileOpParams params2(params.path, size); createOrAddToFile(params2, data); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilesystemMock::removeFile(const char *path, FileSystemArgsIF *args) { @@ -60,7 +60,7 @@ ReturnValue_t FilesystemMock::removeFile(const char *path, FileSystemArgsIF *arg return HasFileSystemIF::FILE_DOES_NOT_EXIST; } else { fileMap.erase(iter); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } } @@ -68,20 +68,20 @@ ReturnValue_t FilesystemMock::createDirectory(FilesystemParams params, bool crea std::string dirPath = params.path; dirMap[dirPath].createCallCount++; dirMap[dirPath].wihParentDir.push(createParentDirs); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilesystemMock::removeDirectory(FilesystemParams params, bool deleteRecurively) { std::string dirPath = params.path; dirMap[dirPath].delCallCount++; dirMap[dirPath].recursiveDeletion.push(deleteRecurively); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t FilesystemMock::rename(const char *oldPath, const char *newPath, FileSystemArgsIF *args) { renameQueue.push(RenameInfo(oldPath, newPath)); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } void FilesystemMock::createOrAddToFile(FileOpParams params, const uint8_t *data) { diff --git a/unittests/mocks/StorageManagerMock.cpp b/unittests/mocks/StorageManagerMock.cpp index 387b5b17..5cd3a575 100644 --- a/unittests/mocks/StorageManagerMock.cpp +++ b/unittests/mocks/StorageManagerMock.cpp @@ -67,13 +67,13 @@ StorageManagerIF::max_subpools_t StorageManagerMock::getNumberOfSubPools() const void StorageManagerMock::reset() { clearStore(); nextAddDataCallFails.first = false; - nextAddDataCallFails.second = result::OK; + nextAddDataCallFails.second = returnvalue::OK; nextModifyDataCallFails.first = false; - nextModifyDataCallFails.second = result::OK; + nextModifyDataCallFails.second = returnvalue::OK; nextDeleteDataCallFails.first = false; - nextDeleteDataCallFails.second = result::OK; + nextDeleteDataCallFails.second = returnvalue::OK; nextFreeElementCallFails.first = false; - nextFreeElementCallFails.second = result::OK; + nextFreeElementCallFails.second = returnvalue::OK; } StorageManagerMock::StorageManagerMock(object_id_t setObjectId, diff --git a/unittests/tcdistributor/testCcsdsDistributor.cpp b/unittests/tcdistributor/testCcsdsDistributor.cpp index ce96a425..c8aa81f7 100644 --- a/unittests/tcdistributor/testCcsdsDistributor.cpp +++ b/unittests/tcdistributor/testCcsdsDistributor.cpp @@ -35,11 +35,12 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { spCreator.setCcsdsLenFromTotalDataFieldLen(dataFieldLen); uint8_t* dataPtr; REQUIRE(pool.getFreeElement(&storeId, spCreator.getSerializedSize() + dataFieldLen, &dataPtr) == - result::OK); + returnvalue::OK); size_t serLen = 0; - REQUIRE(spCreator.SerializeIF::serializeBe(dataPtr, serLen, ccsds::HEADER_LEN) == result::OK); + REQUIRE(spCreator.SerializeIF::serializeBe(dataPtr, serLen, ccsds::HEADER_LEN) == + returnvalue::OK); REQUIRE(spCreator.SerializeIF::serializeBe(buf.data(), serLen, ccsds::HEADER_LEN) == - result::OK); + returnvalue::OK); if (dataField == nullptr) { dataPtr[ccsds::HEADER_LEN] = 0; buf[ccsds::HEADER_LEN] = 0; @@ -51,7 +52,7 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { }; SECTION("State") { - CHECK(ccsdsDistrib.initialize() == result::OK); + CHECK(ccsdsDistrib.initialize() == returnvalue::OK); CHECK(ccsdsDistrib.getRequestQueue() == 1); CHECK(ccsdsDistrib.getIdentifier() == 0); CHECK(ccsdsDistrib.getObjectId() == 1); @@ -61,12 +62,12 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { SECTION("Basic Forwarding") { CcsdsDistributor::DestInfo info(tcAcceptorMock, false); - REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); + REQUIRE(ccsdsDistrib.registerApplication(info) == returnvalue::OK); TmTcMessage message; createSpacePacket(tcAcceptorApid, message); store_address_t storeId = message.getStorageId(); queue.addReceivedMessage(message); - REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); + REQUIRE(ccsdsDistrib.performOperation(0) == returnvalue::OK); CHECK(checkerMock.checkedPacketLen == 7); CHECK(checkerMock.checkCallCount == 1); CHECK(queue.wasMessageSent()); @@ -74,10 +75,10 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { // The packet is forwarded, with no need to delete the data CHECK(pool.hasDataAtId(storeId)); TmTcMessage sentMsg; - CHECK(queue.getNextSentMessage(tcAcceptorQueueId, sentMsg) == result::OK); + CHECK(queue.getNextSentMessage(tcAcceptorQueueId, sentMsg) == returnvalue::OK); CHECK(sentMsg.getStorageId() == storeId); auto accessor = pool.getData(storeId); - CHECK(accessor.first == result::OK); + CHECK(accessor.first == returnvalue::OK); CHECK(accessor.second.size() == ccsds::HEADER_LEN + 1); for (size_t i = 0; i < ccsds::HEADER_LEN; i++) { CHECK(accessor.second.data()[i] == buf[i]); @@ -101,7 +102,7 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { store_address_t storeId = message.getStorageId(); message.setStorageId(storeId); queue.addReceivedMessage(message); - REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); + REQUIRE(ccsdsDistrib.performOperation(0) == returnvalue::OK); CHECK(checkerMock.checkedPacketLen == 7); CHECK(checkerMock.checkCallCount == 1); CHECK(queue.wasMessageSent()); @@ -109,10 +110,10 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { // The packet is forwarded, with no need to delete the data CHECK(pool.hasDataAtId(storeId)); TmTcMessage sentMsg; - CHECK(queue.getNextSentMessage(defaultQueueId, sentMsg) == result::OK); + CHECK(queue.getNextSentMessage(defaultQueueId, sentMsg) == returnvalue::OK); CHECK(sentMsg.getStorageId() == storeId); auto accessor = pool.getData(storeId); - CHECK(accessor.first == result::OK); + CHECK(accessor.first == returnvalue::OK); CHECK(accessor.second.size() == ccsds::HEADER_LEN + 1); for (size_t i = 0; i < ccsds::HEADER_LEN; i++) { CHECK(accessor.second.data()[i] == buf[i]); @@ -126,13 +127,13 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { CcsdsDistributor::DestInfo info(defReceiverMock, true); tgtApid = defaultApid; tgtQueueId = defaultQueueId; - REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); + REQUIRE(ccsdsDistrib.registerApplication(info) == returnvalue::OK); } SECTION("Specific destination") { CcsdsDistributor::DestInfo info(tcAcceptorMock, true); tgtApid = tcAcceptorApid; tgtQueueId = tcAcceptorQueueId; - REQUIRE(ccsdsDistrib.registerApplication(info) == result::OK); + REQUIRE(ccsdsDistrib.registerApplication(info) == returnvalue::OK); } TmTcMessage message; std::array dataField = {0, 1, 2, 3, 4}; @@ -140,16 +141,16 @@ TEST_CASE("CCSDS Distributor", "[ccsds][tmtcdistrib]") { store_address_t storeId = message.getStorageId(); message.setStorageId(storeId); queue.addReceivedMessage(message); - REQUIRE(ccsdsDistrib.performOperation(0) == result::OK); + REQUIRE(ccsdsDistrib.performOperation(0) == returnvalue::OK); CHECK(checkerMock.checkedPacketLen == 11); CHECK(checkerMock.checkCallCount == 1); // Data was deleted from old slot to re-store without the header CHECK(not pool.hasDataAtId(storeId)); TmTcMessage sentMsg; - CHECK(queue.getNextSentMessage(tgtQueueId, sentMsg) == result::OK); + CHECK(queue.getNextSentMessage(tgtQueueId, sentMsg) == returnvalue::OK); CHECK(sentMsg.getStorageId() != storeId); auto accessor = pool.getData(sentMsg.getStorageId()); - CHECK(accessor.first == result::OK); + CHECK(accessor.first == returnvalue::OK); CHECK(accessor.second.size() == 5); // Verify correctness of data field for (size_t i = 0; i < 5; i++) { From a46d8c34d9205988e2d6e320c948bfc5e1a2ae30 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 Aug 2022 16:37:53 +0200 Subject: [PATCH 254/532] small changelog update --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 515580b4..3fe567de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [v6.0.0] -## Changes - ## Added - Add new `UnsignedByteField` class From 9441b4a70e4cc1aaef9cd5e680b3cd6388b99eaf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 Aug 2022 19:37:30 +0200 Subject: [PATCH 255/532] continue dest handler --- src/fsfw/cfdp/handler/DestHandler.cpp | 96 ++++++++++++++++++++++--- src/fsfw/cfdp/handler/DestHandler.h | 25 +++++-- src/fsfw/cfdp/pdu/MetadataInfo.cpp | 39 +++++----- src/fsfw/cfdp/pdu/MetadataInfo.h | 25 ++++--- src/fsfw/events/EventReportingProxyIF.h | 2 +- unittests/cfdp/pdu/testMetadataPdu.cpp | 13 ++-- 6 files changed, 148 insertions(+), 52 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 85ef03f4..2d5c6aa0 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -2,15 +2,31 @@ #include +#include "fsfw/cfdp/pdu/HeaderReader.h" +#include "fsfw/cfdp/pdu/MetadataPduReader.h" #include "fsfw/objectmanager.h" +#include "fsfw/serviceinterface.h" -cfdp::DestHandler::DestHandler(DestHandlerParams params) : p(std::move(params)) {} +using namespace returnvalue; + +cfdp::DestHandler::DestHandler(DestHandlerParams params, FsfwParams fsfwParams) + : dp(std::move(params)), fp(fsfwParams), tlvVec(params.maxTlvsInOnePdu) {} ReturnValue_t cfdp::DestHandler::performStateMachine() { switch (step) { case TransactionStep::IDLE: { - for (const auto& info : p.packetListRef) { + ReturnValue_t status = returnvalue::OK; + ReturnValue_t result; + for (const auto& info : dp.packetListRef) { + if (info.pduType == PduType::FILE_DIRECTIVE and + info.directiveType == FileDirectives::METADATA) { + result = handleMetadataPdu(info); + if (result != OK) { + status = result; + } + } } + return status; } case TransactionStep::TRANSACTION_START: break; @@ -27,26 +43,86 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { } ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) { - if (p.packetListRef.full()) { + if (dp.packetListRef.full()) { return returnvalue::FAILED; } - p.packetListRef.push_back(packet); + dp.packetListRef.push_back(packet); return returnvalue::OK; } ReturnValue_t cfdp::DestHandler::initialize() { - if (p.tmStore == nullptr) { - p.tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if (p.tmStore == nullptr) { + if (fp.tmStore == nullptr) { + fp.tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if (fp.tmStore == nullptr) { return returnvalue::FAILED; } } - if (p.tcStore == nullptr) { - p.tcStore = ObjectManager::instance()->get(objects::TC_STORE); - if (p.tcStore == nullptr) { + if (fp.tcStore == nullptr) { + fp.tcStore = ObjectManager::instance()->get(objects::TC_STORE); + if (fp.tcStore == nullptr) { return returnvalue::FAILED; } } return returnvalue::OK; } +ReturnValue_t cfdp::DestHandler::handleMetadataPdu(const PacketInfo& info) { + // Process metadata PDU + auto constAccessorPair = fp.tcStore->getData(info.storeId); + if (constAccessorPair.first != OK) { + // TODO: This is not a CFDP error. Event and/or warning? + return constAccessorPair.first; + } + cfdp::FileSize fileSize; + cfdp::StringLv sourceFileName; + cfdp::StringLv destFileName; + MetadataInfo metadataInfo(fileSize, sourceFileName, destFileName); + cfdp::Tlv* tlvArrayAsPtr = tlvVec.data(); + metadataInfo.setOptionsArray(&tlvArrayAsPtr, std::nullopt, tlvVec.size()); + MetadataPduReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), + metadataInfo); + ReturnValue_t result = reader.parseData(); + // TODO: The standard does not really specify what happens if this kind of error happens + // I think it might be a good idea to cache some sort of error code, which + // is translated into a warning and/or event by an upper layer + if (result != OK) { + return handleMetadataParseError(constAccessorPair.second.data(), + constAccessorPair.second.size()); + } + return result; +} + +ReturnValue_t cfdp::DestHandler::handleMetadataParseError(const uint8_t* rawData, size_t maxSize) { + // TODO: try to extract destination ID for error + // TODO: Invalid metadata PDU. +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "Parsing Metadata PDU failed with code " << result << std::endl; +#else +#endif + HeaderReader headerReader(rawData, maxSize); + ReturnValue_t result = headerReader.parseData(); + if (result != OK) { + // TODO: Now this really should not happen. Warning or error, + // yield or cache appropriate returnvalue +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "Parsing Header failed" << std::endl; +#else +#endif + // TODO: Trigger appropriate event + return result; + } + cfdp::EntityId destId; + headerReader.getDestId(destId); + RemoteEntityCfg* remoteCfg; + if (not dp.remoteCfgTable.getRemoteCfg(destId, &remoteCfg)) { +// TODO: No remote config for dest ID. I consider this a configuration error. +// Warning or error, yield or cache appropriate returnvalue +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "No remote config exists for destination ID" << std::endl; +#else +#endif + // TODO: Trigger appropriate event + } + // TODO: Appropriate returnvalue? + return returnvalue::FAILED; +} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index c3e30721..d979f09b 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -28,28 +28,34 @@ struct PacketInfo { struct DestHandlerParams { DestHandlerParams(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable, - AcceptsTelemetryIF& packetDest, MessageQueueIF& msgQueue, - etl::ilist& packetList) + etl::ilist& packetList, uint8_t maxTlvsInOnePdu) : cfg(std::move(cfg)), user(user), remoteCfgTable(remoteCfgTable), - packetDest(packetDest), - msgQueue(msgQueue), packetListRef(packetList) {} LocalEntityCfg cfg; UserBase& user; RemoteConfigTableIF& remoteCfgTable; + + etl::ilist& packetListRef; + uint8_t maxTlvsInOnePdu; +}; + +struct FsfwParams { + FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF& msgQueue, + EventReportingProxyIF& eventReporter) + : packetDest(packetDest), msgQueue(msgQueue), eventReporter(eventReporter) {} AcceptsTelemetryIF& packetDest; MessageQueueIF& msgQueue; + EventReportingProxyIF& eventReporter; StorageManagerIF* tcStore = nullptr; StorageManagerIF* tmStore = nullptr; - etl::ilist& packetListRef; }; class DestHandler { public: - explicit DestHandler(DestHandlerParams params); + explicit DestHandler(DestHandlerParams handlerParams, FsfwParams fsfwParams); ReturnValue_t performStateMachine(); @@ -57,8 +63,12 @@ class DestHandler { ReturnValue_t initialize(); + ReturnValue_t handleMetadataPdu(const PacketInfo& info); + ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize); + private: - DestHandlerParams p; + DestHandlerParams dp; + FsfwParams fp; enum class TransactionStep { IDLE = 0, TRANSACTION_START = 1, @@ -68,6 +78,7 @@ class DestHandler { SENDING_FINISHED_PDU = 5 }; TransactionStep step = TransactionStep::IDLE; + std::vector tlvVec; }; } // namespace cfdp diff --git a/src/fsfw/cfdp/pdu/MetadataInfo.cpp b/src/fsfw/cfdp/pdu/MetadataInfo.cpp index daa03473..d88bdd87 100644 --- a/src/fsfw/cfdp/pdu/MetadataInfo.cpp +++ b/src/fsfw/cfdp/pdu/MetadataInfo.cpp @@ -1,22 +1,25 @@ #include "MetadataInfo.h" MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumType, - cfdp::FileSize& fileSize, cfdp::Lv& sourceFileName, - cfdp::Lv& destFileName) - : closureRequested(closureRequested), - checksumType(checksumType), - fileSize(fileSize), - sourceFileName(sourceFileName), - destFileName(destFileName) {} + cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName, + cfdp::StringLv& destFileName) + : MetadataInfo(fileSize, sourceFileName, destFileName) { + this->closureRequested = closureRequested; + this->checksumType = checksumType; +} -void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray_, const size_t* optionsLen_, - const size_t* maxOptionsLen_) { +MetadataInfo::MetadataInfo(cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName, + cfdp::StringLv& destFileName) + : fileSize(fileSize), sourceFileName(sourceFileName), destFileName(destFileName) {} + +void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray_, std::optional optionsLen_, + std::optional maxOptionsLen_) { this->optionsArray = optionsArray_; - if (maxOptionsLen_ != nullptr) { - this->maxOptionsLen = *maxOptionsLen_; + if (maxOptionsLen_) { + this->maxOptionsLen = maxOptionsLen_.value(); } - if (optionsLen_ != nullptr) { - this->optionsLen = *optionsLen_; + if (optionsLen_) { + this->optionsLen = optionsLen_.value(); } } @@ -32,7 +35,7 @@ void MetadataInfo::setClosureRequested(bool closureRequested_) { closureRequested = closureRequested_; } -cfdp::Lv& MetadataInfo::getDestFileName() { return destFileName; } +cfdp::StringLv& MetadataInfo::getDestFileName() { return destFileName; } cfdp::FileSize& MetadataInfo::getFileSize() { return fileSize; } @@ -81,9 +84,11 @@ size_t MetadataInfo::getSerializedSize(bool fssLarge) { return size; } -void MetadataInfo::setDestFileName(cfdp::Lv& destFileName_) { this->destFileName = destFileName_; } +void MetadataInfo::setDestFileName(cfdp::StringLv& destFileName_) { + this->destFileName = destFileName_; +} -void MetadataInfo::setSourceFileName(cfdp::Lv& sourceFileName_) { +void MetadataInfo::setSourceFileName(cfdp::StringLv& sourceFileName_) { this->sourceFileName = sourceFileName_; } @@ -95,4 +100,4 @@ size_t MetadataInfo::getOptionsLen() const { return optionsLen; } void MetadataInfo::setOptionsLen(size_t optionsLen_) { this->optionsLen = optionsLen_; } -cfdp::Lv& MetadataInfo::getSourceFileName() { return sourceFileName; } +cfdp::StringLv& MetadataInfo::getSourceFileName() { return sourceFileName; } diff --git a/src/fsfw/cfdp/pdu/MetadataInfo.h b/src/fsfw/cfdp/pdu/MetadataInfo.h index f71eb2f4..95f4544a 100644 --- a/src/fsfw/cfdp/pdu/MetadataInfo.h +++ b/src/fsfw/cfdp/pdu/MetadataInfo.h @@ -1,30 +1,35 @@ #ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAINFO_H_ #define FSFW_SRC_FSFW_CFDP_PDU_METADATAINFO_H_ +#include + #include "fsfw/cfdp/FileSize.h" #include "fsfw/cfdp/definitions.h" #include "fsfw/cfdp/tlv/Lv.h" +#include "fsfw/cfdp/tlv/StringLv.h" #include "fsfw/cfdp/tlv/Tlv.h" class MetadataInfo { public: + MetadataInfo(cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName, + cfdp::StringLv& destFileName); MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumType, cfdp::FileSize& fileSize, - cfdp::Lv& sourceFileName, cfdp::Lv& destFileName); + cfdp::StringLv& sourceFileName, cfdp::StringLv& destFileName); size_t getSerializedSize(bool fssLarge = false); - void setOptionsArray(cfdp::Tlv** optionsArray, const size_t* optionsLen, - const size_t* maxOptionsLen); + void setOptionsArray(cfdp::Tlv** optionsArray, std::optional optionsLen, + std::optional maxOptionsLen); [[nodiscard]] cfdp::ChecksumType getChecksumType() const; void setChecksumType(cfdp::ChecksumType checksumType); [[nodiscard]] bool isClosureRequested() const; void setClosureRequested(bool closureRequested = false); - void setDestFileName(cfdp::Lv& destFileName); - void setSourceFileName(cfdp::Lv& sourceFileName); + void setDestFileName(cfdp::StringLv& destFileName); + void setSourceFileName(cfdp::StringLv& sourceFileName); - cfdp::Lv& getDestFileName(); - cfdp::Lv& getSourceFileName(); + cfdp::StringLv& getDestFileName(); + cfdp::StringLv& getSourceFileName(); cfdp::FileSize& getFileSize(); [[nodiscard]] bool hasOptions() const; @@ -37,10 +42,10 @@ class MetadataInfo { private: bool closureRequested = false; - cfdp::ChecksumType checksumType; + cfdp::ChecksumType checksumType = cfdp::ChecksumType::NULL_CHECKSUM; cfdp::FileSize& fileSize; - cfdp::Lv& sourceFileName; - cfdp::Lv& destFileName; + cfdp::StringLv& sourceFileName; + cfdp::StringLv& destFileName; cfdp::Tlv** optionsArray = nullptr; size_t optionsLen = 0; diff --git a/src/fsfw/events/EventReportingProxyIF.h b/src/fsfw/events/EventReportingProxyIF.h index c6034c9f..51f8ed1d 100644 --- a/src/fsfw/events/EventReportingProxyIF.h +++ b/src/fsfw/events/EventReportingProxyIF.h @@ -5,7 +5,7 @@ class EventReportingProxyIF { public: - virtual ~EventReportingProxyIF() {} + virtual ~EventReportingProxyIF() = default; virtual void forwardEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0) const = 0; diff --git a/unittests/cfdp/pdu/testMetadataPdu.cpp b/unittests/cfdp/pdu/testMetadataPdu.cpp index cfe24fc6..49f1deb4 100644 --- a/unittests/cfdp/pdu/testMetadataPdu.cpp +++ b/unittests/cfdp/pdu/testMetadataPdu.cpp @@ -21,7 +21,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { std::string firstFileName = "hello.txt"; cfdp::StringLv sourceFileName(firstFileName); - cfdp::Lv destFileName; + cfdp::StringLv destFileName; FileSize fileSize(35); MetadataInfo info(false, ChecksumType::MODULAR, fileSize, sourceFileName, destFileName); @@ -67,11 +67,10 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { REQUIRE(mdBuffer[26] == 0); std::string otherFileName = "hello2.txt"; - cfdp::Lv otherFileNameLv(reinterpret_cast(otherFileName.data()), - otherFileName.size()); + cfdp::StringLv otherFileNameLv(otherFileName.data(), otherFileName.size()); info.setSourceFileName(otherFileNameLv); size_t sizeOfOptions = options.size(); - info.setOptionsArray(options.data(), &sizeOfOptions, &sizeOfOptions); + info.setOptionsArray(options.data(), sizeOfOptions, sizeOfOptions); REQUIRE(info.getMaxOptionsLen() == 2); info.setMaxOptionsLen(3); REQUIRE(info.getMaxOptionsLen() == 3); @@ -129,7 +128,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { } size_t sizeOfOptions = options.size(); size_t maxSize = 4; - info.setOptionsArray(options.data(), &sizeOfOptions, &maxSize); + info.setOptionsArray(options.data(), sizeOfOptions, maxSize); REQUIRE(info.getOptionsLen() == 2); info.setChecksumType(cfdp::ChecksumType::CRC_32C); info.setClosureRequested(true); @@ -166,9 +165,9 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { } mdBuffer[1] = (36 >> 8) & 0xff; mdBuffer[2] = 36 & 0xff; - info.setOptionsArray(nullptr, nullptr, nullptr); + info.setOptionsArray(nullptr, std::nullopt, std::nullopt); REQUIRE(deserializer2.parseData() == cfdp::METADATA_CANT_PARSE_OPTIONS); - info.setOptionsArray(options.data(), &sizeOfOptions, nullptr); + info.setOptionsArray(options.data(), sizeOfOptions, std::nullopt); for (size_t maxSz = 0; maxSz < 46; maxSz++) { MetadataPduReader invalidSzDeser(mdBuffer.data(), maxSz, info); if (not invalidSzDeser.isNull()) { From b1bd63132236d35a92c605fa86d36067fd1fddf6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 Aug 2022 20:30:41 +0200 Subject: [PATCH 256/532] implemented metadata handler --- src/fsfw/cfdp/VarLenFields.h | 1 + src/fsfw/cfdp/handler/DestHandler.cpp | 55 ++++++++++++++++++++++++--- src/fsfw/cfdp/handler/DestHandler.h | 30 +++++++++++++-- src/fsfw/cfdp/handler/defs.h | 9 +++++ src/fsfw/cfdp/pdu/HeaderReader.cpp | 10 +++++ src/fsfw/cfdp/pdu/HeaderReader.h | 6 +++ src/fsfw/cfdp/pdu/PduConfig.h | 10 +++-- 7 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 src/fsfw/cfdp/handler/defs.h diff --git a/src/fsfw/cfdp/VarLenFields.h b/src/fsfw/cfdp/VarLenFields.h index 2b862d66..7f369e0c 100644 --- a/src/fsfw/cfdp/VarLenFields.h +++ b/src/fsfw/cfdp/VarLenFields.h @@ -74,6 +74,7 @@ struct TransactionSeqNum : public VarLenField { }; struct TransactionId { + TransactionId() = default; TransactionId(EntityId entityId, TransactionSeqNum seqNum) : entityId(std::move(entityId)), seqNum(std::move(seqNum)) {} diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 2d5c6aa0..aefa1aa3 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -3,14 +3,19 @@ #include #include "fsfw/cfdp/pdu/HeaderReader.h" -#include "fsfw/cfdp/pdu/MetadataPduReader.h" #include "fsfw/objectmanager.h" #include "fsfw/serviceinterface.h" using namespace returnvalue; cfdp::DestHandler::DestHandler(DestHandlerParams params, FsfwParams fsfwParams) - : dp(std::move(params)), fp(fsfwParams), tlvVec(params.maxTlvsInOnePdu) {} + : tlvVec(params.maxTlvsInOnePdu), + userTlvVec(params.maxTlvsInOnePdu), + dp(std::move(params)), + fp(fsfwParams), + tp(params.maxFilenameLen) { + tp.pduConf.direction = cfdp::Direction::TOWARDS_SENDER; +} ReturnValue_t cfdp::DestHandler::performStateMachine() { switch (step) { @@ -73,10 +78,9 @@ ReturnValue_t cfdp::DestHandler::handleMetadataPdu(const PacketInfo& info) { // TODO: This is not a CFDP error. Event and/or warning? return constAccessorPair.first; } - cfdp::FileSize fileSize; cfdp::StringLv sourceFileName; cfdp::StringLv destFileName; - MetadataInfo metadataInfo(fileSize, sourceFileName, destFileName); + MetadataInfo metadataInfo(tp.fileSize, sourceFileName, destFileName); cfdp::Tlv* tlvArrayAsPtr = tlvVec.data(); metadataInfo.setOptionsArray(&tlvArrayAsPtr, std::nullopt, tlvVec.size()); MetadataPduReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), @@ -89,7 +93,7 @@ ReturnValue_t cfdp::DestHandler::handleMetadataPdu(const PacketInfo& info) { return handleMetadataParseError(constAccessorPair.second.data(), constAccessorPair.second.size()); } - return result; + return startTransaction(reader, metadataInfo); } ReturnValue_t cfdp::DestHandler::handleMetadataParseError(const uint8_t* rawData, size_t maxSize) { @@ -126,3 +130,44 @@ ReturnValue_t cfdp::DestHandler::handleMetadataParseError(const uint8_t* rawData // TODO: Appropriate returnvalue? return returnvalue::FAILED; } + +ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, MetadataInfo& info) { + if (cfdpState != CfdpStates::IDLE) { + // According to standard, discard metadata PDU if we are busy + return returnvalue::OK; + } + step = TransactionStep::TRANSACTION_START; + if (reader.getTransmissionMode() == TransmissionModes::UNACKNOWLEDGED) { + cfdpState = CfdpStates::BUSY_CLASS_1_NACKED; + } else if (reader.getTransmissionMode() == TransmissionModes::ACKNOWLEDGED) { + cfdpState = CfdpStates::BUSY_CLASS_2_ACKED; + } + tp.checksumType = info.getChecksumType(); + tp.closureRequested = info.isClosureRequested(); + size_t sourceNameSize = 0; + const uint8_t* sourceNamePtr = info.getSourceFileName().getValue(&sourceNameSize); + if (sourceNameSize > tp.sourceName.size()) { + // TODO: Warning, event etc. + return FAILED; + } + std::memcpy(tp.sourceName.data(), sourceNamePtr, sourceNameSize); + tp.sourceName[sourceNameSize] = '\0'; + size_t destNameSize = 0; + const uint8_t* destNamePtr = info.getDestFileName().getValue(&destNameSize); + if (destNameSize > tp.destName.size()) { + // TODO: Warning, event etc. + return FAILED; + } + std::memcpy(tp.destName.data(), destNamePtr, destNameSize); + tp.destName[destNameSize] = '\0'; + reader.fillConfig(tp.pduConf); + tp.pduConf.direction = Direction::TOWARDS_SENDER; + tp.transactionId.entityId = tp.pduConf.sourceId; + tp.transactionId.seqNum = tp.pduConf.seqNum; + if (not dp.remoteCfgTable.getRemoteCfg(tp.pduConf.destId, &tp.remoteCfg)) { + // TODO: Warning, event etc. + return FAILED; + } + step = TransactionStep::RECEIVING_FILE_DATA_PDUS; + return OK; +} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index d979f09b..706752b2 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -7,7 +7,9 @@ #include "RemoteConfigTableIF.h" #include "UserBase.h" +#include "defs.h" #include "fsfw/cfdp/handler/mib.h" +#include "fsfw/cfdp/pdu/MetadataPduReader.h" #include "fsfw/cfdp/pdu/PduConfig.h" #include "fsfw/container/DynamicFIFO.h" #include "fsfw/storagemanager/StorageManagerIF.h" @@ -28,7 +30,7 @@ struct PacketInfo { struct DestHandlerParams { DestHandlerParams(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable, - etl::ilist& packetList, uint8_t maxTlvsInOnePdu) + etl::ilist& packetList) : cfg(std::move(cfg)), user(user), remoteCfgTable(remoteCfgTable), @@ -39,7 +41,8 @@ struct DestHandlerParams { RemoteConfigTableIF& remoteCfgTable; etl::ilist& packetListRef; - uint8_t maxTlvsInOnePdu; + uint8_t maxTlvsInOnePdu = 10; + size_t maxFilenameLen = 255; }; struct FsfwParams { @@ -67,8 +70,6 @@ class DestHandler { ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize); private: - DestHandlerParams dp; - FsfwParams fp; enum class TransactionStep { IDLE = 0, TRANSACTION_START = 1, @@ -77,8 +78,29 @@ class DestHandler { TRANSFER_COMPLETION = 4, SENDING_FINISHED_PDU = 5 }; + struct TransactionParams { + explicit TransactionParams(size_t maxFileNameLen) + : sourceName(maxFileNameLen), destName(maxFileNameLen) {} + + ChecksumType checksumType = ChecksumType::NULL_CHECKSUM; + bool closureRequested{}; + std::vector sourceName; + std::vector destName; + cfdp::FileSize fileSize; + TransactionId transactionId; + PduConfig pduConf; + RemoteEntityCfg* remoteCfg; + }; + TransactionStep step = TransactionStep::IDLE; + CfdpStates cfdpState = CfdpStates::IDLE; std::vector tlvVec; + std::vector userTlvVec; + DestHandlerParams dp; + FsfwParams fp; + TransactionParams tp; + + ReturnValue_t startTransaction(MetadataPduReader& reader, MetadataInfo& info); }; } // namespace cfdp diff --git a/src/fsfw/cfdp/handler/defs.h b/src/fsfw/cfdp/handler/defs.h new file mode 100644 index 00000000..9e837a96 --- /dev/null +++ b/src/fsfw/cfdp/handler/defs.h @@ -0,0 +1,9 @@ +#ifndef FSFW_CFDP_HANDLER_DEFS_H +#define FSFW_CFDP_HANDLER_DEFS_H + +namespace cfdp { + +enum class CfdpStates { IDLE, BUSY_CLASS_1_NACKED, BUSY_CLASS_2_ACKED, SUSPENDED }; + +} +#endif // FSFW_CFDP_HANDLER_DEFS_H diff --git a/src/fsfw/cfdp/pdu/HeaderReader.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp index f220ccd3..e2f070db 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.cpp +++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp @@ -139,3 +139,13 @@ bool HeaderReader::isNull() const { } HeaderReader::operator bool() const { return not isNull(); } + +void HeaderReader::fillConfig(PduConfig &cfg) const { + cfg.largeFile = getLargeFileFlag(); + cfg.crcFlag = getCrcFlag(); + cfg.mode = getTransmissionMode(); + cfg.direction = getDirection(); + getTransactionSeqNum(cfg.seqNum); + getSourceId(cfg.sourceId); + getDestId(cfg.destId); +} diff --git a/src/fsfw/cfdp/pdu/HeaderReader.h b/src/fsfw/cfdp/pdu/HeaderReader.h index 9bf740a8..533320b7 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.h +++ b/src/fsfw/cfdp/pdu/HeaderReader.h @@ -45,6 +45,12 @@ class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { explicit operator bool() const; [[nodiscard]] bool isNull() const; + /** + * Fill the provided PDU configuration from the fields detected by this reader. + * @param cfg + */ + void fillConfig(PduConfig& cfg) const; + [[nodiscard]] virtual size_t getHeaderSize() const; [[nodiscard]] size_t getPduDataFieldLen() const override; diff --git a/src/fsfw/cfdp/pdu/PduConfig.h b/src/fsfw/cfdp/pdu/PduConfig.h index 2e513159..368999cc 100644 --- a/src/fsfw/cfdp/pdu/PduConfig.h +++ b/src/fsfw/cfdp/pdu/PduConfig.h @@ -6,16 +6,18 @@ class PduConfig { public: + PduConfig() = default; PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionModes mode, cfdp::TransactionSeqNum seqNum, bool crcFlag = false, bool largeFile = false, cfdp::Direction direction = cfdp::Direction::TOWARDS_RECEIVER); - cfdp::TransmissionModes mode; + + cfdp::TransmissionModes mode = cfdp::TransmissionModes::ACKNOWLEDGED; cfdp::TransactionSeqNum seqNum; cfdp::EntityId sourceId; cfdp::EntityId destId; - bool crcFlag; - bool largeFile; - cfdp::Direction direction; + bool crcFlag = false; + bool largeFile = false; + cfdp::Direction direction = cfdp::Direction::TOWARDS_RECEIVER; }; #endif /* FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_ */ From 26ea6606bf271ef8dc9ce52e624f026296b07015 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 Aug 2022 20:56:09 +0200 Subject: [PATCH 257/532] metadata recvd indication --- src/fsfw/cfdp/handler/DestHandler.cpp | 9 +++++++++ src/fsfw/cfdp/handler/UserBase.h | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index aefa1aa3..a52af18e 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -169,5 +169,14 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met return FAILED; } step = TransactionStep::RECEIVING_FILE_DATA_PDUS; + MetadataRecvdParams params; + params.sourceId = tp.pduConf.sourceId; + params.fileSize = tp.fileSize.getSize(); + params.destFileName = tp.destName.data(); + params.sourceFileName = tp.sourceName.data(); + params.id = tp.transactionId; + params.msgsToUserArray = dynamic_cast(userTlvVec.data()); + params.msgsToUserLen = info.getOptionsLen(); + dp.user.metadataRecvdIndication(params); return OK; } diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index 34af89a5..0003decf 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -29,10 +29,11 @@ struct TransactionFinishedParams { struct MetadataRecvdParams { TransactionId id; EntityId sourceId; - size_t fileSize; - const char* sourceFileName; - const char* destFileName; - std::vector msgsToUser; + uint64_t fileSize; + const char* sourceFileName = ""; + const char* destFileName = ""; + size_t msgsToUserLen = 0; + const MessageToUserTlv* msgsToUserArray = nullptr; }; struct FileSegmentRecvdParams { @@ -63,6 +64,16 @@ class UserBase { virtual void transactionIndication(TransactionId id) = 0; virtual void eofSentIndication(TransactionId id) = 0; virtual void transactionFinishedIndication(TransactionFinishedParams params) = 0; + /** + * Will be called if metadata was received. + * + * IMPORTANT: The passed struct contains the messages to the user in form of a raw C array. + * The TLVs in these arrays are zero-copy types, which means that they point to the raw data + * inside the metadata packet directly. The metadata packet will be deleted from the TC store + * shortly after it was processed. If some of the data is to be cached and/or used after the + * function call, it needs to be copied into another user-provided buffer. + * @param params + */ virtual void metadataRecvdIndication(MetadataRecvdParams params) = 0; virtual void fileSegmentRecvdIndication(FileSegmentRecvdParams params) = 0; virtual void reportIndication(TransactionId id, StatusReportIF& report) = 0; From eb29b79467dbb72cd5234d1d18cadca8745a2c17 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Aug 2022 08:44:20 +0200 Subject: [PATCH 258/532] some more docs --- src/fsfw/cfdp/handler/DestHandler.cpp | 4 +-- src/fsfw/cfdp/handler/UserBase.h | 39 ++++++++++++++++----------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index a52af18e..3d0a4500 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -169,12 +169,10 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met return FAILED; } step = TransactionStep::RECEIVING_FILE_DATA_PDUS; - MetadataRecvdParams params; - params.sourceId = tp.pduConf.sourceId; + MetadataRecvdParams params(tp.transactionId, tp.pduConf.sourceId); params.fileSize = tp.fileSize.getSize(); params.destFileName = tp.destName.data(); params.sourceFileName = tp.sourceName.data(); - params.id = tp.transactionId; params.msgsToUserArray = dynamic_cast(userTlvVec.data()); params.msgsToUserLen = info.getOptionsLen(); dp.user.metadataRecvdIndication(params); diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index 0003decf..eff03d43 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -27,9 +27,11 @@ struct TransactionFinishedParams { }; struct MetadataRecvdParams { - TransactionId id; - EntityId sourceId; - uint64_t fileSize; + MetadataRecvdParams(const TransactionId& id, const EntityId& sourceId): + id(id), sourceId(sourceId) {} + const TransactionId& id; + const EntityId& sourceId; + uint64_t fileSize = 0; const char* sourceFileName = ""; const char* destFileName = ""; size_t msgsToUserLen = 0; @@ -44,21 +46,26 @@ struct FileSegmentRecvdParams { std::pair segmentMetadata; }; +/** + * @brief Base class which provides a user interface to interact with CFDP handlers. + * + * @details + * This class is also used to pass the Virtual Filestore (VFS) Implementation to the CFDP + * handlers so the filestore operations can be mapped to the underlying filestore. + * + * It is used by implementing it in a child class and then passing it to the CFDP + * handler objects. The base class provides default implementation for the user indication + * primitives specified in the CFDP standard. The user can override these implementations + * to provide custom indication handlers. + * + * Please note that for all indication callbacks, the passed transaction ID reference will + * become invalid shortly after the function has been executed. If the transaction ID is to be + * cached or used, create an own copy of it. + * @param vfs Virtual Filestore Object. Will be used for all file operations + */ class UserBase { public: - /** - * @brief Base class which provides a user interface to interact with CFDP handlers. - * - * @details - * This class is also used to pass the Virtual Filestore (VFS) Implementation to the CFDP - * handlers so the filestore operations can be mapped to the underlying filestore. - * - * It is used by implementing it in a child class and then passing it to the CFDP - * handler objects. The base class provides default implementation for the user indication - * primitives specified in the CFDP standard. The user can override these implementations - * to provide custom indication handlers. - * @param vfs Virtual Filestore Object. Will be used for all file operations - */ + explicit UserBase(HasFileSystemIF& vfs); virtual void transactionIndication(TransactionId id) = 0; From 2c730c86325a828d41feb650cbb93040bad1cc19 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Aug 2022 12:11:03 +0200 Subject: [PATCH 259/532] use const struct ref instead --- src/fsfw/cfdp/handler/UserBase.h | 2 +- unittests/mocks/cfdp/UserMock.cpp | 2 +- unittests/mocks/cfdp/UserMock.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index eff03d43..50a00a2d 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -81,7 +81,7 @@ class UserBase { * function call, it needs to be copied into another user-provided buffer. * @param params */ - virtual void metadataRecvdIndication(MetadataRecvdParams params) = 0; + virtual void metadataRecvdIndication(const MetadataRecvdParams& params) = 0; virtual void fileSegmentRecvdIndication(FileSegmentRecvdParams params) = 0; virtual void reportIndication(TransactionId id, StatusReportIF& report) = 0; virtual void suspendedIndication(TransactionId id, ConditionCode code) = 0; diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mocks/cfdp/UserMock.cpp index bcef4e68..2281184e 100644 --- a/unittests/mocks/cfdp/UserMock.cpp +++ b/unittests/mocks/cfdp/UserMock.cpp @@ -8,7 +8,7 @@ void cfdp::UserMock::abandonedIndication(cfdp::TransactionId id, cfdp::Condition uint64_t progress) {} void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {} void cfdp::UserMock::transactionFinishedIndication(TransactionFinishedParams finishedParams) {} -void cfdp::UserMock::metadataRecvdIndication(MetadataRecvdParams params) {} +void cfdp::UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {} void cfdp::UserMock::fileSegmentRecvdIndication(FileSegmentRecvdParams params) {} void cfdp::UserMock::reportIndication(TransactionId id, StatusReportIF& report) {} void cfdp::UserMock::suspendedIndication(TransactionId id, ConditionCode code) {} diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mocks/cfdp/UserMock.h index d9d05336..c58210f6 100644 --- a/unittests/mocks/cfdp/UserMock.h +++ b/unittests/mocks/cfdp/UserMock.h @@ -13,7 +13,7 @@ class UserMock : public UserBase { void abandonedIndication(TransactionId id, ConditionCode code, size_t progress) override; void eofRecvIndication(TransactionId id) override; void transactionFinishedIndication(TransactionFinishedParams params) override; - void metadataRecvdIndication(MetadataRecvdParams params) override; + void metadataRecvdIndication(const MetadataRecvdParams& params) override; void fileSegmentRecvdIndication(FileSegmentRecvdParams params) override; void reportIndication(TransactionId id, StatusReportIF& report) override; void suspendedIndication(TransactionId id, ConditionCode code) override; From 267466be9dc9502d900354be315aabbaed50c7cc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Aug 2022 15:43:58 +0200 Subject: [PATCH 260/532] pass const references to user handler now --- src/fsfw/cfdp/handler/DestHandler.h | 2 +- src/fsfw/cfdp/handler/UserBase.h | 20 ++++++++++---------- unittests/mocks/cfdp/UserMock.cpp | 26 +++++++++++++++----------- unittests/mocks/cfdp/UserMock.h | 20 ++++++++++---------- 4 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 706752b2..fdf79633 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -89,7 +89,7 @@ class DestHandler { cfdp::FileSize fileSize; TransactionId transactionId; PduConfig pduConf; - RemoteEntityCfg* remoteCfg; + RemoteEntityCfg* remoteCfg = nullptr; }; TransactionStep step = TransactionStep::IDLE; diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index 50a00a2d..bd26ae0d 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -68,9 +68,9 @@ class UserBase { explicit UserBase(HasFileSystemIF& vfs); - virtual void transactionIndication(TransactionId id) = 0; - virtual void eofSentIndication(TransactionId id) = 0; - virtual void transactionFinishedIndication(TransactionFinishedParams params) = 0; + virtual void transactionIndication(const TransactionId& id) = 0; + virtual void eofSentIndication(const TransactionId& id) = 0; + virtual void transactionFinishedIndication(const TransactionFinishedParams& params) = 0; /** * Will be called if metadata was received. * @@ -82,13 +82,13 @@ class UserBase { * @param params */ virtual void metadataRecvdIndication(const MetadataRecvdParams& params) = 0; - virtual void fileSegmentRecvdIndication(FileSegmentRecvdParams params) = 0; - virtual void reportIndication(TransactionId id, StatusReportIF& report) = 0; - virtual void suspendedIndication(TransactionId id, ConditionCode code) = 0; - virtual void resumedIndication(TransactionId id, size_t progress) = 0; - virtual void faultIndication(TransactionId id, ConditionCode code, size_t progress) = 0; - virtual void abandonedIndication(TransactionId id, ConditionCode code, size_t progress) = 0; - virtual void eofRecvIndication(TransactionId id) = 0; + virtual void fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) = 0; + virtual void reportIndication(const TransactionId& id, StatusReportIF& report) = 0; + virtual void suspendedIndication(const TransactionId& id, ConditionCode code) = 0; + virtual void resumedIndication(const TransactionId& id, size_t progress) = 0; + virtual void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) = 0; + virtual void abandonedIndication(const TransactionId& id, ConditionCode code, size_t progress) = 0; + virtual void eofRecvIndication(const TransactionId& id) = 0; private: HasFileSystemIF& vfs; diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mocks/cfdp/UserMock.cpp index 2281184e..a6b6ed48 100644 --- a/unittests/mocks/cfdp/UserMock.cpp +++ b/unittests/mocks/cfdp/UserMock.cpp @@ -1,17 +1,21 @@ #include "UserMock.h" +namespace cfdp { + cfdp::UserMock::UserMock(HasFileSystemIF& vfs) : UserBase(vfs) {} -void cfdp::UserMock::transactionIndication(cfdp::TransactionId id) {} -void cfdp::UserMock::eofSentIndication(cfdp::TransactionId id) {} -void cfdp::UserMock::abandonedIndication(cfdp::TransactionId id, cfdp::ConditionCode code, +void UserMock::transactionIndication(const TransactionId& id) {} +void UserMock::eofSentIndication(const TransactionId& id) {} +void UserMock::abandonedIndication(const TransactionId& id, cfdp::ConditionCode code, uint64_t progress) {} -void cfdp::UserMock::eofRecvIndication(cfdp::TransactionId id) {} -void cfdp::UserMock::transactionFinishedIndication(TransactionFinishedParams finishedParams) {} -void cfdp::UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {} -void cfdp::UserMock::fileSegmentRecvdIndication(FileSegmentRecvdParams params) {} -void cfdp::UserMock::reportIndication(TransactionId id, StatusReportIF& report) {} -void cfdp::UserMock::suspendedIndication(TransactionId id, ConditionCode code) {} -void cfdp::UserMock::resumedIndication(TransactionId id, size_t progress) {} -void cfdp::UserMock::faultIndication(cfdp::TransactionId id, cfdp::ConditionCode code, +void UserMock::eofRecvIndication(const TransactionId& id) {} +void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {} +void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {} +void UserMock::fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) {} +void UserMock::reportIndication(const TransactionId& id, StatusReportIF& report) {} +void UserMock::suspendedIndication(const TransactionId& id, ConditionCode code) {} +void UserMock::resumedIndication(const TransactionId& id, size_t progress) {} +void UserMock::faultIndication(const TransactionId& id, cfdp::ConditionCode code, size_t progress) {} + +} diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mocks/cfdp/UserMock.h index c58210f6..f3a5bfd9 100644 --- a/unittests/mocks/cfdp/UserMock.h +++ b/unittests/mocks/cfdp/UserMock.h @@ -8,17 +8,17 @@ class UserMock : public UserBase { public: explicit UserMock(HasFileSystemIF& vfs); - void transactionIndication(TransactionId id) override; - void eofSentIndication(TransactionId id) override; - void abandonedIndication(TransactionId id, ConditionCode code, size_t progress) override; - void eofRecvIndication(TransactionId id) override; - void transactionFinishedIndication(TransactionFinishedParams params) override; + void transactionIndication(const TransactionId& id) override; + void eofSentIndication(const TransactionId& id) override; + void abandonedIndication(const TransactionId& id, ConditionCode code, size_t progress) override; + void eofRecvIndication(const TransactionId& id) override; + void transactionFinishedIndication(const TransactionFinishedParams& params) override; void metadataRecvdIndication(const MetadataRecvdParams& params) override; - void fileSegmentRecvdIndication(FileSegmentRecvdParams params) override; - void reportIndication(TransactionId id, StatusReportIF& report) override; - void suspendedIndication(TransactionId id, ConditionCode code) override; - void resumedIndication(TransactionId id, size_t progress) override; - void faultIndication(TransactionId id, ConditionCode code, size_t progress) override; + void fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) override; + void reportIndication(const TransactionId& id, StatusReportIF& report) override; + void suspendedIndication(const TransactionId& id, ConditionCode code) override; + void resumedIndication(const TransactionId& id, size_t progress) override; + void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) override; }; } // namespace cfdp From 81a7c21cd13a6d10ea5080ac393f4d8f80852573 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Aug 2022 17:31:26 +0200 Subject: [PATCH 261/532] continued router component --- src/fsfw/cfdp/handler/DestHandler.cpp | 50 +++++++++++++++------------ src/fsfw/cfdp/handler/DestHandler.h | 12 +++++++ src/fsfw/cfdp/handler/UserBase.h | 8 ++--- unittests/mocks/cfdp/UserMock.cpp | 8 ++--- 4 files changed, 48 insertions(+), 30 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 3d0a4500..7271c19c 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -18,31 +18,35 @@ cfdp::DestHandler::DestHandler(DestHandlerParams params, FsfwParams fsfwParams) } ReturnValue_t cfdp::DestHandler::performStateMachine() { - switch (step) { - case TransactionStep::IDLE: { - ReturnValue_t status = returnvalue::OK; - ReturnValue_t result; - for (const auto& info : dp.packetListRef) { - if (info.pduType == PduType::FILE_DIRECTIVE and - info.directiveType == FileDirectives::METADATA) { - result = handleMetadataPdu(info); - if (result != OK) { - status = result; - } + if (step == TransactionStep::IDLE) { + ReturnValue_t status = returnvalue::OK; + ReturnValue_t result; + for (const auto& info : dp.packetListRef) { + if (info.pduType == PduType::FILE_DIRECTIVE and + info.directiveType == FileDirectives::METADATA) { + result = handleMetadataPdu(info); + if (result != OK) { + status = result; } } - return status; } - case TransactionStep::TRANSACTION_START: - break; - case TransactionStep::RECEIVING_FILE_DATA_PDUS: - break; - case TransactionStep::SENDING_ACK_PDU: - break; - case TransactionStep::TRANSFER_COMPLETION: - break; - case TransactionStep::SENDING_FINISHED_PDU: - break; + if (step != TransactionStep::IDLE) { + return CALL_FSM_AGAIN; + } + return status; + } + if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) { + for (const auto& info : dp.packetListRef) { + if (info.pduType == PduType::FILE_DATA) { + } + } + return returnvalue::OK; + } + if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { + // TODO: Will be implemented at a later stage +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "CFDP state machine for acknowledged mode not implemented yet" << std::endl; +#endif } return returnvalue::OK; } @@ -178,3 +182,5 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met dp.user.metadataRecvdIndication(params); return OK; } + +cfdp::CfdpStates cfdp::DestHandler::getCfdpState() const { return cfdpState; } diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index fdf79633..74668638 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -58,8 +58,18 @@ struct FsfwParams { class DestHandler { public: + /** + * Will be returned if it is advisable to call the state machine operation call again + */ + ReturnValue_t CALL_FSM_AGAIN = returnvalue::makeCode(1, 0); explicit DestHandler(DestHandlerParams handlerParams, FsfwParams fsfwParams); + /** + * + * @return + * - @c returnvalue::OK State machine OK for this execution cycle + * - @c CALL_FSM_AGAIN State machine should be called again. + */ ReturnValue_t performStateMachine(); ReturnValue_t passPacket(PacketInfo packet); @@ -69,6 +79,8 @@ class DestHandler { ReturnValue_t handleMetadataPdu(const PacketInfo& info); ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize); + [[nodiscard]] CfdpStates getCfdpState() const; + private: enum class TransactionStep { IDLE = 0, diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index bd26ae0d..b6c35570 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -27,8 +27,8 @@ struct TransactionFinishedParams { }; struct MetadataRecvdParams { - MetadataRecvdParams(const TransactionId& id, const EntityId& sourceId): - id(id), sourceId(sourceId) {} + MetadataRecvdParams(const TransactionId& id, const EntityId& sourceId) + : id(id), sourceId(sourceId) {} const TransactionId& id; const EntityId& sourceId; uint64_t fileSize = 0; @@ -65,7 +65,6 @@ struct FileSegmentRecvdParams { */ class UserBase { public: - explicit UserBase(HasFileSystemIF& vfs); virtual void transactionIndication(const TransactionId& id) = 0; @@ -87,7 +86,8 @@ class UserBase { virtual void suspendedIndication(const TransactionId& id, ConditionCode code) = 0; virtual void resumedIndication(const TransactionId& id, size_t progress) = 0; virtual void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) = 0; - virtual void abandonedIndication(const TransactionId& id, ConditionCode code, size_t progress) = 0; + virtual void abandonedIndication(const TransactionId& id, ConditionCode code, + size_t progress) = 0; virtual void eofRecvIndication(const TransactionId& id) = 0; private: diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mocks/cfdp/UserMock.cpp index a6b6ed48..876c2e81 100644 --- a/unittests/mocks/cfdp/UserMock.cpp +++ b/unittests/mocks/cfdp/UserMock.cpp @@ -7,7 +7,7 @@ cfdp::UserMock::UserMock(HasFileSystemIF& vfs) : UserBase(vfs) {} void UserMock::transactionIndication(const TransactionId& id) {} void UserMock::eofSentIndication(const TransactionId& id) {} void UserMock::abandonedIndication(const TransactionId& id, cfdp::ConditionCode code, - uint64_t progress) {} + uint64_t progress) {} void UserMock::eofRecvIndication(const TransactionId& id) {} void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {} void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {} @@ -15,7 +15,7 @@ void UserMock::fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) void UserMock::reportIndication(const TransactionId& id, StatusReportIF& report) {} void UserMock::suspendedIndication(const TransactionId& id, ConditionCode code) {} void UserMock::resumedIndication(const TransactionId& id, size_t progress) {} -void UserMock::faultIndication(const TransactionId& id, cfdp::ConditionCode code, - size_t progress) {} - +void UserMock::faultIndication(const TransactionId& id, cfdp::ConditionCode code, size_t progress) { } + +} // namespace cfdp From ff4cbea57137521d60dfa283cfc72c6989439257 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Aug 2022 17:44:55 +0200 Subject: [PATCH 262/532] improvements for auto-formatter script --- scripts/auto-formatter.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/auto-formatter.sh b/scripts/auto-formatter.sh index c0ae7099..723add4f 100755 --- a/scripts/auto-formatter.sh +++ b/scripts/auto-formatter.sh @@ -3,6 +3,11 @@ if [[ ! -f README.md ]]; then cd .. fi +folder_list=( + "./src" + "./unittests" +) + cmake_fmt="cmake-format" file_selectors="-iname CMakeLists.txt" if command -v ${cmake_fmt} &> /dev/null; then @@ -15,8 +20,10 @@ fi cpp_format="clang-format" file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp" if command -v ${cpp_format} &> /dev/null; then - find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i - find ./unittests ${file_selectors} | xargs ${cpp_format} --style=file -i + for dir in ${folder_list[@]}; do + echo "Auto-formatting ${dir} recursively" + find ${dir} ${file_selectors} | xargs clang-format --style=file -i + done else echo "No ${cpp_format} tool found, not formatting C++/C files" fi From fd278e410b943efeb30435b9a5fb00988c171be9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 12:01:44 +0200 Subject: [PATCH 263/532] additional safety check --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 7b9ba7c0..59261cfd 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -588,10 +588,12 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr } // additional security check, this should never be true - if (itBegin->first > itEnd->first) { + if ((itBegin != telecommandMap.end() and itEnd != telecommandMap.end()) and + (itBegin->first > itEnd->first)) { #if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "11::getMapFilterFromData: itBegin > itEnd\n" << std::endl; #else - sif::printError("11::GetMapFilterFromData: itBegin > itEnd\n"); + sif::printError("11::getMapFilterFromData: itBegin > itEnd\n"); #endif return returnvalue::FAILED; } From e2e0190caef8d26d019ad4e50e3518a7c14e9597 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 29 Aug 2022 14:51:14 +0200 Subject: [PATCH 264/532] Revert "additional safety check" This reverts commit fd278e410b943efeb30435b9a5fb00988c171be9. --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 59261cfd..7b9ba7c0 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -588,12 +588,10 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr } // additional security check, this should never be true - if ((itBegin != telecommandMap.end() and itEnd != telecommandMap.end()) and - (itBegin->first > itEnd->first)) { + if (itBegin->first > itEnd->first) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "11::getMapFilterFromData: itBegin > itEnd\n" << std::endl; #else - sif::printError("11::getMapFilterFromData: itBegin > itEnd\n"); + sif::printError("11::GetMapFilterFromData: itBegin > itEnd\n"); #endif return returnvalue::FAILED; } From 6605ffb6b1e2a039d6132b3e150bdc13c42dd543 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 29 Aug 2022 14:54:52 +0200 Subject: [PATCH 265/532] Fixing check in Srv 11 Filer --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 7b9ba7c0..7f60f7e8 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -588,10 +588,11 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr } // additional security check, this should never be true - if (itBegin->first > itEnd->first) { + if (itBegin > itEnd) { #if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "11::getMapFilterFromData: itBegin > itEnd\n" << std::endl; #else - sif::printError("11::GetMapFilterFromData: itBegin > itEnd\n"); + sif::printError("11::getMapFilterFromData: itBegin > itEnd\n"); #endif return returnvalue::FAILED; } From 3bffb4f968ea14fa77596bf881621c8a1b14803d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 15:20:33 +0200 Subject: [PATCH 266/532] fix for static fw obj setter --- misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp index 4670c7e7..4d6e91f1 100644 --- a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp +++ b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp @@ -35,7 +35,7 @@ void Factory::produceFsfwObjects(void) { } void Factory::setStaticFrameworkObjectIds() { - PusServiceBase::packetSource = objects::NO_OBJECT; + PusServiceBase::PUS_DISTRIBUTOR = objects::NO_OBJECT; PusServiceBase::PACKET_DESTINATION = objects::NO_OBJECT; CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; From b499dedd76637e1330a90f3f8ef0d0743ef0246a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 15:27:53 +0200 Subject: [PATCH 267/532] remove TODO --- src/fsfw/datapoollocal/LocalDataPoolManager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index fa76d2a7..0a7dd5ab 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -14,7 +14,6 @@ #include "internal/HasLocalDpIFManagerAttorney.h" #include "internal/LocalPoolDataSetAttorney.h" -// TODO: Get rid of this. This should be a constructor argument, not something hardcoded in any way object_id_t LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse, From cb23911ccd5b678bc53ceda59f5258b77a042a56 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 15:30:45 +0200 Subject: [PATCH 268/532] default initialization of CDS short struct --- src/fsfw/timemanager/CCSDSTime.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index 607026e3..77801cec 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -39,13 +39,13 @@ class CCSDSTime { * Struct for CDS day-segmented format. */ struct CDS_short { - uint8_t pField; - uint8_t dayMSB; - uint8_t dayLSB; - uint8_t msDay_hh; - uint8_t msDay_h; - uint8_t msDay_l; - uint8_t msDay_ll; + uint8_t pField = P_FIELD_CDS_SHORT; + uint8_t dayMSB = 0; + uint8_t dayLSB = 0; + uint8_t msDay_hh = 0; + uint8_t msDay_h = 0; + uint8_t msDay_l = 0; + uint8_t msDay_ll = 0; }; /** * Struct for the CCS fromat in day of month variation with max resolution From 9a9085b9e61640b79286bd5edc4021cd8bc27f1e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 20:08:59 +0200 Subject: [PATCH 269/532] avoid duplicate code --- src/fsfw/ipc/MessageQueueMessage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/ipc/MessageQueueMessage.cpp b/src/fsfw/ipc/MessageQueueMessage.cpp index 6e841c7f..b0ce090f 100644 --- a/src/fsfw/ipc/MessageQueueMessage.cpp +++ b/src/fsfw/ipc/MessageQueueMessage.cpp @@ -12,7 +12,7 @@ MessageQueueMessage::MessageQueueMessage() : messageSize(getMinimumMessageSize() MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) : messageSize(MessageQueueMessage::HEADER_SIZE + size) { if (size <= MessageQueueMessage::MAX_DATA_SIZE) { - std::memcpy(internalBuffer + MessageQueueMessage::HEADER_SIZE, data, size); + std::memcpy(MessageQueueMessage::getData(), data, size); this->messageSize = MessageQueueMessage::HEADER_SIZE + size; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 From 2cab73d9722da97c32ad46e63cbec4d54645b897 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 29 Aug 2022 20:08:59 +0200 Subject: [PATCH 270/532] avoid duplicate code --- src/fsfw/ipc/MessageQueueMessage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/ipc/MessageQueueMessage.cpp b/src/fsfw/ipc/MessageQueueMessage.cpp index 6e841c7f..b0ce090f 100644 --- a/src/fsfw/ipc/MessageQueueMessage.cpp +++ b/src/fsfw/ipc/MessageQueueMessage.cpp @@ -12,7 +12,7 @@ MessageQueueMessage::MessageQueueMessage() : messageSize(getMinimumMessageSize() MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) : messageSize(MessageQueueMessage::HEADER_SIZE + size) { if (size <= MessageQueueMessage::MAX_DATA_SIZE) { - std::memcpy(internalBuffer + MessageQueueMessage::HEADER_SIZE, data, size); + std::memcpy(MessageQueueMessage::getData(), data, size); this->messageSize = MessageQueueMessage::HEADER_SIZE + size; } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 From 342a56410cd14a6e089670797e1b3fa1481ed512 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 10:28:55 +0200 Subject: [PATCH 271/532] delete commented function --- src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index baf91796..ba3f7a43 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -98,11 +98,6 @@ class ProvidesDataPoolSubscriptionIF { virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; - // virtual ReturnValue_t - // subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics) { - // return subscribeForUpdatePacket(sid, reportingEnabled, isDiagnostics, objects::NO_OBJECT); - // } - [[deprecated( "Please use the new API which takes all arguments as one wrapper " "struct")]] virtual ReturnValue_t From 92d65aa3a5ad2d393cf024d5861d30ffd6aad645 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 10:57:02 +0200 Subject: [PATCH 272/532] use old lpm api --- .../datapoollocal/LocalDataPoolManager.cpp | 65 +++++------ src/fsfw/datapoollocal/LocalDataPoolManager.h | 12 +- .../ProvidesDataPoolSubscriptionIF.h | 107 +++--------------- .../internalerror/InternalErrorReporter.cpp | 5 +- .../devicehandlers/MgmLIS3MDLHandler.cpp | 2 +- .../devicehandlers/MgmRM3100Handler.cpp | 2 +- unittests/datapoollocal/CMakeLists.txt | 2 +- unittests/mocks/LocalPoolOwnerBase.h | 16 +-- 8 files changed, 57 insertions(+), 154 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index fa76d2a7..daad19be 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -326,32 +326,27 @@ void LocalDataPoolManager::resetHkUpdateResetHelper() { } } -ReturnValue_t LocalDataPoolManager::subscribeForRegularPeriodicPacket( - subdp::RegularHkPeriodicParams params) { - return subscribeForPeriodicPacket(params); -} - -ReturnValue_t LocalDataPoolManager::subscribeForDiagPeriodicPacket( - subdp::DiagnosticsHkPeriodicParams params) { - return subscribeForPeriodicPacket(params); -} - -ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(subdp::ParamsBase& params) { +ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool enableReporting, + float collectionInterval, bool isDiagnostics, + object_id_t packetDestination) { struct HkReceiver hkReceiver; - hkReceiver.dataId.sid = params.sid; + hkReceiver.dataId.sid = sid; hkReceiver.reportingType = ReportingType::PERIODIC; hkReceiver.dataType = DataType::DATA_SET; - if (params.receiver == MessageQueueIF::NO_QUEUE) { - hkReceiver.destinationQueue = hkDestinationId; - } else { - hkReceiver.destinationQueue = params.receiver; + if (packetDestination != objects::NO_OBJECT) { + auto* receivedHkIF = ObjectManager::instance()->get(packetDestination); + if (receivedHkIF->getHkQueue() == MessageQueueIF::NO_QUEUE) { + hkReceiver.destinationQueue = hkDestinationId; + } else { + hkReceiver.destinationQueue = receivedHkIF->getHkQueue(); + } } - LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid); + LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); if (dataSet != nullptr) { - LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, params.enableReporting); - LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics()); - LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, params.collectionInterval, + LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enableReporting); + LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics); + LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, collectionInterval, owner->getPeriodicOperationFrequency()); } @@ -359,30 +354,26 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(subdp::ParamsBase return returnvalue::OK; } -ReturnValue_t LocalDataPoolManager::subscribeForRegularUpdatePacket( - subdp::RegularHkUpdateParams params) { - return subscribeForUpdatePacket(params); -} -ReturnValue_t LocalDataPoolManager::subscribeForDiagUpdatePacket( - subdp::DiagnosticsHkUpdateParams params) { - return subscribeForUpdatePacket(params); -} - -ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(subdp::ParamsBase& params) { +ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, + bool isDiagnostics, + object_id_t packetDestination) { struct HkReceiver hkReceiver; - hkReceiver.dataId.sid = params.sid; + hkReceiver.dataId.sid = sid; hkReceiver.reportingType = ReportingType::UPDATE_HK; hkReceiver.dataType = DataType::DATA_SET; - if (params.receiver == MessageQueueIF::NO_QUEUE) { - hkReceiver.destinationQueue = hkDestinationId; - } else { - hkReceiver.destinationQueue = params.receiver; + if (packetDestination != objects::NO_OBJECT) { + auto* receivedHkIF = ObjectManager::instance()->get(packetDestination); + if (receivedHkIF->getHkQueue() == MessageQueueIF::NO_QUEUE) { + hkReceiver.destinationQueue = hkDestinationId; + } else { + hkReceiver.destinationQueue = receivedHkIF->getHkQueue(); + } } - LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid); + LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); if (dataSet != nullptr) { LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true); - LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics()); + LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics); } hkReceivers.push_back(hkReceiver); diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/datapoollocal/LocalDataPoolManager.h index 7db079f6..8b12e29f 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.h @@ -241,13 +241,13 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces MutexIF* getMutexHandle(); 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 subscribeForPeriodicPacket(sid_t sid, bool enableReporting, + float collectionInterval, bool isDiagnostics, + object_id_t packetDestination = objects::NO_OBJECT) override; - ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) override; - ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) override; - ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params); + ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, + bool isDiagnostics, + object_id_t packetDestination = objects::NO_OBJECT) override; protected: /** Core data structure for the actual pool data */ diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index ba3f7a43..eb4e55b7 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -1,90 +1,24 @@ #ifndef FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_ #define FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_ -#include "fsfw/housekeeping/AcceptsHkPacketsIF.h" -#include "fsfw/ipc/MessageQueueIF.h" -#include "fsfw/ipc/messageQueueDefinitions.h" -#include "fsfw/returnvalues/returnvalue.h" +#include "../ipc/messageQueueDefinitions.h" +#include "../returnvalues/returnvalue.h" #include "localPoolDefinitions.h" -namespace subdp { - -struct ParamsBase { - ParamsBase(sid_t sid, bool enableReporting, float collectionInterval, bool diagnostics) - : sid(sid), - enableReporting(enableReporting), - collectionInterval(collectionInterval), - diagnostics(diagnostics) {} - - [[nodiscard]] bool isDiagnostics() const { return diagnostics; } - - sid_t sid; - bool enableReporting; - float collectionInterval; - MessageQueueId_t receiver = MessageQueueIF::NO_QUEUE; - - protected: - bool diagnostics; -}; - -struct RegularHkPeriodicParams : public ParamsBase { - RegularHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval) - : ParamsBase(sid, enableReporting, collectionInterval, false) {} -}; - -struct DiagnosticsHkPeriodicParams : public ParamsBase { - DiagnosticsHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval) - : ParamsBase(sid, enableReporting, collectionInterval, true) {} -}; - -struct RegularHkUpdateParams : public ParamsBase { - RegularHkUpdateParams(sid_t sid, bool enableReporting) - : ParamsBase(sid, enableReporting, 0.0, false) {} -}; - -struct DiagnosticsHkUpdateParams : public ParamsBase { - DiagnosticsHkUpdateParams(sid_t sid, bool enableReporting) - : ParamsBase(sid, enableReporting, 0.0, true) {} -}; -} // namespace subdp - class ProvidesDataPoolSubscriptionIF { public: - virtual ~ProvidesDataPoolSubscriptionIF() = default; + virtual ~ProvidesDataPoolSubscriptionIF(){}; + /** - * @brief Subscribe for the generation of periodic packets. Used for regular HK packets + * @brief Subscribe for the generation of periodic packets. * @details * This subscription mechanism will generally be used by the data creator * to generate housekeeping packets which are downlinked directly. * @return */ - virtual ReturnValue_t subscribeForRegularPeriodicPacket( - subdp::RegularHkPeriodicParams params) = 0; - /** - * @brief Subscribe for the generation of periodic packets. Used for diagnostic packets - * @details - * This subscription mechanism will generally be used by the data creator - * to generate housekeeping packets which are downlinked directly. - * @return - */ - virtual ReturnValue_t subscribeForDiagPeriodicPacket( - subdp::DiagnosticsHkPeriodicParams params) = 0; - - [[deprecated( - "Please use the new API which takes all arguments as one wrapper " - "struct")]] virtual ReturnValue_t - subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval, - bool isDiagnostics, - object_id_t packetDestination = objects::NO_OBJECT) { - if (isDiagnostics) { - subdp::DiagnosticsHkPeriodicParams params(sid, enableReporting, collectionInterval); - return subscribeForDiagPeriodicPacket(params); - } else { - subdp::RegularHkPeriodicParams params(sid, enableReporting, collectionInterval); - return subscribeForRegularPeriodicPacket(params); - } - } - + virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting, + float collectionInterval, bool isDiagnostics, + object_id_t packetDestination) = 0; /** * @brief Subscribe for the generation of packets if the dataset * is marked as changed. @@ -95,23 +29,9 @@ class ProvidesDataPoolSubscriptionIF { * @param packetDestination * @return */ - virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; - virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; - - [[deprecated( - "Please use the new API which takes all arguments as one wrapper " - "struct")]] virtual ReturnValue_t - subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics, - object_id_t packetDestination = objects::NO_OBJECT) { - if (isDiagnostics) { - subdp::DiagnosticsHkUpdateParams params(sid, reportingEnabled); - return subscribeForDiagUpdatePacket(params); - } else { - subdp::RegularHkUpdateParams params(sid, reportingEnabled); - return subscribeForRegularUpdatePacket(params); - } - } - + virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, + bool isDiagnostics, + object_id_t packetDestination) = 0; /** * @brief Subscribe for a notification message which will be sent * if a dataset has changed. @@ -126,7 +46,8 @@ class ProvidesDataPoolSubscriptionIF { * Otherwise, only an notification message is sent. * @return */ - virtual ReturnValue_t subscribeForSetUpdateMessage(uint32_t setId, object_id_t destinationObject, + virtual ReturnValue_t subscribeForSetUpdateMessage(const uint32_t setId, + object_id_t destinationObject, MessageQueueId_t targetQueueId, bool generateSnapshot) = 0; /** @@ -143,7 +64,7 @@ class ProvidesDataPoolSubscriptionIF { * only an notification message is sent. * @return */ - virtual ReturnValue_t subscribeForVariableUpdateMessage(lp_id_t localPoolId, + virtual ReturnValue_t subscribeForVariableUpdateMessage(const lp_id_t localPoolId, object_id_t destinationObject, MessageQueueId_t targetQueueId, bool generateSnapshot) = 0; diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index b3b77366..ad6b711c 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -129,9 +129,8 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry); localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry); localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry); - poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams( - internalErrorSid, false, - static_cast(getPeriodicOperationFrequency()) / static_cast(1000.0))); + poolManager.subscribeForPeriodicPacket(internalErrorSid, false, + static_cast(getPeriodicOperationFrequency()) / static_cast(1000.0), true); internalErrorDataset.setValidity(true, true); return returnvalue::OK; } diff --git a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index 9cb16c35..b4d64dbc 100644 --- a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -466,7 +466,7 @@ ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(localpool::DataPool &lo LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTHS, &mgmXYZ); localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, &temperature); - poolManager.subscribeForRegularPeriodicPacket({dataset.getSid(), false, 10.0}); + poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 10.0, false); return returnvalue::OK; } diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index a32153eb..f1629d89 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -310,7 +310,7 @@ void MgmRM3100Handler::modeChanged() { internalState = InternalState::NONE; } ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(RM3100::FIELD_STRENGTHS, &mgmXYZ); - poolManager.subscribeForRegularPeriodicPacket({primaryDataset.getSid(), false, 10.0}); + poolManager.subscribeForPeriodicPacket(primaryDataset.getSid(), false, 10.0, false); return returnvalue::OK; } diff --git a/unittests/datapoollocal/CMakeLists.txt b/unittests/datapoollocal/CMakeLists.txt index 016645fd..4a7ed61a 100644 --- a/unittests/datapoollocal/CMakeLists.txt +++ b/unittests/datapoollocal/CMakeLists.txt @@ -2,5 +2,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testLocalPoolVariable.cpp testLocalPoolVector.cpp testDataSet.cpp - testLocalPoolManager.cpp + testLocalPoolManager.cpp ) diff --git a/unittests/mocks/LocalPoolOwnerBase.h b/unittests/mocks/LocalPoolOwnerBase.h index f1d1225f..9938c517 100644 --- a/unittests/mocks/LocalPoolOwnerBase.h +++ b/unittests/mocks/LocalPoolOwnerBase.h @@ -11,6 +11,7 @@ #include #include "fsfw/datapool/PoolEntry.h" +#include "fsfw/housekeeping/AcceptsHkPacketsIF.h" #include "mocks/MessageQueueMock.h" #include "tests/TestsConfig.h" @@ -104,8 +105,7 @@ class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF { } ReturnValue_t subscribePeriodicHk(bool enableReporting) { - return poolManager.subscribeForRegularPeriodicPacket( - subdp::RegularHkPeriodicParams(lpool::testSid, enableReporting, 0.2)); + return poolManager.subscribeForPeriodicPacket(lpool::testSid, enableReporting, 0.2, false); } ReturnValue_t subscribeWrapperSetUpdate(MessageQueueId_t receiverId) { @@ -121,17 +121,9 @@ class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF { ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false, AcceptsHkPacketsIF* receiver = nullptr) { if (diagnostics) { - auto params = subdp::DiagnosticsHkUpdateParams(lpool::testSid, true); - if (receiver != nullptr) { - params.receiver = receiver->getHkQueue(); - } - return poolManager.subscribeForDiagUpdatePacket(params); + return poolManager.subscribeForUpdatePacket(lpool::testSid, true, true); } else { - auto params = subdp::RegularHkUpdateParams(lpool::testSid, true); - if (receiver != nullptr) { - params.receiver = receiver->getHkQueue(); - } - return poolManager.subscribeForRegularUpdatePacket(params); + return poolManager.subscribeForUpdatePacket(lpool::testSid, true, false); } } From 0cc8af5eb0af8e7be94c59b3b9eebd318a85d7ec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 10:57:17 +0200 Subject: [PATCH 273/532] afmt --- src/fsfw/datapoollocal/LocalDataPoolManager.cpp | 7 ++++--- src/fsfw/datapoollocal/LocalDataPoolManager.h | 12 ++++++------ src/fsfw/internalerror/InternalErrorReporter.cpp | 3 ++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index daad19be..555a4d68 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -326,9 +326,10 @@ void LocalDataPoolManager::resetHkUpdateResetHelper() { } } -ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool enableReporting, - float collectionInterval, bool isDiagnostics, - object_id_t packetDestination) { +ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool enableReporting, + float collectionInterval, + bool isDiagnostics, + object_id_t packetDestination) { struct HkReceiver hkReceiver; hkReceiver.dataId.sid = sid; hkReceiver.reportingType = ReportingType::PERIODIC; diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/datapoollocal/LocalDataPoolManager.h index 8b12e29f..7073474b 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.h @@ -241,13 +241,13 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces MutexIF* getMutexHandle(); LocalDataPoolManager* getPoolManagerHandle() override; - ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting, - float collectionInterval, bool isDiagnostics, - object_id_t packetDestination = objects::NO_OBJECT) override; + ReturnValue_t subscribeForPeriodicPacket( + sid_t sid, bool enableReporting, float collectionInterval, bool isDiagnostics, + object_id_t packetDestination = objects::NO_OBJECT) override; - ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, - bool isDiagnostics, - object_id_t packetDestination = objects::NO_OBJECT) override; + ReturnValue_t subscribeForUpdatePacket( + sid_t sid, bool reportingEnabled, bool isDiagnostics, + object_id_t packetDestination = objects::NO_OBJECT) override; protected: /** Core data structure for the actual pool data */ diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index ad6b711c..ea2e09ef 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -129,7 +129,8 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry); localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry); localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry); - poolManager.subscribeForPeriodicPacket(internalErrorSid, false, + poolManager.subscribeForPeriodicPacket( + internalErrorSid, false, static_cast(getPeriodicOperationFrequency()) / static_cast(1000.0), true); internalErrorDataset.setValidity(true, true); return returnvalue::OK; From 9fedd03ed8137ab79a57dbc472248b5207fee8d0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 11:02:21 +0200 Subject: [PATCH 274/532] use cfg struct for local pool API --- .../datapoollocal/LocalDataPoolManager.cpp | 67 ++++++----- src/fsfw/datapoollocal/LocalDataPoolManager.h | 12 +- .../ProvidesDataPoolSubscriptionIF.h | 112 +++++++++++++++--- .../internalerror/InternalErrorReporter.cpp | 4 +- .../devicehandlers/MgmLIS3MDLHandler.cpp | 2 +- .../devicehandlers/MgmRM3100Handler.cpp | 2 +- unittests/datapoollocal/CMakeLists.txt | 2 +- unittests/mocks/LocalPoolOwnerBase.h | 16 ++- 8 files changed, 159 insertions(+), 58 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp index d3f866f7..fa76d2a7 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.cpp +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.cpp @@ -14,6 +14,7 @@ #include "internal/HasLocalDpIFManagerAttorney.h" #include "internal/LocalPoolDataSetAttorney.h" +// TODO: Get rid of this. This should be a constructor argument, not something hardcoded in any way object_id_t LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse, @@ -325,28 +326,32 @@ void LocalDataPoolManager::resetHkUpdateResetHelper() { } } -ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool enableReporting, - float collectionInterval, - bool isDiagnostics, - object_id_t packetDestination) { +ReturnValue_t LocalDataPoolManager::subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams params) { + return subscribeForPeriodicPacket(params); +} + +ReturnValue_t LocalDataPoolManager::subscribeForDiagPeriodicPacket( + subdp::DiagnosticsHkPeriodicParams params) { + return subscribeForPeriodicPacket(params); +} + +ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(subdp::ParamsBase& params) { struct HkReceiver hkReceiver; - hkReceiver.dataId.sid = sid; + hkReceiver.dataId.sid = params.sid; hkReceiver.reportingType = ReportingType::PERIODIC; hkReceiver.dataType = DataType::DATA_SET; - if (packetDestination != objects::NO_OBJECT) { - auto* receivedHkIF = ObjectManager::instance()->get(packetDestination); - if (receivedHkIF->getHkQueue() == MessageQueueIF::NO_QUEUE) { - hkReceiver.destinationQueue = hkDestinationId; - } else { - hkReceiver.destinationQueue = receivedHkIF->getHkQueue(); - } + if (params.receiver == MessageQueueIF::NO_QUEUE) { + hkReceiver.destinationQueue = hkDestinationId; + } else { + hkReceiver.destinationQueue = params.receiver; } - LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); + LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid); if (dataSet != nullptr) { - LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enableReporting); - LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics); - LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, collectionInterval, + LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, params.enableReporting); + LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics()); + LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, params.collectionInterval, owner->getPeriodicOperationFrequency()); } @@ -354,26 +359,30 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool e return returnvalue::OK; } -ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, - bool isDiagnostics, - object_id_t packetDestination) { +ReturnValue_t LocalDataPoolManager::subscribeForRegularUpdatePacket( + subdp::RegularHkUpdateParams params) { + return subscribeForUpdatePacket(params); +} +ReturnValue_t LocalDataPoolManager::subscribeForDiagUpdatePacket( + subdp::DiagnosticsHkUpdateParams params) { + return subscribeForUpdatePacket(params); +} + +ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(subdp::ParamsBase& params) { struct HkReceiver hkReceiver; - hkReceiver.dataId.sid = sid; + hkReceiver.dataId.sid = params.sid; hkReceiver.reportingType = ReportingType::UPDATE_HK; hkReceiver.dataType = DataType::DATA_SET; - if (packetDestination != objects::NO_OBJECT) { - auto* receivedHkIF = ObjectManager::instance()->get(packetDestination); - if (receivedHkIF->getHkQueue() == MessageQueueIF::NO_QUEUE) { - hkReceiver.destinationQueue = hkDestinationId; - } else { - hkReceiver.destinationQueue = receivedHkIF->getHkQueue(); - } + if (params.receiver == MessageQueueIF::NO_QUEUE) { + hkReceiver.destinationQueue = hkDestinationId; + } else { + hkReceiver.destinationQueue = params.receiver; } - LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid); + LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid); if (dataSet != nullptr) { LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true); - LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics); + LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics()); } hkReceivers.push_back(hkReceiver); diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/datapoollocal/LocalDataPoolManager.h index 7073474b..7db079f6 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.h @@ -241,13 +241,13 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces MutexIF* getMutexHandle(); LocalDataPoolManager* getPoolManagerHandle() override; - ReturnValue_t subscribeForPeriodicPacket( - sid_t sid, bool enableReporting, float collectionInterval, bool isDiagnostics, - object_id_t packetDestination = objects::NO_OBJECT) override; + ReturnValue_t subscribeForRegularPeriodicPacket(subdp::RegularHkPeriodicParams params) override; + ReturnValue_t subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams params) override; + ReturnValue_t subscribeForPeriodicPacket(subdp::ParamsBase& params); - ReturnValue_t subscribeForUpdatePacket( - sid_t sid, bool reportingEnabled, bool isDiagnostics, - object_id_t packetDestination = objects::NO_OBJECT) override; + ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) override; + ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) override; + ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params); protected: /** Core data structure for the actual pool data */ diff --git a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h index eb4e55b7..baf91796 100644 --- a/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h +++ b/src/fsfw/datapoollocal/ProvidesDataPoolSubscriptionIF.h @@ -1,24 +1,90 @@ #ifndef FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_ #define FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_ -#include "../ipc/messageQueueDefinitions.h" -#include "../returnvalues/returnvalue.h" +#include "fsfw/housekeeping/AcceptsHkPacketsIF.h" +#include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/ipc/messageQueueDefinitions.h" +#include "fsfw/returnvalues/returnvalue.h" #include "localPoolDefinitions.h" +namespace subdp { + +struct ParamsBase { + ParamsBase(sid_t sid, bool enableReporting, float collectionInterval, bool diagnostics) + : sid(sid), + enableReporting(enableReporting), + collectionInterval(collectionInterval), + diagnostics(diagnostics) {} + + [[nodiscard]] bool isDiagnostics() const { return diagnostics; } + + sid_t sid; + bool enableReporting; + float collectionInterval; + MessageQueueId_t receiver = MessageQueueIF::NO_QUEUE; + + protected: + bool diagnostics; +}; + +struct RegularHkPeriodicParams : public ParamsBase { + RegularHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval) + : ParamsBase(sid, enableReporting, collectionInterval, false) {} +}; + +struct DiagnosticsHkPeriodicParams : public ParamsBase { + DiagnosticsHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval) + : ParamsBase(sid, enableReporting, collectionInterval, true) {} +}; + +struct RegularHkUpdateParams : public ParamsBase { + RegularHkUpdateParams(sid_t sid, bool enableReporting) + : ParamsBase(sid, enableReporting, 0.0, false) {} +}; + +struct DiagnosticsHkUpdateParams : public ParamsBase { + DiagnosticsHkUpdateParams(sid_t sid, bool enableReporting) + : ParamsBase(sid, enableReporting, 0.0, true) {} +}; +} // namespace subdp + class ProvidesDataPoolSubscriptionIF { public: - virtual ~ProvidesDataPoolSubscriptionIF(){}; - + virtual ~ProvidesDataPoolSubscriptionIF() = default; /** - * @brief Subscribe for the generation of periodic packets. + * @brief Subscribe for the generation of periodic packets. Used for regular HK packets * @details * This subscription mechanism will generally be used by the data creator * to generate housekeeping packets which are downlinked directly. * @return */ - virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting, - float collectionInterval, bool isDiagnostics, - object_id_t packetDestination) = 0; + virtual ReturnValue_t subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams params) = 0; + /** + * @brief Subscribe for the generation of periodic packets. Used for diagnostic packets + * @details + * This subscription mechanism will generally be used by the data creator + * to generate housekeeping packets which are downlinked directly. + * @return + */ + virtual ReturnValue_t subscribeForDiagPeriodicPacket( + subdp::DiagnosticsHkPeriodicParams params) = 0; + + [[deprecated( + "Please use the new API which takes all arguments as one wrapper " + "struct")]] virtual ReturnValue_t + subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval, + bool isDiagnostics, + object_id_t packetDestination = objects::NO_OBJECT) { + if (isDiagnostics) { + subdp::DiagnosticsHkPeriodicParams params(sid, enableReporting, collectionInterval); + return subscribeForDiagPeriodicPacket(params); + } else { + subdp::RegularHkPeriodicParams params(sid, enableReporting, collectionInterval); + return subscribeForRegularPeriodicPacket(params); + } + } + /** * @brief Subscribe for the generation of packets if the dataset * is marked as changed. @@ -29,9 +95,28 @@ class ProvidesDataPoolSubscriptionIF { * @param packetDestination * @return */ - virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, - bool isDiagnostics, - object_id_t packetDestination) = 0; + virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0; + virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0; + + // virtual ReturnValue_t + // subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics) { + // return subscribeForUpdatePacket(sid, reportingEnabled, isDiagnostics, objects::NO_OBJECT); + // } + + [[deprecated( + "Please use the new API which takes all arguments as one wrapper " + "struct")]] virtual ReturnValue_t + subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics, + object_id_t packetDestination = objects::NO_OBJECT) { + if (isDiagnostics) { + subdp::DiagnosticsHkUpdateParams params(sid, reportingEnabled); + return subscribeForDiagUpdatePacket(params); + } else { + subdp::RegularHkUpdateParams params(sid, reportingEnabled); + return subscribeForRegularUpdatePacket(params); + } + } + /** * @brief Subscribe for a notification message which will be sent * if a dataset has changed. @@ -46,8 +131,7 @@ class ProvidesDataPoolSubscriptionIF { * Otherwise, only an notification message is sent. * @return */ - virtual ReturnValue_t subscribeForSetUpdateMessage(const uint32_t setId, - object_id_t destinationObject, + virtual ReturnValue_t subscribeForSetUpdateMessage(uint32_t setId, object_id_t destinationObject, MessageQueueId_t targetQueueId, bool generateSnapshot) = 0; /** @@ -64,7 +148,7 @@ class ProvidesDataPoolSubscriptionIF { * only an notification message is sent. * @return */ - virtual ReturnValue_t subscribeForVariableUpdateMessage(const lp_id_t localPoolId, + virtual ReturnValue_t subscribeForVariableUpdateMessage(lp_id_t localPoolId, object_id_t destinationObject, MessageQueueId_t targetQueueId, bool generateSnapshot) = 0; diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index ea2e09ef..b3b77366 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -129,9 +129,9 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry); localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry); localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry); - poolManager.subscribeForPeriodicPacket( + poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams( internalErrorSid, false, - static_cast(getPeriodicOperationFrequency()) / static_cast(1000.0), true); + static_cast(getPeriodicOperationFrequency()) / static_cast(1000.0))); internalErrorDataset.setValidity(true, true); return returnvalue::OK; } diff --git a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index b4d64dbc..9cb16c35 100644 --- a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -466,7 +466,7 @@ ReturnValue_t MgmLIS3MDLHandler::initializeLocalDataPool(localpool::DataPool &lo LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(MGMLIS3MDL::FIELD_STRENGTHS, &mgmXYZ); localDataPoolMap.emplace(MGMLIS3MDL::TEMPERATURE_CELCIUS, &temperature); - poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 10.0, false); + poolManager.subscribeForRegularPeriodicPacket({dataset.getSid(), false, 10.0}); return returnvalue::OK; } diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index f1629d89..a32153eb 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -310,7 +310,7 @@ void MgmRM3100Handler::modeChanged() { internalState = InternalState::NONE; } ReturnValue_t MgmRM3100Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(RM3100::FIELD_STRENGTHS, &mgmXYZ); - poolManager.subscribeForPeriodicPacket(primaryDataset.getSid(), false, 10.0, false); + poolManager.subscribeForRegularPeriodicPacket({primaryDataset.getSid(), false, 10.0}); return returnvalue::OK; } diff --git a/unittests/datapoollocal/CMakeLists.txt b/unittests/datapoollocal/CMakeLists.txt index 4a7ed61a..016645fd 100644 --- a/unittests/datapoollocal/CMakeLists.txt +++ b/unittests/datapoollocal/CMakeLists.txt @@ -2,5 +2,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testLocalPoolVariable.cpp testLocalPoolVector.cpp testDataSet.cpp - testLocalPoolManager.cpp + testLocalPoolManager.cpp ) diff --git a/unittests/mocks/LocalPoolOwnerBase.h b/unittests/mocks/LocalPoolOwnerBase.h index 9938c517..f1d1225f 100644 --- a/unittests/mocks/LocalPoolOwnerBase.h +++ b/unittests/mocks/LocalPoolOwnerBase.h @@ -11,7 +11,6 @@ #include #include "fsfw/datapool/PoolEntry.h" -#include "fsfw/housekeeping/AcceptsHkPacketsIF.h" #include "mocks/MessageQueueMock.h" #include "tests/TestsConfig.h" @@ -105,7 +104,8 @@ class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF { } ReturnValue_t subscribePeriodicHk(bool enableReporting) { - return poolManager.subscribeForPeriodicPacket(lpool::testSid, enableReporting, 0.2, false); + return poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(lpool::testSid, enableReporting, 0.2)); } ReturnValue_t subscribeWrapperSetUpdate(MessageQueueId_t receiverId) { @@ -121,9 +121,17 @@ class LocalPoolOwnerBase : public SystemObject, public HasLocalDataPoolIF { ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false, AcceptsHkPacketsIF* receiver = nullptr) { if (diagnostics) { - return poolManager.subscribeForUpdatePacket(lpool::testSid, true, true); + auto params = subdp::DiagnosticsHkUpdateParams(lpool::testSid, true); + if (receiver != nullptr) { + params.receiver = receiver->getHkQueue(); + } + return poolManager.subscribeForDiagUpdatePacket(params); } else { - return poolManager.subscribeForUpdatePacket(lpool::testSid, true, false); + auto params = subdp::RegularHkUpdateParams(lpool::testSid, true); + if (receiver != nullptr) { + params.receiver = receiver->getHkQueue(); + } + return poolManager.subscribeForRegularUpdatePacket(params); } } From aea9db75cb925c92e5e9b574b4d754bd48e51dc6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 11:12:06 +0200 Subject: [PATCH 275/532] better name --- src/fsfw/tmtcservices/VerificationCodes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/tmtcservices/VerificationCodes.h b/src/fsfw/tmtcservices/VerificationCodes.h index 91b76bde..479074eb 100644 --- a/src/fsfw/tmtcservices/VerificationCodes.h +++ b/src/fsfw/tmtcservices/VerificationCodes.h @@ -5,7 +5,7 @@ namespace tcverif { -enum VerifFlags : uint8_t { +enum VerificationFlags : uint8_t { NONE = 0b0000, ACCEPTANCE = 0b0001, START = 0b0010, From a9277622ce13c7e8ece4f0db86ba6bcdcc779e5f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 12:04:15 +0200 Subject: [PATCH 276/532] move data wrapper --- src/fsfw/tmtcpacket/pus/defs.h | 38 -------------- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 4 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 3 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 7 +-- src/fsfw/tmtcservices/tmHelpers.h | 12 ++--- src/fsfw/util/dataWrapper.h | 52 +++++++++++++++++++ .../tmtcservices/testStoreAndSendHelper.cpp | 8 +-- 8 files changed, 72 insertions(+), 56 deletions(-) create mode 100644 src/fsfw/util/dataWrapper.h diff --git a/src/fsfw/tmtcpacket/pus/defs.h b/src/fsfw/tmtcpacket/pus/defs.h index 69b3415c..c5172d8b 100644 --- a/src/fsfw/tmtcpacket/pus/defs.h +++ b/src/fsfw/tmtcpacket/pus/defs.h @@ -13,44 +13,6 @@ using PusChecksumT = uint16_t; //! Version numbers according to ECSS-E-ST-70-41C p.439 enum PusVersion : uint8_t { PUS_A = 1, PUS_C = 2 }; -struct RawData { - const uint8_t* data; - size_t len; -}; - -enum DataTypes { RAW, SERIALIZABLE }; - -union DataUnion { - RawData raw; - SerializeIF* serializable; -}; - -struct DataWrapper { - DataTypes type; - DataUnion dataUnion; - using BufPairT = std::pair; - - [[nodiscard]] size_t getLength() const { - if (type == DataTypes::RAW) { - return dataUnion.raw.len; - } else if (type == DataTypes::SERIALIZABLE and dataUnion.serializable != nullptr) { - return dataUnion.serializable->getSerializedSize(); - } - return 0; - } - - void setRawData(BufPairT bufPair) { - type = DataTypes::RAW; - dataUnion.raw.data = bufPair.first; - dataUnion.raw.len = bufPair.second; - } - - void setSerializable(SerializeIF& serializable) { - type = DataTypes::SERIALIZABLE; - dataUnion.serializable = &serializable; - } -}; - /** * This struct defines the data structure of a Space Packet when accessed * via a pointer. diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index d85d5b72..14a440a0 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -37,14 +37,14 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max if (result != returnvalue::OK) { return result; } - if (pusParams.dataWrapper.type == ecss::DataTypes::RAW) { + if (pusParams.dataWrapper.type == util::DataTypes::RAW) { const uint8_t *data = pusParams.dataWrapper.dataUnion.raw.data; if (data != nullptr and userDataLen > 0) { std::memcpy(*buffer, data, userDataLen); *buffer += userDataLen; *size += userDataLen; } - } else if (pusParams.dataWrapper.type == ecss::DataTypes::SERIALIZABLE and + } else if (pusParams.dataWrapper.type == util::DataTypes::SERIALIZABLE and pusParams.dataWrapper.dataUnion.serializable != nullptr) { result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, streamEndianness); diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 72691c40..4b0d81c8 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -7,6 +7,7 @@ #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" #include "fsfw/tmtcpacket/pus/defs.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" +#include "fsfw/util/dataWrapper.h" struct PusTcParams { PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {} @@ -15,7 +16,7 @@ struct PusTcParams { uint8_t subservice; uint8_t ackFlags = ecss::ACK_ALL; uint16_t sourceId = 0; - ecss::DataWrapper dataWrapper{}; + util::DataWrapper dataWrapper{}; uint8_t pusVersion = ecss::PusVersion::PUS_C; }; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 80853221..b754e990 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -77,12 +77,12 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max } } - if (pusParams.dataWrapper.type == ecss::DataTypes::RAW and + if (pusParams.dataWrapper.type == util::DataTypes::RAW and pusParams.dataWrapper.dataUnion.raw.data != nullptr) { std::memcpy(*buffer, pusParams.dataWrapper.dataUnion.raw.data, userDataLen); *buffer += userDataLen; *size += userDataLen; - } else if (pusParams.dataWrapper.type == ecss::DataTypes::SERIALIZABLE and + } else if (pusParams.dataWrapper.type == util::DataTypes::SERIALIZABLE and pusParams.dataWrapper.dataUnion.serializable != nullptr) { result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, streamEndianness); diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 706a7b70..8fd4f690 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -4,6 +4,7 @@ #include "PusTmIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" +#include "fsfw/util/dataWrapper.h" struct PusTmSecHeader { PusTmSecHeader() = default; @@ -22,19 +23,19 @@ struct PusTmSecHeader { struct PusTmParams { PusTmParams() = default; explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader){}; - PusTmParams(PusTmSecHeader secHeader, ecss::DataWrapper dataWrapper) + PusTmParams(PusTmSecHeader secHeader, util::DataWrapper dataWrapper) : secHeader(secHeader), dataWrapper(dataWrapper) {} PusTmParams(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper) : secHeader(service, subservice, timeStamper) {} PusTmParams(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper, - ecss::DataWrapper dataWrapper_) + util::DataWrapper dataWrapper_) : PusTmParams(service, subservice, timeStamper) { dataWrapper = dataWrapper_; } PusTmSecHeader secHeader; - ecss::DataWrapper dataWrapper{}; + util::DataWrapper dataWrapper{}; }; class TimeStamperIF; diff --git a/src/fsfw/tmtcservices/tmHelpers.h b/src/fsfw/tmtcservices/tmHelpers.h index ab69c9c8..845a73b8 100644 --- a/src/fsfw/tmtcservices/tmHelpers.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -11,13 +11,13 @@ class DataWithObjectIdPrefix : public SerializeIF { public: DataWithObjectIdPrefix(object_id_t objectId, const uint8_t* srcData, size_t srcDataLen) : objectId(objectId) { - dataWrapper.type = ecss::DataTypes::RAW; + dataWrapper.type = util::DataTypes::RAW; dataWrapper.dataUnion.raw.data = srcData; dataWrapper.dataUnion.raw.len = srcDataLen; } DataWithObjectIdPrefix(object_id_t objectId, SerializeIF& serializable) : objectId(objectId) { - dataWrapper.type = ecss::DataTypes::SERIALIZABLE; + dataWrapper.type = util::DataTypes::SERIALIZABLE; dataWrapper.dataUnion.serializable = &serializable; } @@ -26,11 +26,11 @@ class DataWithObjectIdPrefix : public SerializeIF { if (*size + getSerializedSize() > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } - if (dataWrapper.type != ecss::DataTypes::RAW) { + if (dataWrapper.type != util::DataTypes::RAW) { if ((dataWrapper.dataUnion.raw.data == nullptr) and (dataWrapper.dataUnion.raw.len > 0)) { return returnvalue::FAILED; } - } else if (dataWrapper.type == ecss::DataTypes::SERIALIZABLE) { + } else if (dataWrapper.type == util::DataTypes::SERIALIZABLE) { if (dataWrapper.dataUnion.serializable == nullptr) { return returnvalue::FAILED; } @@ -40,7 +40,7 @@ class DataWithObjectIdPrefix : public SerializeIF { if (result != returnvalue::OK) { return result; } - if (dataWrapper.type != ecss::DataTypes::RAW) { + if (dataWrapper.type != util::DataTypes::RAW) { std::memcpy(*buffer, dataWrapper.dataUnion.raw.data, dataWrapper.dataUnion.raw.len); *buffer += dataWrapper.dataUnion.raw.len; *size += dataWrapper.dataUnion.raw.len; @@ -63,7 +63,7 @@ class DataWithObjectIdPrefix : public SerializeIF { private: object_id_t objectId; - ecss::DataWrapper dataWrapper{}; + util::DataWrapper dataWrapper{}; }; } // namespace telemetry diff --git a/src/fsfw/util/dataWrapper.h b/src/fsfw/util/dataWrapper.h new file mode 100644 index 00000000..f5dab447 --- /dev/null +++ b/src/fsfw/util/dataWrapper.h @@ -0,0 +1,52 @@ +#ifndef FSFW_UTIL_DATAWRAPPER_H +#define FSFW_UTIL_DATAWRAPPER_H + +#include +#include +#include + +#include "fsfw/serialize.h" + +namespace util { + +struct RawData { + const uint8_t* data; + size_t len; +}; + +enum DataTypes { RAW, SERIALIZABLE }; + +union DataUnion { + RawData raw; + SerializeIF* serializable; +}; + +struct DataWrapper { + DataTypes type; + DataUnion dataUnion; + using BufPairT = std::pair; + + [[nodiscard]] size_t getLength() const { + if (type == DataTypes::RAW) { + return dataUnion.raw.len; + } else if (type == DataTypes::SERIALIZABLE and dataUnion.serializable != nullptr) { + return dataUnion.serializable->getSerializedSize(); + } + return 0; + } + + void setRawData(BufPairT bufPair) { + type = DataTypes::RAW; + dataUnion.raw.data = bufPair.first; + dataUnion.raw.len = bufPair.second; + } + + void setSerializable(SerializeIF& serializable) { + type = DataTypes::SERIALIZABLE; + dataUnion.serializable = &serializable; + } +}; + +} // namespace util + +#endif // FSFW_UTIL_DATAWRAPPER_H diff --git a/unittests/tmtcservices/testStoreAndSendHelper.cpp b/unittests/tmtcservices/testStoreAndSendHelper.cpp index 4e1bb4fb..2731b28f 100644 --- a/unittests/tmtcservices/testStoreAndSendHelper.cpp +++ b/unittests/tmtcservices/testStoreAndSendHelper.cpp @@ -44,7 +44,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(creator.getSubService() == 2); REQUIRE(creator.getService() == 17); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == ecss::DataTypes::RAW); + REQUIRE(params.dataWrapper.type == util::DataTypes::RAW); REQUIRE(params.dataWrapper.dataUnion.raw.data == nullptr); REQUIRE(params.dataWrapper.dataUnion.raw.len == 0); REQUIRE(tmHelper.sendCounter == 0); @@ -65,7 +65,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(tmHelper.prepareTmPacket(2, data.data(), data.size()) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == ecss::DataTypes::RAW); + REQUIRE(params.dataWrapper.type == util::DataTypes::RAW); REQUIRE(params.dataWrapper.dataUnion.raw.data == data.data()); REQUIRE(params.dataWrapper.dataUnion.raw.len == data.size()); } @@ -75,7 +75,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(tmHelper.prepareTmPacket(2, simpleSer) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == ecss::DataTypes::SERIALIZABLE); + REQUIRE(params.dataWrapper.type == util::DataTypes::SERIALIZABLE); REQUIRE(params.dataWrapper.dataUnion.serializable == &simpleSer); } @@ -86,7 +86,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(tmHelper.prepareTmPacket(2, dataWithObjId) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == ecss::DataTypes::SERIALIZABLE); + REQUIRE(params.dataWrapper.type == util::DataTypes::SERIALIZABLE); REQUIRE(params.dataWrapper.dataUnion.serializable == &dataWithObjId); } From 20d42add0348941baba7b079f03ba0ff57bfd083 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 12:07:09 +0200 Subject: [PATCH 277/532] add new data wrapper helper type --- src/fsfw/util/dataWrapper.h | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/fsfw/util/dataWrapper.h diff --git a/src/fsfw/util/dataWrapper.h b/src/fsfw/util/dataWrapper.h new file mode 100644 index 00000000..f5dab447 --- /dev/null +++ b/src/fsfw/util/dataWrapper.h @@ -0,0 +1,52 @@ +#ifndef FSFW_UTIL_DATAWRAPPER_H +#define FSFW_UTIL_DATAWRAPPER_H + +#include +#include +#include + +#include "fsfw/serialize.h" + +namespace util { + +struct RawData { + const uint8_t* data; + size_t len; +}; + +enum DataTypes { RAW, SERIALIZABLE }; + +union DataUnion { + RawData raw; + SerializeIF* serializable; +}; + +struct DataWrapper { + DataTypes type; + DataUnion dataUnion; + using BufPairT = std::pair; + + [[nodiscard]] size_t getLength() const { + if (type == DataTypes::RAW) { + return dataUnion.raw.len; + } else if (type == DataTypes::SERIALIZABLE and dataUnion.serializable != nullptr) { + return dataUnion.serializable->getSerializedSize(); + } + return 0; + } + + void setRawData(BufPairT bufPair) { + type = DataTypes::RAW; + dataUnion.raw.data = bufPair.first; + dataUnion.raw.len = bufPair.second; + } + + void setSerializable(SerializeIF& serializable) { + type = DataTypes::SERIALIZABLE; + dataUnion.serializable = &serializable; + } +}; + +} // namespace util + +#endif // FSFW_UTIL_DATAWRAPPER_H From 0f27c7e7e707fd3c901a43ac6de4ce072758d918 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 13:24:29 +0200 Subject: [PATCH 278/532] extend data wrapper --- src/fsfw/util/dataWrapper.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/fsfw/util/dataWrapper.h b/src/fsfw/util/dataWrapper.h index f5dab447..5ae2c043 100644 --- a/src/fsfw/util/dataWrapper.h +++ b/src/fsfw/util/dataWrapper.h @@ -10,19 +10,19 @@ namespace util { struct RawData { - const uint8_t* data; - size_t len; + const uint8_t* data = nullptr; + size_t len = 0; }; -enum DataTypes { RAW, SERIALIZABLE }; +enum DataTypes { NONE, RAW, SERIALIZABLE }; union DataUnion { RawData raw; - SerializeIF* serializable; + SerializeIF* serializable = nullptr; }; struct DataWrapper { - DataTypes type; + DataTypes type = DataTypes::NONE; DataUnion dataUnion; using BufPairT = std::pair; @@ -35,6 +35,14 @@ struct DataWrapper { return 0; } + [[nodiscard]] bool isNull() const { + if (type == DataTypes::RAW and dataUnion.raw.data == nullptr or + (type == DataTypes::SERIALIZABLE and dataUnion.serializable == nullptr) or + (type == DataTypes::NONE)) { + return true; + } + return false; + } void setRawData(BufPairT bufPair) { type = DataTypes::RAW; dataUnion.raw.data = bufPair.first; From c756297e5c1ece6a2e22aa036c9a8c1d5a2e435b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 13:39:44 +0200 Subject: [PATCH 279/532] data wrapper update --- src/fsfw/util/dataWrapper.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fsfw/util/dataWrapper.h b/src/fsfw/util/dataWrapper.h index 5ae2c043..8bb373e6 100644 --- a/src/fsfw/util/dataWrapper.h +++ b/src/fsfw/util/dataWrapper.h @@ -36,9 +36,8 @@ struct DataWrapper { } [[nodiscard]] bool isNull() const { - if (type == DataTypes::RAW and dataUnion.raw.data == nullptr or - (type == DataTypes::SERIALIZABLE and dataUnion.serializable == nullptr) or - (type == DataTypes::NONE)) { + if ((type == DataTypes::NONE) or (type == DataTypes::RAW and dataUnion.raw.data == nullptr) or + (type == DataTypes::SERIALIZABLE and dataUnion.serializable == nullptr)) { return true; } return false; From 9131ca688b5071f76e141e2bd312211c5c1bf8d8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 15:01:10 +0200 Subject: [PATCH 280/532] 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 7db079f6..8f369ea0 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 64a7fde30171bfd4711fb01b349184f9777817cf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 15:16:54 +0200 Subject: [PATCH 281/532] this is annoying --- src/fsfw/pus/Service11TelecommandScheduling.h | 5 +++-- src/fsfw/pus/Service11TelecommandScheduling.tpp | 14 +++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.h b/src/fsfw/pus/Service11TelecommandScheduling.h index 2a14401b..57ba4982 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.h +++ b/src/fsfw/pus/Service11TelecommandScheduling.h @@ -38,8 +38,9 @@ class Service11TelecommandScheduling final : public PusServiceBase { static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_11; static constexpr ReturnValue_t INVALID_TYPE_TIME_WINDOW = returnvalue::makeCode(CLASS_ID, 1); - static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = returnvalue::makeCode(CLASS_ID, 2); - static constexpr ReturnValue_t INVALID_RELATIVE_TIME = returnvalue::makeCode(CLASS_ID, 3); + static constexpr ReturnValue_t INVALID_TIME_WINDOW = returnvalue::makeCode(CLASS_ID, 2); + static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = returnvalue::makeCode(CLASS_ID, 3); + static constexpr ReturnValue_t INVALID_RELATIVE_TIME = returnvalue::makeCode(CLASS_ID, 4); static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_11; diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 7f60f7e8..3cf24b11 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -571,6 +571,9 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr if (result != returnvalue::OK) { return result; } + if(fromTimestamp > toTimestamp) { + return INVALID_TIME_WINDOW; + } itBegin = telecommandMap.begin(); itEnd = telecommandMap.begin(); @@ -586,17 +589,6 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr default: return returnvalue::FAILED; } - - // additional security check, this should never be true - if (itBegin > itEnd) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "11::getMapFilterFromData: itBegin > itEnd\n" << std::endl; -#else - sif::printError("11::getMapFilterFromData: itBegin > itEnd\n"); -#endif - return returnvalue::FAILED; - } - // the map range should now be set according to the sent filter. return returnvalue::OK; } From ab719a3e59f25571fba34e28c14d4a8a613394e9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 23:38:55 +0200 Subject: [PATCH 282/532] alternative solution --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 37 +++++++++---------- src/fsfw/devicehandlers/DeviceHandlerBase.h | 6 +-- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 525a3dcc..56d99b71 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -8,6 +8,7 @@ #include "fsfw/ipc/MessageQueueMessage.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serialize/SerialBufferAdapter.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/subsystem/SubsystemBase.h" @@ -1257,30 +1258,32 @@ ReturnValue_t DeviceHandlerBase::letChildHandleMessage(CommandMessage* message) return returnvalue::FAILED; } -void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t replyId, - bool forceDirectTm) { - if (dataSet == nullptr) { - return; - } +void DeviceHandlerBase::handleDeviceTm(const uint8_t* rawData, size_t rawDataLen, + DeviceCommandId_t replyId, bool forceDirectTm) { + SerialBufferAdapter bufferWrapper(rawData, rawDataLen); + handleDeviceTm(bufferWrapper, replyId, forceDirectTm); +} - DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); +void DeviceHandlerBase::handleDeviceTm(SerializeIF& dataSet, DeviceCommandId_t replyId, + bool forceDirectTm) { + auto iter = deviceReplyMap.find(replyId); if (iter == deviceReplyMap.end()) { triggerEvent(DEVICE_UNKNOWN_REPLY, replyId); return; } - /* Regular replies to a command */ + // Regular replies to a command if (iter->second.command != deviceCommandMap.end()) { MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; if (queueId != NO_COMMANDER) { - /* This may fail, but we'll ignore the fault. */ - actionHelper.reportData(queueId, replyId, dataSet); + // This may fail, but we'll ignore the fault. + actionHelper.reportData(queueId, replyId, &dataSet); } - /* This check should make sure we get any TM but don't get anything doubled. */ + // This check should make sure we get any TM but don't get anything doubled. if (wiretappingMode == TM && (requestedRawTraffic != queueId)) { - DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet); + DeviceTmReportingWrapper wrapper(getObjectId(), replyId, &dataSet); actionHelper.reportData(requestedRawTraffic, replyId, &wrapper); } @@ -1289,22 +1292,16 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t r // hiding of sender needed so the service will handle it as // unexpected Data, no matter what state (progress or completed) // it is in - actionHelper.reportData(defaultRawReceiver, replyId, dataSet, true); + actionHelper.reportData(defaultRawReceiver, replyId, &dataSet, true); } } - /* Unrequested or aperiodic replies */ + // Unrequested or aperiodic replies else { - DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet); + DeviceTmReportingWrapper wrapper(getObjectId(), replyId, &dataSet); if (wiretappingMode == TM) { actionHelper.reportData(requestedRawTraffic, replyId, &wrapper); } if (forceDirectTm and defaultRawReceiver != MessageQueueIF::NO_QUEUE) { - // sid_t setSid = sid_t(this->getObjectId(), replyId); - // LocalPoolDataSetBase* dataset = getDataSetHandle(setSid); - // if(dataset != nullptr) { - // poolManager.generateHousekeepingPacket(setSid, dataset, true); - // } - // hiding of sender needed so the service will handle it as // unexpected Data, no matter what state (progress or completed) // it is in diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index a20eae0c..f98d70f3 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -1052,9 +1052,9 @@ class DeviceHandlerBase : public DeviceHandlerIF, bool isAwaitingReply(); - void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId, bool forceDirectTm = false); - // void handleDeviceTM(uint8_t* data, size_t dataSize, DeviceCommandId_t replyId, - // bool forceDirectTm); + void handleDeviceTm(const uint8_t *rawData, size_t rawDataLen, DeviceCommandId_t replyId, + bool forceDirectTm = false); + void handleDeviceTm(SerializeIF &dataSet, DeviceCommandId_t replyId, bool forceDirectTm = false); virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode); From 158007fa7f9cc0b8cf63acecba4d3ca8b5284557 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 Aug 2022 00:02:25 +0200 Subject: [PATCH 283/532] const correct API --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 11 ++++++----- src/fsfw/devicehandlers/DeviceHandlerBase.h | 3 ++- .../DeviceTmReportingWrapper.cpp | 18 +++++------------- .../devicehandlers/DeviceTmReportingWrapper.h | 19 ++++++++++--------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 56d99b71..b0d14380 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1264,7 +1264,7 @@ void DeviceHandlerBase::handleDeviceTm(const uint8_t* rawData, size_t rawDataLen handleDeviceTm(bufferWrapper, replyId, forceDirectTm); } -void DeviceHandlerBase::handleDeviceTm(SerializeIF& dataSet, DeviceCommandId_t replyId, +void DeviceHandlerBase::handleDeviceTm(const SerializeIF& dataSet, DeviceCommandId_t replyId, bool forceDirectTm) { auto iter = deviceReplyMap.find(replyId); if (iter == deviceReplyMap.end()) { @@ -1278,12 +1278,12 @@ void DeviceHandlerBase::handleDeviceTm(SerializeIF& dataSet, DeviceCommandId_t r if (queueId != NO_COMMANDER) { // This may fail, but we'll ignore the fault. - actionHelper.reportData(queueId, replyId, &dataSet); + actionHelper.reportData(queueId, replyId, const_cast(&dataSet)); } // This check should make sure we get any TM but don't get anything doubled. if (wiretappingMode == TM && (requestedRawTraffic != queueId)) { - DeviceTmReportingWrapper wrapper(getObjectId(), replyId, &dataSet); + DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet); actionHelper.reportData(requestedRawTraffic, replyId, &wrapper); } @@ -1292,12 +1292,13 @@ void DeviceHandlerBase::handleDeviceTm(SerializeIF& dataSet, DeviceCommandId_t r // hiding of sender needed so the service will handle it as // unexpected Data, no matter what state (progress or completed) // it is in - actionHelper.reportData(defaultRawReceiver, replyId, &dataSet, true); + actionHelper.reportData(defaultRawReceiver, replyId, const_cast(&dataSet), + true); } } // Unrequested or aperiodic replies else { - DeviceTmReportingWrapper wrapper(getObjectId(), replyId, &dataSet); + DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet); if (wiretappingMode == TM) { actionHelper.reportData(requestedRawTraffic, replyId, &wrapper); } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index f98d70f3..ff1c7dc1 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -1054,7 +1054,8 @@ class DeviceHandlerBase : public DeviceHandlerIF, void handleDeviceTm(const uint8_t *rawData, size_t rawDataLen, DeviceCommandId_t replyId, bool forceDirectTm = false); - void handleDeviceTm(SerializeIF &dataSet, DeviceCommandId_t replyId, bool forceDirectTm = false); + void handleDeviceTm(const SerializeIF &dataSet, DeviceCommandId_t replyId, + bool forceDirectTm = false); virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode); diff --git a/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp b/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp index dc987e6d..8fc0d368 100644 --- a/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp +++ b/src/fsfw/devicehandlers/DeviceTmReportingWrapper.cpp @@ -3,10 +3,10 @@ #include "fsfw/serialize/SerializeAdapter.h" DeviceTmReportingWrapper::DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, - SerializeIF* data) + const SerializeIF& data) : objectId(objectId), actionId(actionId), data(data) {} -DeviceTmReportingWrapper::~DeviceTmReportingWrapper() {} +DeviceTmReportingWrapper::~DeviceTmReportingWrapper() = default; ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { @@ -19,22 +19,14 @@ ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size if (result != returnvalue::OK) { return result; } - return data->serialize(buffer, size, maxSize, streamEndianness); + return data.serialize(buffer, size, maxSize, streamEndianness); } size_t DeviceTmReportingWrapper::getSerializedSize() const { - return sizeof(objectId) + sizeof(ActionId_t) + data->getSerializedSize(); + return sizeof(objectId) + sizeof(ActionId_t) + data.getSerializedSize(); } ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { - ReturnValue_t result = SerializeAdapter::deSerialize(&objectId, buffer, size, streamEndianness); - if (result != returnvalue::OK) { - return result; - } - result = SerializeAdapter::deSerialize(&actionId, buffer, size, streamEndianness); - if (result != returnvalue::OK) { - return result; - } - return data->deSerialize(buffer, size, streamEndianness); + return returnvalue::FAILED; } diff --git a/src/fsfw/devicehandlers/DeviceTmReportingWrapper.h b/src/fsfw/devicehandlers/DeviceTmReportingWrapper.h index 71c64453..ae385f4c 100644 --- a/src/fsfw/devicehandlers/DeviceTmReportingWrapper.h +++ b/src/fsfw/devicehandlers/DeviceTmReportingWrapper.h @@ -7,21 +7,22 @@ class DeviceTmReportingWrapper : public SerializeIF { public: - DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, SerializeIF* data); - virtual ~DeviceTmReportingWrapper(); + DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, const SerializeIF& data); + ~DeviceTmReportingWrapper() 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; - - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) override; + [[nodiscard]] size_t getSerializedSize() const override; private: object_id_t objectId; ActionId_t actionId; - SerializeIF* data; + const SerializeIF& data; + + // Deserialization forbidden + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override; }; #endif /* FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_ */ From 0de7b66218959595826cd8962171167908c6fd87 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 Aug 2022 13:26:44 +0200 Subject: [PATCH 284/532] new retval for permission errors --- src/fsfw/cfdp/handler/mib.h | 10 +++++----- src/fsfw/filesystem/HasFileSystemIF.h | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/fsfw/cfdp/handler/mib.h b/src/fsfw/cfdp/handler/mib.h index 7ba15cd3..11f403dd 100644 --- a/src/fsfw/cfdp/handler/mib.h +++ b/src/fsfw/cfdp/handler/mib.h @@ -28,11 +28,11 @@ struct LocalEntityCfg { struct RemoteEntityCfg { EntityId remoteId; - size_t maxFileSegmentLen; - bool closureRequested; - bool crcOnTransmission; - TransmissionModes defaultTransmissionMode; - ChecksumType defaultChecksum; + size_t maxFileSegmentLen = 2048; + bool closureRequested = false; + bool crcOnTransmission = false; + TransmissionModes defaultTransmissionMode = TransmissionModes::UNACKNOWLEDGED; + ChecksumType defaultChecksum = ChecksumType::NULL_CHECKSUM; const uint8_t version = CFDP_VERSION_2; }; diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index e7e2a529..f206d53c 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -47,20 +47,21 @@ class HasFileSystemIF { //! [EXPORT] : Invalid parameters like file name or repository path static constexpr ReturnValue_t INVALID_PARAMETERS = MAKE_RETURN_CODE(5); - static constexpr ReturnValue_t FILE_DOES_NOT_EXIST = MAKE_RETURN_CODE(7); - static constexpr ReturnValue_t FILE_ALREADY_EXISTS = MAKE_RETURN_CODE(8); - static constexpr ReturnValue_t NOT_A_FILE = MAKE_RETURN_CODE(9); - static constexpr ReturnValue_t FILE_LOCKED = MAKE_RETURN_CODE(10); + static constexpr ReturnValue_t FILE_DOES_NOT_EXIST = MAKE_RETURN_CODE(10); + static constexpr ReturnValue_t FILE_ALREADY_EXISTS = MAKE_RETURN_CODE(11); + static constexpr ReturnValue_t NOT_A_FILE = MAKE_RETURN_CODE(12); + static constexpr ReturnValue_t FILE_LOCKED = MAKE_RETURN_CODE(13); + static constexpr ReturnValue_t PERMISSION_DENIED = MAKE_RETURN_CODE(14); - static constexpr ReturnValue_t DIRECTORY_DOES_NOT_EXIST = MAKE_RETURN_CODE(15); - static constexpr ReturnValue_t DIRECTORY_ALREADY_EXISTS = MAKE_RETURN_CODE(16); - static constexpr ReturnValue_t NOT_A_DIRECTORY = MAKE_RETURN_CODE(17); - static constexpr ReturnValue_t DIRECTORY_NOT_EMPTY = MAKE_RETURN_CODE(18); + static constexpr ReturnValue_t DIRECTORY_DOES_NOT_EXIST = MAKE_RETURN_CODE(21); + static constexpr ReturnValue_t DIRECTORY_ALREADY_EXISTS = MAKE_RETURN_CODE(22); + static constexpr ReturnValue_t NOT_A_DIRECTORY = MAKE_RETURN_CODE(23); + static constexpr ReturnValue_t DIRECTORY_NOT_EMPTY = MAKE_RETURN_CODE(24); //! [EXPORT] : P1: Sequence number missing - static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_WRITE = MAKE_RETURN_CODE(15); + static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_WRITE = MAKE_RETURN_CODE(30); //! [EXPORT] : P1: Sequence number missing - static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_READ = MAKE_RETURN_CODE(16); + static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING_READ = MAKE_RETURN_CODE(31); virtual ~HasFileSystemIF() = default; From 7345c18b0439e27169a02e4a1ce98f6837175635 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 Aug 2022 16:26:18 +0200 Subject: [PATCH 285/532] small fix which allows sending action reply immediately --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 525a3dcc..c4ce7781 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1320,18 +1320,22 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueue return result; } DeviceCommandMap::iterator iter = deviceCommandMap.find(actionId); + MessageQueueId_t prevRecipient = MessageQueueIF::NO_QUEUE; if (iter == deviceCommandMap.end()) { result = COMMAND_NOT_SUPPORTED; } else if (iter->second.isExecuting) { result = COMMAND_ALREADY_SENT; } else { + prevRecipient = iter->second.sendReplyTo; + iter->second.sendReplyTo = commandedBy; result = buildCommandFromCommand(actionId, data, size); } if (result == returnvalue::OK) { - iter->second.sendReplyTo = commandedBy; iter->second.isExecuting = true; cookieInfo.pendingCommand = iter; cookieInfo.state = COOKIE_WRITE_READY; + } else { + iter->second.sendReplyTo = prevRecipient; } return result; } From 28ecd0e5c6304a91bae9840159d200ed8361e68a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 08:51:12 +0200 Subject: [PATCH 286/532] bugfix for SP parser --- src/fsfw/osal/common/TcpTmTcServer.cpp | 19 ++++----- src/fsfw/tmtcservices/SpacePacketParser.cpp | 45 +++++++++++---------- src/fsfw/tmtcservices/SpacePacketParser.h | 18 +++++++-- 3 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/fsfw/osal/common/TcpTmTcServer.cpp b/src/fsfw/osal/common/TcpTmTcServer.cpp index f9cb923e..f1174734 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.cpp +++ b/src/fsfw/osal/common/TcpTmTcServer.cpp @@ -161,7 +161,7 @@ void TcpTmTcServer::handleServerOperation(socket_t& connSocket) { while (true) { ssize_t retval = recv(connSocket, reinterpret_cast(receptionBuffer.data()), - receptionBuffer.capacity(), tcpConfig.tcpFlags); + receptionBuffer.size(), tcpConfig.tcpFlags); if (retval == 0) { size_t availableReadData = ringBuffer.getAvailableReadData(); if (availableReadData > lastRingBufferSize) { @@ -335,31 +335,28 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { } ringBuffer.readData(receptionBuffer.data(), readAmount, true); const uint8_t* bufPtr = receptionBuffer.data(); - const uint8_t** bufPtrPtr = &bufPtr; - size_t startIdx = 0; - size_t foundSize = 0; - size_t readLen = 0; - while (readLen < readAmount) { + FoundPacketInfo info; + ParsingState parseState; + while (parseState.amountRead < readAmount) { if (spacePacketParser == nullptr) { return returnvalue::FAILED; } - result = - spacePacketParser->parseSpacePackets(bufPtrPtr, readAmount, startIdx, foundSize, readLen); + result = spacePacketParser->parseSpacePackets(&bufPtr, readAmount, info, parseState); switch (result) { case (SpacePacketParser::NO_PACKET_FOUND): case (SpacePacketParser::SPLIT_PACKET): { break; } case (returnvalue::OK): { - result = handleTcReception(receptionBuffer.data() + startIdx, foundSize); + result = handleTcReception(receptionBuffer.data() + info.startIdx, info.sizeFound); if (result != returnvalue::OK) { status = result; } } } - ringBuffer.deleteData(foundSize); + ringBuffer.deleteData(info.sizeFound); lastRingBufferSize = ringBuffer.getAvailableReadData(); - std::memset(receptionBuffer.data() + startIdx, 0, foundSize); + // std::memset(receptionBuffer.data() + startIdx, 0, foundSize); } return status; } diff --git a/src/fsfw/tmtcservices/SpacePacketParser.cpp b/src/fsfw/tmtcservices/SpacePacketParser.cpp index b8364138..16ee5dac 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.cpp +++ b/src/fsfw/tmtcservices/SpacePacketParser.cpp @@ -7,16 +7,16 @@ SpacePacketParser::SpacePacketParser(std::vector validPacketIds) : validPacketIds(validPacketIds) {} ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t* buffer, const size_t maxSize, - size_t& startIndex, size_t& foundSize) { + FoundPacketInfo& packetInfo, + ParsingState& parsingState) { const uint8_t** tempPtr = &buffer; - size_t readLen = 0; - return parseSpacePackets(tempPtr, maxSize, startIndex, foundSize, readLen); + return parseSpacePackets(tempPtr, maxSize, packetInfo, parsingState); } ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const size_t maxSize, - size_t& startIndex, size_t& foundSize, - size_t& readLen) { - if (buffer == nullptr or maxSize < 5) { + FoundPacketInfo& packetInfo, + ParsingState& parsingState) { + if (buffer == nullptr or parsingState.nextStartIdx > maxSize) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "SpacePacketParser::parseSpacePackets: Frame invalid" << std::endl; #else @@ -26,35 +26,36 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const } const uint8_t* bufPtr = *buffer; - auto verifyLengthField = [&](size_t idx) { - uint16_t lengthField = bufPtr[idx + 4] << 8 | bufPtr[idx + 5]; + auto verifyLengthField = [&](size_t localIdx) { + uint16_t lengthField = (bufPtr[localIdx + 4] << 8) | bufPtr[localIdx + 5]; size_t packetSize = lengthField + 7; - startIndex = idx; ReturnValue_t result = returnvalue::OK; if (lengthField == 0) { // Skip whole header for now - foundSize = 6; + packetInfo.sizeFound = 6; result = NO_PACKET_FOUND; - } else if (packetSize + idx > maxSize) { + } else if (packetSize + localIdx + parsingState.amountRead > maxSize) { // Don't increment buffer and read length here, user has to decide what to do - foundSize = packetSize; + packetInfo.sizeFound = packetSize; return SPLIT_PACKET; } else { - foundSize = packetSize; + packetInfo.sizeFound = packetSize; } - *buffer += foundSize; - readLen += idx + foundSize; + *buffer += packetInfo.sizeFound; + packetInfo.startIdx = localIdx + parsingState.amountRead; + parsingState.nextStartIdx = localIdx + parsingState.amountRead + packetInfo.sizeFound; + parsingState.amountRead = parsingState.nextStartIdx; return result; }; size_t idx = 0; // Space packet ID as start marker if (validPacketIds.size() > 0) { - while (idx < maxSize - 5) { - uint16_t currentPacketId = bufPtr[idx] << 8 | bufPtr[idx + 1]; + while (idx + parsingState.amountRead < maxSize - 5) { + uint16_t currentPacketId = (bufPtr[idx] << 8) | bufPtr[idx + 1]; if (std::find(validPacketIds.begin(), validPacketIds.end(), currentPacketId) != validPacketIds.end()) { - if (idx + 5 >= maxSize) { + if (idx + parsingState.amountRead >= maxSize - 5) { return SPLIT_PACKET; } return verifyLengthField(idx); @@ -62,10 +63,10 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const idx++; } } - startIndex = 0; - foundSize = maxSize; - *buffer += foundSize; - readLen += foundSize; + parsingState.nextStartIdx = maxSize; + packetInfo.sizeFound = maxSize; + parsingState.amountRead = maxSize; + *buffer += maxSize; return NO_PACKET_FOUND; } // Assume that the user verified a valid start of a space packet diff --git a/src/fsfw/tmtcservices/SpacePacketParser.h b/src/fsfw/tmtcservices/SpacePacketParser.h index 93f90afe..394083b2 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.h +++ b/src/fsfw/tmtcservices/SpacePacketParser.h @@ -7,6 +7,16 @@ #include "fsfw/container/DynamicFIFO.h" #include "fsfw/returnvalues/FwClassIds.h" +struct FoundPacketInfo { + size_t startIdx = 0; + size_t sizeFound = 0; +}; + +struct ParsingState { + size_t nextStartIdx = 0; + size_t amountRead = 0; +}; + /** * @brief This small helper class scans a given buffer for space packets. * Can be used if space packets are serialized in a tightly packed frame. @@ -53,8 +63,8 @@ class SpacePacketParser { * will be assigned. * -@c returnvalue::OK if a packet was found */ - ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, size_t& startIndex, - size_t& foundSize, size_t& readLen); + ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, + FoundPacketInfo& packetInfo, ParsingState& parsingState); /** * Parse a given frame for space packets @@ -69,8 +79,8 @@ class SpacePacketParser { * detected packet * -@c returnvalue::OK if a packet was found */ - ReturnValue_t parseSpacePackets(const uint8_t* buffer, const size_t maxSize, size_t& startIndex, - size_t& foundSize); + ReturnValue_t parseSpacePackets(const uint8_t* buffer, const size_t maxSize, + FoundPacketInfo& packetInfo, ParsingState& parsingState); private: std::vector validPacketIds; From 7ae82a5cb4287e70ff13ef8da3f9264096c1879e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 08:58:18 +0200 Subject: [PATCH 287/532] do not cache previous recipient --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index c4ce7781..efb535a5 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1320,13 +1320,11 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueue return result; } DeviceCommandMap::iterator iter = deviceCommandMap.find(actionId); - MessageQueueId_t prevRecipient = MessageQueueIF::NO_QUEUE; if (iter == deviceCommandMap.end()) { result = COMMAND_NOT_SUPPORTED; } else if (iter->second.isExecuting) { result = COMMAND_ALREADY_SENT; } else { - prevRecipient = iter->second.sendReplyTo; iter->second.sendReplyTo = commandedBy; result = buildCommandFromCommand(actionId, data, size); } @@ -1334,8 +1332,6 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueue iter->second.isExecuting = true; cookieInfo.pendingCommand = iter; cookieInfo.state = COOKIE_WRITE_READY; - } else { - iter->second.sendReplyTo = prevRecipient; } return result; } From 7d3223d766bcd2b0a693885f9db899d8bd1a841a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 10:44:57 +0200 Subject: [PATCH 288/532] add comment blocks --- src/fsfw/devicehandlers/DeviceHandlerBase.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index ff1c7dc1..792e70ad 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -1052,8 +1052,23 @@ class DeviceHandlerBase : public DeviceHandlerIF, bool isAwaitingReply(); + /** + * Wrapper function for @handleDeviceTm which wraps the raw buffer with @SerialBufferAdapter. + * For interpreted data, prefer the other function. + * @param rawData + * @param rawDataLen + * @param replyId + * @param forceDirectTm + */ void handleDeviceTm(const uint8_t *rawData, size_t rawDataLen, DeviceCommandId_t replyId, bool forceDirectTm = false); + /** + * Can be used to handle Service 8 replies. This will also generate the TM wiretapping + * packets accordingly. + * @param dataSet + * @param replyId + * @param forceDirectTm + */ void handleDeviceTm(const SerializeIF &dataSet, DeviceCommandId_t replyId, bool forceDirectTm = false); From c7f300671fd708cbea51393d24857597f964c24b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 10:45:10 +0200 Subject: [PATCH 289/532] update header --- src/fsfw/devicehandlers/DeviceHandlerBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 792e70ad..700e960d 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -1063,7 +1063,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, void handleDeviceTm(const uint8_t *rawData, size_t rawDataLen, DeviceCommandId_t replyId, bool forceDirectTm = false); /** - * Can be used to handle Service 8 replies. This will also generate the TM wiretapping + * Can be used to handle Service 8 data replies. This will also generate the TM wiretapping * packets accordingly. * @param dataSet * @param replyId From 01651f0521d851402426fd6dca4b449e103b3d4d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 10:51:09 +0200 Subject: [PATCH 290/532] more simplfications --- src/fsfw/osal/common/TcpTmTcServer.cpp | 15 +++-- src/fsfw/tmtcservices/SpacePacketParser.cpp | 32 ++++------ src/fsfw/tmtcservices/SpacePacketParser.h | 66 +++++++-------------- 3 files changed, 40 insertions(+), 73 deletions(-) diff --git a/src/fsfw/osal/common/TcpTmTcServer.cpp b/src/fsfw/osal/common/TcpTmTcServer.cpp index f1174734..dff959ba 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.cpp +++ b/src/fsfw/osal/common/TcpTmTcServer.cpp @@ -335,13 +335,13 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { } ringBuffer.readData(receptionBuffer.data(), readAmount, true); const uint8_t* bufPtr = receptionBuffer.data(); - FoundPacketInfo info; - ParsingState parseState; - while (parseState.amountRead < readAmount) { - if (spacePacketParser == nullptr) { - return returnvalue::FAILED; - } - result = spacePacketParser->parseSpacePackets(&bufPtr, readAmount, info, parseState); + SpacePacketParser::FoundPacketInfo info; + if (spacePacketParser == nullptr) { + return returnvalue::FAILED; + } + spacePacketParser->reset(); + while (spacePacketParser->getAmountRead() < readAmount) { + result = spacePacketParser->parseSpacePackets(&bufPtr, readAmount, info); switch (result) { case (SpacePacketParser::NO_PACKET_FOUND): case (SpacePacketParser::SPLIT_PACKET): { @@ -356,7 +356,6 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) { } ringBuffer.deleteData(info.sizeFound); lastRingBufferSize = ringBuffer.getAvailableReadData(); - // std::memset(receptionBuffer.data() + startIdx, 0, foundSize); } return status; } diff --git a/src/fsfw/tmtcservices/SpacePacketParser.cpp b/src/fsfw/tmtcservices/SpacePacketParser.cpp index 16ee5dac..75db7a4e 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.cpp +++ b/src/fsfw/tmtcservices/SpacePacketParser.cpp @@ -6,17 +6,9 @@ SpacePacketParser::SpacePacketParser(std::vector validPacketIds) : validPacketIds(validPacketIds) {} -ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t* buffer, const size_t maxSize, - FoundPacketInfo& packetInfo, - ParsingState& parsingState) { - const uint8_t** tempPtr = &buffer; - return parseSpacePackets(tempPtr, maxSize, packetInfo, parsingState); -} - ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const size_t maxSize, - FoundPacketInfo& packetInfo, - ParsingState& parsingState) { - if (buffer == nullptr or parsingState.nextStartIdx > maxSize) { + FoundPacketInfo& packetInfo) { + if (buffer == nullptr or nextStartIdx > maxSize) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "SpacePacketParser::parseSpacePackets: Frame invalid" << std::endl; #else @@ -30,11 +22,7 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const uint16_t lengthField = (bufPtr[localIdx + 4] << 8) | bufPtr[localIdx + 5]; size_t packetSize = lengthField + 7; ReturnValue_t result = returnvalue::OK; - if (lengthField == 0) { - // Skip whole header for now - packetInfo.sizeFound = 6; - result = NO_PACKET_FOUND; - } else if (packetSize + localIdx + parsingState.amountRead > maxSize) { + if (packetSize + localIdx + amountRead > maxSize) { // Don't increment buffer and read length here, user has to decide what to do packetInfo.sizeFound = packetSize; return SPLIT_PACKET; @@ -42,20 +30,20 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const packetInfo.sizeFound = packetSize; } *buffer += packetInfo.sizeFound; - packetInfo.startIdx = localIdx + parsingState.amountRead; - parsingState.nextStartIdx = localIdx + parsingState.amountRead + packetInfo.sizeFound; - parsingState.amountRead = parsingState.nextStartIdx; + packetInfo.startIdx = localIdx + amountRead; + nextStartIdx = localIdx + amountRead + packetInfo.sizeFound; + amountRead = nextStartIdx; return result; }; size_t idx = 0; // Space packet ID as start marker if (validPacketIds.size() > 0) { - while (idx + parsingState.amountRead < maxSize - 5) { + while (idx + amountRead < maxSize - 5) { uint16_t currentPacketId = (bufPtr[idx] << 8) | bufPtr[idx + 1]; if (std::find(validPacketIds.begin(), validPacketIds.end(), currentPacketId) != validPacketIds.end()) { - if (idx + parsingState.amountRead >= maxSize - 5) { + if (idx + amountRead >= maxSize - 5) { return SPLIT_PACKET; } return verifyLengthField(idx); @@ -63,9 +51,9 @@ ReturnValue_t SpacePacketParser::parseSpacePackets(const uint8_t** buffer, const idx++; } } - parsingState.nextStartIdx = maxSize; + nextStartIdx = maxSize; packetInfo.sizeFound = maxSize; - parsingState.amountRead = maxSize; + amountRead = maxSize; *buffer += maxSize; return NO_PACKET_FOUND; } diff --git a/src/fsfw/tmtcservices/SpacePacketParser.h b/src/fsfw/tmtcservices/SpacePacketParser.h index 394083b2..3a1b4d16 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.h +++ b/src/fsfw/tmtcservices/SpacePacketParser.h @@ -7,16 +7,6 @@ #include "fsfw/container/DynamicFIFO.h" #include "fsfw/returnvalues/FwClassIds.h" -struct FoundPacketInfo { - size_t startIdx = 0; - size_t sizeFound = 0; -}; - -struct ParsingState { - size_t nextStartIdx = 0; - size_t amountRead = 0; -}; - /** * @brief This small helper class scans a given buffer for space packets. * Can be used if space packets are serialized in a tightly packed frame. @@ -27,9 +17,11 @@ struct ParsingState { */ class SpacePacketParser { public: - //! The first entry is the index inside the buffer while the second index - //! is the size of the PUS packet starting at that index. - using IndexSizePair = std::pair; + + struct FoundPacketInfo { + size_t startIdx = 0; + size_t sizeFound = 0; + }; static constexpr uint8_t INTERFACE_ID = CLASS_ID::SPACE_PACKET_PARSER; static constexpr ReturnValue_t NO_PACKET_FOUND = MAKE_RETURN_CODE(0x00); @@ -46,44 +38,32 @@ class SpacePacketParser { SpacePacketParser(std::vector validPacketIds); /** - * Parse a given frame for space packets but also increment the given buffer and assign the - * total number of bytes read so far + * Parse a given frame for space packets but also increments the given buffer. * @param buffer Parser will look for space packets in this buffer * @param maxSize Maximum size of the buffer - * @param startIndex Start index of a found space packet - * @param foundSize Found size of the space packet - * @param readLen Length read so far. This value is incremented by the number of parsed - * bytes which also includes the size of a found packet - * -@c NO_PACKET_FOUND if no packet was found in the given buffer or the length field is - * invalid. foundSize will be set to the size of the space packet header. buffer and - * readLen will be incremented accordingly. - * -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. foundSize - * will be set to the detected packet size and startIndex will be set to the start of the - * detected packet. buffer and read length will not be incremented but the found length - * will be assigned. - * -@c returnvalue::OK if a packet was found + * @param packetInfo Information about packets found. + * -@c NO_PACKET_FOUND if no packet was found in the given buffer + * -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. packetInfo + * will contain the detected packet size and start index. + * -@c returnvalue::OK if a packet was found. Packet size and start index will be set in + * packetInfo */ ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, - FoundPacketInfo& packetInfo, ParsingState& parsingState); + FoundPacketInfo& packetInfo); - /** - * Parse a given frame for space packets - * @param buffer Parser will look for space packets in this buffer - * @param maxSize Maximum size of the buffer - * @param startIndex Start index of a found space packet - * @param foundSize Found size of the space packet - * -@c NO_PACKET_FOUND if no packet was found in the given buffer or the length field is - * invalid. foundSize will be set to the size of the space packet header - * -@c SPLIT_PACKET if a packet was found but the detected size exceeds maxSize. foundSize - * will be set to the detected packet size and startIndex will be set to the start of the - * detected packet - * -@c returnvalue::OK if a packet was found - */ - ReturnValue_t parseSpacePackets(const uint8_t* buffer, const size_t maxSize, - FoundPacketInfo& packetInfo, ParsingState& parsingState); + size_t getAmountRead() { + return amountRead; + } + + void reset() { + nextStartIdx = 0; + amountRead = 0; + } private: std::vector validPacketIds; + size_t nextStartIdx = 0; + size_t amountRead = 0; }; #endif /* FRAMEWORK_TMTCSERVICES_PUSPARSER_H_ */ From 2b01e86f9c7b56d036b7bab0404a10db90bd0d76 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 1 Sep 2022 11:56:07 +0200 Subject: [PATCH 291/532] one small additional precaution --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 4 +++- unittests/CMakeLists.txt | 1 + unittests/pus/CMakeLists.txt | 3 +++ unittests/pus/testService11.cpp | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 unittests/pus/CMakeLists.txt create mode 100644 unittests/pus/testService11.cpp diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 3cf24b11..c82c1703 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -575,11 +575,13 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr return INVALID_TIME_WINDOW; } itBegin = telecommandMap.begin(); - itEnd = telecommandMap.begin(); while (itBegin->first < fromTimestamp && itBegin != telecommandMap.end()) { itBegin++; } + + //start looking for end beginning at begin + itEnd = itBegin; while (itEnd->first <= toTimestamp && itEnd != telecommandMap.end()) { itEnd++; } diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 8c7f2463..d7c35975 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -18,6 +18,7 @@ add_subdirectory(power) add_subdirectory(util) add_subdirectory(container) add_subdirectory(osal) +add_subdirectory(pus) add_subdirectory(serialize) add_subdirectory(datapoollocal) add_subdirectory(storagemanager) diff --git a/unittests/pus/CMakeLists.txt b/unittests/pus/CMakeLists.txt new file mode 100644 index 00000000..ecd7fb49 --- /dev/null +++ b/unittests/pus/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE + testService11.cpp +) diff --git a/unittests/pus/testService11.cpp b/unittests/pus/testService11.cpp new file mode 100644 index 00000000..72708f09 --- /dev/null +++ b/unittests/pus/testService11.cpp @@ -0,0 +1,14 @@ +#include + +#include + +#include "objects/systemObjectList.h" +#include "tmtc/apid.h" +#include "tmtc/pusIds.h" + +TEST_CASE("PUS Service 11", "[pus-srvc11]") { + Service11TelecommandScheduling<13> pusService11(objects::PUS_SERVICE_11_TC_SCHEDULER, + apid::DEFAULT_APID, pus::PUS_SERVICE_11, nullptr); + + // TODO test something... +} \ No newline at end of file From 04bff7a522adf8faaae5137bf3c3b0c54a031502 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Sep 2022 17:51:09 +0200 Subject: [PATCH 292/532] test fix --- unittests/pus/testService11.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unittests/pus/testService11.cpp b/unittests/pus/testService11.cpp index 72708f09..54279543 100644 --- a/unittests/pus/testService11.cpp +++ b/unittests/pus/testService11.cpp @@ -7,8 +7,8 @@ #include "tmtc/pusIds.h" TEST_CASE("PUS Service 11", "[pus-srvc11]") { - Service11TelecommandScheduling<13> pusService11(objects::PUS_SERVICE_11_TC_SCHEDULER, - apid::DEFAULT_APID, pus::PUS_SERVICE_11, nullptr); + Service11TelecommandScheduling<13> pusService11({objects::PUS_SERVICE_11_TC_SCHEDULER, + apid::DEFAULT_APID, pus::PUS_SERVICE_11}, nullptr); // TODO test something... } \ No newline at end of file From ebc02673ddc269f1cfdb98e061dc72c33783d3a6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 08:50:39 +0200 Subject: [PATCH 293/532] 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 f1cfec52..1cd9c678 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 00000000..6e02c1df --- /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 294/532] 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 ecab0493..e48736bf 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 4f9fc092..8396cbbf 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 295/532] 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 3250a739..3626a2b0 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 80355910ee6260496fdfc196230c603c0d654582 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 09:05:10 +0200 Subject: [PATCH 296/532] better warning --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5351aeb4..7b00a708 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -360,7 +360,7 @@ if(NOT FSFW_CONFIG_PATH) if(NOT FSFW_BUILD_DOCS) message( WARNING - "${MSG_PREFIX} Flight Software Framework configuration 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} ..") From db84dcd3ce04bff9af952a693640a6722ed4b2d5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 11:12:16 +0200 Subject: [PATCH 297/532] afmt --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 4 ++-- src/fsfw/tmtcservices/SpacePacketParser.h | 5 +---- unittests/datapoollocal/CMakeLists.txt | 9 +++------ unittests/pus/CMakeLists.txt | 4 +--- unittests/pus/testService11.cpp | 4 ++-- 5 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index aa096855..9016af80 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -566,7 +566,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(); @@ -575,7 +575,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/tmtcservices/SpacePacketParser.h b/src/fsfw/tmtcservices/SpacePacketParser.h index 3a1b4d16..ea0a2feb 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/datapoollocal/CMakeLists.txt b/unittests/datapoollocal/CMakeLists.txt index 016645fd..2c7a573f 100644 --- a/unittests/datapoollocal/CMakeLists.txt +++ b/unittests/datapoollocal/CMakeLists.txt @@ -1,6 +1,3 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testLocalPoolVariable.cpp - testLocalPoolVector.cpp - testDataSet.cpp - testLocalPoolManager.cpp -) +target_sources( + ${FSFW_TEST_TGT} PRIVATE testLocalPoolVariable.cpp testLocalPoolVector.cpp + testDataSet.cpp testLocalPoolManager.cpp) diff --git a/unittests/pus/CMakeLists.txt b/unittests/pus/CMakeLists.txt index ecd7fb49..7f615a50 100644 --- a/unittests/pus/CMakeLists.txt +++ b/unittests/pus/CMakeLists.txt @@ -1,3 +1 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testService11.cpp -) +target_sources(${FSFW_TEST_TGT} PRIVATE testService11.cpp) diff --git a/unittests/pus/testService11.cpp b/unittests/pus/testService11.cpp index 54279543..bd3b22ad 100644 --- a/unittests/pus/testService11.cpp +++ b/unittests/pus/testService11.cpp @@ -7,8 +7,8 @@ #include "tmtc/pusIds.h" TEST_CASE("PUS Service 11", "[pus-srvc11]") { - Service11TelecommandScheduling<13> pusService11({objects::PUS_SERVICE_11_TC_SCHEDULER, - apid::DEFAULT_APID, pus::PUS_SERVICE_11}, nullptr); + Service11TelecommandScheduling<13> pusService11( + {objects::PUS_SERVICE_11_TC_SCHEDULER, apid::DEFAULT_APID, pus::PUS_SERVICE_11}, nullptr); // TODO test something... } \ No newline at end of file From dc79b7ba00ba568e25f0c18f68ea3928149c9ce2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 11:38:46 +0200 Subject: [PATCH 298/532] delete metadata after processing --- src/fsfw/cfdp/handler/DestHandler.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 7271c19c..e7d14db0 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -21,13 +21,15 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { if (step == TransactionStep::IDLE) { ReturnValue_t status = returnvalue::OK; ReturnValue_t result; - for (const auto& info : dp.packetListRef) { - if (info.pduType == PduType::FILE_DIRECTIVE and - info.directiveType == FileDirectives::METADATA) { - result = handleMetadataPdu(info); + for(auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { + if (infoIter->pduType == PduType::FILE_DIRECTIVE and + infoIter->directiveType == FileDirectives::METADATA) { + result = handleMetadataPdu(*infoIter); if (result != OK) { status = result; } + fp.tcStore->deleteData(infoIter->storeId); + dp.packetListRef.erase(infoIter++); } } if (step != TransactionStep::IDLE) { From eae75b29e7966afc0ef11fc2fdc4a0c6d7558bc3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 11:58:16 +0200 Subject: [PATCH 299/532] start file data pdu processing --- src/fsfw/cfdp/handler/DestHandler.cpp | 40 +++++++++++++++++++++++---- src/fsfw/cfdp/handler/DestHandler.h | 1 + src/fsfw/cfdp/pdu/FileDataInfo.h | 14 +++++----- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index e7d14db0..54e3753e 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -2,6 +2,7 @@ #include +#include "fsfw/cfdp/pdu/FileDataReader.h" #include "fsfw/cfdp/pdu/HeaderReader.h" #include "fsfw/objectmanager.h" #include "fsfw/serviceinterface.h" @@ -18,28 +19,41 @@ cfdp::DestHandler::DestHandler(DestHandlerParams params, FsfwParams fsfwParams) } ReturnValue_t cfdp::DestHandler::performStateMachine() { + ReturnValue_t result; + ReturnValue_t status = returnvalue::OK; if (step == TransactionStep::IDLE) { - ReturnValue_t status = returnvalue::OK; - ReturnValue_t result; - for(auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { + for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { if (infoIter->pduType == PduType::FILE_DIRECTIVE and infoIter->directiveType == FileDirectives::METADATA) { result = handleMetadataPdu(*infoIter); if (result != OK) { status = result; } - fp.tcStore->deleteData(infoIter->storeId); + // metadata packet was deleted in metadata handler because a store guard is used dp.packetListRef.erase(infoIter++); } } + if (step == TransactionStep::IDLE) { + // To decrease the already high complexity of the software, all packets arriving before + // a metadata PDU are deleted. + for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { + fp.tcStore->deleteData(infoIter->storeId); + } + dp.packetListRef.clear(); + } + if (step != TransactionStep::IDLE) { return CALL_FSM_AGAIN; } return status; } if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) { - for (const auto& info : dp.packetListRef) { - if (info.pduType == PduType::FILE_DATA) { + for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { + if (infoIter->pduType == PduType::FILE_DATA) { + result = handleFileDataPdu(*infoIter); + if (result != OK) { + status = result; + } } } return returnvalue::OK; @@ -77,6 +91,7 @@ ReturnValue_t cfdp::DestHandler::initialize() { } return returnvalue::OK; } + ReturnValue_t cfdp::DestHandler::handleMetadataPdu(const PacketInfo& info) { // Process metadata PDU auto constAccessorPair = fp.tcStore->getData(info.storeId); @@ -102,6 +117,19 @@ ReturnValue_t cfdp::DestHandler::handleMetadataPdu(const PacketInfo& info) { return startTransaction(reader, metadataInfo); } +ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info) { + // Process file data PDU + auto constAccessorPair = fp.tcStore->getData(info.storeId); + if (constAccessorPair.first != OK) { + // TODO: This is not a CFDP error. Event and/or warning? + cfdp::FileSize offset; + FileDataInfo fdInfo(offset); + FileDataReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), fdInfo); + return constAccessorPair.first; + } + return returnvalue::OK; +} + ReturnValue_t cfdp::DestHandler::handleMetadataParseError(const uint8_t* rawData, size_t maxSize) { // TODO: try to extract destination ID for error // TODO: Invalid metadata PDU. diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 74668638..40bf655c 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -77,6 +77,7 @@ class DestHandler { ReturnValue_t initialize(); ReturnValue_t handleMetadataPdu(const PacketInfo& info); + ReturnValue_t handleFileDataPdu(const PacketInfo& info); ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize); [[nodiscard]] CfdpStates getCfdpState() const; diff --git a/src/fsfw/cfdp/pdu/FileDataInfo.h b/src/fsfw/cfdp/pdu/FileDataInfo.h index 7fd573db..36908d8b 100644 --- a/src/fsfw/cfdp/pdu/FileDataInfo.h +++ b/src/fsfw/cfdp/pdu/FileDataInfo.h @@ -6,25 +6,25 @@ class FileDataInfo { public: - FileDataInfo(cfdp::FileSize& offset); + explicit FileDataInfo(cfdp::FileSize& offset); FileDataInfo(cfdp::FileSize& offset, const uint8_t* fileData, size_t fileSize); - size_t getSerializedSize(bool largeFile = false) const; + [[nodiscard]] size_t getSerializedSize(bool largeFile = false) const; cfdp::FileSize& getOffset(); const uint8_t* getFileData(size_t* fileSize = nullptr) const; void setFileData(const uint8_t* fileData, size_t fileSize); - cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const; - cfdp::SegmentationControl getSegmentationControl() const; - cfdp::RecordContinuationState getRecordContinuationState() const; + [[nodiscard]] cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const; + [[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const; + [[nodiscard]] cfdp::RecordContinuationState getRecordContinuationState() const; void setRecordContinuationState(cfdp::RecordContinuationState recContState); void setSegmentationControl(cfdp::SegmentationControl segCtrl); - size_t getSegmentMetadataLen() const; + [[nodiscard]] size_t getSegmentMetadataLen() const; void setSegmentMetadataLen(size_t len); void setSegmentMetadata(const uint8_t* ptr); - bool hasSegmentMetadata() const; + [[nodiscard]] bool hasSegmentMetadata() const; void setSegmentMetadataFlag(bool enable); ReturnValue_t addSegmentMetadataInfo(cfdp::RecordContinuationState recContState, const uint8_t* segmentMetadata, size_t segmentMetadataLen); From c90d1c8071bf1284393668ada5930180724a4fd7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 14:39:53 +0200 Subject: [PATCH 300/532] continue dest handler impl --- docs/conf.py | 18 ++--- scripts/helper.py | 14 +++- src/fsfw/cfdp/FileSize.h | 16 ++-- src/fsfw/cfdp/handler/DestHandler.cpp | 75 ++++++++++++++++--- src/fsfw/cfdp/handler/DestHandler.h | 11 +-- src/fsfw/cfdp/handler/UserBase.h | 2 + src/fsfw/cfdp/pdu/CMakeLists.txt | 4 +- src/fsfw/cfdp/pdu/EofInfo.h | 8 +- ...EofPduSerializer.cpp => EofPduCreator.cpp} | 15 ++-- .../{EofPduSerializer.h => EofPduCreator.h} | 6 +- ...ofPduDeserializer.cpp => EofPduReader.cpp} | 6 +- .../{EofPduDeserializer.h => EofPduReader.h} | 6 +- src/fsfw/cfdp/pdu/FileDataInfo.cpp | 12 +-- unittests/cfdp/pdu/testEofPdu.cpp | 16 ++-- 14 files changed, 135 insertions(+), 74 deletions(-) rename src/fsfw/cfdp/pdu/{EofPduSerializer.cpp => EofPduCreator.cpp} (71%) rename src/fsfw/cfdp/pdu/{EofPduSerializer.h => EofPduCreator.h} (74%) rename src/fsfw/cfdp/pdu/{EofPduDeserializer.cpp => EofPduReader.cpp} (92%) rename src/fsfw/cfdp/pdu/{EofPduDeserializer.h => EofPduReader.h} (60%) diff --git a/docs/conf.py b/docs/conf.py index 62b17192..a2cb73be 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,12 +17,12 @@ # -- Project information ----------------------------------------------------- -project = 'Flight Software Framework' -copyright = '2021, Institute of Space Systems (IRS)' -author = 'Institute of Space Systems (IRS)' +project = "Flight Software Framework" +copyright = "2021, Institute of Space Systems (IRS)" +author = "Institute of Space Systems (IRS)" # The full version, including alpha/beta/rc tags -release = '2.0.1' +release = "2.0.1" # -- General configuration --------------------------------------------------- @@ -30,17 +30,17 @@ release = '2.0.1' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = [ "breathe" ] +extensions = ["breathe"] breathe_default_project = "fsfw" # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # -- Options for HTML output ------------------------------------------------- @@ -48,9 +48,9 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +html_theme = "alabaster" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = [] \ No newline at end of file +html_static_path = [] diff --git a/scripts/helper.py b/scripts/helper.py index 0ced7186..484e5227 100755 --- a/scripts/helper.py +++ b/scripts/helper.py @@ -51,7 +51,7 @@ def main(): parser.add_argument( "-g", "--generators", - default = "Ninja", + default="Ninja", action="store", help="CMake generators", ) @@ -165,10 +165,18 @@ def create_tests_build_cfg(args): os.mkdir(UNITTEST_FOLDER_NAME) os.chdir(UNITTEST_FOLDER_NAME) if args.windows: - cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON \ + cmake_cmd = ( + 'cmake -G "' + + args.generators + + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON \ -DGCOVR_PATH="py -m gcovr" ..' + ) else: - cmake_cmd = 'cmake -G "' + args.generators + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON ..' + cmake_cmd = ( + 'cmake -G "' + + args.generators + + '" -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON ..' + ) cmd_runner(cmake_cmd) os.chdir("..") diff --git a/src/fsfw/cfdp/FileSize.h b/src/fsfw/cfdp/FileSize.h index 377d08ce..227555e6 100644 --- a/src/fsfw/cfdp/FileSize.h +++ b/src/fsfw/cfdp/FileSize.h @@ -8,10 +8,12 @@ namespace cfdp { struct FileSize : public SerializeIF { public: - FileSize() : largeFile(false){}; + FileSize() = default; explicit FileSize(uint64_t fileSize, bool isLarge = false) { setFileSize(fileSize, isLarge); }; + [[nodiscard]] uint64_t value() const { return fileSize; } + ReturnValue_t serialize(bool isLarge, uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) { this->largeFile = isLarge; @@ -50,20 +52,20 @@ struct FileSize : public SerializeIF { } } - ReturnValue_t setFileSize(uint64_t fileSize, bool largeFile) { + ReturnValue_t setFileSize(uint64_t fileSize_, bool largeFile_) { if (not largeFile and fileSize > UINT32_MAX) { // TODO: emit warning here return returnvalue::FAILED; } - this->fileSize = fileSize; - this->largeFile = largeFile; + this->fileSize = fileSize_; + this->largeFile = largeFile_; return returnvalue::OK; } [[nodiscard]] bool isLargeFile() const { return largeFile; } - uint64_t getSize(bool *largeFile = nullptr) const { - if (largeFile != nullptr) { - *largeFile = this->largeFile; + uint64_t getSize(bool *largeFile_ = nullptr) const { + if (largeFile_ != nullptr) { + *largeFile_ = this->largeFile; } return fileSize; } diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 54e3753e..6aeac040 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -2,10 +2,11 @@ #include +#include "fsfw/FSFW.h" +#include "fsfw/cfdp/pdu/EofPduReader.h" #include "fsfw/cfdp/pdu/FileDataReader.h" #include "fsfw/cfdp/pdu/HeaderReader.h" #include "fsfw/objectmanager.h" -#include "fsfw/serviceinterface.h" using namespace returnvalue; @@ -29,7 +30,7 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { if (result != OK) { status = result; } - // metadata packet was deleted in metadata handler because a store guard is used + // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); } } @@ -54,9 +55,15 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { if (result != OK) { status = result; } + // Store data was deleted in PDU handler because a store guard is used + dp.packetListRef.erase(infoIter++); + } + if (infoIter->pduType == PduType::FILE_DIRECTIVE and + infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) { + result = handleEofPdu(*infoIter); } } - return returnvalue::OK; + return OK; } if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { // TODO: Will be implemented at a later stage @@ -64,32 +71,32 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { sif::warning << "CFDP state machine for acknowledged mode not implemented yet" << std::endl; #endif } - return returnvalue::OK; + return OK; } ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) { if (dp.packetListRef.full()) { - return returnvalue::FAILED; + return FAILED; } dp.packetListRef.push_back(packet); - return returnvalue::OK; + return OK; } ReturnValue_t cfdp::DestHandler::initialize() { if (fp.tmStore == nullptr) { fp.tmStore = ObjectManager::instance()->get(objects::TM_STORE); if (fp.tmStore == nullptr) { - return returnvalue::FAILED; + return FAILED; } } if (fp.tcStore == nullptr) { fp.tcStore = ObjectManager::instance()->get(objects::TC_STORE); if (fp.tcStore == nullptr) { - return returnvalue::FAILED; + return FAILED; } } - return returnvalue::OK; + return OK; } ReturnValue_t cfdp::DestHandler::handleMetadataPdu(const PacketInfo& info) { @@ -122,11 +129,55 @@ ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info) auto constAccessorPair = fp.tcStore->getData(info.storeId); if (constAccessorPair.first != OK) { // TODO: This is not a CFDP error. Event and/or warning? - cfdp::FileSize offset; - FileDataInfo fdInfo(offset); - FileDataReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), fdInfo); return constAccessorPair.first; } + cfdp::FileSize offset; + FileDataInfo fdInfo(offset); + FileDataReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), fdInfo); + ReturnValue_t result = reader.parseData(); + if (result != OK) { + return result; + } + size_t fileSegmentLen = 0; + const uint8_t* fileData = fdInfo.getFileData(&fileSegmentLen); + FileOpParams fileOpParams(tp.sourceName.data(), fileSegmentLen); + result = dp.user.vfs.writeToFile(fileOpParams, fileData); + if (dp.cfg.indicCfg.fileSegmentRecvIndicRequired) { + FileSegmentRecvdParams segParams; + segParams.offset = offset.value(); + segParams.id = tp.transactionId; + segParams.length = fileSegmentLen; + segParams.recContState = fdInfo.getRecordContinuationState(); + size_t segmentMetadatLen = 0; + auto* segMetadata = fdInfo.getSegmentMetadata(&segmentMetadatLen); + segParams.segmentMetadata = {segMetadata, segmentMetadatLen}; + dp.user.fileSegmentRecvdIndication(segParams); + } + if (result != returnvalue::OK) { + // TODO: Proper Error handling +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "File write error" << std::endl; +#endif + } + return result; +} + +ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) { + // Process EOF PDU + auto constAccessorPair = fp.tcStore->getData(info.storeId); + if (constAccessorPair.first != OK) { + // TODO: This is not a CFDP error. Event and/or warning? + return constAccessorPair.first; + } + EofInfo eofInfo(nullptr); + EofPduReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), eofInfo); + ReturnValue_t result = reader.parseData(); + if (result != OK) { + return result; + } + if (eofInfo.getConditionCode() == ConditionCode::NO_ERROR) { + tp.crc = eofInfo.getChecksum(); + } return returnvalue::OK; } diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 40bf655c..8215d22d 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -76,10 +76,6 @@ class DestHandler { ReturnValue_t initialize(); - ReturnValue_t handleMetadataPdu(const PacketInfo& info); - ReturnValue_t handleFileDataPdu(const PacketInfo& info); - ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize); - [[nodiscard]] CfdpStates getCfdpState() const; private: @@ -96,12 +92,13 @@ class DestHandler { : sourceName(maxFileNameLen), destName(maxFileNameLen) {} ChecksumType checksumType = ChecksumType::NULL_CHECKSUM; - bool closureRequested{}; + bool closureRequested = false; std::vector sourceName; std::vector destName; cfdp::FileSize fileSize; TransactionId transactionId; PduConfig pduConf; + uint32_t crc = 0; RemoteEntityCfg* remoteCfg = nullptr; }; @@ -114,6 +111,10 @@ class DestHandler { TransactionParams tp; ReturnValue_t startTransaction(MetadataPduReader& reader, MetadataInfo& info); + ReturnValue_t handleMetadataPdu(const PacketInfo& info); + ReturnValue_t handleFileDataPdu(const PacketInfo& info); + ReturnValue_t handleEofPdu(const PacketInfo& info); + ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize); }; } // namespace cfdp diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index b6c35570..f9db4f49 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -64,6 +64,8 @@ struct FileSegmentRecvdParams { * @param vfs Virtual Filestore Object. Will be used for all file operations */ class UserBase { + friend class DestHandler; + public: explicit UserBase(HasFileSystemIF& vfs); diff --git a/src/fsfw/cfdp/pdu/CMakeLists.txt b/src/fsfw/cfdp/pdu/CMakeLists.txt index 91b5ad2e..77386d20 100644 --- a/src/fsfw/cfdp/pdu/CMakeLists.txt +++ b/src/fsfw/cfdp/pdu/CMakeLists.txt @@ -9,8 +9,8 @@ target_sources( AckPduSerializer.cpp AckPduDeserializer.cpp EofInfo.cpp - EofPduSerializer.cpp - EofPduDeserializer.cpp + EofPduCreator.cpp + EofPduReader.cpp NakInfo.cpp NakPduSerializer.cpp NakPduDeserializer.cpp diff --git a/src/fsfw/cfdp/pdu/EofInfo.h b/src/fsfw/cfdp/pdu/EofInfo.h index fa8adfd9..4b4fb057 100644 --- a/src/fsfw/cfdp/pdu/EofInfo.h +++ b/src/fsfw/cfdp/pdu/EofInfo.h @@ -7,16 +7,16 @@ struct EofInfo { public: - EofInfo(EntityIdTlv* faultLoc = nullptr); + explicit EofInfo(EntityIdTlv* faultLoc = nullptr); EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::FileSize fileSize, EntityIdTlv* faultLoc = nullptr); size_t getSerializedSize(bool fssLarge = false); - uint32_t getChecksum() const; - cfdp::ConditionCode getConditionCode() const; + [[nodiscard]] uint32_t getChecksum() const; + [[nodiscard]] cfdp::ConditionCode getConditionCode() const; - EntityIdTlv* getFaultLoc() const; + [[nodiscard]] EntityIdTlv* getFaultLoc() const; cfdp::FileSize& getFileSize(); void setChecksum(uint32_t checksum); void setConditionCode(cfdp::ConditionCode conditionCode); diff --git a/src/fsfw/cfdp/pdu/EofPduSerializer.cpp b/src/fsfw/cfdp/pdu/EofPduCreator.cpp similarity index 71% rename from src/fsfw/cfdp/pdu/EofPduSerializer.cpp rename to src/fsfw/cfdp/pdu/EofPduCreator.cpp index 94dee640..20b8c64a 100644 --- a/src/fsfw/cfdp/pdu/EofPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduCreator.cpp @@ -1,19 +1,16 @@ -#include "EofPduSerializer.h" +#include "EofPduCreator.h" #include "fsfw/FSFW.h" -#include "fsfw/serviceinterface.h" -EofPduSerializer::EofPduSerializer(PduConfig &conf, EofInfo &info) +EofPduCreator::EofPduCreator(PduConfig &conf, EofInfo &info) : FileDirectiveCreator(conf, cfdp::FileDirectives::EOF_DIRECTIVE, 9), info(info) { - setDirectiveDataFieldLen(info.getSerializedSize(getLargeFileFlag())); + setDirectiveDataFieldLen(info.getSerializedSize(HeaderCreator::getLargeFileFlag())); } -size_t EofPduSerializer::getSerializedSize() const { - return FileDirectiveCreator::getWholePduSize(); -} +size_t EofPduCreator::getSerializedSize() const { return FileDirectiveCreator::getWholePduSize(); } -ReturnValue_t EofPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const { +ReturnValue_t EofPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; diff --git a/src/fsfw/cfdp/pdu/EofPduSerializer.h b/src/fsfw/cfdp/pdu/EofPduCreator.h similarity index 74% rename from src/fsfw/cfdp/pdu/EofPduSerializer.h rename to src/fsfw/cfdp/pdu/EofPduCreator.h index 737e8dee..7f7a25ab 100644 --- a/src/fsfw/cfdp/pdu/EofPduSerializer.h +++ b/src/fsfw/cfdp/pdu/EofPduCreator.h @@ -5,11 +5,11 @@ #include "fsfw/cfdp/pdu/FileDirectiveCreator.h" #include "fsfw/cfdp/tlv/EntityIdTlv.h" -class EofPduSerializer : public FileDirectiveCreator { +class EofPduCreator : public FileDirectiveCreator { public: - EofPduSerializer(PduConfig& conf, EofInfo& info); + EofPduCreator(PduConfig& conf, EofInfo& info); - size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp b/src/fsfw/cfdp/pdu/EofPduReader.cpp similarity index 92% rename from src/fsfw/cfdp/pdu/EofPduDeserializer.cpp rename to src/fsfw/cfdp/pdu/EofPduReader.cpp index 890d7e9a..c80c501c 100644 --- a/src/fsfw/cfdp/pdu/EofPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/EofPduReader.cpp @@ -1,12 +1,12 @@ -#include "EofPduDeserializer.h" +#include "EofPduReader.h" #include "fsfw/FSFW.h" #include "fsfw/serviceinterface.h" -EofPduDeserializer::EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo) +EofPduReader::EofPduReader(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo) : FileDirectiveReader(pduBuf, maxSize), info(eofInfo) {} -ReturnValue_t EofPduDeserializer::parseData() { +ReturnValue_t EofPduReader::parseData() { ReturnValue_t result = FileDirectiveReader::parseData(); if (result != returnvalue::OK) { return result; diff --git a/src/fsfw/cfdp/pdu/EofPduDeserializer.h b/src/fsfw/cfdp/pdu/EofPduReader.h similarity index 60% rename from src/fsfw/cfdp/pdu/EofPduDeserializer.h rename to src/fsfw/cfdp/pdu/EofPduReader.h index ce918475..456ea0dc 100644 --- a/src/fsfw/cfdp/pdu/EofPduDeserializer.h +++ b/src/fsfw/cfdp/pdu/EofPduReader.h @@ -4,11 +4,11 @@ #include "EofInfo.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h" -class EofPduDeserializer : public FileDirectiveReader { +class EofPduReader : public FileDirectiveReader { public: - EofPduDeserializer(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo); + EofPduReader(const uint8_t* pduBuf, size_t maxSize, EofInfo& eofInfo); - virtual ReturnValue_t parseData() override; + ReturnValue_t parseData() override; private: EofInfo& info; diff --git a/src/fsfw/cfdp/pdu/FileDataInfo.cpp b/src/fsfw/cfdp/pdu/FileDataInfo.cpp index 39b6472d..19fc00cd 100644 --- a/src/fsfw/cfdp/pdu/FileDataInfo.cpp +++ b/src/fsfw/cfdp/pdu/FileDataInfo.cpp @@ -57,16 +57,16 @@ ReturnValue_t FileDataInfo::addSegmentMetadataInfo(cfdp::RecordContinuationState return returnvalue::OK; } -const uint8_t *FileDataInfo::getFileData(size_t *fileSize) const { - if (fileSize != nullptr) { - *fileSize = this->fileSize; +const uint8_t *FileDataInfo::getFileData(size_t *fileSize_) const { + if (fileSize_ != nullptr) { + *fileSize_ = this->fileSize; } return fileData; } -const uint8_t *FileDataInfo::getSegmentMetadata(size_t *segmentMetadataLen) { - if (segmentMetadataLen != nullptr) { - *segmentMetadataLen = this->segmentMetadataLen; +const uint8_t *FileDataInfo::getSegmentMetadata(size_t *segmentMetadataLen_) { + if (segmentMetadataLen_ != nullptr) { + *segmentMetadataLen_ = this->segmentMetadataLen; } return segmentMetadata; } diff --git a/unittests/cfdp/pdu/testEofPdu.cpp b/unittests/cfdp/pdu/testEofPdu.cpp index 332035d0..c6718e20 100644 --- a/unittests/cfdp/pdu/testEofPdu.cpp +++ b/unittests/cfdp/pdu/testEofPdu.cpp @@ -1,8 +1,8 @@ #include #include -#include "fsfw/cfdp/pdu/EofPduDeserializer.h" -#include "fsfw/cfdp/pdu/EofPduSerializer.h" +#include "fsfw/cfdp/pdu/EofPduCreator.h" +#include "fsfw/cfdp/pdu/EofPduReader.h" #include "fsfw/globalfunctions/arrayprinter.h" TEST_CASE("EOF PDU", "[cfdp][pdu]") { @@ -22,7 +22,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") { PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); - auto eofSerializer = EofPduSerializer(pduConf, eofInfo); + auto eofSerializer = EofPduCreator(pduConf, eofInfo); SECTION("Serialize") { result = eofSerializer.serialize(&bufPtr, &sz, buf.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); @@ -45,7 +45,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") { eofInfo.setFileSize(0x10ffffff10, true); pduConf.largeFile = true; // Should serialize with fault location now - auto serializeWithFaultLocation = EofPduSerializer(pduConf, eofInfo); + auto serializeWithFaultLocation = EofPduCreator(pduConf, eofInfo); bufPtr = buf.data(); sz = 0; result = serializeWithFaultLocation.serialize(&bufPtr, &sz, buf.size(), @@ -83,7 +83,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") { REQUIRE(result == returnvalue::OK); EntityIdTlv tlv(destId); EofInfo emptyInfo(&tlv); - auto deserializer = EofPduDeserializer(buf.data(), buf.size(), emptyInfo); + auto deserializer = EofPduReader(buf.data(), buf.size(), emptyInfo); result = deserializer.parseData(); REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::NO_ERROR); @@ -94,12 +94,12 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") { eofInfo.setFileSize(0x10ffffff10, true); pduConf.largeFile = true; // Should serialize with fault location now - auto serializeWithFaultLocation = EofPduSerializer(pduConf, eofInfo); + auto serializeWithFaultLocation = EofPduCreator(pduConf, eofInfo); bufPtr = buf.data(); sz = 0; result = serializeWithFaultLocation.serialize(&bufPtr, &sz, buf.size(), SerializeIF::Endianness::NETWORK); - auto deserializer2 = EofPduDeserializer(buf.data(), buf.size(), emptyInfo); + auto deserializer2 = EofPduReader(buf.data(), buf.size(), emptyInfo); result = deserializer2.parseData(); REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::FILESTORE_REJECTION); @@ -110,7 +110,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") { uint16_t destId = emptyInfo.getFaultLoc()->getEntityId().getValue(); REQUIRE(destId == 2); for (size_t maxSz = 0; maxSz < deserializer2.getWholePduSize() - 1; maxSz++) { - auto invalidDeser = EofPduDeserializer(buf.data(), maxSz, emptyInfo); + auto invalidDeser = EofPduReader(buf.data(), maxSz, emptyInfo); result = invalidDeser.parseData(); REQUIRE(result != returnvalue::OK); } From 108e7737e25a18ddef19adc06e5067c840e7bf8f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 17:54:25 +0200 Subject: [PATCH 301/532] continued dest handler --- src/fsfw/cfdp/FileSize.h | 8 +++-- src/fsfw/cfdp/handler/DestHandler.cpp | 46 ++++++++++++++++++++------- src/fsfw/cfdp/handler/DestHandler.h | 12 +++++-- 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/fsfw/cfdp/FileSize.h b/src/fsfw/cfdp/FileSize.h index 227555e6..b0b48452 100644 --- a/src/fsfw/cfdp/FileSize.h +++ b/src/fsfw/cfdp/FileSize.h @@ -1,6 +1,8 @@ #ifndef FSFW_CFDP_FILESIZE_H_ #define FSFW_CFDP_FILESIZE_H_ +#include + #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serialize/SerializeIF.h" @@ -52,13 +54,15 @@ struct FileSize : public SerializeIF { } } - ReturnValue_t setFileSize(uint64_t fileSize_, bool largeFile_) { + ReturnValue_t setFileSize(uint64_t fileSize_, std::optional largeFile_) { + if (largeFile_) { + largeFile = largeFile_.value(); + } if (not largeFile and fileSize > UINT32_MAX) { // TODO: emit warning here return returnvalue::FAILED; } this->fileSize = fileSize_; - this->largeFile = largeFile_; return returnvalue::OK; } diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 6aeac040..e152cbd5 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -49,20 +49,32 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { return status; } if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) { - for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { - if (infoIter->pduType == PduType::FILE_DATA) { - result = handleFileDataPdu(*infoIter); - if (result != OK) { - status = result; + if (step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { + for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { + if (infoIter->pduType == PduType::FILE_DATA) { + result = handleFileDataPdu(*infoIter); + if (result != OK) { + status = result; + } + // Store data was deleted in PDU handler because a store guard is used + dp.packetListRef.erase(infoIter++); + } + // TODO: Support for check timer missing + if (infoIter->pduType == PduType::FILE_DIRECTIVE and + infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) { + result = handleEofPdu(*infoIter); + if (result != OK) { + status = result; + } + // Store data was deleted in PDU handler because a store guard is used + dp.packetListRef.erase(infoIter++); } - // Store data was deleted in PDU handler because a store guard is used - dp.packetListRef.erase(infoIter++); - } - if (infoIter->pduType == PduType::FILE_DIRECTIVE and - infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) { - result = handleEofPdu(*infoIter); } } + if (step == TransactionStep::TRANSFER_COMPLETION) { + } + if (step == TransactionStep::SENDING_FINISHED_PDU) { + } return OK; } if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { @@ -141,7 +153,6 @@ ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info) size_t fileSegmentLen = 0; const uint8_t* fileData = fdInfo.getFileData(&fileSegmentLen); FileOpParams fileOpParams(tp.sourceName.data(), fileSegmentLen); - result = dp.user.vfs.writeToFile(fileOpParams, fileData); if (dp.cfg.indicCfg.fileSegmentRecvIndicRequired) { FileSegmentRecvdParams segParams; segParams.offset = offset.value(); @@ -153,6 +164,10 @@ ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info) segParams.segmentMetadata = {segMetadata, segmentMetadatLen}; dp.user.fileSegmentRecvdIndication(segParams); } + result = dp.user.vfs.writeToFile(fileOpParams, fileData); + if (offset.value() + fileSegmentLen > tp.progress) { + tp.progress = offset.value() + fileSegmentLen; + } if (result != returnvalue::OK) { // TODO: Proper Error handling #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -175,8 +190,15 @@ ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) { if (result != OK) { return result; } + // TODO: Error handling if (eofInfo.getConditionCode() == ConditionCode::NO_ERROR) { tp.crc = eofInfo.getChecksum(); + uint64_t fileSizeFromEof = eofInfo.getFileSize().value(); + // CFDP 4.6.1.2.9: Declare file size error if progress exceeds file size + if (fileSizeFromEof > tp.progress) { + // TODO: File size error + } + tp.fileSize.setFileSize(fileSizeFromEof, std::nullopt); } return returnvalue::OK; } diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 8215d22d..b24a35bc 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -2,6 +2,7 @@ #define FSFW_CFDP_CFDPDESTHANDLER_H #include +#include #include @@ -30,17 +31,23 @@ struct PacketInfo { struct DestHandlerParams { DestHandlerParams(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable, - etl::ilist& packetList) + etl::ilist& packetList, + // TODO: This container can potentially take tons of space. For a better + // memory efficient implementation, an additional abstraction could be + // be used so users can use uint32_t as the pair type + etl::iset>& lostSegmentsContainer) : cfg(std::move(cfg)), user(user), remoteCfgTable(remoteCfgTable), - packetListRef(packetList) {} + packetListRef(packetList), + lostSegmentsContainer(lostSegmentsContainer) {} LocalEntityCfg cfg; UserBase& user; RemoteConfigTableIF& remoteCfgTable; etl::ilist& packetListRef; + etl::iset>& lostSegmentsContainer; uint8_t maxTlvsInOnePdu = 10; size_t maxFilenameLen = 255; }; @@ -99,6 +106,7 @@ class DestHandler { TransactionId transactionId; PduConfig pduConf; uint32_t crc = 0; + uint64_t progress = 0; RemoteEntityCfg* remoteCfg = nullptr; }; From 3147f67fbdde039fa3d98e9646fcb419b5842f25 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 18:03:52 +0200 Subject: [PATCH 302/532] basic dest handler framework almost complete --- src/fsfw/cfdp/handler/DestHandler.cpp | 30 ++++++++++++++++++++++++++- src/fsfw/cfdp/handler/DestHandler.h | 2 ++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index e152cbd5..33947dcd 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -72,10 +72,14 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { } } if (step == TransactionStep::TRANSFER_COMPLETION) { + result = handleTransferCompletion(); + if (result != OK) { + status = result; + } } if (step == TransactionStep::SENDING_FINISHED_PDU) { } - return OK; + return status; } if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { // TODO: Will be implemented at a later stage @@ -200,6 +204,13 @@ ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) { } tp.fileSize.setFileSize(fileSizeFromEof, std::nullopt); } + if (step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { + if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) { + step = TransactionStep::TRANSFER_COMPLETION; + } else if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { + step = TransactionStep::SENDING_ACK_PDU; + } + } return returnvalue::OK; } @@ -287,3 +298,20 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met } cfdp::CfdpStates cfdp::DestHandler::getCfdpState() const { return cfdpState; } + +ReturnValue_t cfdp::DestHandler::handleTransferCompletion() { + // TODO: Checksum verification and notice of completion + if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) { + if (tp.closureRequested) { + step = TransactionStep::SENDING_FINISHED_PDU; + } else { + finish(); + } + } else if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { + step = TransactionStep::SENDING_FINISHED_PDU; + } +} + +void cfdp::DestHandler::finish() { + // TODO: Clear PDU list, reset state to be ready for next transfer +} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index b24a35bc..9b607d65 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -123,6 +123,8 @@ class DestHandler { ReturnValue_t handleFileDataPdu(const PacketInfo& info); ReturnValue_t handleEofPdu(const PacketInfo& info); ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize); + ReturnValue_t handleTransferCompletion(); + void finish(); }; } // namespace cfdp From 134d5a1411dcdf3394dbdb85228d08f10e5066df Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 10:26:35 +0200 Subject: [PATCH 303/532] basic impl which allows naked no closure file transfer --- src/fsfw/cfdp/definitions.h | 2 +- src/fsfw/cfdp/handler/DestHandler.cpp | 71 +++++++++++++++++++++- src/fsfw/cfdp/handler/DestHandler.h | 23 ++++++- src/fsfw/cfdp/handler/UserBase.h | 8 +-- src/fsfw/cfdp/handler/mib.h | 2 +- src/fsfw/cfdp/pdu/MetadataInfo.cpp | 6 +- src/fsfw/cfdp/pdu/MetadataInfo.h | 8 +-- src/fsfw/cfdp/pdu/MetadataPduReader.cpp | 2 +- unittests/cfdp/handler/testDistributor.cpp | 2 +- unittests/cfdp/pdu/testMetadataPdu.cpp | 10 +-- 10 files changed, 111 insertions(+), 23 deletions(-) diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index fc117581..635ead17 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -40,7 +40,7 @@ static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE = //! Checksum types according to the SANA Checksum Types registry //! https://sanaregistry.org/r/checksum_identifiers/ -enum ChecksumType { +enum ChecksumTypes { // Modular legacy checksum MODULAR = 0, CRC_32_PROXIMITY_1 = 1, diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 33947dcd..b6c42601 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -1,5 +1,7 @@ #include "DestHandler.h" +#include + #include #include "fsfw/FSFW.h" @@ -177,6 +179,8 @@ ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info) #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "File write error" << std::endl; #endif + } else { + tp.deliveryStatus = FileDeliveryStatus::RETAINED_IN_FILESTORE; } return result; } @@ -300,7 +304,18 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met cfdp::CfdpStates cfdp::DestHandler::getCfdpState() const { return cfdpState; } ReturnValue_t cfdp::DestHandler::handleTransferCompletion() { - // TODO: Checksum verification and notice of completion + ReturnValue_t result; + if (tp.checksumType != ChecksumTypes::NULL_CHECKSUM) { + result = checksumVerification(); + if (result != OK) { + // TODO: Warning / error handling? + } + } else { + tp.conditionCode = ConditionCode::NO_ERROR; + } + result = noticeOfCompletion(); + if (result != OK) { + } if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) { if (tp.closureRequested) { step = TransactionStep::SENDING_FINISHED_PDU; @@ -310,8 +325,60 @@ ReturnValue_t cfdp::DestHandler::handleTransferCompletion() { } else if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { step = TransactionStep::SENDING_FINISHED_PDU; } + return OK; } void cfdp::DestHandler::finish() { - // TODO: Clear PDU list, reset state to be ready for next transfer + tp.reset(); + dp.packetListRef.clear(); + cfdpState = CfdpStates::IDLE; + step = TransactionStep::IDLE; +} + +ReturnValue_t cfdp::DestHandler::checksumVerification() { + std::array buf{}; + // TODO: Checksum verification and notice of completion + etl::crc32 crcCalc; + uint64_t currentOffset = 0; + FileOpParams params(tp.sourceName.data(), buf.size()); + while (currentOffset < tp.fileSize.value()) { + uint64_t readLen = 0; + if (currentOffset + buf.size() > tp.fileSize.value()) { + readLen = tp.fileSize.value() - currentOffset; + } else { + readLen = buf.size(); + } + if (readLen > 0) { + params.offset = currentOffset; + params.size = readLen; + auto result = dp.user.vfs.readFromFile(params, buf.data(), buf.size()); + if (result != OK) { + // TODO: Better error handling + return FAILED; + } + crcCalc.add(buf.begin(), buf.begin() + readLen); + } + currentOffset += readLen; + } + + uint32_t value = crcCalc.value(); + if (value == tp.crc) { + tp.conditionCode = ConditionCode::NO_ERROR; + tp.deliveryCode = FileDeliveryCode::DATA_COMPLETE; + } else { + // TODO: Proper error handling +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "CRC check for file " << tp.sourceName.data() << " failed" << std::endl; +#endif + tp.conditionCode = ConditionCode::FILE_CHECKSUM_FAILURE; + } + return OK; +} +ReturnValue_t cfdp::DestHandler::noticeOfCompletion() { + if (dp.cfg.indicCfg.transactionFinishedIndicRequired) { + TransactionFinishedParams params(tp.transactionId, tp.conditionCode, tp.deliveryCode, + tp.deliveryStatus); + dp.user.transactionFinishedIndication(params); + } + return OK; } diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 9b607d65..289407c5 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -98,13 +98,32 @@ class DestHandler { explicit TransactionParams(size_t maxFileNameLen) : sourceName(maxFileNameLen), destName(maxFileNameLen) {} - ChecksumType checksumType = ChecksumType::NULL_CHECKSUM; + void reset() { + pduConf = PduConfig(); + transactionId = TransactionId(); + std::fill(sourceName.begin(), sourceName.end(), '\0'); + std::fill(destName.begin(), destName.end(), '\0'); + fileSize.setFileSize(0, false); + conditionCode = ConditionCode::NO_ERROR; + deliveryCode = FileDeliveryCode::DATA_INCOMPLETE; + deliveryStatus = FileDeliveryStatus::DISCARDED_DELIBERATELY; + crc = 0; + progress = 0; + remoteCfg = nullptr; + closureRequested = false; + checksumType = ChecksumTypes::NULL_CHECKSUM; + } + + ChecksumTypes checksumType = ChecksumTypes::NULL_CHECKSUM; bool closureRequested = false; std::vector sourceName; std::vector destName; cfdp::FileSize fileSize; TransactionId transactionId; PduConfig pduConf; + ConditionCode conditionCode = ConditionCode::NO_ERROR; + FileDeliveryCode deliveryCode = FileDeliveryCode::DATA_INCOMPLETE; + FileDeliveryStatus deliveryStatus = FileDeliveryStatus::DISCARDED_DELIBERATELY; uint32_t crc = 0; uint64_t progress = 0; RemoteEntityCfg* remoteCfg = nullptr; @@ -124,6 +143,8 @@ class DestHandler { ReturnValue_t handleEofPdu(const PacketInfo& info); ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize); ReturnValue_t handleTransferCompletion(); + ReturnValue_t noticeOfCompletion(); + ReturnValue_t checksumVerification(); void finish(); }; diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index f9db4f49..e367b4a8 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -14,11 +14,11 @@ namespace cfdp { struct TransactionFinishedParams { - TransactionFinishedParams(TransactionId id, ConditionCode code, FileDeliveryStatus status, - FileDeliveryCode delivCode) - : id(std::move(id)), condCode(code), status(status), deliveryCode(delivCode) {} + TransactionFinishedParams(const TransactionId& id, ConditionCode code, FileDeliveryCode delivCode, + FileDeliveryStatus status) + : id(id), condCode(code), status(status), deliveryCode(delivCode) {} - TransactionId id; + const TransactionId& id; ConditionCode condCode; FileDeliveryStatus status; FileDeliveryCode deliveryCode; diff --git a/src/fsfw/cfdp/handler/mib.h b/src/fsfw/cfdp/handler/mib.h index 11f403dd..3b4c95e4 100644 --- a/src/fsfw/cfdp/handler/mib.h +++ b/src/fsfw/cfdp/handler/mib.h @@ -32,7 +32,7 @@ struct RemoteEntityCfg { bool closureRequested = false; bool crcOnTransmission = false; TransmissionModes defaultTransmissionMode = TransmissionModes::UNACKNOWLEDGED; - ChecksumType defaultChecksum = ChecksumType::NULL_CHECKSUM; + ChecksumTypes defaultChecksum = ChecksumTypes::NULL_CHECKSUM; const uint8_t version = CFDP_VERSION_2; }; diff --git a/src/fsfw/cfdp/pdu/MetadataInfo.cpp b/src/fsfw/cfdp/pdu/MetadataInfo.cpp index d88bdd87..e1eb3ad8 100644 --- a/src/fsfw/cfdp/pdu/MetadataInfo.cpp +++ b/src/fsfw/cfdp/pdu/MetadataInfo.cpp @@ -1,6 +1,6 @@ #include "MetadataInfo.h" -MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumType, +MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumTypes checksumType, cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName, cfdp::StringLv& destFileName) : MetadataInfo(fileSize, sourceFileName, destFileName) { @@ -23,9 +23,9 @@ void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray_, std::optional optionsLen, std::optional maxOptionsLen); - [[nodiscard]] cfdp::ChecksumType getChecksumType() const; - void setChecksumType(cfdp::ChecksumType checksumType); + [[nodiscard]] cfdp::ChecksumTypes getChecksumType() const; + void setChecksumType(cfdp::ChecksumTypes checksumType); [[nodiscard]] bool isClosureRequested() const; void setClosureRequested(bool closureRequested = false); @@ -42,7 +42,7 @@ class MetadataInfo { private: bool closureRequested = false; - cfdp::ChecksumType checksumType = cfdp::ChecksumType::NULL_CHECKSUM; + cfdp::ChecksumTypes checksumType = cfdp::ChecksumTypes::NULL_CHECKSUM; cfdp::FileSize& fileSize; cfdp::StringLv& sourceFileName; cfdp::StringLv& destFileName; diff --git a/src/fsfw/cfdp/pdu/MetadataPduReader.cpp b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp index 66025140..caf8287b 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduReader.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp @@ -15,7 +15,7 @@ ReturnValue_t MetadataPduReader::parseData() { return SerializeIF::STREAM_TOO_SHORT; } info.setClosureRequested((*buf >> 6) & 0x01); - info.setChecksumType(static_cast(*buf & 0x0f)); + info.setChecksumType(static_cast(*buf & 0x0f)); remSize -= 1; buf += 1; auto endianness = getEndianness(); diff --git a/unittests/cfdp/handler/testDistributor.cpp b/unittests/cfdp/handler/testDistributor.cpp index 368ca9c0..f33e1115 100644 --- a/unittests/cfdp/handler/testDistributor.cpp +++ b/unittests/cfdp/handler/testDistributor.cpp @@ -30,7 +30,7 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { cfdp::StringLv sourceFileName(sourceFileString); std::string destFileString = "hello2.txt"; cfdp::StringLv destFileName(destFileString); - MetadataInfo metadataInfo(false, cfdp::ChecksumType::CRC_32, fileSize, sourceFileName, + MetadataInfo metadataInfo(false, cfdp::ChecksumTypes::CRC_32, fileSize, sourceFileName, destFileName); MetadataPduCreator creator(pduConf, metadataInfo); uint8_t* dataPtr = nullptr; diff --git a/unittests/cfdp/pdu/testMetadataPdu.cpp b/unittests/cfdp/pdu/testMetadataPdu.cpp index 49f1deb4..18b60409 100644 --- a/unittests/cfdp/pdu/testMetadataPdu.cpp +++ b/unittests/cfdp/pdu/testMetadataPdu.cpp @@ -23,7 +23,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { cfdp::StringLv sourceFileName(firstFileName); cfdp::StringLv destFileName; FileSize fileSize(35); - MetadataInfo info(false, ChecksumType::MODULAR, fileSize, sourceFileName, destFileName); + MetadataInfo info(false, ChecksumTypes::MODULAR, fileSize, sourceFileName, destFileName); FilestoreResponseTlv response(FilestoreActionCode::CREATE_DIRECTORY, FSR_CREATE_NOT_ALLOWED, sourceFileName, nullptr); @@ -74,7 +74,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { REQUIRE(info.getMaxOptionsLen() == 2); info.setMaxOptionsLen(3); REQUIRE(info.getMaxOptionsLen() == 3); - info.setChecksumType(cfdp::ChecksumType::CRC_32C); + info.setChecksumType(cfdp::ChecksumTypes::CRC_32C); info.setClosureRequested(true); uint8_t* buffer = mdBuffer.data(); size_t sz = 0; @@ -83,8 +83,8 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); REQUIRE((mdBuffer[1] << 8 | mdBuffer[2]) == 37); - auto checksumType = static_cast(mdBuffer[11] & 0x0f); - REQUIRE(checksumType == cfdp::ChecksumType::CRC_32C); + auto checksumType = static_cast(mdBuffer[11] & 0x0f); + REQUIRE(checksumType == cfdp::ChecksumTypes::CRC_32C); bool closureRequested = mdBuffer[11] >> 6 & 0x01; REQUIRE(closureRequested == true); // The size of the two options is 19. Summing up: @@ -130,7 +130,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { size_t maxSize = 4; info.setOptionsArray(options.data(), sizeOfOptions, maxSize); REQUIRE(info.getOptionsLen() == 2); - info.setChecksumType(cfdp::ChecksumType::CRC_32C); + info.setChecksumType(cfdp::ChecksumTypes::CRC_32C); info.setClosureRequested(true); uint8_t* buffer = mdBuffer.data(); size_t sz = 0; From b984128de5ce7cad1b941886c62fb7a83314d507 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 10:30:55 +0200 Subject: [PATCH 304/532] stub for creating finished PDU --- src/fsfw/cfdp/handler/DestHandler.cpp | 7 +++++++ src/fsfw/cfdp/handler/DestHandler.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index b6c42601..90e106a8 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -80,6 +80,11 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { } } if (step == TransactionStep::SENDING_FINISHED_PDU) { + result = sendFinishedPdu(); + if (result != OK) { + status = result; + } + finish(); } return status; } @@ -382,3 +387,5 @@ ReturnValue_t cfdp::DestHandler::noticeOfCompletion() { } return OK; } + +ReturnValue_t cfdp::DestHandler::sendFinishedPdu() { return 0; } diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 289407c5..6b0493ad 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -143,6 +143,7 @@ class DestHandler { ReturnValue_t handleEofPdu(const PacketInfo& info); ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize); ReturnValue_t handleTransferCompletion(); + ReturnValue_t sendFinishedPdu(); ReturnValue_t noticeOfCompletion(); ReturnValue_t checksumVerification(); void finish(); From 3dfc8822266e6e90e78ebaa1647bbfab53a58fb9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 11:03:25 +0200 Subject: [PATCH 305/532] impl finish PDU sending --- src/fsfw/cfdp/handler/DestHandler.cpp | 29 ++++++++++++++++++- src/fsfw/cfdp/pdu/CMakeLists.txt | 4 +-- src/fsfw/cfdp/pdu/FileDirectiveCreator.h | 4 +++ ...uSerializer.cpp => FinishedPduCreator.cpp} | 14 ++++----- src/fsfw/cfdp/pdu/FinishedPduCreator.h | 24 +++++++++++++++ ...Deserializer.cpp => FinishedPduReader.cpp} | 13 ++++----- ...dPduDeserializer.h => FinishedPduReader.h} | 10 +++---- src/fsfw/cfdp/pdu/FinishedPduSerializer.h | 23 --------------- unittests/cfdp/pdu/testFinishedPdu.cpp | 16 +++++----- 9 files changed, 83 insertions(+), 54 deletions(-) rename src/fsfw/cfdp/pdu/{FinishedPduSerializer.cpp => FinishedPduCreator.cpp} (72%) create mode 100644 src/fsfw/cfdp/pdu/FinishedPduCreator.h rename src/fsfw/cfdp/pdu/{FinishedPduDeserializer.cpp => FinishedPduReader.cpp} (85%) rename src/fsfw/cfdp/pdu/{FinishedPduDeserializer.h => FinishedPduReader.h} (52%) delete mode 100644 src/fsfw/cfdp/pdu/FinishedPduSerializer.h diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 90e106a8..fcad9c79 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -7,8 +7,10 @@ #include "fsfw/FSFW.h" #include "fsfw/cfdp/pdu/EofPduReader.h" #include "fsfw/cfdp/pdu/FileDataReader.h" +#include "fsfw/cfdp/pdu/FinishedPduCreator.h" #include "fsfw/cfdp/pdu/HeaderReader.h" #include "fsfw/objectmanager.h" +#include "fsfw/tmtcservices/TmTcMessage.h" using namespace returnvalue; @@ -379,6 +381,7 @@ ReturnValue_t cfdp::DestHandler::checksumVerification() { } return OK; } + ReturnValue_t cfdp::DestHandler::noticeOfCompletion() { if (dp.cfg.indicCfg.transactionFinishedIndicRequired) { TransactionFinishedParams params(tp.transactionId, tp.conditionCode, tp.deliveryCode, @@ -388,4 +391,28 @@ ReturnValue_t cfdp::DestHandler::noticeOfCompletion() { return OK; } -ReturnValue_t cfdp::DestHandler::sendFinishedPdu() { return 0; } +ReturnValue_t cfdp::DestHandler::sendFinishedPdu() { + FinishedInfo info(tp.conditionCode, tp.deliveryCode, tp.deliveryStatus); + FinishPduCreator finishedPdu(tp.pduConf, info); + store_address_t storeId; + uint8_t* dataPtr = nullptr; + ReturnValue_t result = + fp.tcStore->getFreeElement(&storeId, finishedPdu.getSerializedSize(), &dataPtr); + if (result != OK) { + // TODO: Error handling and event, this is a non CFDP specific error (most likely store is full) + return result; + } + size_t serLen = 0; + result = finishedPdu.serialize(dataPtr, serLen, finishedPdu.getSerializedSize()); + if (result != OK) { + // TODO: Error printout, this really should not happen + return result; + } + TmTcMessage msg(storeId); + result = fp.msgQueue.sendMessage(fp.packetDest.getReportReceptionQueue(), &msg); + if (result != OK) { + // TODO: Error handling and event, this is a non CFDP specific error (most likely store is full) + return result; + } + return OK; +} diff --git a/src/fsfw/cfdp/pdu/CMakeLists.txt b/src/fsfw/cfdp/pdu/CMakeLists.txt index 77386d20..a8f0b5a9 100644 --- a/src/fsfw/cfdp/pdu/CMakeLists.txt +++ b/src/fsfw/cfdp/pdu/CMakeLists.txt @@ -15,8 +15,8 @@ target_sources( NakPduSerializer.cpp NakPduDeserializer.cpp FinishedInfo.cpp - FinishedPduSerializer.cpp - FinishedPduDeserializer.cpp + FinishedPduCreator.cpp + FinishedPduReader.cpp MetadataInfo.cpp MetadataPduCreator.cpp MetadataPduReader.cpp diff --git a/src/fsfw/cfdp/pdu/FileDirectiveCreator.h b/src/fsfw/cfdp/pdu/FileDirectiveCreator.h index 566ae3cc..6068fe64 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveCreator.h +++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.h @@ -16,6 +16,10 @@ class FileDirectiveCreator : public HeaderCreator { */ [[nodiscard]] size_t getSerializedSize() const override; + [[nodiscard]] ReturnValue_t serialize(uint8_t* buffer, size_t& serLen, size_t maxSize) const { + return SerializeIF::serialize(buffer, serLen, maxSize, SerializeIF::Endianness::NETWORK); + } + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; diff --git a/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp similarity index 72% rename from src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp rename to src/fsfw/cfdp/pdu/FinishedPduCreator.cpp index b6f793f7..88f4491c 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp @@ -1,20 +1,18 @@ -#include "FinishedPduSerializer.h" +#include "FinishedPduCreator.h" -FinishPduSerializer::FinishPduSerializer(PduConfig &conf, FinishedInfo &finishInfo) +FinishPduCreator::FinishPduCreator(PduConfig &conf, FinishedInfo &finishInfo) : FileDirectiveCreator(conf, cfdp::FileDirectives::FINISH, 0), finishInfo(finishInfo) { updateDirectiveFieldLen(); } -size_t FinishPduSerializer::getSerializedSize() const { - return FinishPduSerializer::getWholePduSize(); -} +size_t FinishPduCreator::getSerializedSize() const { return FinishPduCreator::getWholePduSize(); } -void FinishPduSerializer::updateDirectiveFieldLen() { +void FinishPduCreator::updateDirectiveFieldLen() { setDirectiveDataFieldLen(finishInfo.getSerializedSize()); } -ReturnValue_t FinishPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const { +ReturnValue_t FinishPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; diff --git a/src/fsfw/cfdp/pdu/FinishedPduCreator.h b/src/fsfw/cfdp/pdu/FinishedPduCreator.h new file mode 100644 index 00000000..bef59ada --- /dev/null +++ b/src/fsfw/cfdp/pdu/FinishedPduCreator.h @@ -0,0 +1,24 @@ +#ifndef FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_ +#define FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_ + +#include "FinishedInfo.h" +#include "fsfw/cfdp/pdu/FileDataCreator.h" +#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" + +class FinishPduCreator : public FileDirectiveCreator { + public: + FinishPduCreator(PduConfig& pduConf, FinishedInfo& finishInfo); + + void updateDirectiveFieldLen(); + + [[nodiscard]] size_t getSerializedSize() const override; + + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const override; + using FileDirectiveCreator::serialize; + + private: + FinishedInfo& finishInfo; +}; + +#endif /* FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp b/src/fsfw/cfdp/pdu/FinishedPduReader.cpp similarity index 85% rename from src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp rename to src/fsfw/cfdp/pdu/FinishedPduReader.cpp index 1f3eee18..475942e0 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduReader.cpp @@ -1,10 +1,9 @@ -#include "FinishedPduDeserializer.h" +#include "FinishedPduReader.h" -FinishPduDeserializer::FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize, - FinishedInfo& info) +FinishPduReader::FinishPduReader(const uint8_t* pduBuf, size_t maxSize, FinishedInfo& info) : FileDirectiveReader(pduBuf, maxSize), finishedInfo(info) {} -ReturnValue_t FinishPduDeserializer::parseData() { +ReturnValue_t FinishPduReader::parseData() { ReturnValue_t result = FileDirectiveReader::parseData(); if (result != returnvalue::OK) { return result; @@ -29,10 +28,10 @@ ReturnValue_t FinishPduDeserializer::parseData() { return result; } -FinishedInfo& FinishPduDeserializer::getInfo() { return finishedInfo; } +FinishedInfo& FinishPduReader::getInfo() { return finishedInfo; } -ReturnValue_t FinishPduDeserializer::parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf, - cfdp::ConditionCode conditionCode) { +ReturnValue_t FinishPduReader::parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf, + cfdp::ConditionCode conditionCode) { ReturnValue_t result = returnvalue::OK; size_t fsResponsesIdx = 0; auto endianness = getEndianness(); diff --git a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.h b/src/fsfw/cfdp/pdu/FinishedPduReader.h similarity index 52% rename from src/fsfw/cfdp/pdu/FinishedPduDeserializer.h rename to src/fsfw/cfdp/pdu/FinishedPduReader.h index 1a13cad5..791a2ef4 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduDeserializer.h +++ b/src/fsfw/cfdp/pdu/FinishedPduReader.h @@ -1,12 +1,12 @@ -#ifndef FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ -#define FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ +#ifndef FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ +#define FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ #include "fsfw/cfdp/pdu/FileDirectiveReader.h" #include "fsfw/cfdp/pdu/FinishedInfo.h" -class FinishPduDeserializer : public FileDirectiveReader { +class FinishPduReader : public FileDirectiveReader { public: - FinishPduDeserializer(const uint8_t* pduBuf, size_t maxSize, FinishedInfo& info); + FinishPduReader(const uint8_t* pduBuf, size_t maxSize, FinishedInfo& info); ReturnValue_t parseData() override; @@ -19,4 +19,4 @@ class FinishPduDeserializer : public FileDirectiveReader { cfdp::ConditionCode conditionCode); }; -#endif /* FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ */ +#endif /* FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/FinishedPduSerializer.h b/src/fsfw/cfdp/pdu/FinishedPduSerializer.h deleted file mode 100644 index eb162c94..00000000 --- a/src/fsfw/cfdp/pdu/FinishedPduSerializer.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_ -#define FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_ - -#include "FinishedInfo.h" -#include "fsfw/cfdp/pdu/FileDataCreator.h" -#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" - -class FinishPduSerializer : public FileDirectiveCreator { - public: - FinishPduSerializer(PduConfig& pduConf, FinishedInfo& finishInfo); - - void updateDirectiveFieldLen(); - - size_t getSerializedSize() const override; - - ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const override; - - private: - FinishedInfo& finishInfo; -}; - -#endif /* FSFW_SRC_FSFW_CFDP_PDU_FINISHEDPDUSERIALIZER_H_ */ diff --git a/unittests/cfdp/pdu/testFinishedPdu.cpp b/unittests/cfdp/pdu/testFinishedPdu.cpp index 2f3c466e..194e4252 100644 --- a/unittests/cfdp/pdu/testFinishedPdu.cpp +++ b/unittests/cfdp/pdu/testFinishedPdu.cpp @@ -1,8 +1,8 @@ #include #include -#include "fsfw/cfdp/pdu/FinishedPduDeserializer.h" -#include "fsfw/cfdp/pdu/FinishedPduSerializer.h" +#include "fsfw/cfdp/pdu/FinishedPduCreator.h" +#include "fsfw/cfdp/pdu/FinishedPduReader.h" #include "fsfw/globalfunctions/arrayprinter.h" TEST_CASE("Finished PDU", "[cfdp][pdu]") { @@ -22,7 +22,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY); SECTION("Serialize") { - FinishPduSerializer serializer(pduConf, info); + FinishPduCreator serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getSerializedSize() == 12); @@ -87,10 +87,10 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { SECTION("Deserialize") { FinishedInfo emptyInfo; - FinishPduSerializer serializer(pduConf, info); + FinishPduCreator serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, fnBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); - FinishPduDeserializer deserializer(fnBuffer.data(), fnBuffer.size(), emptyInfo); + FinishPduReader deserializer(fnBuffer.data(), fnBuffer.size(), emptyInfo); result = deserializer.parseData(); REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getFileStatus() == cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY); @@ -114,7 +114,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { FilestoreResponseTlv emptyResponse(firstNameLv, nullptr); responsePtr = &emptyResponse; emptyInfo.setFilestoreResponsesArray(&responsePtr, nullptr, &len); - FinishPduDeserializer deserializer2(fnBuffer.data(), fnBuffer.size(), emptyInfo); + FinishPduReader deserializer2(fnBuffer.data(), fnBuffer.size(), emptyInfo); result = deserializer2.parseData(); REQUIRE(result == returnvalue::OK); REQUIRE(emptyInfo.getFsResponsesLen() == 1); @@ -152,7 +152,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { response.setFilestoreMessage(&emptyFsMsg); emptyInfo.setFilestoreResponsesArray(responses.data(), &len, &len); response2.setFilestoreMessage(&emptyFsMsg); - FinishPduDeserializer deserializer3(fnBuffer.data(), fnBuffer.size(), emptyInfo); + FinishPduReader deserializer3(fnBuffer.data(), fnBuffer.size(), emptyInfo); result = deserializer3.parseData(); REQUIRE(result == returnvalue::OK); auto& infoRef = deserializer3.getInfo(); @@ -181,7 +181,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { REQUIRE(result == cfdp::INVALID_TLV_TYPE); for (size_t maxSz = 0; maxSz < 45; maxSz++) { - FinishPduDeserializer faultyDeser(fnBuffer.data(), maxSz, emptyInfo); + FinishPduReader faultyDeser(fnBuffer.data(), maxSz, emptyInfo); result = faultyDeser.parseData(); REQUIRE(result != returnvalue::OK); } From 0dd2b5ddd48f83383a73b1decd5e27dc68301512 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 11:19:23 +0200 Subject: [PATCH 306/532] need an event reporter proxy --- src/fsfw/cfdp/handler/DestHandler.h | 15 +++++++++++---- unittests/cfdp/handler/testDestHandler.cpp | 12 +++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 6b0493ad..f3e73f32 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -29,13 +29,20 @@ struct PacketInfo { PacketInfo() = default; }; +template +using LostSegmentsList = etl::set, SIZE>; +template +using PacketInfoList = etl::list; +using LostSegmentsListBase = etl::iset>; +using PacketInfoListBase = etl::ilist; + struct DestHandlerParams { DestHandlerParams(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable, - etl::ilist& packetList, + PacketInfoListBase& packetList, // TODO: This container can potentially take tons of space. For a better // memory efficient implementation, an additional abstraction could be // be used so users can use uint32_t as the pair type - etl::iset>& lostSegmentsContainer) + LostSegmentsListBase& lostSegmentsContainer) : cfg(std::move(cfg)), user(user), remoteCfgTable(remoteCfgTable), @@ -46,8 +53,8 @@ struct DestHandlerParams { UserBase& user; RemoteConfigTableIF& remoteCfgTable; - etl::ilist& packetListRef; - etl::iset>& lostSegmentsContainer; + PacketInfoListBase& packetListRef; + LostSegmentsListBase& lostSegmentsContainer; uint8_t maxTlvsInOnePdu = 10; size_t maxFilenameLen = 255; }; diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 1b2de95e..9d6274e0 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -1,20 +1,30 @@ #include #include "fsfw/cfdp.h" +#include "mocks/AcceptsTmMock.h" #include "mocks/FilesystemMock.h" +#include "mocks/MessageQueueMock.h" #include "mocks/cfdp/FaultHandlerMock.h" #include "mocks/cfdp/RemoteConfigTableMock.h" #include "mocks/cfdp/UserMock.h" TEST_CASE("CFDP Dest Handler", "[cfdp]") { using namespace cfdp; + MessageQueueId_t destQueueId = 2; + AcceptsTmMock tmReceiver(destQueueId); + MessageQueueMock mqMock(destQueueId); EntityId localId = EntityId(UnsignedByteField(2)); auto fhMock = FaultHandlerMock(); auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock); auto fsMock = FilesystemMock(); auto userMock = UserMock(fsMock); auto remoteCfgTableMock = RemoteConfigTableMock(); - // auto destHandler = DestHandler(localEntityCfg, userMock, remoteCfgTableMock); + PacketInfoList<64> packetInfoList; + LostSegmentsList<128> lostSegmentsList; + DestHandlerParams dp(localEntityCfg, userMock, remoteCfgTableMock, packetInfoList, + lostSegmentsList); + // FsfwParams fp(destQueueId, mqMock); + // auto destHandler = DestHandler(); SECTION("State") {} } \ No newline at end of file From d2c4d546c305c53d8f814e1b3c811256b1ec155d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 11:37:41 +0200 Subject: [PATCH 307/532] first dest handler unittests - Add new mock class for event reporting proxies - Add basic setup for unittesting the CFDP destination handler --- src/fsfw/cfdp/handler/DestHandler.cpp | 2 ++ src/fsfw/cfdp/handler/DestHandler.h | 17 +++++++++-------- unittests/cfdp/handler/testDestHandler.cpp | 19 ++++++++++++++++--- unittests/mocks/CMakeLists.txt | 3 ++- unittests/mocks/EventReportingProxyMock.cpp | 6 ++++++ unittests/mocks/EventReportingProxyMock.h | 21 +++++++++++++++++++++ 6 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 unittests/mocks/EventReportingProxyMock.cpp create mode 100644 unittests/mocks/EventReportingProxyMock.h diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index fcad9c79..a153682d 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -416,3 +416,5 @@ ReturnValue_t cfdp::DestHandler::sendFinishedPdu() { } return OK; } + +cfdp::DestHandler::TransactionStep cfdp::DestHandler::getTransactionStep() const { return step; } diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index f3e73f32..9b45c60c 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -72,6 +72,14 @@ struct FsfwParams { class DestHandler { public: + enum class TransactionStep { + IDLE = 0, + TRANSACTION_START = 1, + RECEIVING_FILE_DATA_PDUS = 2, + SENDING_ACK_PDU = 3, + TRANSFER_COMPLETION = 4, + SENDING_FINISHED_PDU = 5 + }; /** * Will be returned if it is advisable to call the state machine operation call again */ @@ -91,16 +99,9 @@ class DestHandler { ReturnValue_t initialize(); [[nodiscard]] CfdpStates getCfdpState() const; + [[nodiscard]] TransactionStep getTransactionStep() const; private: - enum class TransactionStep { - IDLE = 0, - TRANSACTION_START = 1, - RECEIVING_FILE_DATA_PDUS = 2, - SENDING_ACK_PDU = 3, - TRANSFER_COMPLETION = 4, - SENDING_FINISHED_PDU = 5 - }; struct TransactionParams { explicit TransactionParams(size_t maxFileNameLen) : sourceName(maxFileNameLen), destName(maxFileNameLen) {} diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 9d6274e0..d1191534 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -2,14 +2,17 @@ #include "fsfw/cfdp.h" #include "mocks/AcceptsTmMock.h" +#include "mocks/EventReportingProxyMock.h" #include "mocks/FilesystemMock.h" #include "mocks/MessageQueueMock.h" +#include "mocks/StorageManagerMock.h" #include "mocks/cfdp/FaultHandlerMock.h" #include "mocks/cfdp/RemoteConfigTableMock.h" #include "mocks/cfdp/UserMock.h" TEST_CASE("CFDP Dest Handler", "[cfdp]") { using namespace cfdp; + using namespace returnvalue; MessageQueueId_t destQueueId = 2; AcceptsTmMock tmReceiver(destQueueId); MessageQueueMock mqMock(destQueueId); @@ -23,8 +26,18 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { LostSegmentsList<128> lostSegmentsList; DestHandlerParams dp(localEntityCfg, userMock, remoteCfgTableMock, packetInfoList, lostSegmentsList); - // FsfwParams fp(destQueueId, mqMock); - // auto destHandler = DestHandler(); + EventReportingProxyMock eventReporterMock; + LocalPool::LocalPoolConfig storeCfg = {{10, 32}, {10, 64}, {10, 128}, {10, 1024}}; + StorageManagerMock tcStore(2, storeCfg); + StorageManagerMock tmStore(3, storeCfg); + FsfwParams fp(tmReceiver, mqMock, eventReporterMock); + fp.tcStore = &tcStore; + fp.tmStore = &tmStore; + auto destHandler = DestHandler(dp, fp); + CHECK(destHandler.initialize() == OK); - SECTION("State") {} + SECTION("State") { + CHECK(destHandler.getCfdpState() == CfdpStates::IDLE); + CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE); + } } \ No newline at end of file diff --git a/unittests/mocks/CMakeLists.txt b/unittests/mocks/CMakeLists.txt index c40a727a..bd093da8 100644 --- a/unittests/mocks/CMakeLists.txt +++ b/unittests/mocks/CMakeLists.txt @@ -15,6 +15,7 @@ target_sources( CcsdsCheckerMock.cpp AcceptsTcMock.cpp StorageManagerMock.cpp - FilesystemMock.cpp) + FilesystemMock.cpp + EventReportingProxyMock.cpp) add_subdirectory(cfdp) diff --git a/unittests/mocks/EventReportingProxyMock.cpp b/unittests/mocks/EventReportingProxyMock.cpp new file mode 100644 index 00000000..cb4f6d93 --- /dev/null +++ b/unittests/mocks/EventReportingProxyMock.cpp @@ -0,0 +1,6 @@ +#include "EventReportingProxyMock.h" + +void EventReportingProxyMock::forwardEvent(Event event, uint32_t parameter1, + uint32_t parameter2) const { + eventQueue.emplace(event, parameter1, parameter2); +} diff --git a/unittests/mocks/EventReportingProxyMock.h b/unittests/mocks/EventReportingProxyMock.h new file mode 100644 index 00000000..c04942c3 --- /dev/null +++ b/unittests/mocks/EventReportingProxyMock.h @@ -0,0 +1,21 @@ +#ifndef FSFW_TESTS_EVENTREPORTPROXYMOCK_H +#define FSFW_TESTS_EVENTREPORTPROXYMOCK_H + +#include + +#include "fsfw/events/EventReportingProxyIF.h" + +class EventReportingProxyMock : public EventReportingProxyIF { + public: + void forwardEvent(Event event, uint32_t parameter1, uint32_t parameter2) const override; + + struct EventInfo { + EventInfo(Event event, uint32_t p1, uint32_t p2) : event(event), p1(p1), p2(p2) {} + + Event event; + uint32_t p1; + uint32_t p2; + }; + mutable std::queue eventQueue; +}; +#endif // FSFW_TESTS_EVENTREPORTPROXYMOCK_H From 52802f127b83eaeaa4741cab9725297ce08d8ad2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 11:40:22 +0200 Subject: [PATCH 308/532] basic test stubs --- unittests/cfdp/handler/testDestHandler.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index d1191534..bc5aabea 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -40,4 +40,16 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { CHECK(destHandler.getCfdpState() == CfdpStates::IDLE); CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE); } + + SECTION("Empty File Transfer") { + + } + + SECTION("Small File Transfer") { + + } + + SECTION("Segmented File Transfer") { + + } } \ No newline at end of file From 5ce1e76723ce34d9e129326d908e0ffb1b25b356 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 14:20:01 +0200 Subject: [PATCH 309/532] init dest handler unittests --- src/fsfw/cfdp/handler/DestHandler.cpp | 3 ++ src/fsfw/cfdp/handler/DestHandler.h | 3 +- src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp | 2 ++ src/fsfw/cfdp/pdu/FileDirectiveCreator.h | 2 ++ src/fsfw/cfdp/pdu/MetadataPduCreator.h | 1 + src/fsfw/cfdp/tlv/StringLv.h | 3 ++ unittests/cfdp/handler/testDestHandler.cpp | 35 +++++++++++++++++----- unittests/mocks/StorageManagerMock.h | 3 ++ 8 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index a153682d..487ee817 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -37,12 +37,14 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); } + infoIter++; } if (step == TransactionStep::IDLE) { // To decrease the already high complexity of the software, all packets arriving before // a metadata PDU are deleted. for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { fp.tcStore->deleteData(infoIter->storeId); + infoIter++; } dp.packetListRef.clear(); } @@ -73,6 +75,7 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); } + infoIter++; } } if (step == TransactionStep::TRANSFER_COMPLETION) { diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 9b45c60c..1b4bed75 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -103,8 +103,9 @@ class DestHandler { private: struct TransactionParams { + // Initialize char vectors with length + 1 for 0 termination explicit TransactionParams(size_t maxFileNameLen) - : sourceName(maxFileNameLen), destName(maxFileNameLen) {} + : sourceName(maxFileNameLen + 1), destName(maxFileNameLen + 1) {} void reset() { pduConf = PduConfig(); diff --git a/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp index 86c1ad92..474a1cc3 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp @@ -35,3 +35,5 @@ void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) { // Set length of data field plus 1 byte for the directive octet HeaderCreator::setPduDataFieldLen(len + 1); } + +cfdp::FileDirectives FileDirectiveCreator::getDirectiveCode() const { return directiveCode; } diff --git a/src/fsfw/cfdp/pdu/FileDirectiveCreator.h b/src/fsfw/cfdp/pdu/FileDirectiveCreator.h index 6068fe64..a3b676b0 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveCreator.h +++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.h @@ -8,6 +8,8 @@ class FileDirectiveCreator : public HeaderCreator { FileDirectiveCreator(PduConfig& pduConf, cfdp::FileDirectives directiveCode, size_t directiveParamFieldLen); + [[nodiscard]] cfdp::FileDirectives getDirectiveCode() const; + /** * This only returns the size of the PDU header + 1 for the directive code octet. * Use FileDirectiveCreator::getWholePduSize to get the full packet length, assuming diff --git a/src/fsfw/cfdp/pdu/MetadataPduCreator.h b/src/fsfw/cfdp/pdu/MetadataPduCreator.h index 2c2f35f8..4486a79c 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduCreator.h +++ b/src/fsfw/cfdp/pdu/MetadataPduCreator.h @@ -14,6 +14,7 @@ class MetadataPduCreator : public FileDirectiveCreator { ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; + using FileDirectiveCreator::serialize; private: MetadataInfo& info; diff --git a/src/fsfw/cfdp/tlv/StringLv.h b/src/fsfw/cfdp/tlv/StringLv.h index a6cc8e20..6c200b8b 100644 --- a/src/fsfw/cfdp/tlv/StringLv.h +++ b/src/fsfw/cfdp/tlv/StringLv.h @@ -12,6 +12,9 @@ class StringLv : public Lv { StringLv(); explicit StringLv(const std::string& fileName); explicit StringLv(const char* filename, size_t len); + + // Delete the move constructor to avoid passing in a temporary + StringLv(const std::string&&) = delete; }; } // namespace cfdp diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index bc5aabea..47f17f2d 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -1,6 +1,7 @@ #include #include "fsfw/cfdp.h" +#include "fsfw/cfdp/pdu/MetadataPduCreator.h" #include "mocks/AcceptsTmMock.h" #include "mocks/EventReportingProxyMock.h" #include "mocks/FilesystemMock.h" @@ -17,6 +18,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { AcceptsTmMock tmReceiver(destQueueId); MessageQueueMock mqMock(destQueueId); EntityId localId = EntityId(UnsignedByteField(2)); + EntityId remoteId = EntityId(UnsignedByteField(3)); auto fhMock = FaultHandlerMock(); auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock); auto fsMock = FilesystemMock(); @@ -41,15 +43,34 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE); } + SECTION("Idle State Machine Iteration") { + CHECK(destHandler.performStateMachine() == OK); + CHECK(destHandler.getCfdpState() == CfdpStates::IDLE); + CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE); + } + SECTION("Empty File Transfer") { - + CHECK(destHandler.performStateMachine() == OK); + FileSize size(0); + std::string srcNameString = "hello.txt"; + std::string destNameString = "hello-cpy.txt"; + StringLv srcName(srcNameString); + StringLv destName(destNameString); + MetadataInfo info(false, cfdp::ChecksumTypes::NULL_CHECKSUM, size, srcName, destName); + auto seqNum = TransactionSeqNum(UnsignedByteField(1)); + PduConfig conf(remoteId, localId, TransmissionModes::UNACKNOWLEDGED, seqNum); + MetadataPduCreator metadataPdu(conf, info); + store_address_t storeId; + uint8_t* ptr; + CHECK(tcStore.getFreeElement(&storeId, metadataPdu.getSerializedSize(), &ptr) == OK); + size_t serLen = 0; + CHECK(metadataPdu.serialize(ptr, serLen, metadataPdu.getSerializedSize()) == OK); + PacketInfo packetInfo(metadataPdu.getPduType(), metadataPdu.getDirectiveCode(), storeId); + packetInfoList.push_back(packetInfo); + CHECK(destHandler.performStateMachine() == OK); } - SECTION("Small File Transfer") { + SECTION("Small File Transfer") {} - } - - SECTION("Segmented File Transfer") { - - } + SECTION("Segmented File Transfer") {} } \ No newline at end of file diff --git a/unittests/mocks/StorageManagerMock.h b/unittests/mocks/StorageManagerMock.h index f33ba19b..a52e46db 100644 --- a/unittests/mocks/StorageManagerMock.h +++ b/unittests/mocks/StorageManagerMock.h @@ -32,6 +32,9 @@ class StorageManagerMock : public LocalPool { std::pair nextModifyDataCallFails; std::pair nextDeleteDataCallFails; std::pair nextFreeElementCallFails; + + using LocalPool::getFreeElement; + void reset(); }; #endif // FSFW_TESTS_STORAGEMANAGERMOCK_H From d64ad71529260c561f452a6e5dfac0f10ac4b6c0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 14:44:35 +0200 Subject: [PATCH 310/532] Some improvements for time stamper API --- .../monitoring/MonitoringMessageContent.h | 8 ++--- .../pus/Service11TelecommandScheduling.tpp | 4 +-- .../pus/Service1TelecommandVerification.cpp | 4 +-- .../pus/Service1TelecommandVerification.h | 4 +-- src/fsfw/timemanager/CdsShortTimeStamper.cpp | 24 +++++++------ src/fsfw/timemanager/CdsShortTimeStamper.h | 13 ++----- src/fsfw/timemanager/TimeReaderIF.h | 20 +++++++++-- src/fsfw/timemanager/TimeStamperIF.h | 23 ------------- src/fsfw/timemanager/TimeWriterIF.h | 34 +++++++++++++++++++ src/fsfw/tmstorage/TmStorePackets.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 6 ++-- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 14 ++++---- src/fsfw/tmtcpacket/pus/tm/PusTmIF.h | 2 +- .../tmtcservices/CommandingServiceBase.cpp | 2 +- src/fsfw/tmtcservices/CommandingServiceBase.h | 2 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 2 +- src/fsfw/tmtcservices/PusServiceBase.h | 2 +- src/fsfw/tmtcservices/SpacePacketParser.h | 5 +-- src/fsfw/tmtcservices/TmStoreHelper.cpp | 6 ++-- src/fsfw/tmtcservices/TmStoreHelper.h | 8 ++--- unittests/mocks/CdsShortTimestamperMock.h | 8 ++--- unittests/pus/testService11.cpp | 4 +-- 22 files changed, 105 insertions(+), 92 deletions(-) delete mode 100644 src/fsfw/timemanager/TimeStamperIF.h create mode 100644 src/fsfw/timemanager/TimeWriterIF.h diff --git a/src/fsfw/monitoring/MonitoringMessageContent.h b/src/fsfw/monitoring/MonitoringMessageContent.h index aeadacdf..7a7b5440 100644 --- a/src/fsfw/monitoring/MonitoringMessageContent.h +++ b/src/fsfw/monitoring/MonitoringMessageContent.h @@ -8,7 +8,7 @@ #include "../serialize/SerialLinkedListAdapter.h" #include "../serialize/SerializeElement.h" #include "../serviceinterface/ServiceInterface.h" -#include "../timemanager/TimeStamperIF.h" +#include "../timemanager/TimeWriterIF.h" #include "HasMonitorsIF.h" #include "MonitoringIF.h" #include "monitoringConf.h" @@ -34,9 +34,9 @@ class MonitoringReportContent : public SerialLinkedListAdapter { SerializeElement limitValue; SerializeElement oldState; SerializeElement newState; - uint8_t rawTimestamp[TimeStamperIF::MAXIMUM_TIMESTAMP_LEN] = {}; + uint8_t rawTimestamp[TimeWriterIF::MAXIMUM_TIMESTAMP_LEN] = {}; SerializeElement> timestampSerializer; - TimeStamperIF* timeStamper; + TimeWriterIF* timeStamper; MonitoringReportContent() : SerialLinkedListAdapter(¶meterObjectId), monitorId(0), @@ -79,7 +79,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter { } bool checkAndSetStamper() { if (timeStamper == nullptr) { - timeStamper = ObjectManager::instance()->get(timeStamperId); + timeStamper = ObjectManager::instance()->get(timeStamperId); if (timeStamper == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MonitoringReportContent::checkAndSetStamper: " diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 05386493..0c750d3c 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -564,7 +564,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(); @@ -573,7 +573,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/pus/Service1TelecommandVerification.cpp b/src/fsfw/pus/Service1TelecommandVerification.cpp index adc00588..a3248045 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.cpp +++ b/src/fsfw/pus/Service1TelecommandVerification.cpp @@ -11,7 +11,7 @@ Service1TelecommandVerification::Service1TelecommandVerification(object_id_t obj uint16_t apid, uint8_t serviceId, object_id_t targetDestination, uint16_t messageQueueDepth, - TimeStamperIF* timeStamper) + TimeWriterIF* timeStamper) : SystemObject(objectId), apid(apid), serviceId(serviceId), @@ -134,7 +134,7 @@ ReturnValue_t Service1TelecommandVerification::initialize() { storeHelper.setTmStore(*tmStore); } if (timeStamper == nullptr) { - timeStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); + timeStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); if (timeStamper == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/src/fsfw/pus/Service1TelecommandVerification.h b/src/fsfw/pus/Service1TelecommandVerification.h index fa4aba7c..f5844995 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.h +++ b/src/fsfw/pus/Service1TelecommandVerification.h @@ -47,7 +47,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, Service1TelecommandVerification(object_id_t objectId, uint16_t apid, uint8_t serviceId, object_id_t targetDestination, uint16_t messageQueueDepth, - TimeStamperIF* timeStamper = nullptr); + TimeWriterIF* timeStamper = nullptr); ~Service1TelecommandVerification() override; /** @@ -87,7 +87,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF, TmStoreHelper storeHelper; TmStoreAndSendWrapper tmHelper; InternalErrorReporterIF* errReporter = nullptr; - TimeStamperIF* timeStamper = nullptr; + TimeWriterIF* timeStamper = nullptr; StorageManagerIF* tmStore = nullptr; MessageQueueIF* tmQueue = nullptr; diff --git a/src/fsfw/timemanager/CdsShortTimeStamper.cpp b/src/fsfw/timemanager/CdsShortTimeStamper.cpp index 8095e28d..8fb33f12 100644 --- a/src/fsfw/timemanager/CdsShortTimeStamper.cpp +++ b/src/fsfw/timemanager/CdsShortTimeStamper.cpp @@ -6,11 +6,6 @@ CdsShortTimeStamper::CdsShortTimeStamper(object_id_t objectId) : SystemObject(objectId) {} -ReturnValue_t CdsShortTimeStamper::addTimeStamp(uint8_t *buffer, const uint8_t maxSize) { - size_t serLen = 0; - return serialize(&buffer, &serLen, maxSize, SerializeIF::Endianness::NETWORK); -} - ReturnValue_t CdsShortTimeStamper::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { if (*size + getSerializedSize() > maxSize) { @@ -33,15 +28,22 @@ size_t CdsShortTimeStamper::getSerializedSize() const { return getTimestampSize( ReturnValue_t CdsShortTimeStamper::deSerialize(const uint8_t **buffer, size_t *size, SerializeIF::Endianness streamEndianness) { - return returnvalue::FAILED; -} - -ReturnValue_t CdsShortTimeStamper::readTimeStamp(const uint8_t *buffer, size_t maxSize) { - if (maxSize < getTimestampSize()) { + if (size == nullptr or buffer == nullptr) { + return returnvalue::FAILED; + } + if (*size < getTimestampSize()) { return SerializeIF::STREAM_TOO_SHORT; } size_t foundLen = 0; - return CCSDSTime::convertFromCcsds(&readTime, buffer, &foundLen, maxSize); + if (((**buffer >> 4) & 0b111) != CCSDSTime::TimeCodeIdentification::CDS) { + return BAD_TIMESTAMP; + } + auto res = CCSDSTime::convertFromCcsds(&readTime, *buffer, &foundLen, *size); + if (res == returnvalue::OK) { + *size -= getSerializedSize(); + *buffer += getSerializedSize(); + } + return res; } timeval &CdsShortTimeStamper::getTime() { return readTime; } diff --git a/src/fsfw/timemanager/CdsShortTimeStamper.h b/src/fsfw/timemanager/CdsShortTimeStamper.h index 4b1f6c28..244d54b6 100644 --- a/src/fsfw/timemanager/CdsShortTimeStamper.h +++ b/src/fsfw/timemanager/CdsShortTimeStamper.h @@ -3,7 +3,7 @@ #include "CCSDSTime.h" #include "TimeReaderIF.h" -#include "TimeStamperIF.h" +#include "TimeWriterIF.h" #include "fsfw/objectmanager/SystemObject.h" /** @@ -15,7 +15,7 @@ * overriding the #addTimeStamp function. * @ingroup utility */ -class CdsShortTimeStamper : public TimeStamperIF, public TimeReaderIF, public SystemObject { +class CdsShortTimeStamper : public TimeWriterIF, public TimeReaderIF, public SystemObject { public: static constexpr size_t TIMESTAMP_LEN = 7; /** @@ -25,20 +25,11 @@ class CdsShortTimeStamper : public TimeStamperIF, public TimeReaderIF, public Sy */ explicit CdsShortTimeStamper(object_id_t objectId); - /** - * Adds a CCSDS CDC short 8 byte timestamp to the given buffer. - * This function can be overriden to use a custom timestamp. - * @param buffer - * @param maxSize - * @return - */ - ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override; ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; - ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override; timeval &getTime() override; [[nodiscard]] size_t getTimestampSize() const override; diff --git a/src/fsfw/timemanager/TimeReaderIF.h b/src/fsfw/timemanager/TimeReaderIF.h index a3343e1c..8fd7415f 100644 --- a/src/fsfw/timemanager/TimeReaderIF.h +++ b/src/fsfw/timemanager/TimeReaderIF.h @@ -5,12 +5,28 @@ #include "TimeStampIF.h" #include "fsfw/returnvalues/returnvalue.h" +#include "fsfw/serialize/SerializeIF.h" -class TimeReaderIF : public TimeStampIF { +class TimeReaderIF : public SerializeIF, public TimeStampIF { public: ~TimeReaderIF() override = default; - virtual ReturnValue_t readTimeStamp(const uint8_t* buffer, size_t maxSize) = 0; virtual timeval& getTime() = 0; + + [[nodiscard]] size_t getSerializedSize() const override { return getTimestampSize(); } + + ReturnValue_t readTimeStamp(const uint8_t* buf, size_t maxSize) { + size_t dummy = 0; + return deSerialize(buf, dummy, maxSize, SerializeIF::Endianness::NETWORK); + } + + private: + /** + * Forbidden, use dedicated IF @TimeWriterIF + */ + [[nodiscard]] ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const override { + return returnvalue::FAILED; + } }; #endif // FSFW_TIMEMANAGER_TIMEREADERIF_H diff --git a/src/fsfw/timemanager/TimeStamperIF.h b/src/fsfw/timemanager/TimeStamperIF.h deleted file mode 100644 index 9085c067..00000000 --- a/src/fsfw/timemanager/TimeStamperIF.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ -#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ - -#include "TimeStampIF.h" -#include "fsfw/returnvalues/returnvalue.h" -#include "fsfw/serialize/SerializeIF.h" - -/** - * A class implementing this IF provides facilities to add a time stamp to the - * buffer provided. - * Implementors need to ensure that calling the method is thread-safe, i.e. - * addTimeStamp may be called in parallel from a different context. - */ -class TimeStamperIF : public SerializeIF, public TimeStampIF { - public: - virtual ReturnValue_t addTimeStamp(uint8_t* buffer, uint8_t maxSize) = 0; - ~TimeStamperIF() override = default; - size_t getTimestampSize() const override { return getSerializedSize(); } - - protected: -}; - -#endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */ diff --git a/src/fsfw/timemanager/TimeWriterIF.h b/src/fsfw/timemanager/TimeWriterIF.h new file mode 100644 index 00000000..bc8aacc5 --- /dev/null +++ b/src/fsfw/timemanager/TimeWriterIF.h @@ -0,0 +1,34 @@ +#ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ +#define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ + +#include "TimeStampIF.h" +#include "fsfw/returnvalues/returnvalue.h" +#include "fsfw/serialize/SerializeIF.h" + +/** + * A class implementing this IF provides facilities to add a time stamp to the + * buffer provided. + * Implementors need to ensure that calling the method is thread-safe, i.e. + * addTimeStamp may be called in parallel from a different context. + */ +class TimeWriterIF : public SerializeIF, public TimeStampIF { + public: + ~TimeWriterIF() override = default; + [[nodiscard]] size_t getTimestampSize() const override { return getSerializedSize(); } + + ReturnValue_t addTimeStamp(uint8_t *buf, size_t maxSize) { + size_t dummy = 0; + return serialize(buf, dummy, maxSize, SerializeIF::Endianness::NETWORK); + } + + private: + /** + * Forbidden, use dedicated IF @TimeReaderIF + */ + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override { + return returnvalue::FAILED; + } +}; + +#endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */ diff --git a/src/fsfw/tmstorage/TmStorePackets.h b/src/fsfw/tmstorage/TmStorePackets.h index a5d2f5a0..e519b3b7 100644 --- a/src/fsfw/tmstorage/TmStorePackets.h +++ b/src/fsfw/tmstorage/TmStorePackets.h @@ -7,7 +7,7 @@ #include "fsfw/serialize/SerialLinkedListAdapter.h" #include "fsfw/serialize/SerializeElement.h" #include "fsfw/timemanager/CCSDSTime.h" -#include "fsfw/timemanager/TimeStamperIF.h" +#include "fsfw/timemanager/TimeWriterIF.h" #include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h" #include "tmStorageConf.h" diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index b754e990..09914e09 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -3,7 +3,7 @@ #include #include "fsfw/globalfunctions/CRC.h" -#include "fsfw/timemanager/TimeStamperIF.h" +#include "fsfw/timemanager/TimeWriterIF.h" PusTmCreator::PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams) : pusParams(initPusParams), spCreator(std::move(initSpParams)) { @@ -30,7 +30,7 @@ uint8_t PusTmCreator::getSubService() const { return pusParams.secHeader.subserv PusTmParams& PusTmCreator::getParams() { return pusParams; } -void PusTmCreator::setTimeStamper(TimeStamperIF& timeStamper_) { +void PusTmCreator::setTimeStamper(TimeWriterIF& timeStamper_) { pusParams.secHeader.timeStamper = &timeStamper_; updateSpLengthField(); } @@ -106,7 +106,7 @@ ReturnValue_t PusTmCreator::deSerialize(const uint8_t** buffer, size_t* size, return returnvalue::FAILED; } -TimeStamperIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader.timeStamper; } +TimeWriterIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader.timeStamper; } SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 8fd4f690..09d02945 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -8,12 +8,12 @@ struct PusTmSecHeader { PusTmSecHeader() = default; - PusTmSecHeader(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper) + PusTmSecHeader(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper) : service(service), subservice(subservice), timeStamper(timeStamper) {} uint8_t service = 0; uint8_t subservice = 0; - TimeStamperIF* timeStamper = nullptr; + TimeWriterIF* timeStamper = nullptr; uint8_t pusVersion = ecss::PusVersion::PUS_C; uint8_t scTimeRefStatus = 0; uint16_t messageTypeCounter = 0; @@ -26,10 +26,10 @@ struct PusTmParams { PusTmParams(PusTmSecHeader secHeader, util::DataWrapper dataWrapper) : secHeader(secHeader), dataWrapper(dataWrapper) {} - PusTmParams(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper) + PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper) : secHeader(service, subservice, timeStamper) {} - PusTmParams(uint8_t service, uint8_t subservice, TimeStamperIF* timeStamper, + PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, util::DataWrapper dataWrapper_) : PusTmParams(service, subservice, timeStamper) { dataWrapper = dataWrapper_; @@ -38,7 +38,7 @@ struct PusTmParams { util::DataWrapper dataWrapper{}; }; -class TimeStamperIF; +class TimeWriterIF; /** * This class provides a high-level interface to create PUS TM packets and then @serialize @@ -56,7 +56,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF PusTmCreator(SpacePacketParams initSpParams, PusTmParams initPusParams); ~PusTmCreator() override = default; - void setTimeStamper(TimeStamperIF& timeStamper); + void setTimeStamper(TimeWriterIF& timeStamper); /** * This function disables the CRC16 calculation on serialization. This is useful to avoid * duplicate calculation if some lower level component needs to update fields like the sequence @@ -86,7 +86,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; - [[nodiscard]] TimeStamperIF* getTimestamper() const; + [[nodiscard]] TimeWriterIF* getTimestamper() const; ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override; ReturnValue_t setSerializableUserData(SerializeIF& serializable) override; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h b/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h index 356cf20b..ee3005ca 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmIF.h @@ -4,7 +4,7 @@ #include #include -#include "fsfw/timemanager/TimeStamperIF.h" +#include "fsfw/timemanager/TimeWriterIF.h" #include "fsfw/tmtcpacket/pus/PusIF.h" #include "fsfw/tmtcpacket/pus/defs.h" diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 46852751..63db51ff 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -104,7 +104,7 @@ ReturnValue_t CommandingServiceBase::initialize() { // This avoids duplicate calculation of the CRC16 tmStoreHelper.disableCrcCalculation(); if (tmTimeStamper == nullptr) { - tmTimeStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); + tmTimeStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); if (tmTimeStamper == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 9dfbd8bf..303d6d2e 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -272,7 +272,7 @@ class CommandingServiceBase : public SystemObject, MessageQueueIF* commandQueue = nullptr; MessageQueueIF* requestQueue = nullptr; - TimeStamperIF* tmTimeStamper = nullptr; + TimeWriterIF* tmTimeStamper = nullptr; VerificationReporterIF* verificationReporter; InternalErrorReporterIF* errReporter = nullptr; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 6900a2ac..091ab2f8 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -178,7 +178,7 @@ ReturnValue_t PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelp } if (psbParams.timeStamper == nullptr) { - auto timerStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); + auto timerStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); if (timerStamper != nullptr) { tmStoreHelper.setTimeStamper(*timerStamper); } diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index ce4b03f5..8a4f3cd0 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -65,7 +65,7 @@ struct PsbParams { * register itself at that object. */ PUSDistributorIF* pusDistributor = nullptr; - TimeStamperIF* timeStamper = nullptr; + TimeWriterIF* timeStamper = nullptr; }; namespace Factory { diff --git a/src/fsfw/tmtcservices/SpacePacketParser.h b/src/fsfw/tmtcservices/SpacePacketParser.h index 3a1b4d16..ea0a2feb 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/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index 501a7840..1c8e0a92 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -11,7 +11,7 @@ TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore) : } TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, - TimeStamperIF& timeStamper) + TimeWriterIF& timeStamper) : tmStore(&tmStore) { creator.setApid(defaultApid); creator.setTimeStamper(timeStamper); @@ -59,7 +59,7 @@ ReturnValue_t TmStoreHelper::addPacketToStore() { SerializeIF::Endianness::NETWORK); } -void TmStoreHelper::setTimeStamper(TimeStamperIF& timeStamper_) { +void TmStoreHelper::setTimeStamper(TimeWriterIF& timeStamper_) { creator.setTimeStamper(timeStamper_); } @@ -67,7 +67,7 @@ void TmStoreHelper::setApid(uint16_t apid) { creator.setApid(apid); } PusTmCreator& TmStoreHelper::getCreatorRef() { return creator; } -TimeStamperIF* TmStoreHelper::getTimeStamper() const { return creator.getTimestamper(); } +TimeWriterIF* TmStoreHelper::getTimeStamper() const { return creator.getTimestamper(); } uint16_t TmStoreHelper::getApid() const { return creator.getApid(); } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index 449a2287..f73d0c8b 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -4,14 +4,14 @@ #include "fsfw/internalerror/InternalErrorReporterIF.h" #include "fsfw/ipc/MessageQueueMessageIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/timemanager/TimeStamperIF.h" +#include "fsfw/timemanager/TimeWriterIF.h" #include "fsfw/tmtcpacket/pus/tm/PusTmCreator.h" class TmStoreHelper { public: explicit TmStoreHelper(uint16_t defaultApid); TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore); - TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, TimeStamperIF& timeStamper); + TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, TimeWriterIF& timeStamper); void disableCrcCalculation(); [[nodiscard]] bool crcCalculationEnabled() const; @@ -20,8 +20,8 @@ class TmStoreHelper { PusTmCreator& getCreatorRef(); - void setTimeStamper(TimeStamperIF& timeStamper); - [[nodiscard]] TimeStamperIF* getTimeStamper() const; + void setTimeStamper(TimeWriterIF& timeStamper); + [[nodiscard]] TimeWriterIF* getTimeStamper() const; [[nodiscard]] StorageManagerIF* getTmStore() const; void setTmStore(StorageManagerIF& store); diff --git a/unittests/mocks/CdsShortTimestamperMock.h b/unittests/mocks/CdsShortTimestamperMock.h index ca7a674c..1ce13581 100644 --- a/unittests/mocks/CdsShortTimestamperMock.h +++ b/unittests/mocks/CdsShortTimestamperMock.h @@ -4,9 +4,9 @@ #include #include "fsfw/timemanager/TimeReaderIF.h" -#include "fsfw/timemanager/TimeStamperIF.h" +#include "fsfw/timemanager/TimeWriterIF.h" -class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { +class CdsShortTimestamperMock : public TimeWriterIF, public TimeReaderIF { public: unsigned int serializeCallCount = 0; unsigned int deserializeCallCount = 0; @@ -61,7 +61,6 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { } [[nodiscard]] size_t getTimestampSize() const override { return getSerializedSize(); } - ReturnValue_t addTimeStamp(uint8_t *buffer, uint8_t maxSize) override { return 0; } void reset() { serializeCallCount = 0; @@ -75,9 +74,6 @@ class CdsShortTimestamperMock : public TimeStamperIF, public TimeReaderIF { serFailRetval = returnvalue::FAILED; } - ReturnValue_t readTimeStamp(const uint8_t *buffer, size_t maxSize) override { - return deSerialize(&buffer, &maxSize, SerializeIF::Endianness::NETWORK); - } timeval &getTime() override { return dummyTime; } private: diff --git a/unittests/pus/testService11.cpp b/unittests/pus/testService11.cpp index 54279543..bd3b22ad 100644 --- a/unittests/pus/testService11.cpp +++ b/unittests/pus/testService11.cpp @@ -7,8 +7,8 @@ #include "tmtc/pusIds.h" TEST_CASE("PUS Service 11", "[pus-srvc11]") { - Service11TelecommandScheduling<13> pusService11({objects::PUS_SERVICE_11_TC_SCHEDULER, - apid::DEFAULT_APID, pus::PUS_SERVICE_11}, nullptr); + Service11TelecommandScheduling<13> pusService11( + {objects::PUS_SERVICE_11_TC_SCHEDULER, apid::DEFAULT_APID, pus::PUS_SERVICE_11}, nullptr); // TODO test something... } \ No newline at end of file From f0b7a103d4412169a792c833258a7229376f3bae Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 15:30:53 +0200 Subject: [PATCH 311/532] refactor ctors --- src/fsfw/serialize/SerialBufferAdapter.cpp | 7 ++++++ src/fsfw/serialize/SerialBufferAdapter.h | 12 +++++----- src/fsfw/tmtcpacket/pus/CustomUserDataIF.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 21 ++++++----------- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 25 ++++++++++++++------- 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 81919f37..0893dbde 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -125,6 +125,13 @@ void SerialBufferAdapter::setBuffer(uint8_t* buffer, count_t bufferLeng this->bufferLength = bufferLength; } +template +void SerialBufferAdapter::setConstBuffer(const uint8_t* buf, count_t bufLen) { + this->buffer = nullptr; + this->bufferLength = bufLen; + this->constBuffer = buf; +} + // forward Template declaration for linker template class SerialBufferAdapter; template class SerialBufferAdapter; diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index 3b95fa20..e53a12bc 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, + 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,13 @@ class SerialBufferAdapter : public SerializeIF { * @param bigEndian * @return */ - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override; uint8_t* getBuffer(); - const uint8_t* getConstBuffer() const; + [[nodiscard]] const uint8_t* getConstBuffer() const; void setBuffer(uint8_t* buffer, count_t bufferLength); + void setConstBuffer(const uint8_t* buf, count_t bufLen); private: bool serializeLength = false; diff --git a/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h b/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h index 779a0414..33592ed1 100644 --- a/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h +++ b/src/fsfw/tmtcpacket/pus/CustomUserDataIF.h @@ -7,6 +7,6 @@ class CustomUserDataIF { public: virtual ~CustomUserDataIF() = default; virtual ReturnValue_t setRawUserData(const uint8_t* data, size_t len) = 0; - virtual ReturnValue_t setSerializableUserData(SerializeIF& serializable) = 0; + virtual ReturnValue_t setSerializableUserData(const SerializeIF& serializable) = 0; }; #endif // FSFW_TMTCPACKET_CREATORDATAIF_H diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 09914e09..1288b6d8 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -51,7 +51,7 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max if (result != returnvalue::OK) { return result; } - size_t userDataLen = pusParams.dataWrapper.getLength(); + size_t userDataLen = pusParams.data->getSerializedSize(); **buffer = ((pusParams.secHeader.pusVersion << 4) & 0xF0) | (pusParams.secHeader.scTimeRefStatus & 0x0F); *buffer += 1; @@ -77,15 +77,8 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max } } - if (pusParams.dataWrapper.type == util::DataTypes::RAW and - pusParams.dataWrapper.dataUnion.raw.data != nullptr) { - std::memcpy(*buffer, pusParams.dataWrapper.dataUnion.raw.data, userDataLen); - *buffer += userDataLen; - *size += userDataLen; - } else if (pusParams.dataWrapper.type == util::DataTypes::SERIALIZABLE and - pusParams.dataWrapper.dataUnion.serializable != nullptr) { - result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, - streamEndianness); + if (pusParams.data != nullptr) { + result = pusParams.data->serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; } @@ -111,7 +104,7 @@ TimeWriterIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader. SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } void PusTmCreator::updateSpLengthField() { - size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + pusParams.dataWrapper.getLength() + + size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + pusParams.data->getSerializedSize() + sizeof(ecss::PusChecksumT) - 1; if (pusParams.secHeader.timeStamper != nullptr) { headerLen += pusParams.secHeader.timeStamper->getSerializedSize(); @@ -134,12 +127,12 @@ void PusTmCreator::setMessageTypeCounter(uint16_t messageTypeCounter) { void PusTmCreator::setDestId(uint16_t destId) { pusParams.secHeader.destId = destId; } ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { - pusParams.dataWrapper.setRawData({data, len}); + pusParams.adapter.setConstBuffer(data, len); updateSpLengthField(); return returnvalue::OK; } -ReturnValue_t PusTmCreator::setSerializableUserData(SerializeIF& serializable) { - pusParams.dataWrapper.setSerializable(serializable); +ReturnValue_t PusTmCreator::setSerializableUserData(const SerializeIF& serializable) { + pusParams.data = &serializable; updateSpLengthField(); return returnvalue::OK; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index 09d02945..c108aa73 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -22,20 +22,29 @@ struct PusTmSecHeader { struct PusTmParams { PusTmParams() = default; - explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader){}; - PusTmParams(PusTmSecHeader secHeader, util::DataWrapper dataWrapper) - : secHeader(secHeader), dataWrapper(dataWrapper) {} - + explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader) {}; + PusTmParams(PusTmSecHeader secHeader, const SerializeIF& data) + : secHeader(secHeader), data(&data) {} + PusTmParams(PusTmSecHeader secHeader, const uint8_t* data, size_t dataLen) + : secHeader(secHeader), adapter(data, dataLen), data(&adapter) { + } PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper) : secHeader(service, subservice, timeStamper) {} PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, - util::DataWrapper dataWrapper_) + const SerializeIF& data_) : PusTmParams(service, subservice, timeStamper) { - dataWrapper = dataWrapper_; + data = &data_; } + + PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, + const uint8_t* data, size_t dataLen) + : secHeader(service, subservice, timeStamper), + adapter(data, dataLen), + data(&adapter) {} PusTmSecHeader secHeader; - util::DataWrapper dataWrapper{}; + SerialBufferAdapter adapter; + const SerializeIF* data = nullptr; }; class TimeWriterIF; @@ -88,7 +97,7 @@ class PusTmCreator : public SerializeIF, public PusTmIF, public CustomUserDataIF [[nodiscard]] size_t getSerializedSize() const override; [[nodiscard]] TimeWriterIF* getTimestamper() const; ReturnValue_t setRawUserData(const uint8_t* data, size_t len) override; - ReturnValue_t setSerializableUserData(SerializeIF& serializable) override; + ReturnValue_t setSerializableUserData(const SerializeIF& serializable) override; // Load all big endian (network endian) helpers into scope using SerializeIF::serializeBe; From b7a1f79d5b97ad333a3d8e20f281329ee69a0114 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 15:36:12 +0200 Subject: [PATCH 312/532] 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 adf9912f..e80abf24 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 75dc7a405d566ba99cb742eb967f6261b2e0c440 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:02:32 +0200 Subject: [PATCH 313/532] del data wrapper --- src/fsfw/serialize/SerialBufferAdapter.cpp | 2 +- src/fsfw/serialize/SerialBufferAdapter.h | 4 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 28 ++++----- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 13 +++- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 20 ++++--- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 20 +++---- src/fsfw/util/dataWrapper.h | 60 ------------------- unittests/tmtcpacket/testPusTcCreator.cpp | 2 +- .../tmtcservices/testStoreAndSendHelper.cpp | 16 ++--- 9 files changed, 52 insertions(+), 113 deletions(-) delete mode 100644 src/fsfw/util/dataWrapper.h diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 0893dbde..0293191e 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, diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index e53a12bc..395f93d2 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.h +++ b/src/fsfw/serialize/SerialBufferAdapter.h @@ -44,7 +44,7 @@ class SerialBufferAdapter : public SerializeIF { ~SerialBufferAdapter() override; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const override; + Endianness streamEndianness) const override; [[nodiscard]] size_t getSerializedSize() const override; @@ -61,7 +61,7 @@ class SerialBufferAdapter : public SerializeIF { * @return */ ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) override; + Endianness streamEndianness) override; uint8_t* getBuffer(); [[nodiscard]] const uint8_t* getConstBuffer() const; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 14a440a0..34d8396d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -14,7 +14,6 @@ PusTcCreator::PusTcCreator(SpacePacketParams spParams, PusTcParams pusParams) ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) const { const uint8_t *start = *buffer; - size_t userDataLen = pusParams.dataWrapper.getLength(); if (*size + getSerializedSize() > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } @@ -37,17 +36,8 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max if (result != returnvalue::OK) { return result; } - if (pusParams.dataWrapper.type == util::DataTypes::RAW) { - const uint8_t *data = pusParams.dataWrapper.dataUnion.raw.data; - if (data != nullptr and userDataLen > 0) { - std::memcpy(*buffer, data, userDataLen); - *buffer += userDataLen; - *size += userDataLen; - } - } else if (pusParams.dataWrapper.type == util::DataTypes::SERIALIZABLE and - pusParams.dataWrapper.dataUnion.serializable != nullptr) { - result = pusParams.dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, - streamEndianness); + if (pusParams.appData != nullptr) { + result = pusParams.appData->serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; } @@ -58,8 +48,11 @@ ReturnValue_t PusTcCreator::serialize(uint8_t **buffer, size_t *size, size_t max } void PusTcCreator::updateSpLengthField() { - spCreator.setDataLen(ecss::PusTcDataFieldHeader::MIN_SIZE + pusParams.dataWrapper.getLength() + - 1); + size_t len = ecss::PusTcDataFieldHeader::MIN_SIZE + 1; + if (pusParams.appData != nullptr) { + len += pusParams.appData->getSerializedSize(); + } + spCreator.setDataLen(len); } size_t PusTcCreator::getSerializedSize() const { return spCreator.getFullPacketLen(); } @@ -91,14 +84,15 @@ SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { // TODO: Check length field? - pusParams.dataWrapper.setRawData({data, len}); + pusParams.bufAdapter.setConstBuffer(data, len); + pusParams.appData = &pusParams.bufAdapter; updateSpLengthField(); return returnvalue::OK; } -ReturnValue_t PusTcCreator::setSerializableUserData(SerializeIF &serializable) { +ReturnValue_t PusTcCreator::setSerializableUserData(const SerializeIF &serializable) { // TODO: Check length field? - pusParams.dataWrapper.setSerializable(serializable); + pusParams.appData = &serializable; updateSpLengthField(); return returnvalue::OK; } diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 4b0d81c8..add8a379 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -7,16 +7,23 @@ #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" #include "fsfw/tmtcpacket/pus/defs.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" -#include "fsfw/util/dataWrapper.h" struct PusTcParams { PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {} + void setRawAppData(const uint8_t *data, size_t len) { + bufAdapter.setConstBuffer(data, len); + appData = &bufAdapter; + } + + void setSerializableAppData(const SerializeIF &serializable) { appData = &serializable; } + uint8_t service; uint8_t subservice; uint8_t ackFlags = ecss::ACK_ALL; uint16_t sourceId = 0; - util::DataWrapper dataWrapper{}; + SerialBufferAdapter bufAdapter; + const SerializeIF *appData = nullptr; uint8_t pusVersion = ecss::PusVersion::PUS_C; }; @@ -52,7 +59,7 @@ class PusTcCreator : public PusTcIF, public SerializeIF, public CustomUserDataIF [[nodiscard]] uint8_t getSubService() const override; [[nodiscard]] uint16_t getSourceId() const override; ReturnValue_t setRawUserData(const uint8_t *data, size_t len) override; - ReturnValue_t setSerializableUserData(SerializeIF &serializable) override; + ReturnValue_t setSerializableUserData(const SerializeIF &serializable) override; // Load all big endian helpers into the class namespace using SerializeIF::serializeBe; diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 1288b6d8..41512c07 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -51,7 +51,6 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max if (result != returnvalue::OK) { return result; } - size_t userDataLen = pusParams.data->getSerializedSize(); **buffer = ((pusParams.secHeader.pusVersion << 4) & 0xF0) | (pusParams.secHeader.scTimeRefStatus & 0x0F); *buffer += 1; @@ -77,8 +76,8 @@ ReturnValue_t PusTmCreator::serialize(uint8_t** buffer, size_t* size, size_t max } } - if (pusParams.data != nullptr) { - result = pusParams.data->serialize(buffer, size, maxSize, streamEndianness); + if (pusParams.sourceData != nullptr) { + result = pusParams.sourceData->serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; } @@ -104,8 +103,10 @@ TimeWriterIF* PusTmCreator::getTimestamper() const { return pusParams.secHeader. SpacePacketParams& PusTmCreator::getSpParams() { return spCreator.getParams(); } void PusTmCreator::updateSpLengthField() { - size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + pusParams.data->getSerializedSize() + - sizeof(ecss::PusChecksumT) - 1; + size_t headerLen = PusTmIF::MIN_SEC_HEADER_LEN + sizeof(ecss::PusChecksumT) - 1; + if (pusParams.sourceData != nullptr) { + headerLen += pusParams.sourceData->getSerializedSize(); + } if (pusParams.secHeader.timeStamper != nullptr) { headerLen += pusParams.secHeader.timeStamper->getSerializedSize(); } @@ -127,12 +128,17 @@ void PusTmCreator::setMessageTypeCounter(uint16_t messageTypeCounter) { void PusTmCreator::setDestId(uint16_t destId) { pusParams.secHeader.destId = destId; } ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { - pusParams.adapter.setConstBuffer(data, len); + if (data == nullptr or len == 0) { + pusParams.sourceData = nullptr; + } else { + pusParams.adapter.setConstBuffer(data, len); + pusParams.sourceData = &pusParams.adapter; + } updateSpLengthField(); return returnvalue::OK; } ReturnValue_t PusTmCreator::setSerializableUserData(const SerializeIF& serializable) { - pusParams.data = &serializable; + pusParams.sourceData = &serializable; updateSpLengthField(); return returnvalue::OK; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index c108aa73..caf6f219 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -4,7 +4,6 @@ #include "PusTmIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" -#include "fsfw/util/dataWrapper.h" struct PusTmSecHeader { PusTmSecHeader() = default; @@ -22,29 +21,26 @@ struct PusTmSecHeader { struct PusTmParams { PusTmParams() = default; - explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader) {}; + explicit PusTmParams(PusTmSecHeader secHeader) : secHeader(secHeader){}; PusTmParams(PusTmSecHeader secHeader, const SerializeIF& data) - : secHeader(secHeader), data(&data) {} + : secHeader(secHeader), sourceData(&data) {} PusTmParams(PusTmSecHeader secHeader, const uint8_t* data, size_t dataLen) - : secHeader(secHeader), adapter(data, dataLen), data(&adapter) { - } + : secHeader(secHeader), adapter(data, dataLen), sourceData(&adapter) {} PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper) : secHeader(service, subservice, timeStamper) {} PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, const SerializeIF& data_) : PusTmParams(service, subservice, timeStamper) { - data = &data_; + sourceData = &data_; } - PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, - const uint8_t* data, size_t dataLen) - : secHeader(service, subservice, timeStamper), - adapter(data, dataLen), - data(&adapter) {} + PusTmParams(uint8_t service, uint8_t subservice, TimeWriterIF* timeStamper, const uint8_t* data, + size_t dataLen) + : secHeader(service, subservice, timeStamper), adapter(data, dataLen), sourceData(&adapter) {} PusTmSecHeader secHeader; SerialBufferAdapter adapter; - const SerializeIF* data = nullptr; + const SerializeIF* sourceData = nullptr; }; class TimeWriterIF; diff --git a/src/fsfw/util/dataWrapper.h b/src/fsfw/util/dataWrapper.h deleted file mode 100644 index 74a9ff5f..00000000 --- a/src/fsfw/util/dataWrapper.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef FSFW_UTIL_DATAWRAPPER_H -#define FSFW_UTIL_DATAWRAPPER_H - -#include -#include -#include - -#include "fsfw/serialize.h" - -namespace util { - -struct RawData { - const uint8_t* data = nullptr; - size_t len = 0; -}; - -enum DataTypes { NONE, RAW, SERIALIZABLE }; - -union DataUnion { - RawData raw; - SerializeIF* serializable = nullptr; -}; - -struct DataWrapper { - DataTypes type = DataTypes::NONE; - DataUnion dataUnion; - using BufPairT = std::pair; - - [[nodiscard]] size_t getLength() const { - if (type == DataTypes::RAW) { - return dataUnion.raw.len; - } else if (type == DataTypes::SERIALIZABLE and dataUnion.serializable != nullptr) { - return dataUnion.serializable->getSerializedSize(); - } - return 0; - } - - [[nodiscard]] bool isNull() const { - if ((type == DataTypes::NONE) or (type == DataTypes::RAW and dataUnion.raw.data == nullptr) or - (type == DataTypes::SERIALIZABLE and dataUnion.serializable == nullptr)) { - return true; - } - return false; - } - - void setRawData(BufPairT bufPair) { - type = DataTypes::RAW; - dataUnion.raw.data = bufPair.first; - dataUnion.raw.len = bufPair.second; - } - - void setSerializable(SerializeIF& serializable) { - type = DataTypes::SERIALIZABLE; - dataUnion.serializable = &serializable; - } -}; - -} // namespace util - -#endif // FSFW_UTIL_DATAWRAPPER_H diff --git a/unittests/tmtcpacket/testPusTcCreator.cpp b/unittests/tmtcpacket/testPusTcCreator.cpp index b18c4717..58f8cbf9 100644 --- a/unittests/tmtcpacket/testPusTcCreator.cpp +++ b/unittests/tmtcpacket/testPusTcCreator.cpp @@ -71,7 +71,7 @@ TEST_CASE("PUS TC Creator", "[pus-tc-creator]") { SECTION("Test with Application Data Raw") { auto& params = creator.getPusParams(); std::array data{1, 2, 3}; - params.dataWrapper.setRawData({data.data(), data.size()}); + params.setRawAppData(data.data(), data.size()); // To get correct size information, the SP length field needs to be updated automatically REQUIRE(creator.getSerializedSize() == 13); creator.updateSpLengthField(); diff --git a/unittests/tmtcservices/testStoreAndSendHelper.cpp b/unittests/tmtcservices/testStoreAndSendHelper.cpp index 2731b28f..46418dfe 100644 --- a/unittests/tmtcservices/testStoreAndSendHelper.cpp +++ b/unittests/tmtcservices/testStoreAndSendHelper.cpp @@ -44,9 +44,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(creator.getSubService() == 2); REQUIRE(creator.getService() == 17); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == util::DataTypes::RAW); - REQUIRE(params.dataWrapper.dataUnion.raw.data == nullptr); - REQUIRE(params.dataWrapper.dataUnion.raw.len == 0); + REQUIRE(params.sourceData == nullptr); REQUIRE(tmHelper.sendCounter == 0); REQUIRE(tmHelper.storeAndSendTmPacket() == returnvalue::OK); REQUIRE(tmHelper.sendCounter == 1); @@ -65,9 +63,9 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(tmHelper.prepareTmPacket(2, data.data(), data.size()) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == util::DataTypes::RAW); - REQUIRE(params.dataWrapper.dataUnion.raw.data == data.data()); - REQUIRE(params.dataWrapper.dataUnion.raw.len == data.size()); + REQUIRE(params.sourceData != nullptr); + REQUIRE(params.sourceData->getSerializedSize() == data.size()); + REQUIRE(params.adapter.getConstBuffer() == data.data()); } SECTION("Serializable Helper") { @@ -75,8 +73,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(tmHelper.prepareTmPacket(2, simpleSer) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == util::DataTypes::SERIALIZABLE); - REQUIRE(params.dataWrapper.dataUnion.serializable == &simpleSer); + REQUIRE(params.sourceData == &simpleSer); } SECTION("Object ID prefix Helper") { @@ -86,8 +83,7 @@ TEST_CASE("TM Store And Send Helper", "[tm-store-send-helper]") { REQUIRE(tmHelper.prepareTmPacket(2, dataWithObjId) == returnvalue::OK); auto& creator = storeHelper.getCreatorRef(); auto& params = creator.getParams(); - REQUIRE(params.dataWrapper.type == util::DataTypes::SERIALIZABLE); - REQUIRE(params.dataWrapper.dataUnion.serializable == &dataWithObjId); + REQUIRE(params.sourceData == &dataWithObjId); } // TODO: Error handling From 4c3f9feb938b83bf2472dccbb06162543f41f853 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:06:24 +0200 Subject: [PATCH 314/532] explicit include --- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index add8a379..a61b19d2 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -6,6 +6,7 @@ #include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" #include "fsfw/tmtcpacket/pus/defs.h" +#include "fsfw/serialize/SerialBufferAdapter.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" struct PusTcParams { From f5421e9abd389dde5e6524f76b9e579dbf494c47 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:10:06 +0200 Subject: [PATCH 315/532] refactor tm helper --- CMakeLists.txt | 3 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h | 1 + src/fsfw/tmtcservices/tmHelpers.h | 38 +++++++---------------- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b00a708..3011b244 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/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index a61b19d2..abccef8d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -1,12 +1,12 @@ #ifndef FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H #define FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H +#include "fsfw/serialize/SerialBufferAdapter.h" #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h" #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" #include "fsfw/tmtcpacket/pus/defs.h" -#include "fsfw/serialize/SerialBufferAdapter.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" struct PusTcParams { diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h index caf6f219..626d873e 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.h @@ -2,6 +2,7 @@ #define FSFW_TMTCPACKET_TMPACKETCREATOR_H #include "PusTmIF.h" +#include "fsfw/serialize/SerialBufferAdapter.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcpacket/pus/CustomUserDataIF.h" diff --git a/src/fsfw/tmtcservices/tmHelpers.h b/src/fsfw/tmtcservices/tmHelpers.h index 845a73b8..be93f5ec 100644 --- a/src/fsfw/tmtcservices/tmHelpers.h +++ b/src/fsfw/tmtcservices/tmHelpers.h @@ -10,48 +10,33 @@ namespace telemetry { class DataWithObjectIdPrefix : public SerializeIF { public: DataWithObjectIdPrefix(object_id_t objectId, const uint8_t* srcData, size_t srcDataLen) - : objectId(objectId) { - dataWrapper.type = util::DataTypes::RAW; - dataWrapper.dataUnion.raw.data = srcData; - dataWrapper.dataUnion.raw.len = srcDataLen; - } + : objectId(objectId), bufAdapter(srcData, srcDataLen), userData(&bufAdapter) {} - DataWithObjectIdPrefix(object_id_t objectId, SerializeIF& serializable) : objectId(objectId) { - dataWrapper.type = util::DataTypes::SERIALIZABLE; - dataWrapper.dataUnion.serializable = &serializable; - } + DataWithObjectIdPrefix(object_id_t objectId, const SerializeIF& serializable) + : objectId(objectId), userData(&serializable) {} ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override { if (*size + getSerializedSize() > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } - if (dataWrapper.type != util::DataTypes::RAW) { - if ((dataWrapper.dataUnion.raw.data == nullptr) and (dataWrapper.dataUnion.raw.len > 0)) { - return returnvalue::FAILED; - } - } else if (dataWrapper.type == util::DataTypes::SERIALIZABLE) { - if (dataWrapper.dataUnion.serializable == nullptr) { - return returnvalue::FAILED; - } - } ReturnValue_t result = SerializeAdapter::serialize(&objectId, buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; } - if (dataWrapper.type != util::DataTypes::RAW) { - std::memcpy(*buffer, dataWrapper.dataUnion.raw.data, dataWrapper.dataUnion.raw.len); - *buffer += dataWrapper.dataUnion.raw.len; - *size += dataWrapper.dataUnion.raw.len; - } else { - return dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, streamEndianness); + if (userData != nullptr) { + return userData->serialize(buffer, size, maxSize, streamEndianness); } return returnvalue::OK; } [[nodiscard]] size_t getSerializedSize() const override { - return sizeof(objectId) + dataWrapper.getLength(); + size_t len = 0; + if (userData != nullptr) { + len += userData->getSerializedSize(); + } + return len; } ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, @@ -63,7 +48,8 @@ class DataWithObjectIdPrefix : public SerializeIF { private: object_id_t objectId; - util::DataWrapper dataWrapper{}; + SerialBufferAdapter bufAdapter; + const SerializeIF* userData = nullptr; }; } // namespace telemetry From ece5ae59e4b7ab50e98d1f7b86e332366ab0c941 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:22:41 +0200 Subject: [PATCH 316/532] compile fixes --- src/fsfw/serialize/SerialBufferAdapter.cpp | 3 ++- src/fsfw/tmtcservices/PusServiceBase.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index f87d0812..36c0cef3 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -119,7 +119,8 @@ const uint8_t* SerialBufferAdapter::getConstBuffer() const { } template -void SerialBufferAdapter::setBuffer(const uint8_t* data, count_t len) { +void SerialBufferAdapter::setBuffer(uint8_t* data, count_t len) { + this->buffer = data; this->constBuffer = data; this->bufferLength = len; } diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index afad9e03..92ce0d99 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -68,7 +68,7 @@ struct PsbParams { * a suitable global distributor with the static ID @PusServiceBase::pusDistributor and * register itself at that object. */ - PUSDistributorIF* pusDistributor = nullptr; + PusDistributorIF* pusDistributor = nullptr; TimeWriterIF* timeStamper = nullptr; }; From afc48726b96d8f8294f1e139aee131ca1007c09f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:23:13 +0200 Subject: [PATCH 317/532] comment out check --- unittests/cfdp/handler/testDestHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 47f17f2d..79491bf9 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -67,7 +67,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { CHECK(metadataPdu.serialize(ptr, serLen, metadataPdu.getSerializedSize()) == OK); PacketInfo packetInfo(metadataPdu.getPduType(), metadataPdu.getDirectiveCode(), storeId); packetInfoList.push_back(packetInfo); - CHECK(destHandler.performStateMachine() == OK); + //CHECK(destHandler.performStateMachine() == OK); } SECTION("Small File Transfer") {} From 1e395dc402e2f0f5ff328ec0b89b92fcfdd17f33 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:25:02 +0200 Subject: [PATCH 318/532] set buffer expects const pointer now --- src/fsfw/serialize/SerialBufferAdapter.cpp | 9 +-------- src/fsfw/serialize/SerialBufferAdapter.h | 3 +-- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 2 +- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 0293191e..f387a1fc 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -119,14 +119,7 @@ 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; -} - -template -void SerialBufferAdapter::setConstBuffer(const uint8_t* buf, count_t bufLen) { +void SerialBufferAdapter::setBuffer(const uint8_t* buf, count_t bufLen) { this->buffer = nullptr; this->bufferLength = bufLen; this->constBuffer = buf; diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index 395f93d2..45ac5f0f 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.h +++ b/src/fsfw/serialize/SerialBufferAdapter.h @@ -65,8 +65,7 @@ class SerialBufferAdapter : public SerializeIF { uint8_t* getBuffer(); [[nodiscard]] const uint8_t* getConstBuffer() const; - void setBuffer(uint8_t* buffer, count_t bufferLength); - void setConstBuffer(const uint8_t* buf, count_t bufLen); + void setBuffer(const uint8_t* buf, count_t bufLen); private: bool serializeLength = false; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 34d8396d..50e75d80 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -84,7 +84,7 @@ SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { // TODO: Check length field? - pusParams.bufAdapter.setConstBuffer(data, len); + pusParams.bufAdapter.setBuffer(data, len); pusParams.appData = &pusParams.bufAdapter; updateSpLengthField(); return returnvalue::OK; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index abccef8d..0bd210b0 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -13,7 +13,7 @@ struct PusTcParams { PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {} void setRawAppData(const uint8_t *data, size_t len) { - bufAdapter.setConstBuffer(data, len); + bufAdapter.setBuffer(data, len); appData = &bufAdapter; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 41512c07..02955ffe 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -131,7 +131,7 @@ ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { if (data == nullptr or len == 0) { pusParams.sourceData = nullptr; } else { - pusParams.adapter.setConstBuffer(data, len); + pusParams.adapter.setBuffer(data, len); pusParams.sourceData = &pusParams.adapter; } updateSpLengthField(); From 3583e30ee66a06f96a36da1b8bae3bf0e581d7a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:27:20 +0200 Subject: [PATCH 319/532] rename const buf setter --- src/fsfw/cfdp/tlv/Lv.cpp | 4 ++-- src/fsfw/cfdp/tlv/Tlv.cpp | 4 ++-- src/fsfw/serialize/SerialBufferAdapter.cpp | 2 +- src/fsfw/serialize/SerialBufferAdapter.h | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 2 +- unittests/serialize/testSerialBufferAdapter.cpp | 3 ++- 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/fsfw/cfdp/tlv/Lv.cpp b/src/fsfw/cfdp/tlv/Lv.cpp index 9c72b260..8105ade6 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(const_cast(*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 3a394741..435466be 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(const_cast(*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/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index f387a1fc..cf28d2ba 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -119,7 +119,7 @@ const uint8_t* SerialBufferAdapter::getConstBuffer() const { } template -void SerialBufferAdapter::setBuffer(const uint8_t* buf, count_t bufLen) { +void SerialBufferAdapter::setConstBuffer(const uint8_t* buf, count_t bufLen) { this->buffer = nullptr; this->bufferLength = bufLen; this->constBuffer = buf; diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index 45ac5f0f..b156bb02 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.h +++ b/src/fsfw/serialize/SerialBufferAdapter.h @@ -65,7 +65,7 @@ class SerialBufferAdapter : public SerializeIF { uint8_t* getBuffer(); [[nodiscard]] const uint8_t* getConstBuffer() const; - void setBuffer(const uint8_t* buf, count_t bufLen); + void setConstBuffer(const uint8_t* buf, count_t bufLen); private: bool serializeLength = false; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 50e75d80..34d8396d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -84,7 +84,7 @@ SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { // TODO: Check length field? - pusParams.bufAdapter.setBuffer(data, len); + pusParams.bufAdapter.setConstBuffer(data, len); pusParams.appData = &pusParams.bufAdapter; updateSpLengthField(); return returnvalue::OK; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 0bd210b0..abccef8d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -13,7 +13,7 @@ struct PusTcParams { PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {} void setRawAppData(const uint8_t *data, size_t len) { - bufAdapter.setBuffer(data, len); + bufAdapter.setConstBuffer(data, len); appData = &bufAdapter; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 02955ffe..41512c07 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -131,7 +131,7 @@ ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { if (data == nullptr or len == 0) { pusParams.sourceData = nullptr; } else { - pusParams.adapter.setBuffer(data, len); + pusParams.adapter.setConstBuffer(data, len); pusParams.sourceData = &pusParams.adapter; } updateSpLengthField(); diff --git a/unittests/serialize/testSerialBufferAdapter.cpp b/unittests/serialize/testSerialBufferAdapter.cpp index e5ea379e..abd179e4 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 16688316a841ffe45909427089fe0af51dc0c81f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:31:56 +0200 Subject: [PATCH 320/532] 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 7b00a708..3011b244 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 9c72b260..33c0e381 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 3a394741..9d5f7f15 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 c82c1703..cb2f227f 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 81919f37..cf28d2ba 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 3b95fa20..b156bb02 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 3a1b4d16..ea0a2feb 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 e5ea379e..abd179e4 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 5a3f05fa7996a0261b7ccb6a6b47153dae949e19 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 17:20:29 +0200 Subject: [PATCH 321/532] return struct ref instead of code --- src/fsfw/cfdp/handler/DestHandler.cpp | 62 +++++++++++++++------- src/fsfw/cfdp/handler/DestHandler.h | 20 +++++-- unittests/cfdp/handler/testDestHandler.cpp | 14 +++-- 3 files changed, 70 insertions(+), 26 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 487ee817..5142731d 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -23,16 +23,19 @@ cfdp::DestHandler::DestHandler(DestHandlerParams params, FsfwParams fsfwParams) tp.pduConf.direction = cfdp::Direction::TOWARDS_SENDER; } -ReturnValue_t cfdp::DestHandler::performStateMachine() { +const cfdp::DestFsmResult& cfdp::DestHandler::performStateMachine() { ReturnValue_t result; - ReturnValue_t status = returnvalue::OK; + uint8_t errorIdx = 0; + fsmRes.callStatus = CallStatus::CALL_AFTER_DELAY; + fsmRes.result = OK; if (step == TransactionStep::IDLE) { for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { if (infoIter->pduType == PduType::FILE_DIRECTIVE and infoIter->directiveType == FileDirectives::METADATA) { result = handleMetadataPdu(*infoIter); - if (result != OK) { - status = result; + if (result != OK and errorIdx < 3) { + fsmRes.errorCodes[errorIdx] = result; + errorIdx++; } // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); @@ -50,17 +53,18 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { } if (step != TransactionStep::IDLE) { - return CALL_FSM_AGAIN; + fsmRes.callStatus = CallStatus::CALL_AGAIN; } - return status; + return updateFsmRes(errorIdx); } if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) { if (step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { if (infoIter->pduType == PduType::FILE_DATA) { result = handleFileDataPdu(*infoIter); - if (result != OK) { - status = result; + if (result != OK and errorIdx < 3) { + fsmRes.errorCodes[errorIdx] = result; + errorIdx++; } // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); @@ -69,8 +73,9 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { if (infoIter->pduType == PduType::FILE_DIRECTIVE and infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) { result = handleEofPdu(*infoIter); - if (result != OK) { - status = result; + if (result != OK and errorIdx < 3) { + fsmRes.errorCodes[errorIdx] = result; + errorIdx++; } // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); @@ -80,18 +85,20 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { } if (step == TransactionStep::TRANSFER_COMPLETION) { result = handleTransferCompletion(); - if (result != OK) { - status = result; + if (result != OK and errorIdx < 3) { + fsmRes.errorCodes[errorIdx] = result; + errorIdx++; } } if (step == TransactionStep::SENDING_FINISHED_PDU) { result = sendFinishedPdu(); - if (result != OK) { - status = result; + if (result != OK and errorIdx < 3) { + fsmRes.errorCodes[errorIdx] = result; + errorIdx++; } finish(); } - return status; + return updateFsmRes(errorIdx); } if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { // TODO: Will be implemented at a later stage @@ -99,7 +106,7 @@ ReturnValue_t cfdp::DestHandler::performStateMachine() { sif::warning << "CFDP state machine for acknowledged mode not implemented yet" << std::endl; #endif } - return OK; + return updateFsmRes(errorIdx); } ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) { @@ -146,7 +153,7 @@ ReturnValue_t cfdp::DestHandler::handleMetadataPdu(const PacketInfo& info) { // I think it might be a good idea to cache some sort of error code, which // is translated into a warning and/or event by an upper layer if (result != OK) { - return handleMetadataParseError(constAccessorPair.second.data(), + return handleMetadataParseError(result, constAccessorPair.second.data(), constAccessorPair.second.size()); } return startTransaction(reader, metadataInfo); @@ -228,7 +235,8 @@ ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) { return returnvalue::OK; } -ReturnValue_t cfdp::DestHandler::handleMetadataParseError(const uint8_t* rawData, size_t maxSize) { +ReturnValue_t cfdp::DestHandler::handleMetadataParseError(ReturnValue_t result, + const uint8_t* rawData, size_t maxSize) { // TODO: try to extract destination ID for error // TODO: Invalid metadata PDU. #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -236,7 +244,7 @@ ReturnValue_t cfdp::DestHandler::handleMetadataParseError(const uint8_t* rawData #else #endif HeaderReader headerReader(rawData, maxSize); - ReturnValue_t result = headerReader.parseData(); + result = headerReader.parseData(); if (result != OK) { // TODO: Now this really should not happen. Warning or error, // yield or cache appropriate returnvalue @@ -296,8 +304,13 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met tp.pduConf.direction = Direction::TOWARDS_SENDER; tp.transactionId.entityId = tp.pduConf.sourceId; tp.transactionId.seqNum = tp.pduConf.seqNum; - if (not dp.remoteCfgTable.getRemoteCfg(tp.pduConf.destId, &tp.remoteCfg)) { + if (not dp.remoteCfgTable.getRemoteCfg(tp.pduConf.sourceId, &tp.remoteCfg)) { // TODO: Warning, event etc. +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "cfdp::DestHandler" << __func__ + << ": No remote configuration found for destination ID " + << tp.pduConf.destId.getValue() << std::endl; +#endif return FAILED; } step = TransactionStep::RECEIVING_FILE_DATA_PDUS; @@ -421,3 +434,12 @@ ReturnValue_t cfdp::DestHandler::sendFinishedPdu() { } cfdp::DestHandler::TransactionStep cfdp::DestHandler::getTransactionStep() const { return step; } + +const cfdp::DestFsmResult& cfdp::DestHandler::updateFsmRes(uint8_t errors) { + fsmRes.errors = errors; + fsmRes.result = OK; + if (fsmRes.errors > 0) { + fsmRes.result = FAILED; + } + return fsmRes; +} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 1b4bed75..30806153 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -70,6 +70,16 @@ struct FsfwParams { StorageManagerIF* tmStore = nullptr; }; +enum class CallStatus { DONE, CALL_AFTER_DELAY, CALL_AGAIN }; + +struct DestFsmResult { + ReturnValue_t result = returnvalue::OK; + CallStatus callStatus = CallStatus::CALL_AFTER_DELAY; + uint32_t packetsSent = 0; + uint8_t errors = 0; + std::array errorCodes = {}; +}; + class DestHandler { public: enum class TransactionStep { @@ -83,7 +93,8 @@ class DestHandler { /** * Will be returned if it is advisable to call the state machine operation call again */ - ReturnValue_t CALL_FSM_AGAIN = returnvalue::makeCode(1, 0); + ReturnValue_t PARTIAL_SUCCESS = returnvalue::makeCode(0, 2); + ReturnValue_t FAILURE = returnvalue::makeCode(0, 3); explicit DestHandler(DestHandlerParams handlerParams, FsfwParams fsfwParams); /** @@ -92,7 +103,7 @@ class DestHandler { * - @c returnvalue::OK State machine OK for this execution cycle * - @c CALL_FSM_AGAIN State machine should be called again. */ - ReturnValue_t performStateMachine(); + const DestFsmResult& performStateMachine(); ReturnValue_t passPacket(PacketInfo packet); @@ -145,16 +156,19 @@ class DestHandler { DestHandlerParams dp; FsfwParams fp; TransactionParams tp; + DestFsmResult fsmRes; ReturnValue_t startTransaction(MetadataPduReader& reader, MetadataInfo& info); ReturnValue_t handleMetadataPdu(const PacketInfo& info); ReturnValue_t handleFileDataPdu(const PacketInfo& info); ReturnValue_t handleEofPdu(const PacketInfo& info); - ReturnValue_t handleMetadataParseError(const uint8_t* rawData, size_t maxSize); + ReturnValue_t handleMetadataParseError(ReturnValue_t result, const uint8_t* rawData, + size_t maxSize); ReturnValue_t handleTransferCompletion(); ReturnValue_t sendFinishedPdu(); ReturnValue_t noticeOfCompletion(); ReturnValue_t checksumVerification(); + const DestFsmResult& updateFsmRes(uint8_t errors); void finish(); }; diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 79491bf9..1873a081 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -33,6 +33,9 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { StorageManagerMock tcStore(2, storeCfg); StorageManagerMock tmStore(3, storeCfg); FsfwParams fp(tmReceiver, mqMock, eventReporterMock); + RemoteEntityCfg cfg; + cfg.remoteId = remoteId; + remoteCfgTableMock.addRemoteConfig(cfg); fp.tcStore = &tcStore; fp.tmStore = &tmStore; auto destHandler = DestHandler(dp, fp); @@ -44,13 +47,17 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { } SECTION("Idle State Machine Iteration") { - CHECK(destHandler.performStateMachine() == OK); + auto res = destHandler.performStateMachine(); + CHECK(res.result == OK); + CHECK(res.callStatus == CallStatus::CALL_AFTER_DELAY); + CHECK(res.errors == 0); CHECK(destHandler.getCfdpState() == CfdpStates::IDLE); CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE); } SECTION("Empty File Transfer") { - CHECK(destHandler.performStateMachine() == OK); + const DestFsmResult& res = destHandler.performStateMachine(); + CHECK(res.result == OK); FileSize size(0); std::string srcNameString = "hello.txt"; std::string destNameString = "hello-cpy.txt"; @@ -67,7 +74,8 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { CHECK(metadataPdu.serialize(ptr, serLen, metadataPdu.getSerializedSize()) == OK); PacketInfo packetInfo(metadataPdu.getPduType(), metadataPdu.getDirectiveCode(), storeId); packetInfoList.push_back(packetInfo); - //CHECK(destHandler.performStateMachine() == OK); + destHandler.performStateMachine(); + CHECK(res.result == OK); } SECTION("Small File Transfer") {} From 2e4cdb73661426a6909cd95c1b731ddb64379681 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 17:42:56 +0200 Subject: [PATCH 322/532] additional filesystem abstractions --- src/fsfw/cfdp/handler/DestHandler.cpp | 62 +++++++++++----------- src/fsfw/cfdp/handler/DestHandler.h | 34 +++++++----- src/fsfw/filesystem/FileSystemArgsIF.h | 2 +- src/fsfw/filesystem/HasFileSystemIF.h | 9 ++++ src/fsfw_hal/host/HostFilesystem.cpp | 14 +++++ src/fsfw_hal/host/HostFilesystem.h | 3 ++ unittests/cfdp/handler/testDestHandler.cpp | 4 +- unittests/mocks/FilesystemMock.cpp | 14 +++++ unittests/mocks/FilesystemMock.h | 6 ++- 9 files changed, 102 insertions(+), 46 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 5142731d..23852272 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -23,12 +23,11 @@ cfdp::DestHandler::DestHandler(DestHandlerParams params, FsfwParams fsfwParams) tp.pduConf.direction = cfdp::Direction::TOWARDS_SENDER; } -const cfdp::DestFsmResult& cfdp::DestHandler::performStateMachine() { +const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() { ReturnValue_t result; uint8_t errorIdx = 0; - fsmRes.callStatus = CallStatus::CALL_AFTER_DELAY; - fsmRes.result = OK; - if (step == TransactionStep::IDLE) { + fsmRes.resetOfIteration(); + if (fsmRes.step == TransactionStep::IDLE) { for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { if (infoIter->pduType == PduType::FILE_DIRECTIVE and infoIter->directiveType == FileDirectives::METADATA) { @@ -42,7 +41,7 @@ const cfdp::DestFsmResult& cfdp::DestHandler::performStateMachine() { } infoIter++; } - if (step == TransactionStep::IDLE) { + if (fsmRes.step == TransactionStep::IDLE) { // To decrease the already high complexity of the software, all packets arriving before // a metadata PDU are deleted. for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { @@ -52,13 +51,13 @@ const cfdp::DestFsmResult& cfdp::DestHandler::performStateMachine() { dp.packetListRef.clear(); } - if (step != TransactionStep::IDLE) { + if (fsmRes.step != TransactionStep::IDLE) { fsmRes.callStatus = CallStatus::CALL_AGAIN; } return updateFsmRes(errorIdx); } - if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) { - if (step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { + if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) { + if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { if (infoIter->pduType == PduType::FILE_DATA) { result = handleFileDataPdu(*infoIter); @@ -83,14 +82,14 @@ const cfdp::DestFsmResult& cfdp::DestHandler::performStateMachine() { infoIter++; } } - if (step == TransactionStep::TRANSFER_COMPLETION) { + if (fsmRes.step == TransactionStep::TRANSFER_COMPLETION) { result = handleTransferCompletion(); if (result != OK and errorIdx < 3) { fsmRes.errorCodes[errorIdx] = result; errorIdx++; } } - if (step == TransactionStep::SENDING_FINISHED_PDU) { + if (fsmRes.step == TransactionStep::SENDING_FINISHED_PDU) { result = sendFinishedPdu(); if (result != OK and errorIdx < 3) { fsmRes.errorCodes[errorIdx] = result; @@ -100,7 +99,7 @@ const cfdp::DestFsmResult& cfdp::DestHandler::performStateMachine() { } return updateFsmRes(errorIdx); } - if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { + if (fsmRes.state == CfdpStates::BUSY_CLASS_2_ACKED) { // TODO: Will be implemented at a later stage #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "CFDP state machine for acknowledged mode not implemented yet" << std::endl; @@ -225,11 +224,11 @@ ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) { } tp.fileSize.setFileSize(fileSizeFromEof, std::nullopt); } - if (step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { - if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) { - step = TransactionStep::TRANSFER_COMPLETION; - } else if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { - step = TransactionStep::SENDING_ACK_PDU; + if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { + if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) { + fsmRes.step = TransactionStep::TRANSFER_COMPLETION; + } else if (fsmRes.state == CfdpStates::BUSY_CLASS_2_ACKED) { + fsmRes.step = TransactionStep::SENDING_ACK_PDU; } } return returnvalue::OK; @@ -272,15 +271,15 @@ ReturnValue_t cfdp::DestHandler::handleMetadataParseError(ReturnValue_t result, } ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, MetadataInfo& info) { - if (cfdpState != CfdpStates::IDLE) { + if (fsmRes.state != CfdpStates::IDLE) { // According to standard, discard metadata PDU if we are busy return returnvalue::OK; } - step = TransactionStep::TRANSACTION_START; + fsmRes.step = TransactionStep::TRANSACTION_START; if (reader.getTransmissionMode() == TransmissionModes::UNACKNOWLEDGED) { - cfdpState = CfdpStates::BUSY_CLASS_1_NACKED; + fsmRes.state = CfdpStates::BUSY_CLASS_1_NACKED; } else if (reader.getTransmissionMode() == TransmissionModes::ACKNOWLEDGED) { - cfdpState = CfdpStates::BUSY_CLASS_2_ACKED; + fsmRes.state = CfdpStates::BUSY_CLASS_2_ACKED; } tp.checksumType = info.getChecksumType(); tp.closureRequested = info.isClosureRequested(); @@ -313,7 +312,7 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met #endif return FAILED; } - step = TransactionStep::RECEIVING_FILE_DATA_PDUS; + fsmRes.step = TransactionStep::RECEIVING_FILE_DATA_PDUS; MetadataRecvdParams params(tp.transactionId, tp.pduConf.sourceId); params.fileSize = tp.fileSize.getSize(); params.destFileName = tp.destName.data(); @@ -324,7 +323,7 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met return OK; } -cfdp::CfdpStates cfdp::DestHandler::getCfdpState() const { return cfdpState; } +cfdp::CfdpStates cfdp::DestHandler::getCfdpState() const { return fsmRes.state; } ReturnValue_t cfdp::DestHandler::handleTransferCompletion() { ReturnValue_t result; @@ -339,14 +338,14 @@ ReturnValue_t cfdp::DestHandler::handleTransferCompletion() { result = noticeOfCompletion(); if (result != OK) { } - if (cfdpState == CfdpStates::BUSY_CLASS_1_NACKED) { + if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) { if (tp.closureRequested) { - step = TransactionStep::SENDING_FINISHED_PDU; + fsmRes.step = TransactionStep::SENDING_FINISHED_PDU; } else { finish(); } - } else if (cfdpState == CfdpStates::BUSY_CLASS_2_ACKED) { - step = TransactionStep::SENDING_FINISHED_PDU; + } else if (fsmRes.state == CfdpStates::BUSY_CLASS_2_ACKED) { + fsmRes.step = TransactionStep::SENDING_FINISHED_PDU; } return OK; } @@ -354,8 +353,8 @@ ReturnValue_t cfdp::DestHandler::handleTransferCompletion() { void cfdp::DestHandler::finish() { tp.reset(); dp.packetListRef.clear(); - cfdpState = CfdpStates::IDLE; - step = TransactionStep::IDLE; + fsmRes.state = CfdpStates::IDLE; + fsmRes.step = TransactionStep::IDLE; } ReturnValue_t cfdp::DestHandler::checksumVerification() { @@ -430,12 +429,15 @@ ReturnValue_t cfdp::DestHandler::sendFinishedPdu() { // TODO: Error handling and event, this is a non CFDP specific error (most likely store is full) return result; } + fsmRes.packetsSent++; return OK; } -cfdp::DestHandler::TransactionStep cfdp::DestHandler::getTransactionStep() const { return step; } +cfdp::DestHandler::TransactionStep cfdp::DestHandler::getTransactionStep() const { + return fsmRes.step; +} -const cfdp::DestFsmResult& cfdp::DestHandler::updateFsmRes(uint8_t errors) { +const cfdp::DestHandler::FsmResult& cfdp::DestHandler::updateFsmRes(uint8_t errors) { fsmRes.errors = errors; fsmRes.result = OK; if (fsmRes.errors > 0) { diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 30806153..ba4bcbe3 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -72,14 +72,6 @@ struct FsfwParams { enum class CallStatus { DONE, CALL_AFTER_DELAY, CALL_AGAIN }; -struct DestFsmResult { - ReturnValue_t result = returnvalue::OK; - CallStatus callStatus = CallStatus::CALL_AFTER_DELAY; - uint32_t packetsSent = 0; - uint8_t errors = 0; - std::array errorCodes = {}; -}; - class DestHandler { public: enum class TransactionStep { @@ -90,6 +82,24 @@ class DestHandler { TRANSFER_COMPLETION = 4, SENDING_FINISHED_PDU = 5 }; + + struct FsmResult { + public: + ReturnValue_t result = returnvalue::OK; + CallStatus callStatus = CallStatus::CALL_AFTER_DELAY; + TransactionStep step = TransactionStep::IDLE; + CfdpStates state = CfdpStates::IDLE; + uint32_t packetsSent = 0; + uint8_t errors = 0; + std::array errorCodes = {}; + void resetOfIteration() { + result = returnvalue::OK; + callStatus = CallStatus::CALL_AFTER_DELAY; + packetsSent = 0; + errors = 0; + errorCodes.fill(returnvalue::OK); + } + }; /** * Will be returned if it is advisable to call the state machine operation call again */ @@ -103,7 +113,7 @@ class DestHandler { * - @c returnvalue::OK State machine OK for this execution cycle * - @c CALL_FSM_AGAIN State machine should be called again. */ - const DestFsmResult& performStateMachine(); + const FsmResult& performStateMachine(); ReturnValue_t passPacket(PacketInfo packet); @@ -149,14 +159,12 @@ class DestHandler { RemoteEntityCfg* remoteCfg = nullptr; }; - TransactionStep step = TransactionStep::IDLE; - CfdpStates cfdpState = CfdpStates::IDLE; std::vector tlvVec; std::vector userTlvVec; DestHandlerParams dp; FsfwParams fp; TransactionParams tp; - DestFsmResult fsmRes; + FsmResult fsmRes; ReturnValue_t startTransaction(MetadataPduReader& reader, MetadataInfo& info); ReturnValue_t handleMetadataPdu(const PacketInfo& info); @@ -168,7 +176,7 @@ class DestHandler { ReturnValue_t sendFinishedPdu(); ReturnValue_t noticeOfCompletion(); ReturnValue_t checksumVerification(); - const DestFsmResult& updateFsmRes(uint8_t errors); + const FsmResult& updateFsmRes(uint8_t errors); void finish(); }; diff --git a/src/fsfw/filesystem/FileSystemArgsIF.h b/src/fsfw/filesystem/FileSystemArgsIF.h index f1617f62..656764fa 100644 --- a/src/fsfw/filesystem/FileSystemArgsIF.h +++ b/src/fsfw/filesystem/FileSystemArgsIF.h @@ -7,7 +7,7 @@ */ class FileSystemArgsIF { public: - virtual ~FileSystemArgsIF(){}; + virtual ~FileSystemArgsIF() = default; }; #endif /* FSFW_SRC_FSFW_MEMORY_FILESYSTEMARGS_H_ */ diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index f206d53c..ee8c5f91 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -73,6 +73,15 @@ class HasFileSystemIF { return MessageQueueIF::NO_QUEUE; } + virtual bool fileExists(FilesystemParams params) = 0; + + /** + * Truncate a file, deleting its contents and setting its size to 0 accordingly. + * @param params + * @return + */ + virtual ReturnValue_t truncateFile(FilesystemParams params) = 0; + /** * @brief Generic function to append to file. * @param fileOpInfo General information: File name, size to write, offset, additional arguments diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp index 20678a8c..6dc099b1 100644 --- a/src/fsfw_hal/host/HostFilesystem.cpp +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -144,3 +144,17 @@ ReturnValue_t HostFilesystem::rename(const char *oldPath_, const char *newPath_, } return returnvalue::OK; } + +bool HostFilesystem::fileExists(FilesystemParams params) { + path path(params.path); + return filesystem::exists(path); +} + +ReturnValue_t HostFilesystem::truncateFile(FilesystemParams params) { + path path(params.path); + if (not filesystem::exists(path)) { + return FILE_DOES_NOT_EXIST; + } + ofstream of(path); + return returnvalue::OK; +} diff --git a/src/fsfw_hal/host/HostFilesystem.h b/src/fsfw_hal/host/HostFilesystem.h index c35e0fda..7b865e2d 100644 --- a/src/fsfw_hal/host/HostFilesystem.h +++ b/src/fsfw_hal/host/HostFilesystem.h @@ -8,6 +8,9 @@ class HostFilesystem : public HasFileSystemIF { public: HostFilesystem(); + + bool fileExists(FilesystemParams params) override; + ReturnValue_t truncateFile(FilesystemParams params) override; ReturnValue_t writeToFile(FileOpParams params, const uint8_t *data) override; ReturnValue_t readFromFile(FileOpParams fileOpInfo, uint8_t **buffer, size_t &readSize, size_t maxSize) override; diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 1873a081..3fc8f472 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -56,7 +56,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { } SECTION("Empty File Transfer") { - const DestFsmResult& res = destHandler.performStateMachine(); + const DestHandler::FsmResult& res = destHandler.performStateMachine(); CHECK(res.result == OK); FileSize size(0); std::string srcNameString = "hello.txt"; @@ -76,6 +76,8 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { packetInfoList.push_back(packetInfo); destHandler.performStateMachine(); CHECK(res.result == OK); + CHECK(res.callStatus == CallStatus::CALL_AGAIN); + destHandler.performStateMachine(); } SECTION("Small File Transfer") {} diff --git a/unittests/mocks/FilesystemMock.cpp b/unittests/mocks/FilesystemMock.cpp index 3d18e3cb..bf0c3bf6 100644 --- a/unittests/mocks/FilesystemMock.cpp +++ b/unittests/mocks/FilesystemMock.cpp @@ -124,3 +124,17 @@ void FilesystemMock::reset() { std::queue empty; std::swap(renameQueue, empty); } + +bool FilesystemMock::fileExists(FilesystemParams params) { + std::string filename(params.path); + auto iter = fileMap.find(filename); + if (iter == fileMap.end()) { + return false; + } + return true; +} + +ReturnValue_t FilesystemMock::truncateFile(FilesystemParams params) { + truncateCalledOnFile = params.path; + return returnvalue::OK; +} diff --git a/unittests/mocks/FilesystemMock.h b/unittests/mocks/FilesystemMock.h index 19d4d38c..74221d70 100644 --- a/unittests/mocks/FilesystemMock.h +++ b/unittests/mocks/FilesystemMock.h @@ -53,8 +53,12 @@ class FilesystemMock : public HasFileSystemIF { std::string newName; }; std::queue renameQueue; - + std::string truncateCalledOnFile; ReturnValue_t feedFile(const std::string &filename, std::ifstream &file); + + bool fileExists(FilesystemParams params) override; + ReturnValue_t truncateFile(FilesystemParams params) override; + ReturnValue_t writeToFile(FileOpParams params, const uint8_t *data) override; ReturnValue_t readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, size_t maxSize) override; From 7b97c8a1823a5acd1813769d2b0e8116edc2e913 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 11:56:05 +0200 Subject: [PATCH 323/532] continue tests --- src/fsfw/cfdp/handler/DestHandler.cpp | 7 ++++++ src/fsfw/cfdp/pdu/EofPduCreator.h | 2 ++ unittests/cfdp/handler/testDestHandler.cpp | 25 ++++++++++++++++------ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 23852272..ed529cc0 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -319,6 +319,13 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met params.sourceFileName = tp.sourceName.data(); params.msgsToUserArray = dynamic_cast(userTlvVec.data()); params.msgsToUserLen = info.getOptionsLen(); + FilesystemParams fparams(tp.destName.data()); + // TODO: Filesystem errors? + if (dp.user.vfs.fileExists(fparams)) { + dp.user.vfs.truncateFile(fparams); + } else { + dp.user.vfs.createFile(fparams); + } dp.user.metadataRecvdIndication(params); return OK; } diff --git a/src/fsfw/cfdp/pdu/EofPduCreator.h b/src/fsfw/cfdp/pdu/EofPduCreator.h index 7f7a25ab..f098a5d2 100644 --- a/src/fsfw/cfdp/pdu/EofPduCreator.h +++ b/src/fsfw/cfdp/pdu/EofPduCreator.h @@ -14,6 +14,8 @@ class EofPduCreator : public FileDirectiveCreator { ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; + using FileDirectiveCreator::serialize; + private: EofInfo& info; }; diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 3fc8f472..82f6db45 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -2,6 +2,7 @@ #include "fsfw/cfdp.h" #include "fsfw/cfdp/pdu/MetadataPduCreator.h" +#include "fsfw/cfdp/pdu/EofPduCreator.h" #include "mocks/AcceptsTmMock.h" #include "mocks/EventReportingProxyMock.h" #include "mocks/FilesystemMock.h" @@ -63,21 +64,33 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { std::string destNameString = "hello-cpy.txt"; StringLv srcName(srcNameString); StringLv destName(destNameString); + FileSize cfdpFileSize(0); MetadataInfo info(false, cfdp::ChecksumTypes::NULL_CHECKSUM, size, srcName, destName); auto seqNum = TransactionSeqNum(UnsignedByteField(1)); PduConfig conf(remoteId, localId, TransmissionModes::UNACKNOWLEDGED, seqNum); - MetadataPduCreator metadataPdu(conf, info); + MetadataPduCreator metadataCreator(conf, info); store_address_t storeId; uint8_t* ptr; - CHECK(tcStore.getFreeElement(&storeId, metadataPdu.getSerializedSize(), &ptr) == OK); + REQUIRE(tcStore.getFreeElement(&storeId, metadataCreator.getSerializedSize(), &ptr) == OK); size_t serLen = 0; - CHECK(metadataPdu.serialize(ptr, serLen, metadataPdu.getSerializedSize()) == OK); - PacketInfo packetInfo(metadataPdu.getPduType(), metadataPdu.getDirectiveCode(), storeId); + REQUIRE(metadataCreator.serialize(ptr, serLen, metadataCreator.getSerializedSize()) == OK); + PacketInfo packetInfo(metadataCreator.getPduType(), metadataCreator.getDirectiveCode(), storeId); packetInfoList.push_back(packetInfo); destHandler.performStateMachine(); - CHECK(res.result == OK); - CHECK(res.callStatus == CallStatus::CALL_AGAIN); + REQUIRE(res.result == OK); + REQUIRE(res.callStatus == CallStatus::CALL_AGAIN); + // Assert that the packet was deleted after handling + REQUIRE(not tcStore.hasDataAtId(storeId)); destHandler.performStateMachine(); + REQUIRE(fsMock.fileMap.find("hello-cpy.txt") != fsMock.fileMap.end()); + REQUIRE(res.result == OK); + REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); + REQUIRE(res.state == CfdpStates::BUSY_CLASS_1_NACKED); + REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS); + EofInfo eofInfo(cfdp::ConditionCode::NO_ERROR, 0, cfdpFileSize); + EofPduCreator eofCreator(conf, eofInfo); + REQUIRE(tcStore.getFreeElement(&storeId, eofCreator.getSerializedSize(), &ptr) == OK); + REQUIRE(eofCreator.serialize(ptr, serLen, eofCreator.getSerializedSize()) == OK); } SECTION("Small File Transfer") {} From 806ae9b41af257886101fb266f82f34c0bbfaf02 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 13:16:00 +0200 Subject: [PATCH 324/532] check that indication was called --- src/fsfw/cfdp/VarLenFields.h | 2 +- src/fsfw/cfdp/handler/DestHandler.cpp | 2 ++ src/fsfw/cfdp/handler/DestHandler.h | 1 + unittests/cfdp/handler/testDestHandler.cpp | 22 +++++++++++++++------- unittests/mocks/cfdp/UserMock.cpp | 12 +++++++++++- unittests/mocks/cfdp/UserMock.h | 6 ++++++ 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/fsfw/cfdp/VarLenFields.h b/src/fsfw/cfdp/VarLenFields.h index 7f369e0c..03664995 100644 --- a/src/fsfw/cfdp/VarLenFields.h +++ b/src/fsfw/cfdp/VarLenFields.h @@ -78,7 +78,7 @@ struct TransactionId { TransactionId(EntityId entityId, TransactionSeqNum seqNum) : entityId(std::move(entityId)), seqNum(std::move(seqNum)) {} - bool operator==(const TransactionId &other) { + bool operator==(const TransactionId &other) const { return entityId == other.entityId and seqNum == other.seqNum; } diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index ed529cc0..6cda227e 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -452,3 +452,5 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::updateFsmRes(uint8_t erro } return fsmRes; } + +const cfdp::TransactionId& cfdp::DestHandler::getTransactionId() const { return tp.transactionId; } diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index ba4bcbe3..b1c56721 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -121,6 +121,7 @@ class DestHandler { [[nodiscard]] CfdpStates getCfdpState() const; [[nodiscard]] TransactionStep getTransactionStep() const; + const TransactionId& getTransactionId() const; private: struct TransactionParams { diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 82f6db45..388f766d 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -1,8 +1,8 @@ #include #include "fsfw/cfdp.h" -#include "fsfw/cfdp/pdu/MetadataPduCreator.h" #include "fsfw/cfdp/pdu/EofPduCreator.h" +#include "fsfw/cfdp/pdu/MetadataPduCreator.h" #include "mocks/AcceptsTmMock.h" #include "mocks/EventReportingProxyMock.h" #include "mocks/FilesystemMock.h" @@ -20,11 +20,11 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { MessageQueueMock mqMock(destQueueId); EntityId localId = EntityId(UnsignedByteField(2)); EntityId remoteId = EntityId(UnsignedByteField(3)); - auto fhMock = FaultHandlerMock(); - auto localEntityCfg = LocalEntityCfg(localId, IndicationCfg(), fhMock); - auto fsMock = FilesystemMock(); - auto userMock = UserMock(fsMock); - auto remoteCfgTableMock = RemoteConfigTableMock(); + FaultHandlerMock fhMock; + LocalEntityCfg localEntityCfg(localId, IndicationCfg(), fhMock); + FilesystemMock fsMock; + UserMock userMock(fsMock); + RemoteConfigTableMock remoteCfgTableMock; PacketInfoList<64> packetInfoList; LostSegmentsList<128> lostSegmentsList; DestHandlerParams dp(localEntityCfg, userMock, remoteCfgTableMock, packetInfoList, @@ -74,7 +74,8 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { REQUIRE(tcStore.getFreeElement(&storeId, metadataCreator.getSerializedSize(), &ptr) == OK); size_t serLen = 0; REQUIRE(metadataCreator.serialize(ptr, serLen, metadataCreator.getSerializedSize()) == OK); - PacketInfo packetInfo(metadataCreator.getPduType(), metadataCreator.getDirectiveCode(), storeId); + PacketInfo packetInfo(metadataCreator.getPduType(), metadataCreator.getDirectiveCode(), + storeId); packetInfoList.push_back(packetInfo); destHandler.performStateMachine(); REQUIRE(res.result == OK); @@ -82,6 +83,13 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { // Assert that the packet was deleted after handling REQUIRE(not tcStore.hasDataAtId(storeId)); destHandler.performStateMachine(); + REQUIRE(userMock.metadataRecvd.size() == 1); + MetadataRecvdParams& params = userMock.metadataRecvd.back(); + REQUIRE(params.id == destHandler.getTransactionId()); + REQUIRE(params.sourceId.getValue() == 3); + REQUIRE(params.fileSize == 0); + REQUIRE(strcmp(params.destFileName, "hello-cpy.txt") == 0); + REQUIRE(strcmp(params.sourceFileName, "hello.txt") == 0); REQUIRE(fsMock.fileMap.find("hello-cpy.txt") != fsMock.fileMap.end()); REQUIRE(res.result == OK); REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mocks/cfdp/UserMock.cpp index 876c2e81..f701a28b 100644 --- a/unittests/mocks/cfdp/UserMock.cpp +++ b/unittests/mocks/cfdp/UserMock.cpp @@ -10,7 +10,12 @@ void UserMock::abandonedIndication(const TransactionId& id, cfdp::ConditionCode uint64_t progress) {} void UserMock::eofRecvIndication(const TransactionId& id) {} void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {} -void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) {} + +void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) { + MetadataRecvdParams copy = params; + metadataRecvd.push(copy); +} + void UserMock::fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) {} void UserMock::reportIndication(const TransactionId& id, StatusReportIF& report) {} void UserMock::suspendedIndication(const TransactionId& id, ConditionCode code) {} @@ -18,4 +23,9 @@ void UserMock::resumedIndication(const TransactionId& id, size_t progress) {} void UserMock::faultIndication(const TransactionId& id, cfdp::ConditionCode code, size_t progress) { } +void UserMock::reset() { + auto empty = std::queue(); + metadataRecvd.swap(empty); +} + } // namespace cfdp diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mocks/cfdp/UserMock.h index f3a5bfd9..523392bd 100644 --- a/unittests/mocks/cfdp/UserMock.h +++ b/unittests/mocks/cfdp/UserMock.h @@ -1,7 +1,10 @@ #ifndef FSFW_TESTS_CFDP_USERMOCK_H #define FSFW_TESTS_CFDP_USERMOCK_H +#include + #include "fsfw/cfdp/handler/UserBase.h" + namespace cfdp { class UserMock : public UserBase { @@ -19,6 +22,9 @@ class UserMock : public UserBase { void suspendedIndication(const TransactionId& id, ConditionCode code) override; void resumedIndication(const TransactionId& id, size_t progress) override; void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) override; + + std::queue metadataRecvd; + void reset(); }; } // namespace cfdp From 428da017bae2d83310fa3bc142253afe73990497 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 13:45:43 +0200 Subject: [PATCH 325/532] empty file transfer unittest almost done --- src/fsfw/cfdp/handler/DestHandler.cpp | 3 +++ unittests/cfdp/handler/testDestHandler.cpp | 18 +++++++++++++++++- unittests/mocks/cfdp/UserMock.cpp | 8 +++++--- unittests/mocks/cfdp/UserMock.h | 1 + 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 6cda227e..e1578c9b 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -224,6 +224,9 @@ ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) { } tp.fileSize.setFileSize(fileSizeFromEof, std::nullopt); } + if (dp.cfg.indicCfg.eofRecvIndicRequired) { + dp.user.eofRecvIndication(getTransactionId()); + } if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) { fsmRes.step = TransactionStep::TRANSFER_COMPLETION; diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 388f766d..7a3253a2 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -66,7 +66,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { StringLv destName(destNameString); FileSize cfdpFileSize(0); MetadataInfo info(false, cfdp::ChecksumTypes::NULL_CHECKSUM, size, srcName, destName); - auto seqNum = TransactionSeqNum(UnsignedByteField(1)); + TransactionSeqNum seqNum(UnsignedByteField(1)); PduConfig conf(remoteId, localId, TransmissionModes::UNACKNOWLEDGED, seqNum); MetadataPduCreator metadataCreator(conf, info); store_address_t storeId; @@ -82,6 +82,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { REQUIRE(res.callStatus == CallStatus::CALL_AGAIN); // Assert that the packet was deleted after handling REQUIRE(not tcStore.hasDataAtId(storeId)); + REQUIRE(packetInfoList.empty()); destHandler.performStateMachine(); REQUIRE(userMock.metadataRecvd.size() == 1); MetadataRecvdParams& params = userMock.metadataRecvd.back(); @@ -90,6 +91,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { REQUIRE(params.fileSize == 0); REQUIRE(strcmp(params.destFileName, "hello-cpy.txt") == 0); REQUIRE(strcmp(params.sourceFileName, "hello.txt") == 0); + userMock.metadataRecvd.pop(); REQUIRE(fsMock.fileMap.find("hello-cpy.txt") != fsMock.fileMap.end()); REQUIRE(res.result == OK); REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); @@ -99,6 +101,20 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { EofPduCreator eofCreator(conf, eofInfo); REQUIRE(tcStore.getFreeElement(&storeId, eofCreator.getSerializedSize(), &ptr) == OK); REQUIRE(eofCreator.serialize(ptr, serLen, eofCreator.getSerializedSize()) == OK); + packetInfo = PacketInfo(eofCreator.getPduType(), eofCreator.getDirectiveCode(), storeId); + packetInfoList.push_back(packetInfo); + auto transactionId = destHandler.getTransactionId(); + // After EOF, operation is done because no closure was requested + destHandler.performStateMachine(); + REQUIRE(res.result == OK); + REQUIRE(res.state == CfdpStates::IDLE); + REQUIRE(res.step == DestHandler::TransactionStep::IDLE); + // Assert that the packet was deleted after handling + REQUIRE(not tcStore.hasDataAtId(storeId)); + REQUIRE(packetInfoList.empty()); + REQUIRE(userMock.eofsRevd.size() == 1); + auto& eofId = userMock.eofsRevd.back(); + CHECK(eofId == transactionId); } SECTION("Small File Transfer") {} diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mocks/cfdp/UserMock.cpp index f701a28b..04d9f4f4 100644 --- a/unittests/mocks/cfdp/UserMock.cpp +++ b/unittests/mocks/cfdp/UserMock.cpp @@ -8,7 +8,9 @@ void UserMock::transactionIndication(const TransactionId& id) {} void UserMock::eofSentIndication(const TransactionId& id) {} void UserMock::abandonedIndication(const TransactionId& id, cfdp::ConditionCode code, uint64_t progress) {} -void UserMock::eofRecvIndication(const TransactionId& id) {} + +void UserMock::eofRecvIndication(const TransactionId& id) { eofsRevd.push(id); } + void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {} void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) { @@ -24,8 +26,8 @@ void UserMock::faultIndication(const TransactionId& id, cfdp::ConditionCode code } void UserMock::reset() { - auto empty = std::queue(); - metadataRecvd.swap(empty); + std::queue().swap(eofsRevd); + std::queue().swap(metadataRecvd); } } // namespace cfdp diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mocks/cfdp/UserMock.h index 523392bd..7d9cfef8 100644 --- a/unittests/mocks/cfdp/UserMock.h +++ b/unittests/mocks/cfdp/UserMock.h @@ -24,6 +24,7 @@ class UserMock : public UserBase { void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) override; std::queue metadataRecvd; + std::queue eofsRevd; void reset(); }; From ba046cebd9b5142283536cd66f4745673a43c636 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 14:06:22 +0200 Subject: [PATCH 326/532] empty file unittest complete --- unittests/cfdp/handler/testDestHandler.cpp | 16 ++++++++++------ unittests/mocks/cfdp/UserMock.cpp | 10 ++++++---- unittests/mocks/cfdp/UserMock.h | 3 ++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 7a3253a2..5bce49d3 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -85,12 +85,12 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { REQUIRE(packetInfoList.empty()); destHandler.performStateMachine(); REQUIRE(userMock.metadataRecvd.size() == 1); - MetadataRecvdParams& params = userMock.metadataRecvd.back(); - REQUIRE(params.id == destHandler.getTransactionId()); - REQUIRE(params.sourceId.getValue() == 3); - REQUIRE(params.fileSize == 0); - REQUIRE(strcmp(params.destFileName, "hello-cpy.txt") == 0); - REQUIRE(strcmp(params.sourceFileName, "hello.txt") == 0); + auto& idMetadataPair = userMock.metadataRecvd.back(); + REQUIRE(idMetadataPair.first == destHandler.getTransactionId()); + REQUIRE(idMetadataPair.second.sourceId.getValue() == 3); + REQUIRE(idMetadataPair.second.fileSize == 0); + REQUIRE(strcmp(idMetadataPair.second.destFileName, "hello-cpy.txt") == 0); + REQUIRE(strcmp(idMetadataPair.second.sourceFileName, "hello.txt") == 0); userMock.metadataRecvd.pop(); REQUIRE(fsMock.fileMap.find("hello-cpy.txt") != fsMock.fileMap.end()); REQUIRE(res.result == OK); @@ -115,6 +115,10 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { REQUIRE(userMock.eofsRevd.size() == 1); auto& eofId = userMock.eofsRevd.back(); CHECK(eofId == transactionId); + REQUIRE(userMock.finishedRecvd.size() == 1); + auto& idParamPair = userMock.finishedRecvd.back(); + CHECK(idParamPair.first == transactionId); + CHECK(idParamPair.second.condCode == ConditionCode::NO_ERROR); } SECTION("Small File Transfer") {} diff --git a/unittests/mocks/cfdp/UserMock.cpp b/unittests/mocks/cfdp/UserMock.cpp index 04d9f4f4..ca15a5e6 100644 --- a/unittests/mocks/cfdp/UserMock.cpp +++ b/unittests/mocks/cfdp/UserMock.cpp @@ -11,11 +11,12 @@ void UserMock::abandonedIndication(const TransactionId& id, cfdp::ConditionCode void UserMock::eofRecvIndication(const TransactionId& id) { eofsRevd.push(id); } -void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) {} +void UserMock::transactionFinishedIndication(const TransactionFinishedParams& finishedParams) { + finishedRecvd.push({finishedParams.id, finishedParams}); +} void UserMock::metadataRecvdIndication(const MetadataRecvdParams& params) { - MetadataRecvdParams copy = params; - metadataRecvd.push(copy); + metadataRecvd.push({params.id, params}); } void UserMock::fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) {} @@ -27,7 +28,8 @@ void UserMock::faultIndication(const TransactionId& id, cfdp::ConditionCode code void UserMock::reset() { std::queue().swap(eofsRevd); - std::queue().swap(metadataRecvd); + std::queue>().swap(metadataRecvd); + std::queue>().swap(finishedRecvd); } } // namespace cfdp diff --git a/unittests/mocks/cfdp/UserMock.h b/unittests/mocks/cfdp/UserMock.h index 7d9cfef8..e2a4a483 100644 --- a/unittests/mocks/cfdp/UserMock.h +++ b/unittests/mocks/cfdp/UserMock.h @@ -23,8 +23,9 @@ class UserMock : public UserBase { void resumedIndication(const TransactionId& id, size_t progress) override; void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) override; - std::queue metadataRecvd; + std::queue> metadataRecvd; std::queue eofsRevd; + std::queue> finishedRecvd; void reset(); }; From 94c9800fae11ec78d676f9ae0e976ac917e6ad0c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 14:33:01 +0200 Subject: [PATCH 327/532] refactored out generic metadata part --- unittests/cfdp/handler/testDestHandler.cpp | 102 +++++++++++++-------- 1 file changed, 65 insertions(+), 37 deletions(-) diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 5bce49d3..c6be9c14 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -1,3 +1,5 @@ +#include + #include #include "fsfw/cfdp.h" @@ -39,9 +41,50 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { remoteCfgTableMock.addRemoteConfig(cfg); fp.tcStore = &tcStore; fp.tmStore = &tmStore; + uint8_t* buf = nullptr; + size_t serLen = 0; auto destHandler = DestHandler(dp, fp); CHECK(destHandler.initialize() == OK); + auto metadataPreparation = [&](PduConfig& conf, FileSize cfdpFileSize, store_address_t& storeId) { + std::string srcNameString = "hello.txt"; + std::string destNameString = "hello-cpy.txt"; + StringLv srcName(srcNameString); + StringLv destName(destNameString); + MetadataInfo info(false, cfdp::ChecksumTypes::NULL_CHECKSUM, cfdpFileSize, srcName, destName); + TransactionSeqNum seqNum(UnsignedByteField(1)); + conf.sourceId = remoteId; + conf.destId = localId; + conf.mode = TransmissionModes::UNACKNOWLEDGED; + conf.seqNum = seqNum; + MetadataPduCreator metadataCreator(conf, info); + REQUIRE(tcStore.getFreeElement(&storeId, metadataCreator.getSerializedSize(), &buf) == OK); + REQUIRE(metadataCreator.serialize(buf, serLen, metadataCreator.getSerializedSize()) == OK); + PacketInfo packetInfo(metadataCreator.getPduType(), metadataCreator.getDirectiveCode(), + storeId); + packetInfoList.push_back(packetInfo); + }; + + auto metadataCheck = [&](const cfdp::DestHandler::FsmResult& res, store_address_t storeId, const char* sourceName, const char* destName) { + REQUIRE(res.result == OK); + REQUIRE(res.callStatus == CallStatus::CALL_AGAIN); + // Assert that the packet was deleted after handling + REQUIRE(not tcStore.hasDataAtId(storeId)); + REQUIRE(packetInfoList.empty()); + REQUIRE(userMock.metadataRecvd.size() == 1); + auto& idMetadataPair = userMock.metadataRecvd.back(); + REQUIRE(idMetadataPair.first == destHandler.getTransactionId()); + REQUIRE(idMetadataPair.second.sourceId.getValue() == 3); + REQUIRE(idMetadataPair.second.fileSize == 0); + REQUIRE(strcmp(idMetadataPair.second.destFileName, destName) == 0); + REQUIRE(strcmp(idMetadataPair.second.sourceFileName, sourceName) == 0); + userMock.metadataRecvd.pop(); + REQUIRE(fsMock.fileMap.find(destName) != fsMock.fileMap.end()); + REQUIRE(res.result == OK); + REQUIRE(res.state == CfdpStates::BUSY_CLASS_1_NACKED); + REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS); + }; + SECTION("State") { CHECK(destHandler.getCfdpState() == CfdpStates::IDLE); CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE); @@ -59,49 +102,19 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { SECTION("Empty File Transfer") { const DestHandler::FsmResult& res = destHandler.performStateMachine(); CHECK(res.result == OK); - FileSize size(0); - std::string srcNameString = "hello.txt"; - std::string destNameString = "hello-cpy.txt"; - StringLv srcName(srcNameString); - StringLv destName(destNameString); FileSize cfdpFileSize(0); - MetadataInfo info(false, cfdp::ChecksumTypes::NULL_CHECKSUM, size, srcName, destName); - TransactionSeqNum seqNum(UnsignedByteField(1)); - PduConfig conf(remoteId, localId, TransmissionModes::UNACKNOWLEDGED, seqNum); - MetadataPduCreator metadataCreator(conf, info); store_address_t storeId; - uint8_t* ptr; - REQUIRE(tcStore.getFreeElement(&storeId, metadataCreator.getSerializedSize(), &ptr) == OK); - size_t serLen = 0; - REQUIRE(metadataCreator.serialize(ptr, serLen, metadataCreator.getSerializedSize()) == OK); - PacketInfo packetInfo(metadataCreator.getPduType(), metadataCreator.getDirectiveCode(), - storeId); - packetInfoList.push_back(packetInfo); + PduConfig conf; + metadataPreparation(conf, cfdpFileSize, storeId); destHandler.performStateMachine(); - REQUIRE(res.result == OK); - REQUIRE(res.callStatus == CallStatus::CALL_AGAIN); - // Assert that the packet was deleted after handling - REQUIRE(not tcStore.hasDataAtId(storeId)); - REQUIRE(packetInfoList.empty()); + metadataCheck(res, storeId, "hello.txt", "hello-cpy.txt"); destHandler.performStateMachine(); - REQUIRE(userMock.metadataRecvd.size() == 1); - auto& idMetadataPair = userMock.metadataRecvd.back(); - REQUIRE(idMetadataPair.first == destHandler.getTransactionId()); - REQUIRE(idMetadataPair.second.sourceId.getValue() == 3); - REQUIRE(idMetadataPair.second.fileSize == 0); - REQUIRE(strcmp(idMetadataPair.second.destFileName, "hello-cpy.txt") == 0); - REQUIRE(strcmp(idMetadataPair.second.sourceFileName, "hello.txt") == 0); - userMock.metadataRecvd.pop(); - REQUIRE(fsMock.fileMap.find("hello-cpy.txt") != fsMock.fileMap.end()); - REQUIRE(res.result == OK); REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); - REQUIRE(res.state == CfdpStates::BUSY_CLASS_1_NACKED); - REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS); EofInfo eofInfo(cfdp::ConditionCode::NO_ERROR, 0, cfdpFileSize); EofPduCreator eofCreator(conf, eofInfo); - REQUIRE(tcStore.getFreeElement(&storeId, eofCreator.getSerializedSize(), &ptr) == OK); - REQUIRE(eofCreator.serialize(ptr, serLen, eofCreator.getSerializedSize()) == OK); - packetInfo = PacketInfo(eofCreator.getPduType(), eofCreator.getDirectiveCode(), storeId); + REQUIRE(tcStore.getFreeElement(&storeId, eofCreator.getSerializedSize(), &buf) == OK); + REQUIRE(eofCreator.serialize(buf, serLen, eofCreator.getSerializedSize()) == OK); + PacketInfo packetInfo(eofCreator.getPduType(), eofCreator.getDirectiveCode(), storeId); packetInfoList.push_back(packetInfo); auto transactionId = destHandler.getTransactionId(); // After EOF, operation is done because no closure was requested @@ -121,7 +134,22 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { CHECK(idParamPair.second.condCode == ConditionCode::NO_ERROR); } - SECTION("Small File Transfer") {} + SECTION("Small File Transfer") { + const DestHandler::FsmResult& res = destHandler.performStateMachine(); + CHECK(res.result == OK); + std::string fileData = "hello test data"; + etl::crc32 crcCalc; + crcCalc.add(fileData.begin(), fileData.end()); + uint32_t crc32 = crcCalc.value(); + FileSize cfdpFileSize(0); + store_address_t storeId; + PduConfig conf; + metadataPreparation(conf, cfdpFileSize, storeId); + destHandler.performStateMachine(); + metadataCheck(res, storeId, "hello.txt", "hello-cpy.txt"); + destHandler.performStateMachine(); + REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); + } SECTION("Segmented File Transfer") {} } \ No newline at end of file From af851165b475fb34dd022a3ee6c54e18cb68e2b9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 15:45:51 +0200 Subject: [PATCH 328/532] continue basic small file transfer unittest --- src/fsfw/cfdp/handler/DestHandler.cpp | 6 +- src/fsfw/cfdp/handler/DestHandler.h | 8 +- src/fsfw/cfdp/pdu/FileDataCreator.cpp | 10 ++- src/fsfw/cfdp/pdu/FileDataCreator.h | 4 + unittests/cfdp/handler/testDestHandler.cpp | 91 ++++++++++++++-------- 5 files changed, 76 insertions(+), 43 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index e1578c9b..ac773cfc 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -174,7 +174,7 @@ ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info) } size_t fileSegmentLen = 0; const uint8_t* fileData = fdInfo.getFileData(&fileSegmentLen); - FileOpParams fileOpParams(tp.sourceName.data(), fileSegmentLen); + FileOpParams fileOpParams(tp.destName.data(), fileSegmentLen); if (dp.cfg.indicCfg.fileSegmentRecvIndicRequired) { FileSegmentRecvdParams segParams; segParams.offset = offset.value(); @@ -372,9 +372,9 @@ ReturnValue_t cfdp::DestHandler::checksumVerification() { // TODO: Checksum verification and notice of completion etl::crc32 crcCalc; uint64_t currentOffset = 0; - FileOpParams params(tp.sourceName.data(), buf.size()); + FileOpParams params(tp.destName.data(), tp.fileSize.value()); while (currentOffset < tp.fileSize.value()) { - uint64_t readLen = 0; + uint64_t readLen; if (currentOffset + buf.size() > tp.fileSize.value()) { readLen = tp.fileSize.value() - currentOffset; } else { diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index b1c56721..71214fcb 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -4,6 +4,7 @@ #include #include +#include #include #include "RemoteConfigTableIF.h" @@ -20,11 +21,12 @@ namespace cfdp { struct PacketInfo { - PacketInfo(PduType type, FileDirectives directive, store_address_t storeId) + PacketInfo(PduType type, store_address_t storeId, + std::optional directive = std::nullopt) : pduType(type), directiveType(directive), storeId(storeId) {} PduType pduType = PduType::FILE_DATA; - FileDirectives directiveType = FileDirectives::INVALID_DIRECTIVE; + std::optional directiveType = FileDirectives::INVALID_DIRECTIVE; store_address_t storeId = store_address_t::invalid(); PacketInfo() = default; }; @@ -121,7 +123,7 @@ class DestHandler { [[nodiscard]] CfdpStates getCfdpState() const; [[nodiscard]] TransactionStep getTransactionStep() const; - const TransactionId& getTransactionId() const; + [[nodiscard]] const TransactionId& getTransactionId() const; private: struct TransactionParams { diff --git a/src/fsfw/cfdp/pdu/FileDataCreator.cpp b/src/fsfw/cfdp/pdu/FileDataCreator.cpp index 0ef8f862..956752fb 100644 --- a/src/fsfw/cfdp/pdu/FileDataCreator.cpp +++ b/src/fsfw/cfdp/pdu/FileDataCreator.cpp @@ -15,13 +15,17 @@ void FileDataCreator::update() { ReturnValue_t FileDataCreator::serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { + if (buffer == nullptr or size == nullptr) { + return returnvalue::FAILED; + } + if (*size + getSerializedSize() > maxSize) { + return SerializeIF::BUFFER_TOO_SHORT; + } ReturnValue_t result = HeaderCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; } - if (*size + this->getSerializedSize() > maxSize) { - return SerializeIF::BUFFER_TOO_SHORT; - } + const uint8_t* readOnlyPtr = nullptr; if (this->hasSegmentMetadataFlag()) { size_t segmentMetadataLen = info.getSegmentMetadataLen(); diff --git a/src/fsfw/cfdp/pdu/FileDataCreator.h b/src/fsfw/cfdp/pdu/FileDataCreator.h index 774baf00..2ce8989d 100644 --- a/src/fsfw/cfdp/pdu/FileDataCreator.h +++ b/src/fsfw/cfdp/pdu/FileDataCreator.h @@ -11,6 +11,10 @@ class FileDataCreator : public HeaderCreator { void update(); + ReturnValue_t serialize(uint8_t* buf, size_t& serLen, size_t maxSize) const { + return SerializeIF::serialize(buf, serLen, maxSize, SerializeIF::Endianness::NETWORK); + } + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index c6be9c14..23d88352 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -1,9 +1,11 @@ #include #include +#include #include "fsfw/cfdp.h" #include "fsfw/cfdp/pdu/EofPduCreator.h" +#include "fsfw/cfdp/pdu/FileDataCreator.h" #include "fsfw/cfdp/pdu/MetadataPduCreator.h" #include "mocks/AcceptsTmMock.h" #include "mocks/EventReportingProxyMock.h" @@ -43,15 +45,17 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { fp.tmStore = &tmStore; uint8_t* buf = nullptr; size_t serLen = 0; + store_address_t storeId; + PduConfig conf; auto destHandler = DestHandler(dp, fp); CHECK(destHandler.initialize() == OK); - auto metadataPreparation = [&](PduConfig& conf, FileSize cfdpFileSize, store_address_t& storeId) { + auto metadataPreparation = [&](FileSize cfdpFileSize, ChecksumTypes checksumType) { std::string srcNameString = "hello.txt"; std::string destNameString = "hello-cpy.txt"; StringLv srcName(srcNameString); StringLv destName(destNameString); - MetadataInfo info(false, cfdp::ChecksumTypes::NULL_CHECKSUM, cfdpFileSize, srcName, destName); + MetadataInfo info(false, checksumType, cfdpFileSize, srcName, destName); TransactionSeqNum seqNum(UnsignedByteField(1)); conf.sourceId = remoteId; conf.destId = localId; @@ -60,12 +64,13 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { MetadataPduCreator metadataCreator(conf, info); REQUIRE(tcStore.getFreeElement(&storeId, metadataCreator.getSerializedSize(), &buf) == OK); REQUIRE(metadataCreator.serialize(buf, serLen, metadataCreator.getSerializedSize()) == OK); - PacketInfo packetInfo(metadataCreator.getPduType(), metadataCreator.getDirectiveCode(), - storeId); + PacketInfo packetInfo(metadataCreator.getPduType(), storeId, + metadataCreator.getDirectiveCode()); packetInfoList.push_back(packetInfo); }; - auto metadataCheck = [&](const cfdp::DestHandler::FsmResult& res, store_address_t storeId, const char* sourceName, const char* destName) { + auto metadataCheck = [&](const cfdp::DestHandler::FsmResult& res, const char* sourceName, + const char* destName, size_t fileLen) { REQUIRE(res.result == OK); REQUIRE(res.callStatus == CallStatus::CALL_AGAIN); // Assert that the packet was deleted after handling @@ -75,7 +80,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { auto& idMetadataPair = userMock.metadataRecvd.back(); REQUIRE(idMetadataPair.first == destHandler.getTransactionId()); REQUIRE(idMetadataPair.second.sourceId.getValue() == 3); - REQUIRE(idMetadataPair.second.fileSize == 0); + REQUIRE(idMetadataPair.second.fileSize == fileLen); REQUIRE(strcmp(idMetadataPair.second.destFileName, destName) == 0); REQUIRE(strcmp(idMetadataPair.second.sourceFileName, sourceName) == 0); userMock.metadataRecvd.pop(); @@ -85,6 +90,31 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS); }; + auto eofPreparation = [&](FileSize cfdpFileSize, uint32_t crc) { + EofInfo eofInfo(cfdp::ConditionCode::NO_ERROR, crc, std::move(cfdpFileSize)); + EofPduCreator eofCreator(conf, eofInfo); + REQUIRE(tcStore.getFreeElement(&storeId, eofCreator.getSerializedSize(), &buf) == OK); + REQUIRE(eofCreator.serialize(buf, serLen, eofCreator.getSerializedSize()) == OK); + PacketInfo packetInfo(eofCreator.getPduType(), storeId, eofCreator.getDirectiveCode()); + packetInfoList.push_back(packetInfo); + }; + + auto eofCheck = [&](const cfdp::DestHandler::FsmResult& res, const TransactionId& id) { + REQUIRE(res.result == OK); + REQUIRE(res.state == CfdpStates::IDLE); + REQUIRE(res.step == DestHandler::TransactionStep::IDLE); + // Assert that the packet was deleted after handling + REQUIRE(not tcStore.hasDataAtId(storeId)); + REQUIRE(packetInfoList.empty()); + REQUIRE(userMock.eofsRevd.size() == 1); + auto& eofId = userMock.eofsRevd.back(); + CHECK(eofId == id); + REQUIRE(userMock.finishedRecvd.size() == 1); + auto& idParamPair = userMock.finishedRecvd.back(); + CHECK(idParamPair.first == id); + CHECK(idParamPair.second.condCode == ConditionCode::NO_ERROR); + }; + SECTION("State") { CHECK(destHandler.getCfdpState() == CfdpStates::IDLE); CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE); @@ -103,35 +133,16 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { const DestHandler::FsmResult& res = destHandler.performStateMachine(); CHECK(res.result == OK); FileSize cfdpFileSize(0); - store_address_t storeId; - PduConfig conf; - metadataPreparation(conf, cfdpFileSize, storeId); + metadataPreparation(cfdpFileSize, ChecksumTypes::NULL_CHECKSUM); destHandler.performStateMachine(); - metadataCheck(res, storeId, "hello.txt", "hello-cpy.txt"); + metadataCheck(res, "hello.txt", "hello-cpy.txt", 0); destHandler.performStateMachine(); REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); - EofInfo eofInfo(cfdp::ConditionCode::NO_ERROR, 0, cfdpFileSize); - EofPduCreator eofCreator(conf, eofInfo); - REQUIRE(tcStore.getFreeElement(&storeId, eofCreator.getSerializedSize(), &buf) == OK); - REQUIRE(eofCreator.serialize(buf, serLen, eofCreator.getSerializedSize()) == OK); - PacketInfo packetInfo(eofCreator.getPduType(), eofCreator.getDirectiveCode(), storeId); - packetInfoList.push_back(packetInfo); auto transactionId = destHandler.getTransactionId(); + eofPreparation(cfdpFileSize, 0); // After EOF, operation is done because no closure was requested destHandler.performStateMachine(); - REQUIRE(res.result == OK); - REQUIRE(res.state == CfdpStates::IDLE); - REQUIRE(res.step == DestHandler::TransactionStep::IDLE); - // Assert that the packet was deleted after handling - REQUIRE(not tcStore.hasDataAtId(storeId)); - REQUIRE(packetInfoList.empty()); - REQUIRE(userMock.eofsRevd.size() == 1); - auto& eofId = userMock.eofsRevd.back(); - CHECK(eofId == transactionId); - REQUIRE(userMock.finishedRecvd.size() == 1); - auto& idParamPair = userMock.finishedRecvd.back(); - CHECK(idParamPair.first == transactionId); - CHECK(idParamPair.second.condCode == ConditionCode::NO_ERROR); + eofCheck(res, transactionId); } SECTION("Small File Transfer") { @@ -141,14 +152,26 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { etl::crc32 crcCalc; crcCalc.add(fileData.begin(), fileData.end()); uint32_t crc32 = crcCalc.value(); - FileSize cfdpFileSize(0); - store_address_t storeId; - PduConfig conf; - metadataPreparation(conf, cfdpFileSize, storeId); + FileSize cfdpFileSize(fileData.size()); + metadataPreparation(cfdpFileSize, ChecksumTypes::CRC_32); destHandler.performStateMachine(); - metadataCheck(res, storeId, "hello.txt", "hello-cpy.txt"); + metadataCheck(res, "hello.txt", "hello-cpy.txt", fileData.size()); destHandler.performStateMachine(); REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); + auto transactionId = destHandler.getTransactionId(); + FileSize offset(0); + FileDataInfo fdPduInfo(offset, reinterpret_cast(fileData.data()), + fileData.size()); + FileDataCreator fdPduCreator(conf, fdPduInfo); + REQUIRE(tcStore.getFreeElement(&storeId, fdPduCreator.getSerializedSize(), &buf) == OK); + REQUIRE(fdPduCreator.serialize(buf, serLen, fdPduCreator.getSerializedSize()) == OK); + PacketInfo packetInfo(fdPduCreator.getPduType(), storeId, std::nullopt); + packetInfoList.push_back(packetInfo); + destHandler.performStateMachine(); + eofPreparation(cfdpFileSize, crc32); + // After EOF, operation is done because no closure was requested + destHandler.performStateMachine(); + eofCheck(res, transactionId); } SECTION("Segmented File Transfer") {} From 07ef9a0ec3d9050f518eed7f0bf363716d0603af Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 15:47:04 +0200 Subject: [PATCH 329/532] 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 7b00a708..36b3082b 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 2ed2a7d9..318619f8 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 67439b428587c573dfe45b35ad1c7c9d8e04ed2b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 16:03:26 +0200 Subject: [PATCH 330/532] refactor away some duplication --- src/fsfw/cfdp/handler/DestHandler.cpp | 32 ++++++++-------------- src/fsfw/cfdp/handler/DestHandler.h | 1 + unittests/cfdp/handler/testDestHandler.cpp | 5 ++++ 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index ac773cfc..4bc7134c 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -32,10 +32,7 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() { if (infoIter->pduType == PduType::FILE_DIRECTIVE and infoIter->directiveType == FileDirectives::METADATA) { result = handleMetadataPdu(*infoIter); - if (result != OK and errorIdx < 3) { - fsmRes.errorCodes[errorIdx] = result; - errorIdx++; - } + checkAndHandleError(result, errorIdx); // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); } @@ -61,10 +58,7 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() { for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { if (infoIter->pduType == PduType::FILE_DATA) { result = handleFileDataPdu(*infoIter); - if (result != OK and errorIdx < 3) { - fsmRes.errorCodes[errorIdx] = result; - errorIdx++; - } + checkAndHandleError(result, errorIdx); // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); } @@ -72,10 +66,7 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() { if (infoIter->pduType == PduType::FILE_DIRECTIVE and infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) { result = handleEofPdu(*infoIter); - if (result != OK and errorIdx < 3) { - fsmRes.errorCodes[errorIdx] = result; - errorIdx++; - } + checkAndHandleError(result, errorIdx); // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); } @@ -84,17 +75,11 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() { } if (fsmRes.step == TransactionStep::TRANSFER_COMPLETION) { result = handleTransferCompletion(); - if (result != OK and errorIdx < 3) { - fsmRes.errorCodes[errorIdx] = result; - errorIdx++; - } + checkAndHandleError(result, errorIdx); } if (fsmRes.step == TransactionStep::SENDING_FINISHED_PDU) { result = sendFinishedPdu(); - if (result != OK and errorIdx < 3) { - fsmRes.errorCodes[errorIdx] = result; - errorIdx++; - } + checkAndHandleError(result, errorIdx); finish(); } return updateFsmRes(errorIdx); @@ -457,3 +442,10 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::updateFsmRes(uint8_t erro } const cfdp::TransactionId& cfdp::DestHandler::getTransactionId() const { return tp.transactionId; } + +void cfdp::DestHandler::checkAndHandleError(ReturnValue_t result, uint8_t& errorIdx) { + if (result != OK and errorIdx < 3) { + fsmRes.errorCodes[errorIdx] = result; + errorIdx++; + } +} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 71214fcb..8d2fc6e9 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -180,6 +180,7 @@ class DestHandler { ReturnValue_t noticeOfCompletion(); ReturnValue_t checksumVerification(); const FsmResult& updateFsmRes(uint8_t errors); + void checkAndHandleError(ReturnValue_t result, uint8_t& errorIdx); void finish(); }; diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 23d88352..85cbf23e 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -168,6 +168,11 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { PacketInfo packetInfo(fdPduCreator.getPduType(), storeId, std::nullopt); packetInfoList.push_back(packetInfo); destHandler.performStateMachine(); + REQUIRE(res.result == OK); + REQUIRE(res.state == CfdpStates::BUSY_CLASS_1_NACKED); + REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS); + REQUIRE(not tcStore.hasDataAtId(storeId)); + REQUIRE(packetInfoList.empty()); eofPreparation(cfdpFileSize, crc32); // After EOF, operation is done because no closure was requested destHandler.performStateMachine(); From aebd401d5b9de69c57dbff14ac9b3412f7f09219 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 16:14:39 +0200 Subject: [PATCH 331/532] start segmentes file unittest --- unittests/cfdp/handler/testDestHandler.cpp | 39 ++++++++++++++++++---- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 85cbf23e..cdf8e104 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "fsfw/cfdp.h" #include "fsfw/cfdp/pdu/EofPduCreator.h" @@ -73,6 +74,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { const char* destName, size_t fileLen) { REQUIRE(res.result == OK); REQUIRE(res.callStatus == CallStatus::CALL_AGAIN); + REQUIRE(res.errors == 0); // Assert that the packet was deleted after handling REQUIRE(not tcStore.hasDataAtId(storeId)); REQUIRE(packetInfoList.empty()); @@ -102,6 +104,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { auto eofCheck = [&](const cfdp::DestHandler::FsmResult& res, const TransactionId& id) { REQUIRE(res.result == OK); REQUIRE(res.state == CfdpStates::IDLE); + REQUIRE(res.errors == 0); REQUIRE(res.step == DestHandler::TransactionStep::IDLE); // Assert that the packet was deleted after handling REQUIRE(not tcStore.hasDataAtId(storeId)); @@ -115,6 +118,14 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { CHECK(idParamPair.second.condCode == ConditionCode::NO_ERROR); }; + auto fileDataPduCheck = [&](const cfdp::DestHandler::FsmResult& res) { + REQUIRE(res.result == OK); + REQUIRE(res.state == CfdpStates::BUSY_CLASS_1_NACKED); + REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS); + REQUIRE(not tcStore.hasDataAtId(storeId)); + REQUIRE(packetInfoList.empty()); + }; + SECTION("State") { CHECK(destHandler.getCfdpState() == CfdpStates::IDLE); CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE); @@ -168,16 +179,32 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { PacketInfo packetInfo(fdPduCreator.getPduType(), storeId, std::nullopt); packetInfoList.push_back(packetInfo); destHandler.performStateMachine(); - REQUIRE(res.result == OK); - REQUIRE(res.state == CfdpStates::BUSY_CLASS_1_NACKED); - REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS); - REQUIRE(not tcStore.hasDataAtId(storeId)); - REQUIRE(packetInfoList.empty()); + fileDataPduCheck(res); eofPreparation(cfdpFileSize, crc32); // After EOF, operation is done because no closure was requested destHandler.performStateMachine(); eofCheck(res, transactionId); } - SECTION("Segmented File Transfer") {} + SECTION("Segmented File Transfer") { + const DestHandler::FsmResult& res = destHandler.performStateMachine(); + CHECK(res.result == OK); + std::random_device dev; + std::mt19937 rng(dev()); + std::uniform_int_distribution distU8(0, 255); + std::array largerFileData{}; + for(auto& val: largerFileData) { + val = distU8(rng); + } + etl::crc32 crcCalc; + crcCalc.add(largerFileData.begin(), largerFileData.end()); + uint32_t crc32 = crcCalc.value(); + FileSize cfdpFileSize(largerFileData.size()); + metadataPreparation(cfdpFileSize, ChecksumTypes::CRC_32); + destHandler.performStateMachine(); + metadataCheck(res, "hello.txt", "hello-cpy.txt", largerFileData.size()); + destHandler.performStateMachine(); + REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); + auto transactionId = destHandler.getTransactionId(); + } } \ No newline at end of file From c54caf134a860c376187e7730341d399f4ae89df Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 16:33:38 +0200 Subject: [PATCH 332/532] segmented file transfer working --- src/fsfw/cfdp/handler/DestHandler.cpp | 14 ++++--- unittests/cfdp/handler/testDestHandler.cpp | 45 +++++++++++++++++++--- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 4bc7134c..cd3cc3b4 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -35,8 +35,9 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() { checkAndHandleError(result, errorIdx); // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); + } else { + infoIter++; } - infoIter++; } if (fsmRes.step == TransactionStep::IDLE) { // To decrease the already high complexity of the software, all packets arriving before @@ -61,16 +62,16 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() { checkAndHandleError(result, errorIdx); // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); - } - // TODO: Support for check timer missing - if (infoIter->pduType == PduType::FILE_DIRECTIVE and - infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) { + } else if (infoIter->pduType == PduType::FILE_DIRECTIVE and + infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) { + // TODO: Support for check timer missing result = handleEofPdu(*infoIter); checkAndHandleError(result, errorIdx); // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); + } else { + infoIter++; } - infoIter++; } } if (fsmRes.step == TransactionStep::TRANSFER_COMPLETION) { @@ -160,6 +161,7 @@ ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info) size_t fileSegmentLen = 0; const uint8_t* fileData = fdInfo.getFileData(&fileSegmentLen); FileOpParams fileOpParams(tp.destName.data(), fileSegmentLen); + fileOpParams.offset = offset.value(); if (dp.cfg.indicCfg.fileSegmentRecvIndicRequired) { FileSegmentRecvdParams segParams; segParams.offset = offset.value(); diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index cdf8e104..404d8eed 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -1,8 +1,8 @@ #include #include -#include #include +#include #include "fsfw/cfdp.h" #include "fsfw/cfdp/pdu/EofPduCreator.h" @@ -118,11 +118,14 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { CHECK(idParamPair.second.condCode == ConditionCode::NO_ERROR); }; - auto fileDataPduCheck = [&](const cfdp::DestHandler::FsmResult& res) { + auto fileDataPduCheck = [&](const cfdp::DestHandler::FsmResult& res, + const std::vector& idsToCheck) { REQUIRE(res.result == OK); REQUIRE(res.state == CfdpStates::BUSY_CLASS_1_NACKED); REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS); - REQUIRE(not tcStore.hasDataAtId(storeId)); + for (const auto id : idsToCheck) { + REQUIRE(not tcStore.hasDataAtId(id)); + } REQUIRE(packetInfoList.empty()); }; @@ -179,7 +182,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { PacketInfo packetInfo(fdPduCreator.getPduType(), storeId, std::nullopt); packetInfoList.push_back(packetInfo); destHandler.performStateMachine(); - fileDataPduCheck(res); + fileDataPduCheck(res, {storeId}); eofPreparation(cfdpFileSize, crc32); // After EOF, operation is done because no closure was requested destHandler.performStateMachine(); @@ -193,7 +196,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { std::mt19937 rng(dev()); std::uniform_int_distribution distU8(0, 255); std::array largerFileData{}; - for(auto& val: largerFileData) { + for (auto& val : largerFileData) { val = distU8(rng); } etl::crc32 crcCalc; @@ -206,5 +209,37 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { destHandler.performStateMachine(); REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); auto transactionId = destHandler.getTransactionId(); + + std::vector idsToCheck; + { + FileSize offset(0); + FileDataInfo fdPduInfo(offset, reinterpret_cast(largerFileData.data()), + largerFileData.size() / 2); + FileDataCreator fdPduCreator(conf, fdPduInfo); + REQUIRE(tcStore.getFreeElement(&storeId, fdPduCreator.getSerializedSize(), &buf) == OK); + REQUIRE(fdPduCreator.serialize(buf, serLen, fdPduCreator.getSerializedSize()) == OK); + PacketInfo packetInfo(fdPduCreator.getPduType(), storeId, std::nullopt); + idsToCheck.push_back(storeId); + packetInfoList.push_back(packetInfo); + } + + { + FileSize offset(512); + FileDataInfo fdPduInfo(offset, reinterpret_cast(largerFileData.data() + 512), + largerFileData.size() / 2); + FileDataCreator fdPduCreator(conf, fdPduInfo); + REQUIRE(tcStore.getFreeElement(&storeId, fdPduCreator.getSerializedSize(), &buf) == OK); + REQUIRE(fdPduCreator.serialize(buf, serLen, fdPduCreator.getSerializedSize()) == OK); + PacketInfo packetInfo(fdPduCreator.getPduType(), storeId, std::nullopt); + idsToCheck.push_back(storeId); + packetInfoList.push_back(packetInfo); + } + + destHandler.performStateMachine(); + fileDataPduCheck(res, idsToCheck); + eofPreparation(cfdpFileSize, crc32); + // After EOF, operation is done because no closure was requested + destHandler.performStateMachine(); + eofCheck(res, transactionId); } } \ No newline at end of file From 8971eb386ed8985fcfb5eb6aa1dc157b20c2d897 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Sep 2022 17:40:22 +0200 Subject: [PATCH 333/532] retval replacement --- src/fsfw_tests/integration/devices/TestDeviceHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp index 01f0494b..fdf02a70 100644 --- a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp +++ b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp @@ -646,7 +646,7 @@ ReturnValue_t TestDevice::initializeLocalDataPool(localpool::DataPool& localData /* Subscribe for periodic HK packets but do not enable reporting for now. Non-diangostic with a period of one second */ poolManager.subscribeForRegularPeriodicPacket({sid, false, 1.0}); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, From 282704e0fd186f1f13b5ca5046f207afdf49b2f1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Sep 2022 17:54:04 +0200 Subject: [PATCH 334/532] 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 dd928efe..076ab1d2 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 335/532] 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 076ab1d2..890912c2 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 2ecf88d8..682332c9 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 770463e61857dbd323818d40abde662e91c28aca Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Sep 2022 18:04:46 +0200 Subject: [PATCH 336/532] remove old code --- src/fsfw/cfdp/CfdpHandler.cpp | 54 ------------------------------ src/fsfw/cfdp/CfdpHandler.h | 63 ----------------------------------- 2 files changed, 117 deletions(-) delete mode 100644 src/fsfw/cfdp/CfdpHandler.cpp delete mode 100644 src/fsfw/cfdp/CfdpHandler.h diff --git a/src/fsfw/cfdp/CfdpHandler.cpp b/src/fsfw/cfdp/CfdpHandler.cpp deleted file mode 100644 index 1bf03e10..00000000 --- a/src/fsfw/cfdp/CfdpHandler.cpp +++ /dev/null @@ -1,54 +0,0 @@ -//#include "fsfw/cfdp/CfdpHandler.h" -// -//#include "fsfw/cfdp/CfdpMessage.h" -//#include "fsfw/ipc/CommandMessage.h" -//#include "fsfw/ipc/QueueFactory.h" -//#include "fsfw/objectmanager/ObjectManager.h" -//#include "fsfw/storagemanager/storeAddress.h" -//#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" -// -// CfdpHandler::CfdpHandler(object_id_t setObjectId, CfdpHandler* dist) -// : SystemObject(setObjectId) { -// requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION); -// distributor = dist; -//} -// -// CfdpHandler::~CfdpHandler() = default; -// -// ReturnValue_t CfdpHandler::initialize() { -// ReturnValue_t result = SystemObject::initialize(); -// if (result != RETURN_OK) { -// return result; -// } -// this->distributor->registerHandler(this); -// return HasReturnvaluesIF::RETURN_OK; -//} -// -// ReturnValue_t CfdpHandler::handleRequest(store_address_t storeId) { -//#if FSFW_VERBOSE_LEVEL >= 1 -//#if FSFW_CPP_OSTREAM_ENABLED == 1 -// sif::debug << "CFDPHandler::handleRequest" << std::endl; -//#else -// sif::printDebug("CFDPHandler::handleRequest\n"); -//#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ -//#endif -// -// // TODO read out packet from store using storeId -// -// return RETURN_OK; -//} -// -// ReturnValue_t CfdpHandler::performOperation(uint8_t opCode) { -// ReturnValue_t status = RETURN_OK; -// CommandMessage currentMessage; -// for (status = this->requestQueue->receiveMessage(¤tMessage); status == RETURN_OK; -// status = this->requestQueue->receiveMessage(¤tMessage)) { -// store_address_t storeId = CfdpMessage::getStoreId(¤tMessage); -// this->handleRequest(storeId); -// } -// return RETURN_OK; -//} -// -// uint32_t CfdpHandler::getIdentifier() const { return 0; } -// -// MessageQueueId_t CfdpHandler::getRequestQueue() const { return this->requestQueue->getId(); } diff --git a/src/fsfw/cfdp/CfdpHandler.h b/src/fsfw/cfdp/CfdpHandler.h deleted file mode 100644 index 8c2827ec..00000000 --- a/src/fsfw/cfdp/CfdpHandler.h +++ /dev/null @@ -1,63 +0,0 @@ -//#ifndef FSFW_CFDP_CFDPHANDLER_H_ -//#define FSFW_CFDP_CFDPHANDLER_H_ -// -//#include "fsfw/ipc/MessageQueueIF.h" -//#include "fsfw/objectmanager/SystemObject.h" -//#include "fsfw/returnvalues/HasReturnvaluesIF.h" -//#include "fsfw/storagemanager/storeAddress.h" -//#include "fsfw/tasks/ExecutableObjectIF.h" -//#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -// -// namespace Factory { -// void setStaticFrameworkObjectIds(); -//} -// -// class CfdpHandler : public ExecutableObjectIF, -// public AcceptsTelecommandsIF, -// public SystemObject, -// public HasReturnvaluesIF { -// friend void(Factory::setStaticFrameworkObjectIds)(); -// -// public: -// CfdpHandler(object_id_t setObjectId, CfdpHandler* distributor); -// /** -// * The destructor is empty. -// */ -// virtual ~CfdpHandler(); -// -// virtual ReturnValue_t handleRequest(store_address_t storeId); -// -// virtual ReturnValue_t initialize() override; -// virtual uint32_t getIdentifier() const override; -// MessageQueueId_t getRequestQueue() const override; -// ReturnValue_t performOperation(uint8_t opCode) override; -// -// protected: -// /** -// * This is a complete instance of the telecommand reception queue -// * of the class. It is initialized on construction of the class. -// */ -// MessageQueueIF* requestQueue = nullptr; -// -// CfdpHandler* distributor = nullptr; -// -// /** -// * The current CFDP packet to be processed. -// * It is deleted after handleRequest was executed. -// */ -// CfdpPacketStored currentPacket; -// -// static object_id_t packetSource; -// -// static object_id_t packetDestination; -// -// private: -// /** -// * This constant sets the maximum number of packets accepted per call. -// * Remember that one packet must be completely handled in one -// * #handleRequest call. -// */ -// static const uint8_t CFDP_HANDLER_MAX_RECEPTION = 100; -//}; -// -//#endif /* FSFW_CFDP_CFDPHANDLER_H_ */ From 11a4b276423ac287f5522cdbf913a81e1ee3d347 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Sep 2022 18:20:38 +0200 Subject: [PATCH 337/532] allow deferred init --- src/fsfw/cfdp/handler/DestHandler.cpp | 12 +++++++++++- src/fsfw/cfdp/handler/DestHandler.h | 10 ++++++---- unittests/cfdp/handler/testDestHandler.cpp | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index cd3cc3b4..3660f75c 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -116,6 +116,10 @@ ReturnValue_t cfdp::DestHandler::initialize() { return FAILED; } } + + if (fp.msgQueue == nullptr) { + return FAILED; + } return OK; } @@ -421,7 +425,7 @@ ReturnValue_t cfdp::DestHandler::sendFinishedPdu() { return result; } TmTcMessage msg(storeId); - result = fp.msgQueue.sendMessage(fp.packetDest.getReportReceptionQueue(), &msg); + result = fp.msgQueue->sendMessage(fp.packetDest.getReportReceptionQueue(), &msg); if (result != OK) { // TODO: Error handling and event, this is a non CFDP specific error (most likely store is full) return result; @@ -451,3 +455,9 @@ void cfdp::DestHandler::checkAndHandleError(ReturnValue_t result, uint8_t& error errorIdx++; } } + +void cfdp::DestHandler::setMsgQueue(MessageQueueIF& queue) { fp.msgQueue = &queue; } + +void cfdp::DestHandler::setEventReporter(EventReportingProxyIF& reporter) { + fp.eventReporter = &reporter; +} diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 8d2fc6e9..5507045f 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -62,12 +62,12 @@ struct DestHandlerParams { }; struct FsfwParams { - FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF& msgQueue, - EventReportingProxyIF& eventReporter) + FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue, + EventReportingProxyIF* eventReporter) : packetDest(packetDest), msgQueue(msgQueue), eventReporter(eventReporter) {} AcceptsTelemetryIF& packetDest; - MessageQueueIF& msgQueue; - EventReportingProxyIF& eventReporter; + MessageQueueIF* msgQueue; + EventReportingProxyIF* eventReporter = nullptr; StorageManagerIF* tcStore = nullptr; StorageManagerIF* tmStore = nullptr; }; @@ -116,6 +116,8 @@ class DestHandler { * - @c CALL_FSM_AGAIN State machine should be called again. */ const FsmResult& performStateMachine(); + void setMsgQueue(MessageQueueIF& queue); + void setEventReporter(EventReportingProxyIF& reporter); ReturnValue_t passPacket(PacketInfo packet); diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 404d8eed..20ddf678 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -38,7 +38,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { LocalPool::LocalPoolConfig storeCfg = {{10, 32}, {10, 64}, {10, 128}, {10, 1024}}; StorageManagerMock tcStore(2, storeCfg); StorageManagerMock tmStore(3, storeCfg); - FsfwParams fp(tmReceiver, mqMock, eventReporterMock); + FsfwParams fp(tmReceiver, &mqMock, &eventReporterMock); RemoteEntityCfg cfg; cfg.remoteId = remoteId; remoteCfgTableMock.addRemoteConfig(cfg); From 683cf8a047013571dc206d60c52810b8a92905a4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Sep 2022 11:08:40 +0200 Subject: [PATCH 338/532] some additional tests --- src/fsfw/cfdp/CfdpDistributor.cpp | 3 +- src/fsfw/cfdp/CfdpDistributor.h | 4 +- src/fsfw/cfdp/handler/DestHandler.cpp | 6 +- src/fsfw/cfdp/handler/DestHandler.h | 1 + src/fsfw/cfdp/pdu/FileDataReader.cpp | 8 +- src/fsfw/cfdp/pdu/FileDataReader.h | 4 +- src/fsfw/cfdp/pdu/FileDirectiveReader.cpp | 8 +- src/fsfw/cfdp/pdu/FileDirectiveReader.h | 4 +- src/fsfw/cfdp/pdu/HeaderReader.cpp | 67 +++-- .../pdu/{HeaderReader.h => PduHeaderReader.h} | 13 +- unittests/cfdp/pdu/testCfdpHeader.cpp | 253 +++++++++--------- unittests/cfdp/pdu/testKeepAlivePdu.cpp | 12 +- unittests/cfdp/pdu/testPromptPdu.cpp | 2 +- 13 files changed, 205 insertions(+), 180 deletions(-) rename src/fsfw/cfdp/pdu/{HeaderReader.h => PduHeaderReader.h} (88%) diff --git a/src/fsfw/cfdp/CfdpDistributor.cpp b/src/fsfw/cfdp/CfdpDistributor.cpp index d0237959..b233e67e 100644 --- a/src/fsfw/cfdp/CfdpDistributor.cpp +++ b/src/fsfw/cfdp/CfdpDistributor.cpp @@ -21,7 +21,8 @@ ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) { if (accessorPair.first != returnvalue::OK) { return accessorPair.first; } - ReturnValue_t result = pduReader.setData(accessorPair.second.data(), accessorPair.second.size()); + ReturnValue_t result = + pduReader.setReadOnlyData(accessorPair.second.data(), accessorPair.second.size()); if (result != returnvalue::OK) { return result; } diff --git a/src/fsfw/cfdp/CfdpDistributor.h b/src/fsfw/cfdp/CfdpDistributor.h index 39ce0d27..13d000eb 100644 --- a/src/fsfw/cfdp/CfdpDistributor.h +++ b/src/fsfw/cfdp/CfdpDistributor.h @@ -4,7 +4,7 @@ #include #include -#include "fsfw/cfdp/pdu/HeaderReader.h" +#include "fsfw/cfdp/pdu/PduHeaderReader.h" #include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tcdistribution/CfdpPacketChecker.h" #include "fsfw/tcdistribution/TcDistributorBase.h" @@ -60,7 +60,7 @@ class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF { const char* name; MessageQueueId_t queueId; }; - HeaderReader pduReader; + PduHeaderReader pduReader; ReturnValue_t lastTcError = returnvalue::OK; ReturnValue_t lastTmError = returnvalue::OK; // I don't think a regular OBSW will have more than 1 or 2 of these destinations, so I think diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 3660f75c..3ddf96ff 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -8,7 +8,7 @@ #include "fsfw/cfdp/pdu/EofPduReader.h" #include "fsfw/cfdp/pdu/FileDataReader.h" #include "fsfw/cfdp/pdu/FinishedPduCreator.h" -#include "fsfw/cfdp/pdu/HeaderReader.h" +#include "fsfw/cfdp/pdu/PduHeaderReader.h" #include "fsfw/objectmanager.h" #include "fsfw/tmtcservices/TmTcMessage.h" @@ -236,7 +236,7 @@ ReturnValue_t cfdp::DestHandler::handleMetadataParseError(ReturnValue_t result, sif::warning << "Parsing Metadata PDU failed with code " << result << std::endl; #else #endif - HeaderReader headerReader(rawData, maxSize); + PduHeaderReader headerReader(rawData, maxSize); result = headerReader.parseData(); if (result != OK) { // TODO: Now this really should not happen. Warning or error, @@ -461,3 +461,5 @@ void cfdp::DestHandler::setMsgQueue(MessageQueueIF& queue) { fp.msgQueue = &queu void cfdp::DestHandler::setEventReporter(EventReportingProxyIF& reporter) { fp.eventReporter = &reporter; } + +const cfdp::DestHandlerParams& cfdp::DestHandler::getDestHandlerParams() const { return dp; } diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 5507045f..975ccaaf 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -126,6 +126,7 @@ class DestHandler { [[nodiscard]] CfdpStates getCfdpState() const; [[nodiscard]] TransactionStep getTransactionStep() const; [[nodiscard]] const TransactionId& getTransactionId() const; + [[nodiscard]] const DestHandlerParams& getDestHandlerParams() const; private: struct TransactionParams { diff --git a/src/fsfw/cfdp/pdu/FileDataReader.cpp b/src/fsfw/cfdp/pdu/FileDataReader.cpp index 8eac4c3f..9155ef28 100644 --- a/src/fsfw/cfdp/pdu/FileDataReader.cpp +++ b/src/fsfw/cfdp/pdu/FileDataReader.cpp @@ -1,16 +1,16 @@ #include "FileDataReader.h" FileDataReader::FileDataReader(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info) - : HeaderReader(pduBuf, maxSize), info(info) {} + : PduHeaderReader(pduBuf, maxSize), info(info) {} ReturnValue_t FileDataReader::parseData() { - ReturnValue_t result = HeaderReader::parseData(); + ReturnValue_t result = PduHeaderReader::parseData(); if (result != returnvalue::OK) { return result; } - size_t currentIdx = HeaderReader::getHeaderSize(); + size_t currentIdx = PduHeaderReader::getHeaderSize(); const uint8_t* buf = pointers.rawPtr + currentIdx; - size_t remSize = HeaderReader::getWholePduSize() - currentIdx; + size_t remSize = PduHeaderReader::getWholePduSize() - currentIdx; if (remSize < 1) { return SerializeIF::STREAM_TOO_SHORT; } diff --git a/src/fsfw/cfdp/pdu/FileDataReader.h b/src/fsfw/cfdp/pdu/FileDataReader.h index 62e0f89b..aa962e2b 100644 --- a/src/fsfw/cfdp/pdu/FileDataReader.h +++ b/src/fsfw/cfdp/pdu/FileDataReader.h @@ -3,9 +3,9 @@ #include "../definitions.h" #include "FileDataInfo.h" -#include "HeaderReader.h" +#include "PduHeaderReader.h" -class FileDataReader : public HeaderReader { +class FileDataReader : public PduHeaderReader { public: FileDataReader(const uint8_t* pduBuf, size_t maxSize, FileDataInfo& info); diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp index 4099efd9..5d43ebb0 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp @@ -1,12 +1,12 @@ #include "FileDirectiveReader.h" FileDirectiveReader::FileDirectiveReader(const uint8_t *pduBuf, size_t maxSize) - : HeaderReader(pduBuf, maxSize) {} + : PduHeaderReader(pduBuf, maxSize) {} cfdp::FileDirectives FileDirectiveReader::getFileDirective() const { return fileDirective; } ReturnValue_t FileDirectiveReader::parseData() { - ReturnValue_t result = HeaderReader::parseData(); + ReturnValue_t result = PduHeaderReader::parseData(); if (result != returnvalue::OK) { return result; } @@ -16,7 +16,7 @@ ReturnValue_t FileDirectiveReader::parseData() { if (FileDirectiveReader::getWholePduSize() > maxSize) { return SerializeIF::STREAM_TOO_SHORT; } - size_t currentIdx = HeaderReader::getHeaderSize(); + size_t currentIdx = PduHeaderReader::getHeaderSize(); if (not checkFileDirective(pointers.rawPtr[currentIdx])) { return cfdp::INVALID_DIRECTIVE_FIELDS; } @@ -26,7 +26,7 @@ ReturnValue_t FileDirectiveReader::parseData() { size_t FileDirectiveReader::getHeaderSize() const { // return size of header plus the directive byte - return HeaderReader::getHeaderSize() + 1; + return PduHeaderReader::getHeaderSize() + 1; } bool FileDirectiveReader::checkFileDirective(uint8_t rawByte) { diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.h b/src/fsfw/cfdp/pdu/FileDirectiveReader.h index 69dd44cd..83a71c71 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveReader.h +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.h @@ -2,7 +2,7 @@ #define FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVEDESERIALIZER_H_ #include "../definitions.h" -#include "fsfw/cfdp/pdu/HeaderReader.h" +#include "fsfw/cfdp/pdu/PduHeaderReader.h" /** * @brief This class is used to deserialize a PDU file directive header from raw memory. @@ -11,7 +11,7 @@ * This is a zero-copy implementation and #parseData needs to be called to ensure the data is * valid. */ -class FileDirectiveReader : public HeaderReader { +class FileDirectiveReader : public PduHeaderReader { public: FileDirectiveReader(const uint8_t* pduBuf, size_t maxSize); diff --git a/src/fsfw/cfdp/pdu/HeaderReader.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp index e2f070db..3417a57c 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.cpp +++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp @@ -1,12 +1,14 @@ -#include "HeaderReader.h" - #include #include -HeaderReader::HeaderReader(const uint8_t *pduBuf, size_t maxSize) { setData(pduBuf, maxSize); } +#include "PduHeaderReader.h" -ReturnValue_t HeaderReader::parseData() { +PduHeaderReader::PduHeaderReader(const uint8_t *pduBuf, size_t maxSize) { + setReadOnlyData(pduBuf, maxSize); +} + +ReturnValue_t PduHeaderReader::parseData() { if (pointers.rawPtr == nullptr) { return returnvalue::FAILED; } @@ -20,10 +22,15 @@ ReturnValue_t HeaderReader::parseData() { cfdp::WidthInBytes widthSeqNum = getLenSeqNum(); seqNumRaw = static_cast(sourceIdRaw) + static_cast(widthEntityIds); destIdRaw = static_cast(seqNumRaw) + static_cast(widthSeqNum); + if (getWholePduSize() > PduHeaderReader::getHeaderSize()) { + pointers.dataFieldStart = reinterpret_cast(destIdRaw) + widthEntityIds; + } else { + pointers.dataFieldStart = nullptr; + } return returnvalue::OK; } -ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) { +ReturnValue_t PduHeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *args) { if (dataPtr == nullptr) { return returnvalue::FAILED; } @@ -35,68 +42,68 @@ ReturnValue_t HeaderReader::setData(uint8_t *dataPtr, size_t maxSize_, void *arg return returnvalue::OK; } -size_t HeaderReader::getHeaderSize() const { +size_t PduHeaderReader::getHeaderSize() const { if (pointers.fixedHeader != nullptr) { return getLenEntityIds() * 2 + getLenSeqNum() + 4; } return 0; } -size_t HeaderReader::getPduDataFieldLen() const { +size_t PduHeaderReader::getPduDataFieldLen() const { return (pointers.fixedHeader->pduDataFieldLenH << 8) | pointers.fixedHeader->pduDataFieldLenL; } -size_t HeaderReader::getWholePduSize() const { - return getPduDataFieldLen() + HeaderReader::getHeaderSize(); +size_t PduHeaderReader::getWholePduSize() const { + return getPduDataFieldLen() + PduHeaderReader::getHeaderSize(); } -cfdp::PduType HeaderReader::getPduType() const { +cfdp::PduType PduHeaderReader::getPduType() const { return static_cast((pointers.fixedHeader->firstByte >> 4) & 0x01); } -cfdp::Direction HeaderReader::getDirection() const { +cfdp::Direction PduHeaderReader::getDirection() const { return static_cast((pointers.fixedHeader->firstByte >> 3) & 0x01); } -cfdp::TransmissionModes HeaderReader::getTransmissionMode() const { +cfdp::TransmissionModes PduHeaderReader::getTransmissionMode() const { return static_cast((pointers.fixedHeader->firstByte >> 2) & 0x01); } -bool HeaderReader::getCrcFlag() const { return (pointers.fixedHeader->firstByte >> 1) & 0x01; } +bool PduHeaderReader::getCrcFlag() const { return (pointers.fixedHeader->firstByte >> 1) & 0x01; } -bool HeaderReader::getLargeFileFlag() const { return pointers.fixedHeader->firstByte & 0x01; } +bool PduHeaderReader::getLargeFileFlag() const { return pointers.fixedHeader->firstByte & 0x01; } -cfdp::SegmentationControl HeaderReader::getSegmentationControl() const { +cfdp::SegmentationControl PduHeaderReader::getSegmentationControl() const { return static_cast((pointers.fixedHeader->fourthByte >> 7) & 0x01); } -cfdp::WidthInBytes HeaderReader::getLenEntityIds() const { +cfdp::WidthInBytes PduHeaderReader::getLenEntityIds() const { return static_cast((pointers.fixedHeader->fourthByte >> 4) & 0x07); } -cfdp::WidthInBytes HeaderReader::getLenSeqNum() const { +cfdp::WidthInBytes PduHeaderReader::getLenSeqNum() const { return static_cast(pointers.fixedHeader->fourthByte & 0x07); } -cfdp::SegmentMetadataFlag HeaderReader::getSegmentMetadataFlag() const { +cfdp::SegmentMetadataFlag PduHeaderReader::getSegmentMetadataFlag() const { return static_cast((pointers.fixedHeader->fourthByte >> 3) & 0x01); } -void HeaderReader::getSourceId(cfdp::EntityId &sourceId) const { +void PduHeaderReader::getSourceId(cfdp::EntityId &sourceId) const { assignVarLenField(dynamic_cast(&sourceId), getLenEntityIds(), this->sourceIdRaw); } -void HeaderReader::getDestId(cfdp::EntityId &destId) const { +void PduHeaderReader::getDestId(cfdp::EntityId &destId) const { assignVarLenField(dynamic_cast(&destId), getLenEntityIds(), this->destIdRaw); } -void HeaderReader::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const { +void PduHeaderReader::getTransactionSeqNum(cfdp::TransactionSeqNum &seqNum) const { assignVarLenField(dynamic_cast(&seqNum), getLenSeqNum(), this->seqNumRaw); } -void HeaderReader::assignVarLenField(cfdp::VarLenField *field, cfdp::WidthInBytes width, - void *sourcePtr) const { +void PduHeaderReader::assignVarLenField(cfdp::VarLenField *field, cfdp::WidthInBytes width, + void *sourcePtr) const { switch (width) { case (cfdp::WidthInBytes::ONE_BYTE): { auto *fieldTyped = static_cast(sourcePtr); @@ -122,25 +129,25 @@ void HeaderReader::assignVarLenField(cfdp::VarLenField *field, cfdp::WidthInByte } } -size_t HeaderReader::getMaxSize() const { return maxSize; } +size_t PduHeaderReader::getMaxSize() const { return maxSize; } -bool HeaderReader::hasSegmentMetadataFlag() const { +bool PduHeaderReader::hasSegmentMetadataFlag() const { if (this->getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT) { return true; } return false; } -ReturnValue_t HeaderReader::setData(const uint8_t *dataPtr, size_t maxSize_) { +ReturnValue_t PduHeaderReader::setReadOnlyData(const uint8_t *dataPtr, size_t maxSize_) { return setData(const_cast(dataPtr), maxSize_, nullptr); } -bool HeaderReader::isNull() const { +bool PduHeaderReader::isNull() const { return pointers.rawPtr == nullptr or pointers.fixedHeader == nullptr; } -HeaderReader::operator bool() const { return not isNull(); } +PduHeaderReader::operator bool() const { return not isNull(); } -void HeaderReader::fillConfig(PduConfig &cfg) const { +void PduHeaderReader::fillConfig(PduConfig &cfg) const { cfg.largeFile = getLargeFileFlag(); cfg.crcFlag = getCrcFlag(); cfg.mode = getTransmissionMode(); @@ -149,3 +156,5 @@ void HeaderReader::fillConfig(PduConfig &cfg) const { getSourceId(cfg.sourceId); getDestId(cfg.destId); } + +const uint8_t *PduHeaderReader::getPduDataField() const { return pointers.dataFieldStart; } diff --git a/src/fsfw/cfdp/pdu/HeaderReader.h b/src/fsfw/cfdp/pdu/PduHeaderReader.h similarity index 88% rename from src/fsfw/cfdp/pdu/HeaderReader.h rename to src/fsfw/cfdp/pdu/PduHeaderReader.h index 533320b7..7809f59c 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.h +++ b/src/fsfw/cfdp/pdu/PduHeaderReader.h @@ -23,16 +23,16 @@ struct PduHeaderFixedStruct { * This is a zero-copy implementation and #parseData needs to be called to ensure the data is * valid. */ -class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { +class PduHeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { public: - HeaderReader() = default; + PduHeaderReader() = default; /** * Initialize a PDU header from raw data. This is a zero-copy implementation and #parseData * needs to be called to ensure the data is valid * @param pduBuf * @param maxSize */ - HeaderReader(const uint8_t* pduBuf, size_t maxSize); + PduHeaderReader(const uint8_t* pduBuf, size_t maxSize); /** * This needs to be called before accessing the PDU fields to avoid segmentation faults. @@ -74,6 +74,7 @@ class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { ReturnValue_t deserResult = returnvalue::OK; [[nodiscard]] size_t getMaxSize() const; + [[nodiscard]] const uint8_t* getPduDataField() const; /** * Can also be used to reset the pointer to a nullptr, but the getter functions will not @@ -83,11 +84,12 @@ class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { * @param args * @return */ - ReturnValue_t setData(const uint8_t* dataPtr, size_t maxSize); + ReturnValue_t setReadOnlyData(const uint8_t* dataPtr, size_t maxSize); protected: struct Pointers { PduHeaderFixedStruct* fixedHeader = nullptr; + const uint8_t* dataFieldStart = nullptr; const uint8_t* rawPtr = nullptr; }; @@ -96,8 +98,7 @@ class HeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { private: /** - * Can also be used to reset the pointer to a nullptr, but the getter functions will not - * perform nullptr checks! + * This is a reader class and setting mutable data is forbidden. Use @setReadOnlyData instead. * @param dataPtr * @param maxSize * @param args diff --git a/unittests/cfdp/pdu/testCfdpHeader.cpp b/unittests/cfdp/pdu/testCfdpHeader.cpp index 99a0c470..6d22154b 100644 --- a/unittests/cfdp/pdu/testCfdpHeader.cpp +++ b/unittests/cfdp/pdu/testCfdpHeader.cpp @@ -1,10 +1,14 @@ #include #include +#include "fsfw/cfdp/pdu/FinishedInfo.h" +#include "fsfw/cfdp/pdu/FinishedPduCreator.h" #include "fsfw/cfdp/pdu/HeaderCreator.h" -#include "fsfw/cfdp/pdu/HeaderReader.h" +#include "fsfw/cfdp/pdu/PduHeaderReader.h" #include "fsfw/returnvalues/returnvalue.h" +using namespace returnvalue; + TEST_CASE("CFDP Header", "[cfdp]") { using namespace cfdp; std::array serBuf{}; @@ -17,63 +21,62 @@ TEST_CASE("CFDP Header", "[cfdp]") { uint8_t* serTarget = serBuf.data(); const uint8_t* deserTarget = serTarget; size_t serSize = 0; - auto headerSerializer = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); + auto creator = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); SECTION("Header State") { REQUIRE(seqNum.getSerializedSize() == 1); - REQUIRE(headerSerializer.getPduDataFieldLen() == 0); - REQUIRE(headerSerializer.getSerializedSize() == 7); - REQUIRE(headerSerializer.getWholePduSize() == 7); - REQUIRE(headerSerializer.getCrcFlag() == false); - REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_RECEIVER); - REQUIRE(headerSerializer.getLargeFileFlag() == false); - REQUIRE(headerSerializer.getLenEntityIds() == 1); - REQUIRE(headerSerializer.getLenSeqNum() == 1); - REQUIRE(headerSerializer.getPduType() == cfdp::PduType::FILE_DIRECTIVE); - REQUIRE(headerSerializer.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); - REQUIRE(headerSerializer.getSegmentationControl() == false); - REQUIRE(headerSerializer.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); + REQUIRE(creator.getPduDataFieldLen() == 0); + REQUIRE(creator.getSerializedSize() == 7); + REQUIRE(creator.getWholePduSize() == 7); + REQUIRE(creator.getCrcFlag() == false); + REQUIRE(creator.getDirection() == cfdp::Direction::TOWARDS_RECEIVER); + REQUIRE(creator.getLargeFileFlag() == false); + REQUIRE(creator.getLenEntityIds() == 1); + REQUIRE(creator.getLenSeqNum() == 1); + REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DIRECTIVE); + REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); + REQUIRE(creator.getSegmentationControl() == false); + REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); cfdp::TransactionSeqNum seqNumLocal; - headerSerializer.getTransactionSeqNum(seqNumLocal); + creator.getTransactionSeqNum(seqNumLocal); REQUIRE(seqNumLocal.getWidth() == cfdp::WidthInBytes::ONE_BYTE); REQUIRE(seqNumLocal.getValue() == 2); cfdp::EntityId sourceDestId; - headerSerializer.getSourceId(sourceDestId); + creator.getSourceId(sourceDestId); REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::ONE_BYTE); REQUIRE(sourceDestId.getValue() == 0); - headerSerializer.getDestId(sourceDestId); + creator.getDestId(sourceDestId); REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::ONE_BYTE); REQUIRE(sourceDestId.getValue() == 1); } SECTION("Deserialization fails") { const uint8_t** dummyPtr = nullptr; - REQUIRE(headerSerializer.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK) == + REQUIRE(creator.deSerialize(dummyPtr, &serSize, SerializeIF::Endianness::NETWORK) == returnvalue::FAILED); } SECTION("Serialization fails") { - REQUIRE(headerSerializer.serialize(nullptr, &serSize, serBuf.size(), - SerializeIF::Endianness::NETWORK) == returnvalue::FAILED); + REQUIRE(creator.serialize(nullptr, &serSize, serBuf.size(), SerializeIF::Endianness::NETWORK) == + returnvalue::FAILED); } SECTION("Buffer Too Short") { for (uint8_t idx = 0; idx < 7; idx++) { - result = headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); + result = creator.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG); REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); } } SECTION("Set Data Field Len") { // Set PDU data field len - headerSerializer.setPduDataFieldLen(0x0ff0); - REQUIRE(headerSerializer.getPduDataFieldLen() == 0x0ff0); - REQUIRE(headerSerializer.getSerializedSize() == 7); - REQUIRE(headerSerializer.getWholePduSize() == 7 + 0x0ff0); + creator.setPduDataFieldLen(0x0ff0); + REQUIRE(creator.getPduDataFieldLen() == 0x0ff0); + REQUIRE(creator.getSerializedSize() == 7); + REQUIRE(creator.getWholePduSize() == 7 + 0x0ff0); serTarget = serBuf.data(); serSize = 0; - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); + result = creator.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); REQUIRE(serBuf[1] == 0x0f); REQUIRE(serBuf[2] == 0xf0); } @@ -83,28 +86,27 @@ TEST_CASE("CFDP Header", "[cfdp]") { pduConf.largeFile = true; pduConf.direction = cfdp::Direction::TOWARDS_SENDER; pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; - headerSerializer.setSegmentationControl( - cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); - headerSerializer.setPduType(cfdp::PduType::FILE_DATA); - headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); + creator.setSegmentationControl(cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); + creator.setPduType(cfdp::PduType::FILE_DATA); + creator.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); serTarget = serBuf.data(); serSize = 0; SECTION("Regular") { // Everything except version bit flipped to one now - REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG) == returnvalue::OK); + REQUIRE(creator.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG) == returnvalue::OK); CHECK(serBuf[0] == 0x3f); CHECK(serBuf[3] == 0x99); - REQUIRE(headerSerializer.getCrcFlag() == true); - REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER); - REQUIRE(headerSerializer.getLargeFileFlag() == true); - REQUIRE(headerSerializer.getLenEntityIds() == 1); - REQUIRE(headerSerializer.getLenSeqNum() == 1); - REQUIRE(headerSerializer.getPduType() == cfdp::PduType::FILE_DATA); - REQUIRE(headerSerializer.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); - REQUIRE(headerSerializer.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); - REQUIRE(headerSerializer.getSegmentationControl() == true); + REQUIRE(creator.getCrcFlag() == true); + REQUIRE(creator.getDirection() == cfdp::Direction::TOWARDS_SENDER); + REQUIRE(creator.getLargeFileFlag() == true); + REQUIRE(creator.getLenEntityIds() == 1); + REQUIRE(creator.getLenSeqNum() == 1); + REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DATA); + REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); + REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); + REQUIRE(creator.getSegmentationControl() == true); } SECTION("Other variable sized fields") { @@ -112,18 +114,18 @@ TEST_CASE("CFDP Header", "[cfdp]") { pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); REQUIRE(pduConf.sourceId.getSerializedSize() == 4); - REQUIRE(headerSerializer.getSerializedSize() == 14); - REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG) == returnvalue::OK); - REQUIRE(headerSerializer.getCrcFlag() == true); - REQUIRE(headerSerializer.getDirection() == cfdp::Direction::TOWARDS_SENDER); - REQUIRE(headerSerializer.getLargeFileFlag() == true); - REQUIRE(headerSerializer.getLenEntityIds() == 4); - REQUIRE(headerSerializer.getLenSeqNum() == 2); - REQUIRE(headerSerializer.getPduType() == cfdp::PduType::FILE_DATA); - REQUIRE(headerSerializer.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); - REQUIRE(headerSerializer.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); - REQUIRE(headerSerializer.getSegmentationControl() == true); + REQUIRE(creator.getSerializedSize() == 14); + REQUIRE(creator.serialize(&serTarget, &serSize, serBuf.size(), + SerializeIF::Endianness::BIG) == returnvalue::OK); + REQUIRE(creator.getCrcFlag() == true); + REQUIRE(creator.getDirection() == cfdp::Direction::TOWARDS_SENDER); + REQUIRE(creator.getLargeFileFlag() == true); + REQUIRE(creator.getLenEntityIds() == 4); + REQUIRE(creator.getLenSeqNum() == 2); + REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DATA); + REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); + REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); + REQUIRE(creator.getSegmentationControl() == true); // Last three bits are 2 now (length of seq number) and bit 1 to bit 3 is 4 (len entity IDs) REQUIRE(serBuf[3] == 0b11001010); uint32_t entityId = 0; @@ -148,9 +150,8 @@ TEST_CASE("CFDP Header", "[cfdp]") { pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); pduConf.destId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0x00ff00ff); for (uint8_t idx = 0; idx < 14; idx++) { - REQUIRE( - headerSerializer.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG) == - SerializeIF::BUFFER_TOO_SHORT); + REQUIRE(creator.serialize(&serTarget, &serSize, idx, SerializeIF::Endianness::BIG) == + SerializeIF::BUFFER_TOO_SHORT); } } } @@ -165,8 +166,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { } SECTION("Header Serialization") { - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); + result = creator.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); REQUIRE(result == returnvalue::OK); REQUIRE(serSize == 7); // Only version bits are set @@ -214,40 +214,49 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(result == static_cast(SerializeIF::BUFFER_TOO_SHORT)); } - SECTION("Header Deserialization") { - REQUIRE(headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG) == returnvalue::OK); + SECTION("Header Deserialization 0") { + REQUIRE(creator.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG) == + returnvalue::OK); REQUIRE(serBuf[1] == 0); REQUIRE(serBuf[2] == 0); // Entity and Transaction Sequence number are 1 byte large REQUIRE(serBuf[3] == 0b00010001); REQUIRE(serSize == 7); // Deser call not strictly necessary - auto headerDeser = HeaderReader(serBuf.data(), serBuf.size()); + auto reader = PduHeaderReader(serBuf.data(), serBuf.size()); - ReturnValue_t serResult = headerDeser.parseData(); + ReturnValue_t serResult = reader.parseData(); REQUIRE(serResult == returnvalue::OK); - REQUIRE(headerDeser.getPduDataFieldLen() == 0); - REQUIRE(headerDeser.getHeaderSize() == 7); - REQUIRE(headerDeser.getWholePduSize() == 7); - REQUIRE(headerDeser.getCrcFlag() == false); - REQUIRE(headerDeser.getDirection() == cfdp::Direction::TOWARDS_RECEIVER); - REQUIRE(headerDeser.getLargeFileFlag() == false); - REQUIRE(headerDeser.getLenEntityIds() == 1); - REQUIRE(headerDeser.getLenSeqNum() == 1); - REQUIRE(headerDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE); - REQUIRE(headerDeser.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); - REQUIRE(headerDeser.getSegmentationControl() == false); - REQUIRE(headerDeser.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); + REQUIRE(reader.getPduDataFieldLen() == 0); + REQUIRE(reader.getHeaderSize() == 7); + REQUIRE(reader.getWholePduSize() == 7); + REQUIRE(reader.getCrcFlag() == false); + REQUIRE(reader.getDirection() == cfdp::Direction::TOWARDS_RECEIVER); + REQUIRE(reader.getLargeFileFlag() == false); + REQUIRE(reader.getLenEntityIds() == 1); + REQUIRE(reader.getLenSeqNum() == 1); + REQUIRE(reader.getPduType() == cfdp::PduType::FILE_DIRECTIVE); + REQUIRE(reader.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); + REQUIRE(reader.getSegmentationControl() == false); + REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); + // No PDU data contained, so the PDU data field is empty + REQUIRE(reader.getPduDataField() == nullptr); + size_t deSerSize = reader.getWholePduSize(); + serTarget = serBuf.data(); + const auto** serTargetConst = const_cast(&serTarget); + result = reader.parseData(); + REQUIRE(result == returnvalue::OK); + } + + SECTION("Header Deserialization 1") { pduConf.crcFlag = true; pduConf.largeFile = true; pduConf.direction = cfdp::Direction::TOWARDS_SENDER; pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; - headerSerializer.setSegmentationControl( - cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); - headerSerializer.setPduType(cfdp::PduType::FILE_DATA); - headerSerializer.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); + creator.setSegmentationControl(cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); + creator.setPduType(cfdp::PduType::FILE_DATA); + creator.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); REQUIRE(result == returnvalue::OK); result = pduConf.sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 0xff00ff00); @@ -256,61 +265,63 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(result == returnvalue::OK); serTarget = serBuf.data(); serSize = 0; - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - headerDeser = HeaderReader(serBuf.data(), serBuf.size()); - - result = headerDeser.parseData(); - REQUIRE(result == returnvalue::OK); + result = creator.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); + PduHeaderReader reader(serBuf.data(), serBuf.size()); + REQUIRE(reader.parseData() == returnvalue::OK); // Everything except version bit flipped to one now REQUIRE(serBuf[0] == 0x3f); REQUIRE(serBuf[3] == 0b11001010); - REQUIRE(headerDeser.getWholePduSize() == 14); + REQUIRE(reader.getWholePduSize() == 14); - REQUIRE(headerDeser.getCrcFlag() == true); - REQUIRE(headerDeser.getDirection() == cfdp::Direction::TOWARDS_SENDER); - REQUIRE(headerDeser.getLargeFileFlag() == true); - REQUIRE(headerDeser.getLenEntityIds() == 4); - REQUIRE(headerDeser.getLenSeqNum() == 2); - REQUIRE(headerDeser.getPduType() == cfdp::PduType::FILE_DATA); - REQUIRE(headerDeser.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); - REQUIRE(headerDeser.getSegmentationControl() == true); - REQUIRE(headerDeser.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); + REQUIRE(reader.getCrcFlag() == true); + REQUIRE(reader.getDirection() == cfdp::Direction::TOWARDS_SENDER); + REQUIRE(reader.getLargeFileFlag() == true); + REQUIRE(reader.getLenEntityIds() == 4); + REQUIRE(reader.getLenSeqNum() == 2); + REQUIRE(reader.getPduType() == cfdp::PduType::FILE_DATA); + REQUIRE(reader.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); + REQUIRE(reader.getSegmentationControl() == true); + REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); + // Again, no data field set because this is a header only + REQUIRE(reader.getPduDataField() == nullptr); cfdp::TransactionSeqNum seqNumLocal; - headerDeser.getTransactionSeqNum(seqNumLocal); + reader.getTransactionSeqNum(seqNumLocal); REQUIRE(seqNumLocal.getWidth() == cfdp::WidthInBytes::TWO_BYTES); REQUIRE(seqNumLocal.getValue() == 0x0fff); cfdp::EntityId sourceDestId; - headerDeser.getSourceId(sourceDestId); + reader.getSourceId(sourceDestId); REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::FOUR_BYTES); REQUIRE(sourceDestId.getValue() == 0xff00ff00); - headerDeser.getDestId(sourceDestId); + reader.getDestId(sourceDestId); REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::FOUR_BYTES); REQUIRE(sourceDestId.getValue() == 0x00ff00ff); + CHECK(reader.setReadOnlyData(nullptr, -1) != returnvalue::OK); + REQUIRE(reader.getHeaderSize() == 14); - size_t deSerSize = headerDeser.getWholePduSize(); - serTarget = serBuf.data(); - const auto** serTargetConst = const_cast(&serTarget); - result = headerDeser.parseData(); - REQUIRE(result == returnvalue::OK); + SECTION("Manipulate Source Dest ID") { + serTarget = serBuf.data(); + serSize = 0; + pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 22); + pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48); + result = creator.serialize(&serTarget, &serSize, serBuf.size(), SerializeIF::Endianness::BIG); + reader.getSourceId(sourceDestId); + REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::ONE_BYTE); + REQUIRE(sourceDestId.getValue() == 22); + } + } - CHECK(headerDeser.setData(nullptr, -1) != returnvalue::OK); - REQUIRE(headerDeser.getHeaderSize() == 14); - headerDeser.setData(serBuf.data(), serBuf.size()); - - serTarget = serBuf.data(); - serSize = 0; - pduConf.sourceId.setValue(cfdp::WidthInBytes::ONE_BYTE, 22); - pduConf.destId.setValue(cfdp::WidthInBytes::ONE_BYTE, 48); - result = headerSerializer.serialize(&serTarget, &serSize, serBuf.size(), - SerializeIF::Endianness::BIG); - REQUIRE(result == returnvalue::OK); - REQUIRE(headerDeser.getWholePduSize() == 8); - headerDeser.setData(serBuf.data(), serBuf.size()); - - headerDeser.getSourceId(sourceDestId); - REQUIRE(sourceDestId.getWidth() == cfdp::WidthInBytes::ONE_BYTE); - REQUIRE(sourceDestId.getValue() == 22); + SECTION("Verify data field pointer") { + FinishedInfo info(cfdp::ConditionCode::INACTIVITY_DETECTED, + cfdp::FileDeliveryCode::DATA_INCOMPLETE, + cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY); + FinishPduCreator finishCreator(pduConf, info); + REQUIRE(finishCreator.serialize(serBuf.data(), serSize, serBuf.size()) == OK); + // This PDU contains the directive code and some finishes PDU properties packed into one byte + // in addition to the header + REQUIRE(finishCreator.getSerializedSize() == 9); + PduHeaderReader reader(serBuf.data(), serBuf.size()); + REQUIRE(reader.parseData() == returnvalue::OK); + REQUIRE(reader.getPduDataField() == serBuf.data() + 7); } } diff --git a/unittests/cfdp/pdu/testKeepAlivePdu.cpp b/unittests/cfdp/pdu/testKeepAlivePdu.cpp index b82feb32..34a529e9 100644 --- a/unittests/cfdp/pdu/testKeepAlivePdu.cpp +++ b/unittests/cfdp/pdu/testKeepAlivePdu.cpp @@ -61,19 +61,19 @@ TEST_CASE("Keep Alive PDU", "[cfdp][pdu]") { // Set another file size progress.setFileSize(200, false); - KeepAlivePduDeserializer deserializer(kaBuffer.data(), kaBuffer.size(), progress); - result = deserializer.parseData(); + KeepAlivePduDeserializer reader(kaBuffer.data(), kaBuffer.size(), progress); + result = reader.parseData(); REQUIRE(result == returnvalue::OK); - auto& progRef = deserializer.getProgress(); + auto& progRef = reader.getProgress(); // Should have been overwritten REQUIRE(progRef.getSize() == 0x50); - sz = deserializer.getWholePduSize(); + sz = reader.getWholePduSize(); // invalid max size for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { - ReturnValue_t setResult = deserializer.setData(kaBuffer.data(), invalidMaxSz); + ReturnValue_t setResult = reader.setReadOnlyData(kaBuffer.data(), invalidMaxSz); if (setResult == returnvalue::OK) { - result = deserializer.parseData(); + result = reader.parseData(); REQUIRE(result != returnvalue::OK); } } diff --git a/unittests/cfdp/pdu/testPromptPdu.cpp b/unittests/cfdp/pdu/testPromptPdu.cpp index ffabf9a4..1efd751d 100644 --- a/unittests/cfdp/pdu/testPromptPdu.cpp +++ b/unittests/cfdp/pdu/testPromptPdu.cpp @@ -59,7 +59,7 @@ TEST_CASE("Prompt PDU", "[cfdp][pdu]") { rawBuf[2] = 2; for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { - ReturnValue_t setResult = deserializer.setData(rawBuf.data(), invalidMaxSz); + ReturnValue_t setResult = deserializer.setReadOnlyData(rawBuf.data(), invalidMaxSz); if (setResult == returnvalue::OK) { result = deserializer.parseData(); REQUIRE(result != returnvalue::OK); From c87667c03f82f2be88e2a684b98a25be4cdae26b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Sep 2022 11:26:17 +0200 Subject: [PATCH 339/532] some API improvements --- src/fsfw/cfdp/definitions.h | 2 +- src/fsfw/cfdp/handler/DestHandler.cpp | 9 ++++++--- src/fsfw/cfdp/handler/DestHandler.h | 14 ++++++++++++-- src/fsfw/cfdp/pdu/FileDataCreator.cpp | 2 +- src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp | 2 +- src/fsfw/cfdp/pdu/HeaderCreator.cpp | 6 +++--- src/fsfw/cfdp/pdu/HeaderCreator.h | 8 ++++---- src/fsfw/cfdp/pdu/HeaderReader.cpp | 4 ++-- src/fsfw/cfdp/pdu/PduHeaderIF.h | 2 +- src/fsfw/cfdp/pdu/PduHeaderReader.h | 2 +- unittests/cfdp/pdu/testCfdpHeader.cpp | 16 ++++++++-------- unittests/cfdp/pdu/testFileDirective.cpp | 2 +- unittests/cfdp/testCfdp.cpp | 2 +- 13 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 635ead17..e5c11a0b 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -49,7 +49,7 @@ enum ChecksumTypes { NULL_CHECKSUM = 15 }; -enum PduType : uint8_t { FILE_DIRECTIVE = 0, FILE_DATA = 1 }; +enum PduTypes : uint8_t { FILE_DIRECTIVE = 0, FILE_DATA = 1 }; enum TransmissionModes : uint8_t { ACKNOWLEDGED = 0, UNACKNOWLEDGED = 1 }; diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 3ddf96ff..a89a5eeb 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -29,7 +29,7 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() { fsmRes.resetOfIteration(); if (fsmRes.step == TransactionStep::IDLE) { for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { - if (infoIter->pduType == PduType::FILE_DIRECTIVE and + if (infoIter->pduType == PduTypes::FILE_DIRECTIVE and infoIter->directiveType == FileDirectives::METADATA) { result = handleMetadataPdu(*infoIter); checkAndHandleError(result, errorIdx); @@ -57,12 +57,12 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() { if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) { if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { - if (infoIter->pduType == PduType::FILE_DATA) { + if (infoIter->pduType == PduTypes::FILE_DATA) { result = handleFileDataPdu(*infoIter); checkAndHandleError(result, errorIdx); // Store data was deleted in PDU handler because a store guard is used dp.packetListRef.erase(infoIter++); - } else if (infoIter->pduType == PduType::FILE_DIRECTIVE and + } else if (infoIter->pduType == PduTypes::FILE_DIRECTIVE and infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) { // TODO: Support for check timer missing result = handleEofPdu(*infoIter); @@ -463,3 +463,6 @@ void cfdp::DestHandler::setEventReporter(EventReportingProxyIF& reporter) { } const cfdp::DestHandlerParams& cfdp::DestHandler::getDestHandlerParams() const { return dp; } + +StorageManagerIF* cfdp::DestHandler::getTmStore() const { return fp.tcStore; } +StorageManagerIF* cfdp::DestHandler::getTcStore() const { return fp.tmStore; } diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 975ccaaf..8a8dd28e 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -21,11 +21,11 @@ namespace cfdp { struct PacketInfo { - PacketInfo(PduType type, store_address_t storeId, + PacketInfo(PduTypes type, store_address_t storeId, std::optional directive = std::nullopt) : pduType(type), directiveType(directive), storeId(storeId) {} - PduType pduType = PduType::FILE_DATA; + PduTypes pduType = PduTypes::FILE_DATA; std::optional directiveType = FileDirectives::INVALID_DIRECTIVE; store_address_t storeId = store_address_t::invalid(); PacketInfo() = default; @@ -62,6 +62,14 @@ struct DestHandlerParams { }; struct FsfwParams { + + FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue, + EventReportingProxyIF* eventReporter, StorageManagerIF& tcStore, StorageManagerIF& tmStore) + : FsfwParams(packetDest, msgQueue, eventReporter) { + this->tcStore = &tcStore; + this->tmStore = &tmStore; + } + FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue, EventReportingProxyIF* eventReporter) : packetDest(packetDest), msgQueue(msgQueue), eventReporter(eventReporter) {} @@ -127,6 +135,8 @@ class DestHandler { [[nodiscard]] TransactionStep getTransactionStep() const; [[nodiscard]] const TransactionId& getTransactionId() const; [[nodiscard]] const DestHandlerParams& getDestHandlerParams() const; + [[nodiscard]] StorageManagerIF* getTcStore() const; + [[nodiscard]] StorageManagerIF* getTmStore() const; private: struct TransactionParams { diff --git a/src/fsfw/cfdp/pdu/FileDataCreator.cpp b/src/fsfw/cfdp/pdu/FileDataCreator.cpp index 956752fb..b9a45b5a 100644 --- a/src/fsfw/cfdp/pdu/FileDataCreator.cpp +++ b/src/fsfw/cfdp/pdu/FileDataCreator.cpp @@ -3,7 +3,7 @@ #include FileDataCreator::FileDataCreator(PduConfig& conf, FileDataInfo& info) - : HeaderCreator(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) { + : HeaderCreator(conf, cfdp::PduTypes::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) { update(); } diff --git a/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp index 474a1cc3..1e4da14d 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp @@ -2,7 +2,7 @@ FileDirectiveCreator::FileDirectiveCreator(PduConfig &pduConf, cfdp::FileDirectives directiveCode, size_t directiveParamFieldLen) - : HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1), + : HeaderCreator(pduConf, cfdp::PduTypes::FILE_DIRECTIVE, directiveParamFieldLen + 1), directiveCode(directiveCode) {} size_t FileDirectiveCreator::getSerializedSize() const { diff --git a/src/fsfw/cfdp/pdu/HeaderCreator.cpp b/src/fsfw/cfdp/pdu/HeaderCreator.cpp index e64f8481..3c50c396 100644 --- a/src/fsfw/cfdp/pdu/HeaderCreator.cpp +++ b/src/fsfw/cfdp/pdu/HeaderCreator.cpp @@ -1,6 +1,6 @@ #include "HeaderCreator.h" -HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen, +HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduTypes pduType, size_t initPduDataFieldLen, cfdp::SegmentMetadataFlag segmentMetadataFlag, cfdp::SegmentationControl segCtrl) : pduType(pduType), @@ -65,13 +65,13 @@ void HeaderCreator::setPduDataFieldLen(size_t pduDataFieldLen_) { pduDataFieldLen = pduDataFieldLen_; } -void HeaderCreator::setPduType(cfdp::PduType pduType_) { pduType = pduType_; } +void HeaderCreator::setPduType(cfdp::PduTypes pduType_) { pduType = pduType_; } void HeaderCreator::setSegmentMetadataFlag(cfdp::SegmentMetadataFlag segmentMetadataFlag_) { segmentMetadataFlag = segmentMetadataFlag_; } -cfdp::PduType HeaderCreator::getPduType() const { return pduType; } +cfdp::PduTypes HeaderCreator::getPduType() const { return pduType; } cfdp::Direction HeaderCreator::getDirection() const { return pduConf.direction; } diff --git a/src/fsfw/cfdp/pdu/HeaderCreator.h b/src/fsfw/cfdp/pdu/HeaderCreator.h index bbb4a518..a4b5c7ff 100644 --- a/src/fsfw/cfdp/pdu/HeaderCreator.h +++ b/src/fsfw/cfdp/pdu/HeaderCreator.h @@ -9,7 +9,7 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF { public: HeaderCreator( - PduConfig& pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen, + PduConfig& pduConf, cfdp::PduTypes pduType, size_t initPduDataFieldLen, cfdp::SegmentMetadataFlag segmentMetadataFlag = cfdp::SegmentMetadataFlag::NOT_PRESENT, cfdp::SegmentationControl segCtrl = cfdp::SegmentationControl::NO_RECORD_BOUNDARIES_PRESERVATION); @@ -29,13 +29,13 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF { Endianness streamEndianness) override; void setPduDataFieldLen(size_t pduDataFieldLen); - void setPduType(cfdp::PduType pduType); + void setPduType(cfdp::PduTypes pduType); void setSegmentMetadataFlag(cfdp::SegmentMetadataFlag); [[nodiscard]] size_t getPduDataFieldLen() const override; [[nodiscard]] size_t getWholePduSize() const override; - [[nodiscard]] cfdp::PduType getPduType() const override; + [[nodiscard]] cfdp::PduTypes getPduType() const override; [[nodiscard]] cfdp::Direction getDirection() const override; [[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override; [[nodiscard]] bool getCrcFlag() const override; @@ -52,7 +52,7 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF { void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const override; private: - cfdp::PduType pduType; + cfdp::PduTypes pduType; cfdp::SegmentMetadataFlag segmentMetadataFlag; cfdp::SegmentationControl segmentationCtrl; size_t pduDataFieldLen; diff --git a/src/fsfw/cfdp/pdu/HeaderReader.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp index 3417a57c..f8b19ce2 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.cpp +++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp @@ -57,8 +57,8 @@ size_t PduHeaderReader::getWholePduSize() const { return getPduDataFieldLen() + PduHeaderReader::getHeaderSize(); } -cfdp::PduType PduHeaderReader::getPduType() const { - return static_cast((pointers.fixedHeader->firstByte >> 4) & 0x01); +cfdp::PduTypes PduHeaderReader::getPduType() const { + return static_cast((pointers.fixedHeader->firstByte >> 4) & 0x01); } cfdp::Direction PduHeaderReader::getDirection() const { diff --git a/src/fsfw/cfdp/pdu/PduHeaderIF.h b/src/fsfw/cfdp/pdu/PduHeaderIF.h index a8d007b6..d9e4017d 100644 --- a/src/fsfw/cfdp/pdu/PduHeaderIF.h +++ b/src/fsfw/cfdp/pdu/PduHeaderIF.h @@ -17,7 +17,7 @@ class PduHeaderIF { [[nodiscard]] virtual size_t getWholePduSize() const = 0; [[nodiscard]] virtual size_t getPduDataFieldLen() const = 0; - [[nodiscard]] virtual cfdp::PduType getPduType() const = 0; + [[nodiscard]] virtual cfdp::PduTypes getPduType() const = 0; [[nodiscard]] virtual cfdp::Direction getDirection() const = 0; [[nodiscard]] virtual cfdp::TransmissionModes getTransmissionMode() const = 0; [[nodiscard]] virtual bool getCrcFlag() const = 0; diff --git a/src/fsfw/cfdp/pdu/PduHeaderReader.h b/src/fsfw/cfdp/pdu/PduHeaderReader.h index 7809f59c..a36b2145 100644 --- a/src/fsfw/cfdp/pdu/PduHeaderReader.h +++ b/src/fsfw/cfdp/pdu/PduHeaderReader.h @@ -56,7 +56,7 @@ class PduHeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { [[nodiscard]] size_t getPduDataFieldLen() const override; [[nodiscard]] size_t getWholePduSize() const override; - [[nodiscard]] cfdp::PduType getPduType() const override; + [[nodiscard]] cfdp::PduTypes getPduType() const override; [[nodiscard]] cfdp::Direction getDirection() const override; [[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override; [[nodiscard]] bool getCrcFlag() const override; diff --git a/unittests/cfdp/pdu/testCfdpHeader.cpp b/unittests/cfdp/pdu/testCfdpHeader.cpp index 6d22154b..b51450ec 100644 --- a/unittests/cfdp/pdu/testCfdpHeader.cpp +++ b/unittests/cfdp/pdu/testCfdpHeader.cpp @@ -21,7 +21,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { uint8_t* serTarget = serBuf.data(); const uint8_t* deserTarget = serTarget; size_t serSize = 0; - auto creator = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); + auto creator = HeaderCreator(pduConf, cfdp::PduTypes::FILE_DIRECTIVE, 0); SECTION("Header State") { REQUIRE(seqNum.getSerializedSize() == 1); @@ -33,7 +33,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(creator.getLargeFileFlag() == false); REQUIRE(creator.getLenEntityIds() == 1); REQUIRE(creator.getLenSeqNum() == 1); - REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DIRECTIVE); + REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE); REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); REQUIRE(creator.getSegmentationControl() == false); REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); @@ -87,7 +87,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { pduConf.direction = cfdp::Direction::TOWARDS_SENDER; pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; creator.setSegmentationControl(cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); - creator.setPduType(cfdp::PduType::FILE_DATA); + creator.setPduType(cfdp::PduTypes::FILE_DATA); creator.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); serTarget = serBuf.data(); serSize = 0; @@ -103,7 +103,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(creator.getLargeFileFlag() == true); REQUIRE(creator.getLenEntityIds() == 1); REQUIRE(creator.getLenSeqNum() == 1); - REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DATA); + REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DATA); REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); REQUIRE(creator.getSegmentationControl() == true); @@ -122,7 +122,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(creator.getLargeFileFlag() == true); REQUIRE(creator.getLenEntityIds() == 4); REQUIRE(creator.getLenSeqNum() == 2); - REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DATA); + REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DATA); REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); REQUIRE(creator.getSegmentationControl() == true); @@ -235,7 +235,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(reader.getLargeFileFlag() == false); REQUIRE(reader.getLenEntityIds() == 1); REQUIRE(reader.getLenSeqNum() == 1); - REQUIRE(reader.getPduType() == cfdp::PduType::FILE_DIRECTIVE); + REQUIRE(reader.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE); REQUIRE(reader.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); REQUIRE(reader.getSegmentationControl() == false); REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); @@ -255,7 +255,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { pduConf.direction = cfdp::Direction::TOWARDS_SENDER; pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; creator.setSegmentationControl(cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); - creator.setPduType(cfdp::PduType::FILE_DATA); + creator.setPduType(cfdp::PduTypes::FILE_DATA); creator.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); REQUIRE(result == returnvalue::OK); @@ -278,7 +278,7 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(reader.getLargeFileFlag() == true); REQUIRE(reader.getLenEntityIds() == 4); REQUIRE(reader.getLenSeqNum() == 2); - REQUIRE(reader.getPduType() == cfdp::PduType::FILE_DATA); + REQUIRE(reader.getPduType() == cfdp::PduTypes::FILE_DATA); REQUIRE(reader.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); REQUIRE(reader.getSegmentationControl() == true); REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); diff --git a/unittests/cfdp/pdu/testFileDirective.cpp b/unittests/cfdp/pdu/testFileDirective.cpp index 3af8b966..cb1df08d 100644 --- a/unittests/cfdp/pdu/testFileDirective.cpp +++ b/unittests/cfdp/pdu/testFileDirective.cpp @@ -76,7 +76,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK); REQUIRE(fdDeser.getPduDataFieldLen() == 5); REQUIRE(fdDeser.getHeaderSize() == 8); - REQUIRE(fdDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE); + REQUIRE(fdDeser.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE); serBuf[7] = 0xff; // Invalid file directive diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 3bd474f7..2e493539 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -68,7 +68,7 @@ TEST_CASE("CFDP Base", "[cfdp]") { REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK); REQUIRE(fdDeser.getPduDataFieldLen() == 5); REQUIRE(fdDeser.getHeaderSize() == 8); - REQUIRE(fdDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE); + REQUIRE(fdDeser.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE); serBuf[7] = 0xff; // Invalid file directive From d52f3354552371db87b881d6100dcdabc14598ce Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 8 Sep 2022 11:47:40 +0200 Subject: [PATCH 340/532] 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 dd928efe..092c234c 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)) { From ec1e07b466980795430497323daa220738fe6932 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Sep 2022 11:53:06 +0200 Subject: [PATCH 341/532] some more returncodes --- src/fsfw/cfdp/definitions.h | 6 ++++-- src/fsfw/cfdp/handler/DestHandler.h | 4 ++-- src/fsfw/cfdp/pdu/FileDirectiveReader.cpp | 4 ++-- src/fsfw/cfdp/pdu/FileDirectiveReader.h | 3 +-- unittests/cfdp/pdu/testAckPdu.cpp | 2 +- unittests/cfdp/pdu/testFileDirective.cpp | 2 +- unittests/cfdp/testCfdp.cpp | 2 +- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index e5c11a0b..35c4c5f8 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -20,7 +20,7 @@ static constexpr uint8_t VERSION_BITS = CFDP_VERSION_2 << 5; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; static constexpr ReturnValue_t INVALID_TLV_TYPE = returnvalue::makeCode(CFDP_CLASS_ID, 1); -static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = returnvalue::makeCode(CFDP_CLASS_ID, 2); +static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELD = returnvalue::makeCode(CFDP_CLASS_ID, 2); static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = returnvalue::makeCode(CFDP_CLASS_ID, 3); static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = returnvalue::makeCode(CFDP_CLASS_ID, 4); @@ -30,13 +30,14 @@ static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = returnvalue::makeCode(CFDP_CLASS_ID, 5); static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = returnvalue::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES = - returnvalue::makeCode(CFDP_CLASS_ID, 6); + returnvalue::makeCode(CFDP_CLASS_ID, 7); static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = returnvalue::makeCode(CFDP_CLASS_ID, 8); //! Can not parse filestore response because user did not pass a valid instance //! or remaining size is invalid static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE = returnvalue::makeCode(CFDP_CLASS_ID, 9); +static constexpr ReturnValue_t INVALID_PDU_FORMAT = returnvalue::makeCode(CFDP_CLASS_ID, 10); //! Checksum types according to the SANA Checksum Types registry //! https://sanaregistry.org/r/checksum_identifiers/ @@ -71,6 +72,7 @@ enum WidthInBytes : uint8_t { enum FileDirectives : uint8_t { INVALID_DIRECTIVE = 0x0f, + // The _DIRECTIVE suffix is mandatory here because of some nameclash! EOF_DIRECTIVE = 0x04, FINISH = 0x05, ACK = 0x06, diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 8a8dd28e..000fc2c0 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -62,9 +62,9 @@ struct DestHandlerParams { }; struct FsfwParams { - FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue, - EventReportingProxyIF* eventReporter, StorageManagerIF& tcStore, StorageManagerIF& tmStore) + EventReportingProxyIF* eventReporter, StorageManagerIF& tcStore, + StorageManagerIF& tmStore) : FsfwParams(packetDest, msgQueue, eventReporter) { this->tcStore = &tcStore; this->tmStore = &tmStore; diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp index 5d43ebb0..748ac830 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp @@ -18,7 +18,7 @@ ReturnValue_t FileDirectiveReader::parseData() { } size_t currentIdx = PduHeaderReader::getHeaderSize(); if (not checkFileDirective(pointers.rawPtr[currentIdx])) { - return cfdp::INVALID_DIRECTIVE_FIELDS; + return cfdp::INVALID_DIRECTIVE_FIELD; } setFileDirective(static_cast(pointers.rawPtr[currentIdx])); return returnvalue::OK; @@ -32,7 +32,7 @@ size_t FileDirectiveReader::getHeaderSize() const { bool FileDirectiveReader::checkFileDirective(uint8_t rawByte) { if (rawByte < cfdp::FileDirectives::EOF_DIRECTIVE or (rawByte > cfdp::FileDirectives::PROMPT and rawByte != cfdp::FileDirectives::KEEP_ALIVE)) { - // Invalid directive field. TODO: Custom returnvalue + // Invalid directive field return false; } return true; diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.h b/src/fsfw/cfdp/pdu/FileDirectiveReader.h index 83a71c71..5bec486c 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveReader.h +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.h @@ -26,10 +26,9 @@ class FileDirectiveReader : public PduHeaderReader { void setEndianness(SerializeIF::Endianness endianness); [[nodiscard]] SerializeIF::Endianness getEndianness() const; - - protected: static bool checkFileDirective(uint8_t rawByte); + protected: private: void setFileDirective(cfdp::FileDirectives fileDirective); cfdp::FileDirectives fileDirective = cfdp::FileDirectives::INVALID_DIRECTIVE; diff --git a/unittests/cfdp/pdu/testAckPdu.cpp b/unittests/cfdp/pdu/testAckPdu.cpp index 1eb1b340..02832d9f 100644 --- a/unittests/cfdp/pdu/testAckPdu.cpp +++ b/unittests/cfdp/pdu/testAckPdu.cpp @@ -91,7 +91,7 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { buf[sz - 2] = prevVal; buf[sz - 3] = cfdp::FileDirectives::INVALID_DIRECTIVE; result = reader2.parseData(); - REQUIRE(result == cfdp::INVALID_DIRECTIVE_FIELDS); + REQUIRE(result == cfdp::INVALID_DIRECTIVE_FIELD); buf[sz - 3] = cfdp::FileDirectives::ACK; auto maxSizeTooSmall = AckPduDeserializer(buf.data(), sz - 2, ackInfo2); result = maxSizeTooSmall.parseData(); diff --git a/unittests/cfdp/pdu/testFileDirective.cpp b/unittests/cfdp/pdu/testFileDirective.cpp index cb1df08d..31e627a6 100644 --- a/unittests/cfdp/pdu/testFileDirective.cpp +++ b/unittests/cfdp/pdu/testFileDirective.cpp @@ -80,6 +80,6 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { serBuf[7] = 0xff; // Invalid file directive - REQUIRE(fdDeser.parseData() == cfdp::INVALID_DIRECTIVE_FIELDS); + REQUIRE(fdDeser.parseData() == cfdp::INVALID_DIRECTIVE_FIELD); } } \ No newline at end of file diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 2e493539..38504a5b 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -72,7 +72,7 @@ TEST_CASE("CFDP Base", "[cfdp]") { serBuf[7] = 0xff; // Invalid file directive - REQUIRE(fdDeser.parseData() == cfdp::INVALID_DIRECTIVE_FIELDS); + REQUIRE(fdDeser.parseData() == cfdp::INVALID_DIRECTIVE_FIELD); } SECTION("File Size") { From b73754dfd62ec61410160beca8562a558c6e89cc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Sep 2022 12:07:16 +0200 Subject: [PATCH 342/532] implemented basic PDU forwarding --- ...AckPduSerializer.cpp => AckPduCreator.cpp} | 12 ++++----- .../{AckPduSerializer.h => AckPduCreator.h} | 12 ++++----- ...ckPduDeserializer.cpp => AckPduReader.cpp} | 26 ++++++++++++------- .../{AckPduDeserializer.h => AckPduReader.h} | 9 ++++--- src/fsfw/cfdp/pdu/CMakeLists.txt | 4 +-- unittests/cfdp/pdu/testAckPdu.cpp | 18 ++++++------- 6 files changed, 45 insertions(+), 36 deletions(-) rename src/fsfw/cfdp/pdu/{AckPduSerializer.cpp => AckPduCreator.cpp} (72%) rename src/fsfw/cfdp/pdu/{AckPduSerializer.h => AckPduCreator.h} (62%) rename src/fsfw/cfdp/pdu/{AckPduDeserializer.cpp => AckPduReader.cpp} (52%) rename src/fsfw/cfdp/pdu/{AckPduDeserializer.h => AckPduReader.h} (59%) diff --git a/src/fsfw/cfdp/pdu/AckPduSerializer.cpp b/src/fsfw/cfdp/pdu/AckPduCreator.cpp similarity index 72% rename from src/fsfw/cfdp/pdu/AckPduSerializer.cpp rename to src/fsfw/cfdp/pdu/AckPduCreator.cpp index 67744171..88fcedc9 100644 --- a/src/fsfw/cfdp/pdu/AckPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/AckPduCreator.cpp @@ -1,14 +1,12 @@ -#include "AckPduSerializer.h" +#include "AckPduCreator.h" -AckPduSerializer::AckPduSerializer(AckInfo &ackInfo, PduConfig &pduConf) +AckPduCreator::AckPduCreator(AckInfo &ackInfo, PduConfig &pduConf) : FileDirectiveCreator(pduConf, cfdp::FileDirectives::ACK, 2), ackInfo(ackInfo) {} -size_t AckPduSerializer::getSerializedSize() const { - return FileDirectiveCreator::getWholePduSize(); -} +size_t AckPduCreator::getSerializedSize() const { return FileDirectiveCreator::getWholePduSize(); } -ReturnValue_t AckPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const { +ReturnValue_t AckPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; diff --git a/src/fsfw/cfdp/pdu/AckPduSerializer.h b/src/fsfw/cfdp/pdu/AckPduCreator.h similarity index 62% rename from src/fsfw/cfdp/pdu/AckPduSerializer.h rename to src/fsfw/cfdp/pdu/AckPduCreator.h index 92014e4e..c0a89cc3 100644 --- a/src/fsfw/cfdp/pdu/AckPduSerializer.h +++ b/src/fsfw/cfdp/pdu/AckPduCreator.h @@ -1,11 +1,11 @@ -#ifndef FSFW_SRC_FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_ -#define FSFW_SRC_FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_ +#ifndef FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_ +#define FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_ #include "AckInfo.h" #include "FileDirectiveCreator.h" #include "FileDirectiveReader.h" -class AckPduSerializer : public FileDirectiveCreator { +class AckPduCreator : public FileDirectiveCreator { public: /** * @brief Serializer to pack ACK PDUs @@ -16,9 +16,9 @@ class AckPduSerializer : public FileDirectiveCreator { * @param transactionStatus * @param pduConf */ - AckPduSerializer(AckInfo& ackInfo, PduConfig& pduConf); + AckPduCreator(AckInfo& ackInfo, PduConfig& pduConf); - size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; @@ -27,4 +27,4 @@ class AckPduSerializer : public FileDirectiveCreator { AckInfo& ackInfo; }; -#endif /* FSFW_SRC_FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_ */ +#endif /* FSFW_CFDP_PDU_ACKPDUSERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp b/src/fsfw/cfdp/pdu/AckPduReader.cpp similarity index 52% rename from src/fsfw/cfdp/pdu/AckPduDeserializer.cpp rename to src/fsfw/cfdp/pdu/AckPduReader.cpp index f09db97e..4f75a2b8 100644 --- a/src/fsfw/cfdp/pdu/AckPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/AckPduReader.cpp @@ -1,9 +1,9 @@ -#include "AckPduDeserializer.h" +#include "AckPduReader.h" -AckPduDeserializer::AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, AckInfo& info) +AckPduReader::AckPduReader(const uint8_t* pduBuf, size_t maxSize, AckInfo& info) : FileDirectiveReader(pduBuf, maxSize), info(info) {} -ReturnValue_t AckPduDeserializer::parseData() { +ReturnValue_t AckPduReader::parseData() { ReturnValue_t result = FileDirectiveReader::parseData(); if (result != returnvalue::OK) { return result; @@ -18,14 +18,12 @@ ReturnValue_t AckPduDeserializer::parseData() { return returnvalue::OK; } -bool AckPduDeserializer::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) { - uint8_t ackedDirective = static_cast(firstByte >> 4); - - if (ackedDirective != cfdp::FileDirectives::EOF_DIRECTIVE and - ackedDirective != cfdp::FileDirectives::FINISH) { +bool AckPduReader::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) { + cfdp::FileDirectives directive; + if (not checkAckedDirectiveField(firstByte, directive)) { return false; } - this->info.setAckedDirective(static_cast(ackedDirective)); + this->info.setAckedDirective(directive); uint8_t directiveSubtypeCode = firstByte & 0x0f; if (directiveSubtypeCode != 0b0000 and directiveSubtypeCode != 0b0001) { return false; @@ -35,3 +33,13 @@ bool AckPduDeserializer::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) this->info.setTransactionStatus(static_cast(secondByte & 0x0f)); return true; } +bool AckPduReader::checkAckedDirectiveField(uint8_t firstPduDataByte, + cfdp::FileDirectives& ackedDirective) { + uint8_t ackedDirectiveRaw = static_cast(firstPduDataByte >> 4); + if (ackedDirectiveRaw != cfdp::FileDirectives::EOF_DIRECTIVE and + ackedDirectiveRaw != cfdp::FileDirectives::FINISH) { + return false; + } + ackedDirective = (static_cast(ackedDirectiveRaw)); + return true; +} diff --git a/src/fsfw/cfdp/pdu/AckPduDeserializer.h b/src/fsfw/cfdp/pdu/AckPduReader.h similarity index 59% rename from src/fsfw/cfdp/pdu/AckPduDeserializer.h rename to src/fsfw/cfdp/pdu/AckPduReader.h index 4da50261..2b5dd411 100644 --- a/src/fsfw/cfdp/pdu/AckPduDeserializer.h +++ b/src/fsfw/cfdp/pdu/AckPduReader.h @@ -4,16 +4,19 @@ #include "AckInfo.h" #include "fsfw/cfdp/pdu/FileDirectiveReader.h" -class AckPduDeserializer : public FileDirectiveReader { +class AckPduReader : public FileDirectiveReader { public: - AckPduDeserializer(const uint8_t* pduBuf, size_t maxSize, AckInfo& info); + AckPduReader(const uint8_t* pduBuf, size_t maxSize, AckInfo& info); /** * * @return * - cfdp::INVALID_DIRECTIVE_FIELDS: Invalid fields */ - ReturnValue_t parseData(); + ReturnValue_t parseData() override; + + static bool checkAckedDirectiveField(uint8_t firstPduDataByte, + cfdp::FileDirectives& ackedDirective); private: bool checkAndSetCodes(uint8_t rawAckedByte, uint8_t rawAckedConditionCode); diff --git a/src/fsfw/cfdp/pdu/CMakeLists.txt b/src/fsfw/cfdp/pdu/CMakeLists.txt index a8f0b5a9..22ac76c7 100644 --- a/src/fsfw/cfdp/pdu/CMakeLists.txt +++ b/src/fsfw/cfdp/pdu/CMakeLists.txt @@ -6,8 +6,8 @@ target_sources( FileDirectiveReader.cpp FileDirectiveCreator.cpp AckInfo.cpp - AckPduSerializer.cpp - AckPduDeserializer.cpp + AckPduCreator.cpp + AckPduReader.cpp EofInfo.cpp EofPduCreator.cpp EofPduReader.cpp diff --git a/unittests/cfdp/pdu/testAckPdu.cpp b/unittests/cfdp/pdu/testAckPdu.cpp index 02832d9f..44b66bd5 100644 --- a/unittests/cfdp/pdu/testAckPdu.cpp +++ b/unittests/cfdp/pdu/testAckPdu.cpp @@ -1,8 +1,8 @@ #include #include -#include "fsfw/cfdp/pdu/AckPduDeserializer.h" -#include "fsfw/cfdp/pdu/AckPduSerializer.h" +#include "fsfw/cfdp/pdu/AckPduCreator.h" +#include "fsfw/cfdp/pdu/AckPduReader.h" #include "fsfw/globalfunctions/arrayprinter.h" TEST_CASE("ACK PDU", "[cfdp][pdu]") { @@ -18,7 +18,7 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { auto pduConf = PduConfig(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); AckInfo ackInfo(FileDirectives::EOF_DIRECTIVE, ConditionCode::NO_ERROR, AckTransactionStatus::ACTIVE); - auto ackSerializer = AckPduSerializer(ackInfo, pduConf); + auto ackSerializer = AckPduCreator(ackInfo, pduConf); result = ackSerializer.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); @@ -30,7 +30,7 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { ackInfo.setAckedDirective(FileDirectives::FINISH); ackInfo.setAckedConditionCode(ConditionCode::FILESTORE_REJECTION); ackInfo.setTransactionStatus(AckTransactionStatus::TERMINATED); - auto ackSerializer2 = AckPduSerializer(ackInfo, pduConf); + auto ackSerializer2 = AckPduCreator(ackInfo, pduConf); bufptr = buf.data(); sz = 0; result = ackSerializer2.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); @@ -44,7 +44,7 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { bufptr = buf.data(); sz = 0; ackInfo.setAckedDirective(FileDirectives::KEEP_ALIVE); - auto ackSerializer3 = AckPduSerializer(ackInfo, pduConf); + auto ackSerializer3 = AckPduCreator(ackInfo, pduConf); result = ackSerializer3.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); // Invalid file directive REQUIRE(result != returnvalue::OK); @@ -57,7 +57,7 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { SECTION("Deserialize") { AckInfo ackInfo2; - auto reader = AckPduDeserializer(buf.data(), sz, ackInfo2); + auto reader = AckPduReader(buf.data(), sz, ackInfo2); result = reader.parseData(); REQUIRE(result == returnvalue::OK); REQUIRE(ackInfo2.getAckedDirective() == FileDirectives::EOF_DIRECTIVE); @@ -67,13 +67,13 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { AckInfo newInfo = AckInfo(FileDirectives::FINISH, ConditionCode::FILESTORE_REJECTION, AckTransactionStatus::TERMINATED); - auto ackSerializer2 = AckPduSerializer(newInfo, pduConf); + auto ackSerializer2 = AckPduCreator(newInfo, pduConf); bufptr = buf.data(); sz = 0; result = ackSerializer2.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); - auto reader2 = AckPduDeserializer(buf.data(), sz, ackInfo2); + auto reader2 = AckPduReader(buf.data(), sz, ackInfo2); result = reader2.parseData(); REQUIRE(result == returnvalue::OK); REQUIRE(ackInfo2.getAckedDirective() == FileDirectives::FINISH); @@ -93,7 +93,7 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { result = reader2.parseData(); REQUIRE(result == cfdp::INVALID_DIRECTIVE_FIELD); buf[sz - 3] = cfdp::FileDirectives::ACK; - auto maxSizeTooSmall = AckPduDeserializer(buf.data(), sz - 2, ackInfo2); + auto maxSizeTooSmall = AckPduReader(buf.data(), sz - 2, ackInfo2); result = maxSizeTooSmall.parseData(); REQUIRE(result == SerializeIF::STREAM_TOO_SHORT); } From 34dd478848cc43bf9520d366207f20bdfe2c4962 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Sep 2022 16:25:19 +0200 Subject: [PATCH 343/532] helper class OneRemoteConfigProvider --- src/fsfw/cfdp/VarLenFields.cpp | 4 ++++ src/fsfw/cfdp/VarLenFields.h | 1 + src/fsfw/cfdp/handler/RemoteConfigTableIF.h | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/fsfw/cfdp/VarLenFields.cpp b/src/fsfw/cfdp/VarLenFields.cpp index 512c713c..b9e0b3a8 100644 --- a/src/fsfw/cfdp/VarLenFields.cpp +++ b/src/fsfw/cfdp/VarLenFields.cpp @@ -131,3 +131,7 @@ bool cfdp::VarLenField::operator<(const cfdp::VarLenField &other) const { bool cfdp::VarLenField::operator==(const cfdp::VarLenField &other) const { return getWidth() == other.getWidth() and getValue() == other.getValue(); } + +bool cfdp::VarLenField::operator!=(const cfdp::VarLenField &other) const { + return not(*this == other); +} diff --git a/src/fsfw/cfdp/VarLenFields.h b/src/fsfw/cfdp/VarLenFields.h index 03664995..37a9cf5c 100644 --- a/src/fsfw/cfdp/VarLenFields.h +++ b/src/fsfw/cfdp/VarLenFields.h @@ -27,6 +27,7 @@ class VarLenField : public SerializeIF { VarLenField(cfdp::WidthInBytes width, size_t value); bool operator==(const VarLenField &other) const; + bool operator!=(const VarLenField &other) const; bool operator<(const VarLenField &other) const; ReturnValue_t setValue(cfdp::WidthInBytes, size_t value); diff --git a/src/fsfw/cfdp/handler/RemoteConfigTableIF.h b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h index 1cd1ec1d..d0e6121d 100644 --- a/src/fsfw/cfdp/handler/RemoteConfigTableIF.h +++ b/src/fsfw/cfdp/handler/RemoteConfigTableIF.h @@ -11,6 +11,25 @@ class RemoteConfigTableIF { virtual bool getRemoteCfg(const cfdp::EntityId& remoteId, cfdp::RemoteEntityCfg** cfg) = 0; }; +/** + * Helper class for the common case that there is exactly one remote entity + */ +class OneRemoteConfigProvider : public RemoteConfigTableIF { + public: + explicit OneRemoteConfigProvider(RemoteEntityCfg cfg) : cfg(std::move(cfg)) {} + + bool getRemoteCfg(const EntityId& remoteId, cfdp::RemoteEntityCfg** cfg_) override { + if (remoteId != cfg.remoteId) { + return false; + } + *cfg_ = &cfg; + return true; + } + + private: + RemoteEntityCfg cfg; +}; + } // namespace cfdp #endif // FSFW_CFDP_HANDLER_REMOTECONFIGTABLEIF_H From 3e9b47d3a2ea4cf0407ecae8fbac1ef9feee7d1e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Sep 2022 15:12:26 +0200 Subject: [PATCH 344/532] update docs release in conf.py --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index a2cb73be..700b0ee9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ copyright = "2021, Institute of Space Systems (IRS)" author = "Institute of Space Systems (IRS)" # The full version, including alpha/beta/rc tags -release = "2.0.1" +release = "5.0.0" # -- General configuration --------------------------------------------------- From 26b3e5a013726d86dfa5c64ec784499c763f143e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Sep 2022 15:14:42 +0200 Subject: [PATCH 345/532] fix misc def config --- misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp index 4d6e91f1..85a733b4 100644 --- a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp +++ b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -41,13 +40,9 @@ void Factory::setStaticFrameworkObjectIds() { CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; DeviceHandlerBase::rawDataReceiverId = objects::PUS_SERVICE_2_DEVICE_ACCESS; DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT; - - TmPacketBase::timeStamperId = objects::NO_OBJECT; } From 003a6d00fa5cca7450f9bab77244ee2b99106fe2 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 13:13:18 +0200 Subject: [PATCH 346/532] Documentation build tools in docker --- automation/Dockerfile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/automation/Dockerfile b/automation/Dockerfile index 318619f8..81e3e14a 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -5,16 +5,18 @@ RUN apt-get --yes upgrade #tzdata is a dependency, won't install otherwise ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping +RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping python3 pip doxygen graphviz + +RUN python3 -m pip install sphinx breathe RUN git clone https://github.com/catchorg/Catch2.git && \ - cd Catch2 && \ - git checkout v3.1.0 && \ - cmake -Bbuild -H. -DBUILD_TESTING=OFF && \ - cmake --build build/ --target install + cd Catch2 && \ + git checkout v3.1.0 && \ + cmake -Bbuild -H. -DBUILD_TESTING=OFF && \ + cmake --build build/ --target install RUN git clone https://github.com/ETLCPP/etl.git && \ - cd etl && \ - git checkout 20.28.0 && \ - cmake -B build . && \ - cmake --install build/ + cd etl && \ + git checkout 20.28.0 && \ + cmake -B build . && \ + cmake --install build/ \ No newline at end of file From 92e3ab04f3eaf0b560195407b94d772bd63c4956 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 13:54:23 +0200 Subject: [PATCH 347/532] testing Jenkinsfile --- automation/Jenkinsfile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 02340190..8cdf68aa 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,9 +1,10 @@ pipeline { environment { BUILDDIR = 'cmake-build-tests' + DOCDDIR = 'cmake-build-documentation' } agent { - docker { image 'fsfw-ci:d3'} + docker { image 'fsfw-ci:d4'} } stages { stage('Clean') { @@ -39,5 +40,17 @@ pipeline { } } } + stage('Documentation') { + steps { + dir(DOCDDIR) { + sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' + sh 'make Sphinx' + sh 'cd docs/sphinx' + sshagent(credentials: ['documentation-buildfix']) { + sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' + } + } + } + } } } From d79b5348d85ab4415f985fa1ef0275b5097d753e Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:00:36 +0200 Subject: [PATCH 348/532] testing Jenkinsfile --- automation/Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 8cdf68aa..dcd98d5b 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -47,6 +47,7 @@ pipeline { sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { + sh 'ssh -vvv buildfix@documents.intra.irs.uni-stuttgart.de uname -a' sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } From 8bbde054136bb61c63f1f0715994efa552f2620b Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:08:04 +0200 Subject: [PATCH 349/532] add jenkins user in docker so that ssh will work --- automation/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/automation/Dockerfile b/automation/Dockerfile index 81e3e14a..ce7088fb 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -19,4 +19,7 @@ RUN git clone https://github.com/ETLCPP/etl.git && \ cd etl && \ git checkout 20.28.0 && \ cmake -B build . && \ - cmake --install build/ \ No newline at end of file + cmake --install build/ + +#ssh needs a valid user to work +RUN adduser -m -u 114 jenkins From ecf51b29139953c25e2347b41dcd648b0ceddb43 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:09:08 +0200 Subject: [PATCH 350/532] testing Jenkinsfile --- automation/Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index dcd98d5b..6bc5b0a6 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { DOCDDIR = 'cmake-build-documentation' } agent { - docker { image 'fsfw-ci:d4'} + docker { image 'fsfw-ci:d5'} } stages { stage('Clean') { @@ -42,6 +42,7 @@ pipeline { } stage('Documentation') { steps { + echo env.BRANCH_NAME dir(DOCDDIR) { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' From 9c7248e78e38659005b082b9946211c5a868684d Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:20:30 +0200 Subject: [PATCH 351/532] typo in Dockerfile --- automation/Dockerfile | 2 +- automation/Jenkinsfile | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/automation/Dockerfile b/automation/Dockerfile index ce7088fb..5bd7d382 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -22,4 +22,4 @@ RUN git clone https://github.com/ETLCPP/etl.git && \ cmake --install build/ #ssh needs a valid user to work -RUN adduser -m -u 114 jenkins +RUN adduser --uid 114 jenkins diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 6bc5b0a6..54b21b36 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -41,18 +41,34 @@ pipeline { } } stage('Documentation') { + when { + branch 'development' + } steps { - echo env.BRANCH_NAME dir(DOCDDIR) { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'ssh -vvv buildfix@documents.intra.irs.uni-stuttgart.de uname -a' sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } } } + stage('Master Documentation') { + when { + branch 'master' + } + steps { + dir(DOCDDIR) { + sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' + sh 'make Sphinx' + sh 'cd docs/sphinx' + sshagent(credentials: ['documentation-buildfix']) { + sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' + } + } + } + } } } From 9bd600c4882415f2c0d2a083d60403fdebeb88f8 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:32:10 +0200 Subject: [PATCH 352/532] testing Jenkinsfile --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 54b21b36..3dfc083a 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -42,7 +42,7 @@ pipeline { } stage('Documentation') { when { - branch 'development' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From 8e835be55fe088e6fba19cc98a12d109f8071a57 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:46:12 +0200 Subject: [PATCH 353/532] testing Jenkinsfile --- automation/Jenkinsfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 3dfc083a..84133c43 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -4,7 +4,10 @@ pipeline { DOCDDIR = 'cmake-build-documentation' } agent { - docker { image 'fsfw-ci:d5'} + docker { + image 'fsfw-ci:d5' + args '--network host' + } } stages { stage('Clean') { @@ -41,6 +44,7 @@ pipeline { } } stage('Documentation') { + agent any when { branch 'mohr/documentation_ci' } @@ -50,7 +54,7 @@ pipeline { sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' + sh 'scp -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } } From a1ea671e2fb91b1e2e6b0d904e9b81701db29e28 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Sep 2022 14:46:41 +0200 Subject: [PATCH 354/532] header include update --- src/fsfw/tcdistribution/TcDistributorBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/tcdistribution/TcDistributorBase.cpp b/src/fsfw/tcdistribution/TcDistributorBase.cpp index f87993f8..a561b465 100644 --- a/src/fsfw/tcdistribution/TcDistributorBase.cpp +++ b/src/fsfw/tcdistribution/TcDistributorBase.cpp @@ -1,4 +1,4 @@ -#include "fsfw/tcdistribution/TcDistributorBase.h" +#include "TcDistributorBase.h" #include "definitions.h" #include "fsfw/ipc/QueueFactory.h" From fa5605c959fef28b285d26ed074439774fb5373d Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 14:50:37 +0200 Subject: [PATCH 355/532] testing Jenkinsfile --- automation/Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 84133c43..8deeb994 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -44,7 +44,6 @@ pipeline { } } stage('Documentation') { - agent any when { branch 'mohr/documentation_ci' } @@ -69,7 +68,7 @@ pipeline { sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -r ./* buildfix@documents.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' + sh 'scp -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' } } } From 382543fc5989c6608e0aa7550ace6aa70f7d78e3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Sep 2022 15:26:14 +0200 Subject: [PATCH 356/532] important bugfix --- src/fsfw/cfdp/handler/DestHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index a89a5eeb..c4566814 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -464,5 +464,5 @@ void cfdp::DestHandler::setEventReporter(EventReportingProxyIF& reporter) { const cfdp::DestHandlerParams& cfdp::DestHandler::getDestHandlerParams() const { return dp; } -StorageManagerIF* cfdp::DestHandler::getTmStore() const { return fp.tcStore; } -StorageManagerIF* cfdp::DestHandler::getTcStore() const { return fp.tmStore; } +StorageManagerIF* cfdp::DestHandler::getTmStore() const { return fp.tmStore; } +StorageManagerIF* cfdp::DestHandler::getTcStore() const { return fp.tcStore; } From 6451a16888fb2a465dd4fcaff7fe49fc7ab352b7 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 17:51:01 +0200 Subject: [PATCH 357/532] fixing scp command --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 8deeb994..d3bb31be 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -68,7 +68,7 @@ pipeline { sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' + sh 'scp -o StrictHostKeyChecking=no -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' } } } From 24ecf125a3979f77baa502fbbabacaf94d262c99 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 17:55:12 +0200 Subject: [PATCH 358/532] fixing scp command again --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index d3bb31be..5fe38b03 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -53,7 +53,7 @@ pipeline { sh 'make Sphinx' sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' + sh 'scp -o StrictHostKeyChecking=no -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } } From f34cf9095dbe72a865881af1267b2e4523917295 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 18:02:38 +0200 Subject: [PATCH 359/532] fixing scp yet again --- automation/Jenkinsfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 5fe38b03..3095a27c 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -51,9 +51,8 @@ pipeline { dir(DOCDDIR) { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' - sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -o StrictHostKeyChecking=no -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' + sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } } @@ -66,9 +65,8 @@ pipeline { dir(DOCDDIR) { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' - sh 'cd docs/sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'scp -o StrictHostKeyChecking=no -r ./* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' + sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' } } } From 3257935150a26dcca09282c04fbc432738cd6831 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 18:06:16 +0200 Subject: [PATCH 360/532] fixing scp yet again again --- automation/Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 3095a27c..ac0f54be 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -52,6 +52,7 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { + sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/development/*' sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } @@ -66,6 +67,7 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { + sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/master/*' sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' } } From 21a9d89fb36a9838961b9d9b3e6137b67af665a2 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 18:14:26 +0200 Subject: [PATCH 361/532] pushing code coverage report to documentation server --- automation/Jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index ac0f54be..cc61a320 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -56,6 +56,12 @@ pipeline { sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' } } + dir(BUILDDIR) { + sshagent(credentials: ['documentation-buildfix']) { + sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/coverage/development/*' + sh 'scp -o StrictHostKeyChecking=no -r fsfw-tests_coverage/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/coverage/development' + } + } } } stage('Master Documentation') { @@ -71,6 +77,12 @@ pipeline { sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' } } + dir(BUILDDIR) { + sshagent(credentials: ['documentation-buildfix']) { + sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/coverage/master/*' + sh 'scp -o StrictHostKeyChecking=no -r fsfw-tests_coverage/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/coverage/master' + } + } } } } From af282c7d3ee9e9e2d5f6b0d03e411a267b6115c9 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 18:17:56 +0200 Subject: [PATCH 362/532] reverting to only publish development --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index cc61a320..8b123fa9 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'mohr/documentation_ci' + branch 'development' } steps { dir(DOCDDIR) { From 6970068d568bd693282ddd7fef066bd8a9dc6ecc Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 13 Sep 2022 18:19:35 +0200 Subject: [PATCH 363/532] small fix in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b2ca52d..7094e5dc 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host .. Then you can generate the documentation using ```sh -cmake --build . -j +cmake --build . -- Sphinx -j ``` You can find the generated documentation inside the `docs/sphinx` folder inside the build From 44615c150b7690a3beccf459e3203561f17edf0a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Sep 2022 14:00:20 +0200 Subject: [PATCH 364/532] add printout capabilities --- src/fsfw/cfdp/VarLenFields.h | 15 ++++++++ src/fsfw/cfdp/handler/DestHandler.cpp | 38 ++++++++++++------- src/fsfw/cfdp/handler/mib.h | 1 + .../ServiceInterfaceBuffer.cpp | 1 - src/fsfw_hal/common/CMakeLists.txt | 2 +- src/fsfw_hal/common/printChar.c | 2 +- 6 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/fsfw/cfdp/VarLenFields.h b/src/fsfw/cfdp/VarLenFields.h index 37a9cf5c..37602c75 100644 --- a/src/fsfw/cfdp/VarLenFields.h +++ b/src/fsfw/cfdp/VarLenFields.h @@ -7,6 +7,7 @@ #include "fsfw/cfdp/definitions.h" #include "fsfw/serialize/SerializeIF.h" +#include "fsfw/serviceinterface.h" #include "fsfw/util/UnsignedByteField.h" namespace cfdp { @@ -43,6 +44,14 @@ class VarLenField : public SerializeIF { [[nodiscard]] cfdp::WidthInBytes getWidth() const; [[nodiscard]] size_t getValue() const; +#if FSFW_CPP_OSTREAM_ENABLED == 1 + friend std::ostream &operator<<(std::ostream &os, const VarLenField &id) { + os << "dec: " << id.getValue() << ", hex: " << std::hex << std::setw(id.getWidth()) + << std::setfill('0') << id.getValue() << std::dec << std::setfill('0'); + return os; + } +#endif + private: ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; @@ -83,6 +92,12 @@ struct TransactionId { return entityId == other.entityId and seqNum == other.seqNum; } +#if FSFW_CPP_OSTREAM_ENABLED == 1 + friend std::ostream &operator<<(std::ostream &os, const TransactionId &id) { + os << "Source ID { " << id.entityId << " }, Sequence Number " << id.seqNum.getValue(); + return os; + } +#endif EntityId entityId; TransactionSeqNum seqNum; }; diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index c4566814..d43d1482 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -252,7 +252,8 @@ ReturnValue_t cfdp::DestHandler::handleMetadataParseError(ReturnValue_t result, headerReader.getDestId(destId); RemoteEntityCfg* remoteCfg; if (not dp.remoteCfgTable.getRemoteCfg(destId, &remoteCfg)) { -// TODO: No remote config for dest ID. I consider this a configuration error. +// TODO: No remote config for dest ID. I consider this a configuration error, which is not +// covered by the standard. // Warning or error, yield or cache appropriate returnvalue #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "No remote config exists for destination ID" << std::endl; @@ -267,8 +268,9 @@ ReturnValue_t cfdp::DestHandler::handleMetadataParseError(ReturnValue_t result, ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, MetadataInfo& info) { if (fsmRes.state != CfdpStates::IDLE) { // According to standard, discard metadata PDU if we are busy - return returnvalue::OK; + return OK; } + ReturnValue_t result = OK; fsmRes.step = TransactionStep::TRANSACTION_START; if (reader.getTransmissionMode() == TransmissionModes::UNACKNOWLEDGED) { fsmRes.state = CfdpStates::BUSY_CLASS_1_NACKED; @@ -302,10 +304,26 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "cfdp::DestHandler" << __func__ << ": No remote configuration found for destination ID " - << tp.pduConf.destId.getValue() << std::endl; + << tp.pduConf.sourceId.getValue() << std::endl; #endif return FAILED; } + // If both dest name size and source name size are 0, we are dealing with a metadata only PDU, + // so there is no need to create a file or truncate an existing file + if (destNameSize > 0 and sourceNameSize > 0) { + FilesystemParams fparams(tp.destName.data()); + // TODO: Filesystem errors? + if (dp.user.vfs.fileExists(fparams)) { + dp.user.vfs.truncateFile(fparams); + } else { + result = dp.user.vfs.createFile(fparams); + if (result != OK) { + // TODO: Handle FS error. This is probably a case for the filestore rejection mechanism of + // CFDP. + // In any case, it does not really make sense to continue here + } + } + } fsmRes.step = TransactionStep::RECEIVING_FILE_DATA_PDUS; MetadataRecvdParams params(tp.transactionId, tp.pduConf.sourceId); params.fileSize = tp.fileSize.getSize(); @@ -313,15 +331,8 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, Met params.sourceFileName = tp.sourceName.data(); params.msgsToUserArray = dynamic_cast(userTlvVec.data()); params.msgsToUserLen = info.getOptionsLen(); - FilesystemParams fparams(tp.destName.data()); - // TODO: Filesystem errors? - if (dp.user.vfs.fileExists(fparams)) { - dp.user.vfs.truncateFile(fparams); - } else { - dp.user.vfs.createFile(fparams); - } dp.user.metadataRecvdIndication(params); - return OK; + return result; } cfdp::CfdpStates cfdp::DestHandler::getCfdpState() const { return fsmRes.state; } @@ -376,7 +387,8 @@ ReturnValue_t cfdp::DestHandler::checksumVerification() { params.size = readLen; auto result = dp.user.vfs.readFromFile(params, buf.data(), buf.size()); if (result != OK) { - // TODO: Better error handling + // TODO: I think this is a case for a filestore rejection, but it might sense to print + // a warning or trigger an event because this should generally not happen return FAILED; } crcCalc.add(buf.begin(), buf.begin() + readLen); @@ -391,7 +403,7 @@ ReturnValue_t cfdp::DestHandler::checksumVerification() { } else { // TODO: Proper error handling #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CRC check for file " << tp.sourceName.data() << " failed" << std::endl; + sif::warning << "CRC check for file " << tp.destName.data() << " failed" << std::endl; #endif tp.conditionCode = ConditionCode::FILE_CHECKSUM_FAILURE; } diff --git a/src/fsfw/cfdp/handler/mib.h b/src/fsfw/cfdp/handler/mib.h index 3b4c95e4..76284f2d 100644 --- a/src/fsfw/cfdp/handler/mib.h +++ b/src/fsfw/cfdp/handler/mib.h @@ -27,6 +27,7 @@ struct LocalEntityCfg { }; struct RemoteEntityCfg { + explicit RemoteEntityCfg(EntityId id) : remoteId(std::move(id)) {} EntityId remoteId; size_t maxFileSegmentLen = 2048; bool closureRequested = false; diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp index 23892dcc..0e73be83 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp @@ -3,7 +3,6 @@ #if FSFW_CPP_OSTREAM_ENABLED == 1 #include - #include #include "fsfw/serviceinterface/serviceInterfaceDefintions.h" diff --git a/src/fsfw_hal/common/CMakeLists.txt b/src/fsfw_hal/common/CMakeLists.txt index 1cd9c678..2f4608f8 100644 --- a/src/fsfw_hal/common/CMakeLists.txt +++ b/src/fsfw_hal/common/CMakeLists.txt @@ -1,3 +1,3 @@ add_subdirectory(gpio) -target_sources(${LIB_FSFW_NAME} PRIVATE printChar.c) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE printChar.c) diff --git a/src/fsfw_hal/common/printChar.c b/src/fsfw_hal/common/printChar.c index 6e02c1df..24fba5c8 100644 --- a/src/fsfw_hal/common/printChar.c +++ b/src/fsfw_hal/common/printChar.c @@ -1,5 +1,5 @@ -#include #include +#include void __attribute__((weak)) printChar(const char* character, bool errStream) { if (errStream) { From ac7dc55fc1061e8cba20a93e415037b7db135946 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Sep 2022 19:07:17 +0200 Subject: [PATCH 365/532] fix unittest --- unittests/cfdp/handler/testDestHandler.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp index 20ddf678..30bb9fc5 100644 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ b/unittests/cfdp/handler/testDestHandler.cpp @@ -39,8 +39,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") { StorageManagerMock tcStore(2, storeCfg); StorageManagerMock tmStore(3, storeCfg); FsfwParams fp(tmReceiver, &mqMock, &eventReporterMock); - RemoteEntityCfg cfg; - cfg.remoteId = remoteId; + RemoteEntityCfg cfg(remoteId); remoteCfgTableMock.addRemoteConfig(cfg); fp.tcStore = &tcStore; fp.tmStore = &tmStore; From 3a524549491f875d7356c6b996ecb4c5bbc28606 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Sep 2022 19:15:52 +0200 Subject: [PATCH 366/532] removed handlers --- src/fsfw/cfdp.h | 1 - src/fsfw/cfdp/handler/CMakeLists.txt | 3 +- src/fsfw/cfdp/handler/DestHandler.cpp | 480 ------------------- src/fsfw/cfdp/handler/DestHandler.h | 202 -------- src/fsfw/cfdp/handler/SourceHandler.cpp | 1 - src/fsfw/cfdp/handler/SourceHandler.h | 6 - unittests/cfdp/handler/CMakeLists.txt | 5 +- unittests/cfdp/handler/testDestHandler.cpp | 244 ---------- unittests/cfdp/handler/testSourceHandler.cpp | 3 - unittests/cfdp/testLvs.cpp | 1 + unittests/cfdp/testTlv.cpp | 1 + 11 files changed, 5 insertions(+), 942 deletions(-) delete mode 100644 src/fsfw/cfdp/handler/DestHandler.cpp delete mode 100644 src/fsfw/cfdp/handler/DestHandler.h delete mode 100644 src/fsfw/cfdp/handler/SourceHandler.cpp delete mode 100644 src/fsfw/cfdp/handler/SourceHandler.h delete mode 100644 unittests/cfdp/handler/testDestHandler.cpp delete mode 100644 unittests/cfdp/handler/testSourceHandler.cpp diff --git a/src/fsfw/cfdp.h b/src/fsfw/cfdp.h index 28ddfec2..86086432 100644 --- a/src/fsfw/cfdp.h +++ b/src/fsfw/cfdp.h @@ -2,7 +2,6 @@ #define FSFW_CFDP_H #include "cfdp/definitions.h" -#include "cfdp/handler/DestHandler.h" #include "cfdp/handler/FaultHandlerBase.h" #include "cfdp/tlv/Lv.h" #include "cfdp/tlv/StringLv.h" diff --git a/src/fsfw/cfdp/handler/CMakeLists.txt b/src/fsfw/cfdp/handler/CMakeLists.txt index 7ad995c0..90130806 100644 --- a/src/fsfw/cfdp/handler/CMakeLists.txt +++ b/src/fsfw/cfdp/handler/CMakeLists.txt @@ -1,2 +1 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE SourceHandler.cpp DestHandler.cpp - FaultHandlerBase.cpp UserBase.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE FaultHandlerBase.cpp UserBase.cpp) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp deleted file mode 100644 index d43d1482..00000000 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ /dev/null @@ -1,480 +0,0 @@ -#include "DestHandler.h" - -#include - -#include - -#include "fsfw/FSFW.h" -#include "fsfw/cfdp/pdu/EofPduReader.h" -#include "fsfw/cfdp/pdu/FileDataReader.h" -#include "fsfw/cfdp/pdu/FinishedPduCreator.h" -#include "fsfw/cfdp/pdu/PduHeaderReader.h" -#include "fsfw/objectmanager.h" -#include "fsfw/tmtcservices/TmTcMessage.h" - -using namespace returnvalue; - -cfdp::DestHandler::DestHandler(DestHandlerParams params, FsfwParams fsfwParams) - : tlvVec(params.maxTlvsInOnePdu), - userTlvVec(params.maxTlvsInOnePdu), - dp(std::move(params)), - fp(fsfwParams), - tp(params.maxFilenameLen) { - tp.pduConf.direction = cfdp::Direction::TOWARDS_SENDER; -} - -const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() { - ReturnValue_t result; - uint8_t errorIdx = 0; - fsmRes.resetOfIteration(); - if (fsmRes.step == TransactionStep::IDLE) { - for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { - if (infoIter->pduType == PduTypes::FILE_DIRECTIVE and - infoIter->directiveType == FileDirectives::METADATA) { - result = handleMetadataPdu(*infoIter); - checkAndHandleError(result, errorIdx); - // Store data was deleted in PDU handler because a store guard is used - dp.packetListRef.erase(infoIter++); - } else { - infoIter++; - } - } - if (fsmRes.step == TransactionStep::IDLE) { - // To decrease the already high complexity of the software, all packets arriving before - // a metadata PDU are deleted. - for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { - fp.tcStore->deleteData(infoIter->storeId); - infoIter++; - } - dp.packetListRef.clear(); - } - - if (fsmRes.step != TransactionStep::IDLE) { - fsmRes.callStatus = CallStatus::CALL_AGAIN; - } - return updateFsmRes(errorIdx); - } - if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) { - if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { - for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) { - if (infoIter->pduType == PduTypes::FILE_DATA) { - result = handleFileDataPdu(*infoIter); - checkAndHandleError(result, errorIdx); - // Store data was deleted in PDU handler because a store guard is used - dp.packetListRef.erase(infoIter++); - } else if (infoIter->pduType == PduTypes::FILE_DIRECTIVE and - infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) { - // TODO: Support for check timer missing - result = handleEofPdu(*infoIter); - checkAndHandleError(result, errorIdx); - // Store data was deleted in PDU handler because a store guard is used - dp.packetListRef.erase(infoIter++); - } else { - infoIter++; - } - } - } - if (fsmRes.step == TransactionStep::TRANSFER_COMPLETION) { - result = handleTransferCompletion(); - checkAndHandleError(result, errorIdx); - } - if (fsmRes.step == TransactionStep::SENDING_FINISHED_PDU) { - result = sendFinishedPdu(); - checkAndHandleError(result, errorIdx); - finish(); - } - return updateFsmRes(errorIdx); - } - if (fsmRes.state == CfdpStates::BUSY_CLASS_2_ACKED) { - // TODO: Will be implemented at a later stage -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CFDP state machine for acknowledged mode not implemented yet" << std::endl; -#endif - } - return updateFsmRes(errorIdx); -} - -ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) { - if (dp.packetListRef.full()) { - return FAILED; - } - dp.packetListRef.push_back(packet); - return OK; -} - -ReturnValue_t cfdp::DestHandler::initialize() { - if (fp.tmStore == nullptr) { - fp.tmStore = ObjectManager::instance()->get(objects::TM_STORE); - if (fp.tmStore == nullptr) { - return FAILED; - } - } - - if (fp.tcStore == nullptr) { - fp.tcStore = ObjectManager::instance()->get(objects::TC_STORE); - if (fp.tcStore == nullptr) { - return FAILED; - } - } - - if (fp.msgQueue == nullptr) { - return FAILED; - } - return OK; -} - -ReturnValue_t cfdp::DestHandler::handleMetadataPdu(const PacketInfo& info) { - // Process metadata PDU - auto constAccessorPair = fp.tcStore->getData(info.storeId); - if (constAccessorPair.first != OK) { - // TODO: This is not a CFDP error. Event and/or warning? - return constAccessorPair.first; - } - cfdp::StringLv sourceFileName; - cfdp::StringLv destFileName; - MetadataInfo metadataInfo(tp.fileSize, sourceFileName, destFileName); - cfdp::Tlv* tlvArrayAsPtr = tlvVec.data(); - metadataInfo.setOptionsArray(&tlvArrayAsPtr, std::nullopt, tlvVec.size()); - MetadataPduReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), - metadataInfo); - ReturnValue_t result = reader.parseData(); - // TODO: The standard does not really specify what happens if this kind of error happens - // I think it might be a good idea to cache some sort of error code, which - // is translated into a warning and/or event by an upper layer - if (result != OK) { - return handleMetadataParseError(result, constAccessorPair.second.data(), - constAccessorPair.second.size()); - } - return startTransaction(reader, metadataInfo); -} - -ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info) { - // Process file data PDU - auto constAccessorPair = fp.tcStore->getData(info.storeId); - if (constAccessorPair.first != OK) { - // TODO: This is not a CFDP error. Event and/or warning? - return constAccessorPair.first; - } - cfdp::FileSize offset; - FileDataInfo fdInfo(offset); - FileDataReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), fdInfo); - ReturnValue_t result = reader.parseData(); - if (result != OK) { - return result; - } - size_t fileSegmentLen = 0; - const uint8_t* fileData = fdInfo.getFileData(&fileSegmentLen); - FileOpParams fileOpParams(tp.destName.data(), fileSegmentLen); - fileOpParams.offset = offset.value(); - if (dp.cfg.indicCfg.fileSegmentRecvIndicRequired) { - FileSegmentRecvdParams segParams; - segParams.offset = offset.value(); - segParams.id = tp.transactionId; - segParams.length = fileSegmentLen; - segParams.recContState = fdInfo.getRecordContinuationState(); - size_t segmentMetadatLen = 0; - auto* segMetadata = fdInfo.getSegmentMetadata(&segmentMetadatLen); - segParams.segmentMetadata = {segMetadata, segmentMetadatLen}; - dp.user.fileSegmentRecvdIndication(segParams); - } - result = dp.user.vfs.writeToFile(fileOpParams, fileData); - if (offset.value() + fileSegmentLen > tp.progress) { - tp.progress = offset.value() + fileSegmentLen; - } - if (result != returnvalue::OK) { - // TODO: Proper Error handling -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "File write error" << std::endl; -#endif - } else { - tp.deliveryStatus = FileDeliveryStatus::RETAINED_IN_FILESTORE; - } - return result; -} - -ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) { - // Process EOF PDU - auto constAccessorPair = fp.tcStore->getData(info.storeId); - if (constAccessorPair.first != OK) { - // TODO: This is not a CFDP error. Event and/or warning? - return constAccessorPair.first; - } - EofInfo eofInfo(nullptr); - EofPduReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), eofInfo); - ReturnValue_t result = reader.parseData(); - if (result != OK) { - return result; - } - // TODO: Error handling - if (eofInfo.getConditionCode() == ConditionCode::NO_ERROR) { - tp.crc = eofInfo.getChecksum(); - uint64_t fileSizeFromEof = eofInfo.getFileSize().value(); - // CFDP 4.6.1.2.9: Declare file size error if progress exceeds file size - if (fileSizeFromEof > tp.progress) { - // TODO: File size error - } - tp.fileSize.setFileSize(fileSizeFromEof, std::nullopt); - } - if (dp.cfg.indicCfg.eofRecvIndicRequired) { - dp.user.eofRecvIndication(getTransactionId()); - } - if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) { - if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) { - fsmRes.step = TransactionStep::TRANSFER_COMPLETION; - } else if (fsmRes.state == CfdpStates::BUSY_CLASS_2_ACKED) { - fsmRes.step = TransactionStep::SENDING_ACK_PDU; - } - } - return returnvalue::OK; -} - -ReturnValue_t cfdp::DestHandler::handleMetadataParseError(ReturnValue_t result, - const uint8_t* rawData, size_t maxSize) { - // TODO: try to extract destination ID for error - // TODO: Invalid metadata PDU. -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Parsing Metadata PDU failed with code " << result << std::endl; -#else -#endif - PduHeaderReader headerReader(rawData, maxSize); - result = headerReader.parseData(); - if (result != OK) { - // TODO: Now this really should not happen. Warning or error, - // yield or cache appropriate returnvalue -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Parsing Header failed" << std::endl; -#else -#endif - // TODO: Trigger appropriate event - return result; - } - cfdp::EntityId destId; - headerReader.getDestId(destId); - RemoteEntityCfg* remoteCfg; - if (not dp.remoteCfgTable.getRemoteCfg(destId, &remoteCfg)) { -// TODO: No remote config for dest ID. I consider this a configuration error, which is not -// covered by the standard. -// Warning or error, yield or cache appropriate returnvalue -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "No remote config exists for destination ID" << std::endl; -#else -#endif - // TODO: Trigger appropriate event - } - // TODO: Appropriate returnvalue? - return returnvalue::FAILED; -} - -ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, MetadataInfo& info) { - if (fsmRes.state != CfdpStates::IDLE) { - // According to standard, discard metadata PDU if we are busy - return OK; - } - ReturnValue_t result = OK; - fsmRes.step = TransactionStep::TRANSACTION_START; - if (reader.getTransmissionMode() == TransmissionModes::UNACKNOWLEDGED) { - fsmRes.state = CfdpStates::BUSY_CLASS_1_NACKED; - } else if (reader.getTransmissionMode() == TransmissionModes::ACKNOWLEDGED) { - fsmRes.state = CfdpStates::BUSY_CLASS_2_ACKED; - } - tp.checksumType = info.getChecksumType(); - tp.closureRequested = info.isClosureRequested(); - size_t sourceNameSize = 0; - const uint8_t* sourceNamePtr = info.getSourceFileName().getValue(&sourceNameSize); - if (sourceNameSize > tp.sourceName.size()) { - // TODO: Warning, event etc. - return FAILED; - } - std::memcpy(tp.sourceName.data(), sourceNamePtr, sourceNameSize); - tp.sourceName[sourceNameSize] = '\0'; - size_t destNameSize = 0; - const uint8_t* destNamePtr = info.getDestFileName().getValue(&destNameSize); - if (destNameSize > tp.destName.size()) { - // TODO: Warning, event etc. - return FAILED; - } - std::memcpy(tp.destName.data(), destNamePtr, destNameSize); - tp.destName[destNameSize] = '\0'; - reader.fillConfig(tp.pduConf); - tp.pduConf.direction = Direction::TOWARDS_SENDER; - tp.transactionId.entityId = tp.pduConf.sourceId; - tp.transactionId.seqNum = tp.pduConf.seqNum; - if (not dp.remoteCfgTable.getRemoteCfg(tp.pduConf.sourceId, &tp.remoteCfg)) { - // TODO: Warning, event etc. -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "cfdp::DestHandler" << __func__ - << ": No remote configuration found for destination ID " - << tp.pduConf.sourceId.getValue() << std::endl; -#endif - return FAILED; - } - // If both dest name size and source name size are 0, we are dealing with a metadata only PDU, - // so there is no need to create a file or truncate an existing file - if (destNameSize > 0 and sourceNameSize > 0) { - FilesystemParams fparams(tp.destName.data()); - // TODO: Filesystem errors? - if (dp.user.vfs.fileExists(fparams)) { - dp.user.vfs.truncateFile(fparams); - } else { - result = dp.user.vfs.createFile(fparams); - if (result != OK) { - // TODO: Handle FS error. This is probably a case for the filestore rejection mechanism of - // CFDP. - // In any case, it does not really make sense to continue here - } - } - } - fsmRes.step = TransactionStep::RECEIVING_FILE_DATA_PDUS; - MetadataRecvdParams params(tp.transactionId, tp.pduConf.sourceId); - params.fileSize = tp.fileSize.getSize(); - params.destFileName = tp.destName.data(); - params.sourceFileName = tp.sourceName.data(); - params.msgsToUserArray = dynamic_cast(userTlvVec.data()); - params.msgsToUserLen = info.getOptionsLen(); - dp.user.metadataRecvdIndication(params); - return result; -} - -cfdp::CfdpStates cfdp::DestHandler::getCfdpState() const { return fsmRes.state; } - -ReturnValue_t cfdp::DestHandler::handleTransferCompletion() { - ReturnValue_t result; - if (tp.checksumType != ChecksumTypes::NULL_CHECKSUM) { - result = checksumVerification(); - if (result != OK) { - // TODO: Warning / error handling? - } - } else { - tp.conditionCode = ConditionCode::NO_ERROR; - } - result = noticeOfCompletion(); - if (result != OK) { - } - if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) { - if (tp.closureRequested) { - fsmRes.step = TransactionStep::SENDING_FINISHED_PDU; - } else { - finish(); - } - } else if (fsmRes.state == CfdpStates::BUSY_CLASS_2_ACKED) { - fsmRes.step = TransactionStep::SENDING_FINISHED_PDU; - } - return OK; -} - -void cfdp::DestHandler::finish() { - tp.reset(); - dp.packetListRef.clear(); - fsmRes.state = CfdpStates::IDLE; - fsmRes.step = TransactionStep::IDLE; -} - -ReturnValue_t cfdp::DestHandler::checksumVerification() { - std::array buf{}; - // TODO: Checksum verification and notice of completion - etl::crc32 crcCalc; - uint64_t currentOffset = 0; - FileOpParams params(tp.destName.data(), tp.fileSize.value()); - while (currentOffset < tp.fileSize.value()) { - uint64_t readLen; - if (currentOffset + buf.size() > tp.fileSize.value()) { - readLen = tp.fileSize.value() - currentOffset; - } else { - readLen = buf.size(); - } - if (readLen > 0) { - params.offset = currentOffset; - params.size = readLen; - auto result = dp.user.vfs.readFromFile(params, buf.data(), buf.size()); - if (result != OK) { - // TODO: I think this is a case for a filestore rejection, but it might sense to print - // a warning or trigger an event because this should generally not happen - return FAILED; - } - crcCalc.add(buf.begin(), buf.begin() + readLen); - } - currentOffset += readLen; - } - - uint32_t value = crcCalc.value(); - if (value == tp.crc) { - tp.conditionCode = ConditionCode::NO_ERROR; - tp.deliveryCode = FileDeliveryCode::DATA_COMPLETE; - } else { - // TODO: Proper error handling -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CRC check for file " << tp.destName.data() << " failed" << std::endl; -#endif - tp.conditionCode = ConditionCode::FILE_CHECKSUM_FAILURE; - } - return OK; -} - -ReturnValue_t cfdp::DestHandler::noticeOfCompletion() { - if (dp.cfg.indicCfg.transactionFinishedIndicRequired) { - TransactionFinishedParams params(tp.transactionId, tp.conditionCode, tp.deliveryCode, - tp.deliveryStatus); - dp.user.transactionFinishedIndication(params); - } - return OK; -} - -ReturnValue_t cfdp::DestHandler::sendFinishedPdu() { - FinishedInfo info(tp.conditionCode, tp.deliveryCode, tp.deliveryStatus); - FinishPduCreator finishedPdu(tp.pduConf, info); - store_address_t storeId; - uint8_t* dataPtr = nullptr; - ReturnValue_t result = - fp.tcStore->getFreeElement(&storeId, finishedPdu.getSerializedSize(), &dataPtr); - if (result != OK) { - // TODO: Error handling and event, this is a non CFDP specific error (most likely store is full) - return result; - } - size_t serLen = 0; - result = finishedPdu.serialize(dataPtr, serLen, finishedPdu.getSerializedSize()); - if (result != OK) { - // TODO: Error printout, this really should not happen - return result; - } - TmTcMessage msg(storeId); - result = fp.msgQueue->sendMessage(fp.packetDest.getReportReceptionQueue(), &msg); - if (result != OK) { - // TODO: Error handling and event, this is a non CFDP specific error (most likely store is full) - return result; - } - fsmRes.packetsSent++; - return OK; -} - -cfdp::DestHandler::TransactionStep cfdp::DestHandler::getTransactionStep() const { - return fsmRes.step; -} - -const cfdp::DestHandler::FsmResult& cfdp::DestHandler::updateFsmRes(uint8_t errors) { - fsmRes.errors = errors; - fsmRes.result = OK; - if (fsmRes.errors > 0) { - fsmRes.result = FAILED; - } - return fsmRes; -} - -const cfdp::TransactionId& cfdp::DestHandler::getTransactionId() const { return tp.transactionId; } - -void cfdp::DestHandler::checkAndHandleError(ReturnValue_t result, uint8_t& errorIdx) { - if (result != OK and errorIdx < 3) { - fsmRes.errorCodes[errorIdx] = result; - errorIdx++; - } -} - -void cfdp::DestHandler::setMsgQueue(MessageQueueIF& queue) { fp.msgQueue = &queue; } - -void cfdp::DestHandler::setEventReporter(EventReportingProxyIF& reporter) { - fp.eventReporter = &reporter; -} - -const cfdp::DestHandlerParams& cfdp::DestHandler::getDestHandlerParams() const { return dp; } - -StorageManagerIF* cfdp::DestHandler::getTmStore() const { return fp.tmStore; } -StorageManagerIF* cfdp::DestHandler::getTcStore() const { return fp.tcStore; } diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h deleted file mode 100644 index 000fc2c0..00000000 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ /dev/null @@ -1,202 +0,0 @@ -#ifndef FSFW_CFDP_CFDPDESTHANDLER_H -#define FSFW_CFDP_CFDPDESTHANDLER_H - -#include -#include - -#include -#include - -#include "RemoteConfigTableIF.h" -#include "UserBase.h" -#include "defs.h" -#include "fsfw/cfdp/handler/mib.h" -#include "fsfw/cfdp/pdu/MetadataPduReader.h" -#include "fsfw/cfdp/pdu/PduConfig.h" -#include "fsfw/container/DynamicFIFO.h" -#include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/storagemanager/storeAddress.h" -#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" - -namespace cfdp { - -struct PacketInfo { - PacketInfo(PduTypes type, store_address_t storeId, - std::optional directive = std::nullopt) - : pduType(type), directiveType(directive), storeId(storeId) {} - - PduTypes pduType = PduTypes::FILE_DATA; - std::optional directiveType = FileDirectives::INVALID_DIRECTIVE; - store_address_t storeId = store_address_t::invalid(); - PacketInfo() = default; -}; - -template -using LostSegmentsList = etl::set, SIZE>; -template -using PacketInfoList = etl::list; -using LostSegmentsListBase = etl::iset>; -using PacketInfoListBase = etl::ilist; - -struct DestHandlerParams { - DestHandlerParams(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable, - PacketInfoListBase& packetList, - // TODO: This container can potentially take tons of space. For a better - // memory efficient implementation, an additional abstraction could be - // be used so users can use uint32_t as the pair type - LostSegmentsListBase& lostSegmentsContainer) - : cfg(std::move(cfg)), - user(user), - remoteCfgTable(remoteCfgTable), - packetListRef(packetList), - lostSegmentsContainer(lostSegmentsContainer) {} - - LocalEntityCfg cfg; - UserBase& user; - RemoteConfigTableIF& remoteCfgTable; - - PacketInfoListBase& packetListRef; - LostSegmentsListBase& lostSegmentsContainer; - uint8_t maxTlvsInOnePdu = 10; - size_t maxFilenameLen = 255; -}; - -struct FsfwParams { - FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue, - EventReportingProxyIF* eventReporter, StorageManagerIF& tcStore, - StorageManagerIF& tmStore) - : FsfwParams(packetDest, msgQueue, eventReporter) { - this->tcStore = &tcStore; - this->tmStore = &tmStore; - } - - FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue, - EventReportingProxyIF* eventReporter) - : packetDest(packetDest), msgQueue(msgQueue), eventReporter(eventReporter) {} - AcceptsTelemetryIF& packetDest; - MessageQueueIF* msgQueue; - EventReportingProxyIF* eventReporter = nullptr; - StorageManagerIF* tcStore = nullptr; - StorageManagerIF* tmStore = nullptr; -}; - -enum class CallStatus { DONE, CALL_AFTER_DELAY, CALL_AGAIN }; - -class DestHandler { - public: - enum class TransactionStep { - IDLE = 0, - TRANSACTION_START = 1, - RECEIVING_FILE_DATA_PDUS = 2, - SENDING_ACK_PDU = 3, - TRANSFER_COMPLETION = 4, - SENDING_FINISHED_PDU = 5 - }; - - struct FsmResult { - public: - ReturnValue_t result = returnvalue::OK; - CallStatus callStatus = CallStatus::CALL_AFTER_DELAY; - TransactionStep step = TransactionStep::IDLE; - CfdpStates state = CfdpStates::IDLE; - uint32_t packetsSent = 0; - uint8_t errors = 0; - std::array errorCodes = {}; - void resetOfIteration() { - result = returnvalue::OK; - callStatus = CallStatus::CALL_AFTER_DELAY; - packetsSent = 0; - errors = 0; - errorCodes.fill(returnvalue::OK); - } - }; - /** - * Will be returned if it is advisable to call the state machine operation call again - */ - ReturnValue_t PARTIAL_SUCCESS = returnvalue::makeCode(0, 2); - ReturnValue_t FAILURE = returnvalue::makeCode(0, 3); - explicit DestHandler(DestHandlerParams handlerParams, FsfwParams fsfwParams); - - /** - * - * @return - * - @c returnvalue::OK State machine OK for this execution cycle - * - @c CALL_FSM_AGAIN State machine should be called again. - */ - const FsmResult& performStateMachine(); - void setMsgQueue(MessageQueueIF& queue); - void setEventReporter(EventReportingProxyIF& reporter); - - ReturnValue_t passPacket(PacketInfo packet); - - ReturnValue_t initialize(); - - [[nodiscard]] CfdpStates getCfdpState() const; - [[nodiscard]] TransactionStep getTransactionStep() const; - [[nodiscard]] const TransactionId& getTransactionId() const; - [[nodiscard]] const DestHandlerParams& getDestHandlerParams() const; - [[nodiscard]] StorageManagerIF* getTcStore() const; - [[nodiscard]] StorageManagerIF* getTmStore() const; - - private: - struct TransactionParams { - // Initialize char vectors with length + 1 for 0 termination - explicit TransactionParams(size_t maxFileNameLen) - : sourceName(maxFileNameLen + 1), destName(maxFileNameLen + 1) {} - - void reset() { - pduConf = PduConfig(); - transactionId = TransactionId(); - std::fill(sourceName.begin(), sourceName.end(), '\0'); - std::fill(destName.begin(), destName.end(), '\0'); - fileSize.setFileSize(0, false); - conditionCode = ConditionCode::NO_ERROR; - deliveryCode = FileDeliveryCode::DATA_INCOMPLETE; - deliveryStatus = FileDeliveryStatus::DISCARDED_DELIBERATELY; - crc = 0; - progress = 0; - remoteCfg = nullptr; - closureRequested = false; - checksumType = ChecksumTypes::NULL_CHECKSUM; - } - - ChecksumTypes checksumType = ChecksumTypes::NULL_CHECKSUM; - bool closureRequested = false; - std::vector sourceName; - std::vector destName; - cfdp::FileSize fileSize; - TransactionId transactionId; - PduConfig pduConf; - ConditionCode conditionCode = ConditionCode::NO_ERROR; - FileDeliveryCode deliveryCode = FileDeliveryCode::DATA_INCOMPLETE; - FileDeliveryStatus deliveryStatus = FileDeliveryStatus::DISCARDED_DELIBERATELY; - uint32_t crc = 0; - uint64_t progress = 0; - RemoteEntityCfg* remoteCfg = nullptr; - }; - - std::vector tlvVec; - std::vector userTlvVec; - DestHandlerParams dp; - FsfwParams fp; - TransactionParams tp; - FsmResult fsmRes; - - ReturnValue_t startTransaction(MetadataPduReader& reader, MetadataInfo& info); - ReturnValue_t handleMetadataPdu(const PacketInfo& info); - ReturnValue_t handleFileDataPdu(const PacketInfo& info); - ReturnValue_t handleEofPdu(const PacketInfo& info); - ReturnValue_t handleMetadataParseError(ReturnValue_t result, const uint8_t* rawData, - size_t maxSize); - ReturnValue_t handleTransferCompletion(); - ReturnValue_t sendFinishedPdu(); - ReturnValue_t noticeOfCompletion(); - ReturnValue_t checksumVerification(); - const FsmResult& updateFsmRes(uint8_t errors); - void checkAndHandleError(ReturnValue_t result, uint8_t& errorIdx); - void finish(); -}; - -} // namespace cfdp - -#endif // FSFW_CFDP_CFDPDESTHANDLER_H diff --git a/src/fsfw/cfdp/handler/SourceHandler.cpp b/src/fsfw/cfdp/handler/SourceHandler.cpp deleted file mode 100644 index 513b25f3..00000000 --- a/src/fsfw/cfdp/handler/SourceHandler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "SourceHandler.h" diff --git a/src/fsfw/cfdp/handler/SourceHandler.h b/src/fsfw/cfdp/handler/SourceHandler.h deleted file mode 100644 index 319cf258..00000000 --- a/src/fsfw/cfdp/handler/SourceHandler.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef FSFW_CFDP_CFDPSOURCEHANDLER_H -#define FSFW_CFDP_CFDPSOURCEHANDLER_H - -class SourceHandler {}; - -#endif // FSFW_CFDP_CFDPSOURCEHANDLER_H diff --git a/unittests/cfdp/handler/CMakeLists.txt b/unittests/cfdp/handler/CMakeLists.txt index f70e5dfb..0993a398 100644 --- a/unittests/cfdp/handler/CMakeLists.txt +++ b/unittests/cfdp/handler/CMakeLists.txt @@ -1,3 +1,2 @@ -target_sources( - ${FSFW_TEST_TGT} PRIVATE testDistributor.cpp testDestHandler.cpp - testSourceHandler.cpp testFaultHandler.cpp) +target_sources(${FSFW_TEST_TGT} PRIVATE testDistributor.cpp + testFaultHandler.cpp) diff --git a/unittests/cfdp/handler/testDestHandler.cpp b/unittests/cfdp/handler/testDestHandler.cpp deleted file mode 100644 index 30bb9fc5..00000000 --- a/unittests/cfdp/handler/testDestHandler.cpp +++ /dev/null @@ -1,244 +0,0 @@ -#include - -#include -#include -#include - -#include "fsfw/cfdp.h" -#include "fsfw/cfdp/pdu/EofPduCreator.h" -#include "fsfw/cfdp/pdu/FileDataCreator.h" -#include "fsfw/cfdp/pdu/MetadataPduCreator.h" -#include "mocks/AcceptsTmMock.h" -#include "mocks/EventReportingProxyMock.h" -#include "mocks/FilesystemMock.h" -#include "mocks/MessageQueueMock.h" -#include "mocks/StorageManagerMock.h" -#include "mocks/cfdp/FaultHandlerMock.h" -#include "mocks/cfdp/RemoteConfigTableMock.h" -#include "mocks/cfdp/UserMock.h" - -TEST_CASE("CFDP Dest Handler", "[cfdp]") { - using namespace cfdp; - using namespace returnvalue; - MessageQueueId_t destQueueId = 2; - AcceptsTmMock tmReceiver(destQueueId); - MessageQueueMock mqMock(destQueueId); - EntityId localId = EntityId(UnsignedByteField(2)); - EntityId remoteId = EntityId(UnsignedByteField(3)); - FaultHandlerMock fhMock; - LocalEntityCfg localEntityCfg(localId, IndicationCfg(), fhMock); - FilesystemMock fsMock; - UserMock userMock(fsMock); - RemoteConfigTableMock remoteCfgTableMock; - PacketInfoList<64> packetInfoList; - LostSegmentsList<128> lostSegmentsList; - DestHandlerParams dp(localEntityCfg, userMock, remoteCfgTableMock, packetInfoList, - lostSegmentsList); - EventReportingProxyMock eventReporterMock; - LocalPool::LocalPoolConfig storeCfg = {{10, 32}, {10, 64}, {10, 128}, {10, 1024}}; - StorageManagerMock tcStore(2, storeCfg); - StorageManagerMock tmStore(3, storeCfg); - FsfwParams fp(tmReceiver, &mqMock, &eventReporterMock); - RemoteEntityCfg cfg(remoteId); - remoteCfgTableMock.addRemoteConfig(cfg); - fp.tcStore = &tcStore; - fp.tmStore = &tmStore; - uint8_t* buf = nullptr; - size_t serLen = 0; - store_address_t storeId; - PduConfig conf; - auto destHandler = DestHandler(dp, fp); - CHECK(destHandler.initialize() == OK); - - auto metadataPreparation = [&](FileSize cfdpFileSize, ChecksumTypes checksumType) { - std::string srcNameString = "hello.txt"; - std::string destNameString = "hello-cpy.txt"; - StringLv srcName(srcNameString); - StringLv destName(destNameString); - MetadataInfo info(false, checksumType, cfdpFileSize, srcName, destName); - TransactionSeqNum seqNum(UnsignedByteField(1)); - conf.sourceId = remoteId; - conf.destId = localId; - conf.mode = TransmissionModes::UNACKNOWLEDGED; - conf.seqNum = seqNum; - MetadataPduCreator metadataCreator(conf, info); - REQUIRE(tcStore.getFreeElement(&storeId, metadataCreator.getSerializedSize(), &buf) == OK); - REQUIRE(metadataCreator.serialize(buf, serLen, metadataCreator.getSerializedSize()) == OK); - PacketInfo packetInfo(metadataCreator.getPduType(), storeId, - metadataCreator.getDirectiveCode()); - packetInfoList.push_back(packetInfo); - }; - - auto metadataCheck = [&](const cfdp::DestHandler::FsmResult& res, const char* sourceName, - const char* destName, size_t fileLen) { - REQUIRE(res.result == OK); - REQUIRE(res.callStatus == CallStatus::CALL_AGAIN); - REQUIRE(res.errors == 0); - // Assert that the packet was deleted after handling - REQUIRE(not tcStore.hasDataAtId(storeId)); - REQUIRE(packetInfoList.empty()); - REQUIRE(userMock.metadataRecvd.size() == 1); - auto& idMetadataPair = userMock.metadataRecvd.back(); - REQUIRE(idMetadataPair.first == destHandler.getTransactionId()); - REQUIRE(idMetadataPair.second.sourceId.getValue() == 3); - REQUIRE(idMetadataPair.second.fileSize == fileLen); - REQUIRE(strcmp(idMetadataPair.second.destFileName, destName) == 0); - REQUIRE(strcmp(idMetadataPair.second.sourceFileName, sourceName) == 0); - userMock.metadataRecvd.pop(); - REQUIRE(fsMock.fileMap.find(destName) != fsMock.fileMap.end()); - REQUIRE(res.result == OK); - REQUIRE(res.state == CfdpStates::BUSY_CLASS_1_NACKED); - REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS); - }; - - auto eofPreparation = [&](FileSize cfdpFileSize, uint32_t crc) { - EofInfo eofInfo(cfdp::ConditionCode::NO_ERROR, crc, std::move(cfdpFileSize)); - EofPduCreator eofCreator(conf, eofInfo); - REQUIRE(tcStore.getFreeElement(&storeId, eofCreator.getSerializedSize(), &buf) == OK); - REQUIRE(eofCreator.serialize(buf, serLen, eofCreator.getSerializedSize()) == OK); - PacketInfo packetInfo(eofCreator.getPduType(), storeId, eofCreator.getDirectiveCode()); - packetInfoList.push_back(packetInfo); - }; - - auto eofCheck = [&](const cfdp::DestHandler::FsmResult& res, const TransactionId& id) { - REQUIRE(res.result == OK); - REQUIRE(res.state == CfdpStates::IDLE); - REQUIRE(res.errors == 0); - REQUIRE(res.step == DestHandler::TransactionStep::IDLE); - // Assert that the packet was deleted after handling - REQUIRE(not tcStore.hasDataAtId(storeId)); - REQUIRE(packetInfoList.empty()); - REQUIRE(userMock.eofsRevd.size() == 1); - auto& eofId = userMock.eofsRevd.back(); - CHECK(eofId == id); - REQUIRE(userMock.finishedRecvd.size() == 1); - auto& idParamPair = userMock.finishedRecvd.back(); - CHECK(idParamPair.first == id); - CHECK(idParamPair.second.condCode == ConditionCode::NO_ERROR); - }; - - auto fileDataPduCheck = [&](const cfdp::DestHandler::FsmResult& res, - const std::vector& idsToCheck) { - REQUIRE(res.result == OK); - REQUIRE(res.state == CfdpStates::BUSY_CLASS_1_NACKED); - REQUIRE(res.step == DestHandler::TransactionStep::RECEIVING_FILE_DATA_PDUS); - for (const auto id : idsToCheck) { - REQUIRE(not tcStore.hasDataAtId(id)); - } - REQUIRE(packetInfoList.empty()); - }; - - SECTION("State") { - CHECK(destHandler.getCfdpState() == CfdpStates::IDLE); - CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE); - } - - SECTION("Idle State Machine Iteration") { - auto res = destHandler.performStateMachine(); - CHECK(res.result == OK); - CHECK(res.callStatus == CallStatus::CALL_AFTER_DELAY); - CHECK(res.errors == 0); - CHECK(destHandler.getCfdpState() == CfdpStates::IDLE); - CHECK(destHandler.getTransactionStep() == DestHandler::TransactionStep::IDLE); - } - - SECTION("Empty File Transfer") { - const DestHandler::FsmResult& res = destHandler.performStateMachine(); - CHECK(res.result == OK); - FileSize cfdpFileSize(0); - metadataPreparation(cfdpFileSize, ChecksumTypes::NULL_CHECKSUM); - destHandler.performStateMachine(); - metadataCheck(res, "hello.txt", "hello-cpy.txt", 0); - destHandler.performStateMachine(); - REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); - auto transactionId = destHandler.getTransactionId(); - eofPreparation(cfdpFileSize, 0); - // After EOF, operation is done because no closure was requested - destHandler.performStateMachine(); - eofCheck(res, transactionId); - } - - SECTION("Small File Transfer") { - const DestHandler::FsmResult& res = destHandler.performStateMachine(); - CHECK(res.result == OK); - std::string fileData = "hello test data"; - etl::crc32 crcCalc; - crcCalc.add(fileData.begin(), fileData.end()); - uint32_t crc32 = crcCalc.value(); - FileSize cfdpFileSize(fileData.size()); - metadataPreparation(cfdpFileSize, ChecksumTypes::CRC_32); - destHandler.performStateMachine(); - metadataCheck(res, "hello.txt", "hello-cpy.txt", fileData.size()); - destHandler.performStateMachine(); - REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); - auto transactionId = destHandler.getTransactionId(); - FileSize offset(0); - FileDataInfo fdPduInfo(offset, reinterpret_cast(fileData.data()), - fileData.size()); - FileDataCreator fdPduCreator(conf, fdPduInfo); - REQUIRE(tcStore.getFreeElement(&storeId, fdPduCreator.getSerializedSize(), &buf) == OK); - REQUIRE(fdPduCreator.serialize(buf, serLen, fdPduCreator.getSerializedSize()) == OK); - PacketInfo packetInfo(fdPduCreator.getPduType(), storeId, std::nullopt); - packetInfoList.push_back(packetInfo); - destHandler.performStateMachine(); - fileDataPduCheck(res, {storeId}); - eofPreparation(cfdpFileSize, crc32); - // After EOF, operation is done because no closure was requested - destHandler.performStateMachine(); - eofCheck(res, transactionId); - } - - SECTION("Segmented File Transfer") { - const DestHandler::FsmResult& res = destHandler.performStateMachine(); - CHECK(res.result == OK); - std::random_device dev; - std::mt19937 rng(dev()); - std::uniform_int_distribution distU8(0, 255); - std::array largerFileData{}; - for (auto& val : largerFileData) { - val = distU8(rng); - } - etl::crc32 crcCalc; - crcCalc.add(largerFileData.begin(), largerFileData.end()); - uint32_t crc32 = crcCalc.value(); - FileSize cfdpFileSize(largerFileData.size()); - metadataPreparation(cfdpFileSize, ChecksumTypes::CRC_32); - destHandler.performStateMachine(); - metadataCheck(res, "hello.txt", "hello-cpy.txt", largerFileData.size()); - destHandler.performStateMachine(); - REQUIRE(res.callStatus == CallStatus::CALL_AFTER_DELAY); - auto transactionId = destHandler.getTransactionId(); - - std::vector idsToCheck; - { - FileSize offset(0); - FileDataInfo fdPduInfo(offset, reinterpret_cast(largerFileData.data()), - largerFileData.size() / 2); - FileDataCreator fdPduCreator(conf, fdPduInfo); - REQUIRE(tcStore.getFreeElement(&storeId, fdPduCreator.getSerializedSize(), &buf) == OK); - REQUIRE(fdPduCreator.serialize(buf, serLen, fdPduCreator.getSerializedSize()) == OK); - PacketInfo packetInfo(fdPduCreator.getPduType(), storeId, std::nullopt); - idsToCheck.push_back(storeId); - packetInfoList.push_back(packetInfo); - } - - { - FileSize offset(512); - FileDataInfo fdPduInfo(offset, reinterpret_cast(largerFileData.data() + 512), - largerFileData.size() / 2); - FileDataCreator fdPduCreator(conf, fdPduInfo); - REQUIRE(tcStore.getFreeElement(&storeId, fdPduCreator.getSerializedSize(), &buf) == OK); - REQUIRE(fdPduCreator.serialize(buf, serLen, fdPduCreator.getSerializedSize()) == OK); - PacketInfo packetInfo(fdPduCreator.getPduType(), storeId, std::nullopt); - idsToCheck.push_back(storeId); - packetInfoList.push_back(packetInfo); - } - - destHandler.performStateMachine(); - fileDataPduCheck(res, idsToCheck); - eofPreparation(cfdpFileSize, crc32); - // After EOF, operation is done because no closure was requested - destHandler.performStateMachine(); - eofCheck(res, transactionId); - } -} \ No newline at end of file diff --git a/unittests/cfdp/handler/testSourceHandler.cpp b/unittests/cfdp/handler/testSourceHandler.cpp deleted file mode 100644 index 570ecb08..00000000 --- a/unittests/cfdp/handler/testSourceHandler.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include - -TEST_CASE("CFDP Source Handler", "[cfdp]") {} \ No newline at end of file diff --git a/unittests/cfdp/testLvs.cpp b/unittests/cfdp/testLvs.cpp index 062281e5..22094568 100644 --- a/unittests/cfdp/testLvs.cpp +++ b/unittests/cfdp/testLvs.cpp @@ -2,6 +2,7 @@ #include #include "fsfw/cfdp.h" +#include "fsfw/cfdp/VarLenFields.h" TEST_CASE("CFDP LV", "[cfdp][lv]") { using namespace cfdp; diff --git a/unittests/cfdp/testTlv.cpp b/unittests/cfdp/testTlv.cpp index 3e7435cd..b78d8a80 100644 --- a/unittests/cfdp/testTlv.cpp +++ b/unittests/cfdp/testTlv.cpp @@ -2,6 +2,7 @@ #include #include "fsfw/cfdp.h" +#include "fsfw/cfdp/VarLenFields.h" TEST_CASE("CFDP TLV", "[cfdp][tlv]") { using namespace cfdp; From 73f1917c816cb199311e3c2ccc3ff5daa8c9ca0d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Sep 2022 19:26:07 +0200 Subject: [PATCH 367/532] update changelog --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fe567de..24bc89fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/). PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/655 which also includes a migration guide +## CFDP + +- Refactoring of CFDP stack which was done during implementation of the CFDP source and destination + handlers. + - New filesystem module, changes for filesystem abstraction `HasFileSystemIF` to better + fit requirements of CFDP + - New `HostFilesystem` implementation of the `HasFileSystemIF` + - New `cfdp::UserBase` class which is the abstraction for the CFDP user in an OBSW context. + - mib module for the CFDP stack + - PDU classes renamed from `...Serializer`/`...Deserializer` to `...Creator`/`...Reader` + respetively + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/682/files + # [v5.0.0] 25.07.2022 ## Changes From 2e27a85c95e26b906207e433308e9ee64308cac3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Sep 2022 19:48:11 +0200 Subject: [PATCH 368/532] finished renaming operation --- src/fsfw/cfdp/pdu/CMakeLists.txt | 12 +++++----- ...Serializer.cpp => KeepAlivePduCreator.cpp} | 12 +++++----- src/fsfw/cfdp/pdu/KeepAlivePduCreator.h | 22 +++++++++++++++++++ src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h | 19 ---------------- ...eserializer.cpp => KeepAlivePduReader.cpp} | 10 ++++----- src/fsfw/cfdp/pdu/KeepAlivePduReader.h | 19 ++++++++++++++++ src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h | 22 ------------------- ...NakPduSerializer.cpp => NakPduCreator.cpp} | 14 +++++------- .../{NakPduSerializer.h => NakPduCreator.h} | 12 +++++----- src/fsfw/cfdp/pdu/NakPduDeserializer.h | 21 ------------------ ...akPduDeserializer.cpp => NakPduReader.cpp} | 6 ++--- src/fsfw/cfdp/pdu/NakPduReader.h | 21 ++++++++++++++++++ ...PduSerializer.cpp => PromptPduCreator.cpp} | 11 +++++----- ...omptPduSerializer.h => PromptPduCreator.h} | 4 ++-- ...duDeserializer.cpp => PromptPduReader.cpp} | 8 +++---- ...mptPduDeserializer.h => PromptPduReader.h} | 4 ++-- unittests/cfdp/pdu/testKeepAlivePdu.cpp | 10 ++++----- unittests/cfdp/pdu/testNakPdu.cpp | 16 +++++++------- unittests/cfdp/pdu/testPromptPdu.cpp | 10 ++++----- 19 files changed, 125 insertions(+), 128 deletions(-) rename src/fsfw/cfdp/pdu/{KeepAlivePduSerializer.cpp => KeepAlivePduCreator.cpp} (54%) create mode 100644 src/fsfw/cfdp/pdu/KeepAlivePduCreator.h delete mode 100644 src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h rename src/fsfw/cfdp/pdu/{KeepAlivePduDeserializer.cpp => KeepAlivePduReader.cpp} (56%) create mode 100644 src/fsfw/cfdp/pdu/KeepAlivePduReader.h delete mode 100644 src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h rename src/fsfw/cfdp/pdu/{NakPduSerializer.cpp => NakPduCreator.cpp} (74%) rename src/fsfw/cfdp/pdu/{NakPduSerializer.h => NakPduCreator.h} (70%) delete mode 100644 src/fsfw/cfdp/pdu/NakPduDeserializer.h rename src/fsfw/cfdp/pdu/{NakPduDeserializer.cpp => NakPduReader.cpp} (90%) create mode 100644 src/fsfw/cfdp/pdu/NakPduReader.h rename src/fsfw/cfdp/pdu/{PromptPduSerializer.cpp => PromptPduCreator.cpp} (54%) rename src/fsfw/cfdp/pdu/{PromptPduSerializer.h => PromptPduCreator.h} (77%) rename src/fsfw/cfdp/pdu/{PromptPduDeserializer.cpp => PromptPduReader.cpp} (65%) rename src/fsfw/cfdp/pdu/{PromptPduDeserializer.h => PromptPduReader.h} (78%) diff --git a/src/fsfw/cfdp/pdu/CMakeLists.txt b/src/fsfw/cfdp/pdu/CMakeLists.txt index 22ac76c7..c08a4b29 100644 --- a/src/fsfw/cfdp/pdu/CMakeLists.txt +++ b/src/fsfw/cfdp/pdu/CMakeLists.txt @@ -12,18 +12,18 @@ target_sources( EofPduCreator.cpp EofPduReader.cpp NakInfo.cpp - NakPduSerializer.cpp - NakPduDeserializer.cpp + NakPduCreator.cpp + NakPduReader.cpp FinishedInfo.cpp FinishedPduCreator.cpp FinishedPduReader.cpp MetadataInfo.cpp MetadataPduCreator.cpp MetadataPduReader.cpp - KeepAlivePduSerializer.cpp - KeepAlivePduDeserializer.cpp - PromptPduSerializer.cpp - PromptPduDeserializer.cpp + KeepAlivePduCreator.cpp + KeepAlivePduReader.cpp + PromptPduCreator.cpp + PromptPduReader.cpp FileDataCreator.cpp FileDataReader.cpp FileDataInfo.cpp) diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduCreator.cpp similarity index 54% rename from src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp rename to src/fsfw/cfdp/pdu/KeepAlivePduCreator.cpp index 882f401f..8b0ad6c8 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/KeepAlivePduCreator.cpp @@ -1,22 +1,22 @@ -#include "KeepAlivePduSerializer.h" +#include "KeepAlivePduCreator.h" -KeepAlivePduSerializer::KeepAlivePduSerializer(PduConfig &conf, cfdp::FileSize &progress) +KeepAlivePduCreator::KeepAlivePduCreator(PduConfig &conf, cfdp::FileSize &progress) : FileDirectiveCreator(conf, cfdp::FileDirectives::KEEP_ALIVE, 4), progress(progress) { updateDirectiveFieldLen(); } -size_t KeepAlivePduSerializer::getSerializedSize() const { +size_t KeepAlivePduCreator::getSerializedSize() const { return FileDirectiveCreator::getWholePduSize(); } -void KeepAlivePduSerializer::updateDirectiveFieldLen() { +void KeepAlivePduCreator::updateDirectiveFieldLen() { if (this->getLargeFileFlag()) { this->setDirectiveDataFieldLen(8); } } -ReturnValue_t KeepAlivePduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const { +ReturnValue_t KeepAlivePduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduCreator.h b/src/fsfw/cfdp/pdu/KeepAlivePduCreator.h new file mode 100644 index 00000000..aa4bf0fd --- /dev/null +++ b/src/fsfw/cfdp/pdu/KeepAlivePduCreator.h @@ -0,0 +1,22 @@ +#ifndef FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_ +#define FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_ + +#include "fsfw/cfdp/FileSize.h" +#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" + +class KeepAlivePduCreator : public FileDirectiveCreator { + public: + KeepAlivePduCreator(PduConfig& conf, cfdp::FileSize& progress); + + void updateDirectiveFieldLen(); + + [[nodiscard]] size_t getSerializedSize() const override; + + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const override; + + private: + cfdp::FileSize& progress; +}; + +#endif /* FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h b/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h deleted file mode 100644 index 1a8ca14d..00000000 --- a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUDESERIALIZER_H_ -#define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUDESERIALIZER_H_ - -#include "fsfw/cfdp/FileSize.h" -#include "fsfw/cfdp/pdu/FileDirectiveReader.h" - -class KeepAlivePduDeserializer : public FileDirectiveReader { - public: - KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize, cfdp::FileSize& progress); - - ReturnValue_t parseData() override; - - cfdp::FileSize& getProgress(); - - private: - cfdp::FileSize& progress; -}; - -#endif /* FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUDESERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduReader.cpp similarity index 56% rename from src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp rename to src/fsfw/cfdp/pdu/KeepAlivePduReader.cpp index 9686cf0a..d3362cf9 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/KeepAlivePduReader.cpp @@ -1,10 +1,10 @@ -#include "KeepAlivePduDeserializer.h" +#include "KeepAlivePduReader.h" -KeepAlivePduDeserializer::KeepAlivePduDeserializer(const uint8_t* pduBuf, size_t maxSize, - cfdp::FileSize& progress) +KeepAlivePduReader::KeepAlivePduReader(const uint8_t* pduBuf, size_t maxSize, + cfdp::FileSize& progress) : FileDirectiveReader(pduBuf, maxSize), progress(progress) {} -ReturnValue_t KeepAlivePduDeserializer::parseData() { +ReturnValue_t KeepAlivePduReader::parseData() { ReturnValue_t result = FileDirectiveReader::parseData(); if (result != returnvalue::OK) { return result; @@ -15,4 +15,4 @@ ReturnValue_t KeepAlivePduDeserializer::parseData() { return progress.deSerialize(&buffer, &remLen, getEndianness()); } -cfdp::FileSize& KeepAlivePduDeserializer::getProgress() { return progress; } +cfdp::FileSize& KeepAlivePduReader::getProgress() { return progress; } diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduReader.h b/src/fsfw/cfdp/pdu/KeepAlivePduReader.h new file mode 100644 index 00000000..38e061f1 --- /dev/null +++ b/src/fsfw/cfdp/pdu/KeepAlivePduReader.h @@ -0,0 +1,19 @@ +#ifndef FSFW_CFDP_PDU_KEEPALIVEREADER_H_ +#define FSFW_CFDP_PDU_KEEPALIVEREADER_H_ + +#include "fsfw/cfdp/FileSize.h" +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" + +class KeepAlivePduReader : public FileDirectiveReader { + public: + KeepAlivePduReader(const uint8_t* pduBuf, size_t maxSize, cfdp::FileSize& progress); + + ReturnValue_t parseData() override; + + cfdp::FileSize& getProgress(); + + private: + cfdp::FileSize& progress; +}; + +#endif /* FSFW_CFDP_PDU_KEEPALIVEPDUREADER_H_ */ diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h b/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h deleted file mode 100644 index 0fabeb0a..00000000 --- a/src/fsfw/cfdp/pdu/KeepAlivePduSerializer.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_ -#define FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_ - -#include "fsfw/cfdp/FileSize.h" -#include "fsfw/cfdp/pdu/FileDirectiveCreator.h" - -class KeepAlivePduSerializer : public FileDirectiveCreator { - public: - KeepAlivePduSerializer(PduConfig& conf, cfdp::FileSize& progress); - - void updateDirectiveFieldLen(); - - size_t getSerializedSize() const override; - - ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const override; - - private: - cfdp::FileSize& progress; -}; - -#endif /* FSFW_SRC_FSFW_CFDP_PDU_KEEPALIVEPDUSERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/NakPduSerializer.cpp b/src/fsfw/cfdp/pdu/NakPduCreator.cpp similarity index 74% rename from src/fsfw/cfdp/pdu/NakPduSerializer.cpp rename to src/fsfw/cfdp/pdu/NakPduCreator.cpp index 7f5efa08..c4493fcb 100644 --- a/src/fsfw/cfdp/pdu/NakPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/NakPduCreator.cpp @@ -1,20 +1,18 @@ -#include "NakPduSerializer.h" +#include "NakPduCreator.h" -NakPduSerializer::NakPduSerializer(PduConfig &pduConf, NakInfo &nakInfo) +NakPduCreator::NakPduCreator(PduConfig &pduConf, NakInfo &nakInfo) : FileDirectiveCreator(pduConf, cfdp::FileDirectives::NAK, 0), nakInfo(nakInfo) { updateDirectiveFieldLen(); } -void NakPduSerializer::updateDirectiveFieldLen() { +void NakPduCreator::updateDirectiveFieldLen() { this->setDirectiveDataFieldLen(nakInfo.getSerializedSize(getLargeFileFlag())); } -size_t NakPduSerializer::getSerializedSize() const { - return FileDirectiveCreator::getWholePduSize(); -} +size_t NakPduCreator::getSerializedSize() const { return FileDirectiveCreator::getWholePduSize(); } -ReturnValue_t NakPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const { +ReturnValue_t NakPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; diff --git a/src/fsfw/cfdp/pdu/NakPduSerializer.h b/src/fsfw/cfdp/pdu/NakPduCreator.h similarity index 70% rename from src/fsfw/cfdp/pdu/NakPduSerializer.h rename to src/fsfw/cfdp/pdu/NakPduCreator.h index 12e1bae2..bfcff78d 100644 --- a/src/fsfw/cfdp/pdu/NakPduSerializer.h +++ b/src/fsfw/cfdp/pdu/NakPduCreator.h @@ -1,5 +1,5 @@ -#ifndef FSFW_SRC_FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_ -#define FSFW_SRC_FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_ +#ifndef FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_ +#define FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_ #include @@ -8,7 +8,7 @@ #include "fsfw/cfdp/definitions.h" #include "fsfw/cfdp/pdu/FileDirectiveCreator.h" -class NakPduSerializer : public FileDirectiveCreator { +class NakPduCreator : public FileDirectiveCreator { public: /** * @@ -18,9 +18,9 @@ class NakPduSerializer : public FileDirectiveCreator { * @param [in] segmentRequests Pointer to the start of a list of segment requests * @param segmentRequestLen Length of the segment request list to be serialized */ - NakPduSerializer(PduConfig& PduConf, NakInfo& nakInfo); + NakPduCreator(PduConfig& PduConf, NakInfo& nakInfo); - size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const override; @@ -35,4 +35,4 @@ class NakPduSerializer : public FileDirectiveCreator { NakInfo& nakInfo; }; -#endif /* FSFW_SRC_FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_ */ +#endif /* FSFW_CFDP_PDU_NAKPDUSERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/NakPduDeserializer.h b/src/fsfw/cfdp/pdu/NakPduDeserializer.h deleted file mode 100644 index c119564d..00000000 --- a/src/fsfw/cfdp/pdu/NakPduDeserializer.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ -#define FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ - -#include "fsfw/cfdp/pdu/FileDirectiveReader.h" -#include "fsfw/cfdp/pdu/NakInfo.h" - -class NakPduDeserializer : public FileDirectiveReader { - public: - NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, NakInfo& info); - - /** - * This needs to be called before accessing the PDU fields to avoid segmentation faults. - * @return - */ - virtual ReturnValue_t parseData() override; - - private: - NakInfo& nakInfo; -}; - -#endif /* FSFW_SRC_FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp b/src/fsfw/cfdp/pdu/NakPduReader.cpp similarity index 90% rename from src/fsfw/cfdp/pdu/NakPduDeserializer.cpp rename to src/fsfw/cfdp/pdu/NakPduReader.cpp index c27e96be..c67774c0 100644 --- a/src/fsfw/cfdp/pdu/NakPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/NakPduReader.cpp @@ -1,9 +1,9 @@ -#include "NakPduDeserializer.h" +#include "NakPduReader.h" -NakPduDeserializer::NakPduDeserializer(const uint8_t* pduBuf, size_t maxSize, NakInfo& info) +NakPduReader::NakPduReader(const uint8_t* pduBuf, size_t maxSize, NakInfo& info) : FileDirectiveReader(pduBuf, maxSize), nakInfo(info) {} -ReturnValue_t NakPduDeserializer::parseData() { +ReturnValue_t NakPduReader::parseData() { ReturnValue_t result = FileDirectiveReader::parseData(); if (result != returnvalue::OK) { return result; diff --git a/src/fsfw/cfdp/pdu/NakPduReader.h b/src/fsfw/cfdp/pdu/NakPduReader.h new file mode 100644 index 00000000..7e08229d --- /dev/null +++ b/src/fsfw/cfdp/pdu/NakPduReader.h @@ -0,0 +1,21 @@ +#ifndef FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ +#define FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ + +#include "fsfw/cfdp/pdu/FileDirectiveReader.h" +#include "fsfw/cfdp/pdu/NakInfo.h" + +class NakPduReader : public FileDirectiveReader { + public: + NakPduReader(const uint8_t* pduBuf, size_t maxSize, NakInfo& info); + + /** + * This needs to be called before accessing the PDU fields to avoid segmentation faults. + * @return + */ + ReturnValue_t parseData() override; + + private: + NakInfo& nakInfo; +}; + +#endif /* FSFW_CFDP_PDU_NAKPDUDESERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp b/src/fsfw/cfdp/pdu/PromptPduCreator.cpp similarity index 54% rename from src/fsfw/cfdp/pdu/PromptPduSerializer.cpp rename to src/fsfw/cfdp/pdu/PromptPduCreator.cpp index 0823e932..43077cf6 100644 --- a/src/fsfw/cfdp/pdu/PromptPduSerializer.cpp +++ b/src/fsfw/cfdp/pdu/PromptPduCreator.cpp @@ -1,16 +1,15 @@ -#include "PromptPduSerializer.h" +#include "PromptPduCreator.h" -PromptPduSerializer::PromptPduSerializer(PduConfig &conf, - cfdp::PromptResponseRequired responseRequired) +PromptPduCreator::PromptPduCreator(PduConfig &conf, cfdp::PromptResponseRequired responseRequired) : FileDirectiveCreator(conf, cfdp::FileDirectives::PROMPT, 1), responseRequired(responseRequired) {} -size_t PromptPduSerializer::getSerializedSize() const { +size_t PromptPduCreator::getSerializedSize() const { return FileDirectiveCreator::getWholePduSize(); } -ReturnValue_t PromptPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize, - Endianness streamEndianness) const { +ReturnValue_t PromptPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const { ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness); if (result != returnvalue::OK) { return result; diff --git a/src/fsfw/cfdp/pdu/PromptPduSerializer.h b/src/fsfw/cfdp/pdu/PromptPduCreator.h similarity index 77% rename from src/fsfw/cfdp/pdu/PromptPduSerializer.h rename to src/fsfw/cfdp/pdu/PromptPduCreator.h index 1abe362e..ccecab6e 100644 --- a/src/fsfw/cfdp/pdu/PromptPduSerializer.h +++ b/src/fsfw/cfdp/pdu/PromptPduCreator.h @@ -3,9 +3,9 @@ #include "fsfw/cfdp/pdu/FileDirectiveCreator.h" -class PromptPduSerializer : public FileDirectiveCreator { +class PromptPduCreator : public FileDirectiveCreator { public: - PromptPduSerializer(PduConfig& conf, cfdp::PromptResponseRequired responseRequired); + PromptPduCreator(PduConfig& conf, cfdp::PromptResponseRequired responseRequired); [[nodiscard]] size_t getSerializedSize() const override; diff --git a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp b/src/fsfw/cfdp/pdu/PromptPduReader.cpp similarity index 65% rename from src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp rename to src/fsfw/cfdp/pdu/PromptPduReader.cpp index 1bccee82..f554c3c9 100644 --- a/src/fsfw/cfdp/pdu/PromptPduDeserializer.cpp +++ b/src/fsfw/cfdp/pdu/PromptPduReader.cpp @@ -1,13 +1,13 @@ -#include "PromptPduDeserializer.h" +#include "PromptPduReader.h" -PromptPduDeserializer::PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize) +PromptPduReader::PromptPduReader(const uint8_t *pduBuf, size_t maxSize) : FileDirectiveReader(pduBuf, maxSize) {} -cfdp::PromptResponseRequired PromptPduDeserializer::getPromptResponseRequired() const { +cfdp::PromptResponseRequired PromptPduReader::getPromptResponseRequired() const { return responseRequired; } -ReturnValue_t PromptPduDeserializer::parseData() { +ReturnValue_t PromptPduReader::parseData() { ReturnValue_t result = FileDirectiveReader::parseData(); if (result != returnvalue::OK) { return result; diff --git a/src/fsfw/cfdp/pdu/PromptPduDeserializer.h b/src/fsfw/cfdp/pdu/PromptPduReader.h similarity index 78% rename from src/fsfw/cfdp/pdu/PromptPduDeserializer.h rename to src/fsfw/cfdp/pdu/PromptPduReader.h index 91ed5a9a..2afcb20e 100644 --- a/src/fsfw/cfdp/pdu/PromptPduDeserializer.h +++ b/src/fsfw/cfdp/pdu/PromptPduReader.h @@ -3,9 +3,9 @@ #include "fsfw/cfdp/pdu/FileDirectiveReader.h" -class PromptPduDeserializer : public FileDirectiveReader { +class PromptPduReader : public FileDirectiveReader { public: - PromptPduDeserializer(const uint8_t *pduBuf, size_t maxSize); + PromptPduReader(const uint8_t *pduBuf, size_t maxSize); [[nodiscard]] cfdp::PromptResponseRequired getPromptResponseRequired() const; ReturnValue_t parseData() override; diff --git a/unittests/cfdp/pdu/testKeepAlivePdu.cpp b/unittests/cfdp/pdu/testKeepAlivePdu.cpp index 34a529e9..9b0e9669 100644 --- a/unittests/cfdp/pdu/testKeepAlivePdu.cpp +++ b/unittests/cfdp/pdu/testKeepAlivePdu.cpp @@ -1,8 +1,8 @@ #include #include -#include "fsfw/cfdp/pdu/KeepAlivePduDeserializer.h" -#include "fsfw/cfdp/pdu/KeepAlivePduSerializer.h" +#include "fsfw/cfdp/pdu/KeepAlivePduCreator.h" +#include "fsfw/cfdp/pdu/KeepAlivePduReader.h" #include "fsfw/globalfunctions/arrayprinter.h" TEST_CASE("Keep Alive PDU", "[cfdp][pdu]") { @@ -19,7 +19,7 @@ TEST_CASE("Keep Alive PDU", "[cfdp][pdu]") { FileSize progress(0x50); SECTION("Serialize") { - KeepAlivePduSerializer serializer(pduConf, progress); + KeepAlivePduCreator serializer(pduConf, progress); result = serializer.serialize(&buffer, &sz, kaBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); REQUIRE(kaBuffer[10] == cfdp::FileDirectives::KEEP_ALIVE); @@ -55,13 +55,13 @@ TEST_CASE("Keep Alive PDU", "[cfdp][pdu]") { } SECTION("Deserialize") { - KeepAlivePduSerializer serializer(pduConf, progress); + KeepAlivePduCreator serializer(pduConf, progress); result = serializer.serialize(&buffer, &sz, kaBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); // Set another file size progress.setFileSize(200, false); - KeepAlivePduDeserializer reader(kaBuffer.data(), kaBuffer.size(), progress); + KeepAlivePduReader reader(kaBuffer.data(), kaBuffer.size(), progress); result = reader.parseData(); REQUIRE(result == returnvalue::OK); auto& progRef = reader.getProgress(); diff --git a/unittests/cfdp/pdu/testNakPdu.cpp b/unittests/cfdp/pdu/testNakPdu.cpp index 954979fc..f2779788 100644 --- a/unittests/cfdp/pdu/testNakPdu.cpp +++ b/unittests/cfdp/pdu/testNakPdu.cpp @@ -1,8 +1,8 @@ #include #include -#include "fsfw/cfdp/pdu/NakPduDeserializer.h" -#include "fsfw/cfdp/pdu/NakPduSerializer.h" +#include "fsfw/cfdp/pdu/NakPduCreator.h" +#include "fsfw/cfdp/pdu/NakPduReader.h" #include "fsfw/cfdp/pdu/PduConfig.h" #include "fsfw/globalfunctions/arrayprinter.h" @@ -21,7 +21,7 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") { FileSize endOfScope(1050); NakInfo info(startOfScope, endOfScope); SECTION("Serializer") { - NakPduSerializer serializer(pduConf, info); + NakPduCreator serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getSerializedSize() == 19); @@ -87,13 +87,13 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") { } SECTION("Deserializer") { - NakPduSerializer serializer(pduConf, info); + NakPduCreator serializer(pduConf, info); result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); info.getStartOfScope().setFileSize(0, false); info.getEndOfScope().setFileSize(0, false); - NakPduDeserializer deserializer(nakBuffer.data(), nakBuffer.size(), info); + NakPduReader deserializer(nakBuffer.data(), nakBuffer.size(), info); result = deserializer.parseData(); REQUIRE(result == returnvalue::OK); REQUIRE(deserializer.getWholePduSize() == 19); @@ -112,7 +112,7 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") { result = serializer.serialize(&buffer, &sz, nakBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); - NakPduDeserializer deserializeWithSegReqs(nakBuffer.data(), nakBuffer.size(), info); + NakPduReader deserializeWithSegReqs(nakBuffer.data(), nakBuffer.size(), info); result = deserializeWithSegReqs.parseData(); REQUIRE(result == returnvalue::OK); NakInfo::SegmentRequest* segReqsPtr = nullptr; @@ -126,14 +126,14 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") { REQUIRE(deserializeWithSegReqs.getPduDataFieldLen() == 25); REQUIRE(info.getSegmentRequestsLen() == 2); for (size_t idx = 0; idx < 34; idx++) { - NakPduDeserializer faultyDeserializer(nakBuffer.data(), idx, info); + NakPduReader faultyDeserializer(nakBuffer.data(), idx, info); result = faultyDeserializer.parseData(); REQUIRE(result != returnvalue::OK); } for (size_t pduFieldLen = 0; pduFieldLen < 25; pduFieldLen++) { nakBuffer[1] = (pduFieldLen >> 8) & 0xff; nakBuffer[2] = pduFieldLen & 0xff; - NakPduDeserializer faultyDeserializer(nakBuffer.data(), nakBuffer.size(), info); + NakPduReader faultyDeserializer(nakBuffer.data(), nakBuffer.size(), info); result = faultyDeserializer.parseData(); if (pduFieldLen == 9) { REQUIRE(info.getSegmentRequestsLen() == 0); diff --git a/unittests/cfdp/pdu/testPromptPdu.cpp b/unittests/cfdp/pdu/testPromptPdu.cpp index 1efd751d..538f6459 100644 --- a/unittests/cfdp/pdu/testPromptPdu.cpp +++ b/unittests/cfdp/pdu/testPromptPdu.cpp @@ -1,8 +1,8 @@ #include #include -#include "fsfw/cfdp/pdu/PromptPduDeserializer.h" -#include "fsfw/cfdp/pdu/PromptPduSerializer.h" +#include "fsfw/cfdp/pdu/PromptPduCreator.h" +#include "fsfw/cfdp/pdu/PromptPduReader.h" #include "fsfw/globalfunctions/arrayprinter.h" TEST_CASE("Prompt PDU", "[cfdp][pdu]") { @@ -17,7 +17,7 @@ TEST_CASE("Prompt PDU", "[cfdp][pdu]") { PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); SECTION("Serialize") { - PromptPduSerializer serializer(pduConf, cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); + PromptPduCreator serializer(pduConf, cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); result = serializer.serialize(&buffer, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getWholePduSize() == 12); @@ -41,11 +41,11 @@ TEST_CASE("Prompt PDU", "[cfdp][pdu]") { } SECTION("Deserialize") { - PromptPduSerializer serializer(pduConf, cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); + PromptPduCreator serializer(pduConf, cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); result = serializer.serialize(&buffer, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); - PromptPduDeserializer deserializer(rawBuf.data(), rawBuf.size()); + PromptPduReader deserializer(rawBuf.data(), rawBuf.size()); result = deserializer.parseData(); REQUIRE(result == returnvalue::OK); REQUIRE(deserializer.getPromptResponseRequired() == From 723f8749d42ba24b13bc7a1606e12139f7cfda5d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Sep 2022 19:52:33 +0200 Subject: [PATCH 369/532] bump changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24bc89fc..d85ad754 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - mib module for the CFDP stack - PDU classes renamed from `...Serializer`/`...Deserializer` to `...Creator`/`...Reader` respetively + - Renamed `TcDistributor` to `TcDistributorBase` to prevent confusion + - Refactored `TcDisitributorBase` to be more flexible and usable for CFDP distribution + - Renamed `CCSDSDistributor` to `CcsdsDistributor` and add feature which allows it + to remove the CCSDS header when routing a packet. This allows CCSDS agnostic receiver + implementation without an extra component PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/682/files # [v5.0.0] 25.07.2022 From 9d626e0a5d8656671f7a846f15186f1d6830c841 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Sep 2022 19:59:02 +0200 Subject: [PATCH 370/532] include correction --- src/fsfw/serviceinterface/ServiceInterfaceStream.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fsfw/serviceinterface/ServiceInterfaceStream.h b/src/fsfw/serviceinterface/ServiceInterfaceStream.h index 0b3d6745..ca746e7d 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceStream.h +++ b/src/fsfw/serviceinterface/ServiceInterfaceStream.h @@ -1,9 +1,8 @@ #ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ -#include - #include "ServiceInterfaceBuffer.h" +#include "fsfw/FSFW.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 From 0849c8a08dca5c44d0907584198395ff216dcc47 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Sep 2022 20:10:41 +0200 Subject: [PATCH 371/532] adding files manually --- src/fsfw/cfdp/CfdpHandler.cpp | 4 +- src/fsfw/cfdp/CfdpHandler.h | 4 +- src/fsfw/pus/CService200ModeCommanding.cpp | 4 +- src/fsfw/pus/CService201HealthCommanding.cpp | 4 +- .../pus/Service11TelecommandScheduling.tpp | 4 +- src/fsfw/pus/Service17Test.cpp | 4 +- src/fsfw/pus/Service20ParameterManagement.cpp | 4 +- src/fsfw/pus/Service2DeviceAccess.cpp | 4 +- src/fsfw/pus/Service3Housekeeping.cpp | 2 +- src/fsfw/pus/Service5EventReporting.cpp | 1 + src/fsfw/pus/Service8FunctionManagement.cpp | 4 +- src/fsfw/pus/Service9TimeManagement.cpp | 4 +- src/fsfw/tcdistribution/CFDPDistributor.h | 4 +- src/fsfw/tcdistribution/CMakeLists.txt | 9 +- .../tcdistribution/CcsdsPacketChecker.cpp | 8 +- src/fsfw/tcdistribution/PusDistributor.cpp | 103 +++++++++--------- src/fsfw/tcdistribution/PusDistributor.h | 37 +++++-- src/fsfw/tcdistribution/PusPacketChecker.cpp | 8 +- src/fsfw/tcdistribution/definitions.h | 23 ++-- src/fsfw/tmtcservices/AcceptsTelecommandsIF.h | 16 +-- src/fsfw/tmtcservices/AcceptsTelemetryIF.h | 2 + .../tmtcservices/CommandingServiceBase.cpp | 18 +-- src/fsfw/tmtcservices/CommandingServiceBase.h | 9 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 14 ++- src/fsfw/tmtcservices/PusServiceBase.h | 12 +- src/fsfw/tmtcservices/TmTcBridge.cpp | 14 ++- src/fsfw/tmtcservices/TmTcBridge.h | 19 ++-- unittests/mocks/AcceptsTmMock.cpp | 2 + unittests/mocks/AcceptsTmMock.h | 1 + 29 files changed, 196 insertions(+), 146 deletions(-) diff --git a/src/fsfw/cfdp/CfdpHandler.cpp b/src/fsfw/cfdp/CfdpHandler.cpp index cfe423e3..cd6caf3c 100644 --- a/src/fsfw/cfdp/CfdpHandler.cpp +++ b/src/fsfw/cfdp/CfdpHandler.cpp @@ -51,6 +51,6 @@ ReturnValue_t CfdpHandler::performOperation(uint8_t opCode) { return returnvalue::OK; } -uint16_t CfdpHandler::getIdentifier() { return 0; } +uint32_t CfdpHandler::getIdentifier() const { return 0; } -MessageQueueId_t CfdpHandler::getRequestQueue() { return this->requestQueue->getId(); } +MessageQueueId_t CfdpHandler::getRequestQueue() const { return this->requestQueue->getId(); } diff --git a/src/fsfw/cfdp/CfdpHandler.h b/src/fsfw/cfdp/CfdpHandler.h index 94bb529e..14058893 100644 --- a/src/fsfw/cfdp/CfdpHandler.h +++ b/src/fsfw/cfdp/CfdpHandler.h @@ -25,8 +25,8 @@ class CfdpHandler : public ExecutableObjectIF, public AcceptsTelecommandsIF, pub virtual ReturnValue_t handleRequest(store_address_t storeId); virtual ReturnValue_t initialize() override; - virtual uint16_t getIdentifier() override; - MessageQueueId_t getRequestQueue() override; + uint32_t getIdentifier() const override; + MessageQueueId_t getRequestQueue() const override; ReturnValue_t performOperation(uint8_t opCode) override; protected: diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index 69c057ea..d28df59b 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -10,8 +10,8 @@ CService200ModeCommanding::CService200ModeCommanding(object_id_t objectId, uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands, uint16_t commandTimeoutSeconds) - : CommandingServiceBase(objectId, apid, serviceId, numParallelCommands, commandTimeoutSeconds) { -} + : CommandingServiceBase(objectId, apid, "PUS 200 Mode MGMT", serviceId, numParallelCommands, + commandTimeoutSeconds) {} CService200ModeCommanding::~CService200ModeCommanding() {} diff --git a/src/fsfw/pus/CService201HealthCommanding.cpp b/src/fsfw/pus/CService201HealthCommanding.cpp index c8458edb..bf21c5bd 100644 --- a/src/fsfw/pus/CService201HealthCommanding.cpp +++ b/src/fsfw/pus/CService201HealthCommanding.cpp @@ -10,8 +10,8 @@ CService201HealthCommanding::CService201HealthCommanding(object_id_t objectId, u uint8_t serviceId, uint8_t numParallelCommands, uint16_t commandTimeoutSeconds) - : CommandingServiceBase(objectId, apid, serviceId, numParallelCommands, commandTimeoutSeconds) { -} + : CommandingServiceBase(objectId, apid, "PUS 201 Health MGMT", serviceId, numParallelCommands, + commandTimeoutSeconds) {} ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) { switch (subservice) { diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 0c750d3c..9016af80 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -16,7 +16,9 @@ inline Service11TelecommandScheduling::Service11TelecommandScheduli : PusServiceBase(params), RELEASE_TIME_MARGIN_SECONDS(releaseTimeMarginSeconds), debugMode(debugMode), - tcRecipient(tcRecipient) {} + tcRecipient(tcRecipient) { + params.name = "PUS 11 TC Scheduling"; +} template inline Service11TelecommandScheduling::~Service11TelecommandScheduling() = default; diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index 0a9db32f..bea2eeb8 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -8,7 +8,9 @@ Service17Test::Service17Test(PsbParams params) : PusServiceBase(params), storeHelper(params.apid), - tmHelper(params.serviceId, storeHelper, sendHelper) {} + tmHelper(params.serviceId, storeHelper, sendHelper) { + params.name = "PUS 17 Test"; +} Service17Test::~Service17Test() = default; diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index f58a0d6c..e12d47bc 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -11,8 +11,8 @@ Service20ParameterManagement::Service20ParameterManagement(object_id_t objectId, uint8_t serviceId, uint8_t numberOfParallelCommands, uint16_t commandTimeoutSeconds) - : CommandingServiceBase(objectId, apid, serviceId, numberOfParallelCommands, - commandTimeoutSeconds) {} + : CommandingServiceBase(objectId, apid, "PUS 20 Parameter MGMT", serviceId, + numberOfParallelCommands, commandTimeoutSeconds) {} Service20ParameterManagement::~Service20ParameterManagement() = default; diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index 6eea1807..517c35e6 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -14,8 +14,8 @@ Service2DeviceAccess::Service2DeviceAccess(object_id_t objectId, uint16_t apid, uint8_t serviceId, uint8_t numberOfParallelCommands, uint16_t commandTimeoutSeconds) - : CommandingServiceBase(objectId, apid, serviceId, numberOfParallelCommands, - commandTimeoutSeconds) {} + : CommandingServiceBase(objectId, apid, "PUS 2 Raw Commanding", serviceId, + numberOfParallelCommands, commandTimeoutSeconds) {} Service2DeviceAccess::~Service2DeviceAccess() {} diff --git a/src/fsfw/pus/Service3Housekeeping.cpp b/src/fsfw/pus/Service3Housekeeping.cpp index 41bb2472..3ce93c70 100644 --- a/src/fsfw/pus/Service3Housekeeping.cpp +++ b/src/fsfw/pus/Service3Housekeeping.cpp @@ -5,7 +5,7 @@ #include "fsfw/pus/servicepackets/Service3Packets.h" Service3Housekeeping::Service3Housekeeping(object_id_t objectId, uint16_t apid, uint8_t serviceId) - : CommandingServiceBase(objectId, apid, serviceId, NUM_OF_PARALLEL_COMMANDS, + : CommandingServiceBase(objectId, apid, "PUS 3 HK", serviceId, NUM_OF_PARALLEL_COMMANDS, COMMAND_TIMEOUT_SECONDS) {} Service3Housekeeping::~Service3Housekeeping() {} diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index 9fbbc8d9..9145920c 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -13,6 +13,7 @@ Service5EventReporting::Service5EventReporting(PsbParams params, size_t maxNumbe storeHelper(params.apid), tmHelper(params.serviceId, storeHelper, sendHelper), maxNumberReportsPerCycle(maxNumberReportsPerCycle) { + psbParams.name = "PUS 5 Event Reporting"; eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); } diff --git a/src/fsfw/pus/Service8FunctionManagement.cpp b/src/fsfw/pus/Service8FunctionManagement.cpp index b9ef6c4d..8b7c6972 100644 --- a/src/fsfw/pus/Service8FunctionManagement.cpp +++ b/src/fsfw/pus/Service8FunctionManagement.cpp @@ -12,8 +12,8 @@ Service8FunctionManagement::Service8FunctionManagement(object_id_t objectId, uin uint8_t serviceId, uint8_t numParallelCommands, uint16_t commandTimeoutSeconds) - : CommandingServiceBase(objectId, apid, serviceId, numParallelCommands, commandTimeoutSeconds) { -} + : CommandingServiceBase(objectId, apid, "PUS 8 Functional Commanding", serviceId, + numParallelCommands, commandTimeoutSeconds) {} Service8FunctionManagement::~Service8FunctionManagement() {} diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 698290c9..d19cb518 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -5,7 +5,9 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/CCSDSTime.h" -Service9TimeManagement::Service9TimeManagement(PsbParams params) : PusServiceBase(params) {} +Service9TimeManagement::Service9TimeManagement(PsbParams params) : PusServiceBase(params) { + params.name = "PUS 9 Time MGMT"; +} Service9TimeManagement::~Service9TimeManagement() = default; diff --git a/src/fsfw/tcdistribution/CFDPDistributor.h b/src/fsfw/tcdistribution/CFDPDistributor.h index 17e79ff3..5d422a71 100644 --- a/src/fsfw/tcdistribution/CFDPDistributor.h +++ b/src/fsfw/tcdistribution/CFDPDistributor.h @@ -33,9 +33,9 @@ class CFDPDistributor : public TcDistributor, */ ~CFDPDistributor() override; ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) override; - MessageQueueId_t getRequestQueue() override; + MessageQueueId_t getRequestQueue() const override; ReturnValue_t initialize() override; - uint16_t getIdentifier() override; + uint32_t getIdentifier() const override; protected: uint16_t apid; diff --git a/src/fsfw/tcdistribution/CMakeLists.txt b/src/fsfw/tcdistribution/CMakeLists.txt index 532ba2ca..bcad563a 100644 --- a/src/fsfw/tcdistribution/CMakeLists.txt +++ b/src/fsfw/tcdistribution/CMakeLists.txt @@ -1,9 +1,4 @@ target_sources( ${LIB_FSFW_NAME} - PRIVATE CCSDSDistributor.cpp - PusDistributor.cpp - TcDistributor.cpp - PusPacketChecker.cpp - TcPacketCheckCFDP.cpp - CFDPDistributor.cpp - CcsdsPacketChecker.cpp) + PRIVATE CcsdsDistributor.cpp PusDistributor.cpp TcDistributorBase.cpp + PusPacketChecker.cpp TcPacketCheckCFDP.cpp CcsdsPacketChecker.cpp) diff --git a/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp b/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp index 08ec1811..977a90a2 100644 --- a/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp +++ b/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp @@ -10,19 +10,19 @@ ReturnValue_t CcsdsPacketChecker::checkPacket(const SpacePacketReader& currentPa size_t packetLen) { if (checkApid) { if (currentPacket.getApid() != apid) { - return tcdistrib::INVALID_APID; + return tmtcdistrib::INVALID_APID; } } if (currentPacket.getVersion() != ccsdsVersion) { - return tcdistrib::INVALID_CCSDS_VERSION; + return tmtcdistrib::INVALID_CCSDS_VERSION; } if (currentPacket.getPacketType() != packetType) { - return tcdistrib::INVALID_PACKET_TYPE; + return tmtcdistrib::INVALID_PACKET_TYPE; } // This assumes that the getFullPacketLen version uses the space packet data length field if (currentPacket.getFullPacketLen() != packetLen) { - return tcdistrib::INCOMPLETE_PACKET; + return tmtcdistrib::INCOMPLETE_PACKET; } return returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index c94d5736..7599114b 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -3,14 +3,14 @@ #include "definitions.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tcdistribution/CCSDSDistributorIF.h" +#include "fsfw/tcdistribution/CcsdsDistributorIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" #define PUS_DISTRIBUTOR_DEBUGGING 0 PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, - CCSDSDistributorIF* distributor, StorageManagerIF* store_) - : TcDistributor(setObjectId), + CcsdsDistributorIF* distributor, StorageManagerIF* store_) + : TcDistributorBase(setObjectId), store(store_), checker(setApid, ccsds::PacketType::TC), ccsdsDistributor(distributor), @@ -18,61 +18,59 @@ PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, PusDistributor::~PusDistributor() = default; -PusDistributor::TcMqMapIter PusDistributor::selectDestination() { +ReturnValue_t PusDistributor::selectDestination(MessageQueueId_t& destId) { #if FSFW_CPP_OSTREAM_ENABLED == 1 && PUS_DISTRIBUTOR_DEBUGGING == 1 store_address_t storeId = currentMessage.getStorageId(); sif::debug << "PUSDistributor::handlePacket received: " << storeId.poolIndex << ", " << storeId.packetIndex << std::endl; #endif - auto queueMapIt = queueMap.end(); // TODO: Need to set the data const uint8_t* packetPtr = nullptr; size_t packetLen = 0; - if (store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != returnvalue::OK) { - return queueMapIt; - } - ReturnValue_t result = reader.setReadOnlyData(packetPtr, packetLen); + ReturnValue_t result = + store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != returnvalue::OK; if (result != returnvalue::OK) { tcStatus = PACKET_LOST; - return queueMapIt; + return result; + } + result = reader.setReadOnlyData(packetPtr, packetLen); + if (result != returnvalue::OK) { + tcStatus = PACKET_LOST; + return result; } // CRC check done by checker result = reader.parseDataWithoutCrcCheck(); if (result != returnvalue::OK) { tcStatus = PACKET_LOST; - return queueMapIt; + return result; } + if (reader.getFullData() != nullptr) { tcStatus = checker.checkPacket(reader, reader.getFullPacketLen()); if (tcStatus != returnvalue::OK) { checkerFailurePrinter(); } - uint32_t queue_id = reader.getService(); - queueMapIt = queueMap.find(queue_id); + uint8_t pusId = reader.getService(); + auto iter = receiverMap.find(pusId); + if (iter == receiverMap.end()) { + tcStatus = DESTINATION_NOT_FOUND; +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl; +#else + sif::printDebug("PUSDistributor::handlePacket: Destination not found\n"); +#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ +#endif + } + destId = iter->second.destId; } else { tcStatus = PACKET_LOST; } - - if (queueMapIt == this->queueMap.end()) { - tcStatus = DESTINATION_NOT_FOUND; -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl; -#else - sif::printDebug("PUSDistributor::handlePacket: Destination not found\n"); -#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif - } - - if (tcStatus != returnvalue::OK) { - return this->queueMap.end(); - } else { - return queueMapIt; - } + return tcStatus; } -ReturnValue_t PusDistributor::registerService(AcceptsTelecommandsIF* service) { - uint16_t serviceId = service->getIdentifier(); +ReturnValue_t PusDistributor::registerService(const AcceptsTelecommandsIF& service) { + uint16_t serviceId = service.getIdentifier(); #if PUS_DISTRIBUTOR_DEBUGGING == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "Service ID: " << static_cast(serviceId) << std::endl; @@ -80,8 +78,8 @@ ReturnValue_t PusDistributor::registerService(AcceptsTelecommandsIF* service) { sif::printInfo("Service ID: %d\n", static_cast(serviceId)); #endif #endif - MessageQueueId_t queue = service->getRequestQueue(); - auto returnPair = queueMap.emplace(serviceId, queue); + MessageQueueId_t queue = service.getRequestQueue(); + auto returnPair = receiverMap.emplace(serviceId, ServiceInfo(service.getName(), queue)); if (not returnPair.second) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -97,7 +95,7 @@ ReturnValue_t PusDistributor::registerService(AcceptsTelecommandsIF* service) { return returnvalue::OK; } -MessageQueueId_t PusDistributor::getRequestQueue() { return tcQueue->getId(); } +MessageQueueId_t PusDistributor::getRequestQueue() const { return tcQueue->getId(); } ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { if (queueStatus != returnvalue::OK) { @@ -115,7 +113,7 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { } } -uint16_t PusDistributor::getIdentifier() { return checker.getApid(); } +uint32_t PusDistributor::getIdentifier() const { return checker.getApid(); } ReturnValue_t PusDistributor::initialize() { if (store == nullptr) { @@ -130,7 +128,7 @@ ReturnValue_t PusDistributor::initialize() { sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; #else sif::printError("PusDistributor::initialize: Packet source invalid\n"); - sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); + sif::printError("Make sure it exists and implements CcsdsDistributorIF\n"); #endif return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -141,28 +139,29 @@ ReturnValue_t PusDistributor::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } } - return ccsdsDistributor->registerApplication(this); + return ccsdsDistributor->registerApplication(CcsdsDistributorIF::DestInfo(*this, false)); } void PusDistributor::checkerFailurePrinter() const { #if FSFW_VERBOSE_LEVEL >= 1 - const char* keyword = "unnamed error"; - if (tcStatus == tcdistrib::INCORRECT_CHECKSUM) { - keyword = "checksum"; - } else if (tcStatus == tcdistrib::INCORRECT_PRIMARY_HEADER) { - keyword = "incorrect primary header"; - } else if (tcStatus == tcdistrib::INVALID_APID) { - keyword = "illegal APID"; - } else if (tcStatus == tcdistrib::INCORRECT_SECONDARY_HEADER) { - keyword = "incorrect secondary header"; - } else if (tcStatus == tcdistrib::INCOMPLETE_PACKET) { - keyword = "incomplete packet"; + const char* reason = "Unknown reason"; + if (tcStatus == tmtcdistrib::INCORRECT_CHECKSUM) { + reason = "Checksum Error"; + } else if (tcStatus == tmtcdistrib::INCORRECT_PRIMARY_HEADER) { + reason = "Incorrect Primary Header"; + } else if (tcStatus == tmtcdistrib::INVALID_APID) { + reason = "Illegal APID"; + } else if (tcStatus == tmtcdistrib::INCORRECT_SECONDARY_HEADER) { + reason = "Incorrect Secondary Header"; + } else if (tcStatus == tmtcdistrib::INCOMPLETE_PACKET) { + reason = "Incomplete packet"; } #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "PUSDistributor::handlePacket: Packet format invalid, " << keyword << " error" - << std::endl; + sif::warning << "PUSDistributor::handlePacket: Check failed: " << reason << std::endl; #else - sif::printWarning("PUSDistributor::handlePacket: Packet format invalid, %s error\n", keyword); + sif::printWarning("PUSDistributor::handlePacket: Check failed: %s\n", reason); #endif #endif } + +const char* PusDistributor::getName() const { return "PUS Distributor"; } diff --git a/src/fsfw/tcdistribution/PusDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h index d2265f95..206f112a 100644 --- a/src/fsfw/tcdistribution/PusDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -1,15 +1,17 @@ #ifndef FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ #define FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ -#include "PUSDistributorIF.h" +#include + +#include "PusDistributorIF.h" #include "PusPacketChecker.h" -#include "TcDistributor.h" +#include "TcDistributorBase.h" #include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tmtcpacket/pus/tc.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/VerificationReporter.h" -class CCSDSDistributorIF; +class CcsdsDistributorIF; /** * This class accepts PUS Telecommands and forwards them to Application @@ -17,7 +19,9 @@ class CCSDSDistributorIF; * sends acceptance success or failure messages. * @ingroup tc_distribution */ -class PusDistributor : public TcDistributor, public PUSDistributorIF, public AcceptsTelecommandsIF { +class PusDistributor : public TcDistributorBase, + public PusDistributorIF, + public AcceptsTelecommandsIF { public: /** * The ctor passes @c set_apid to the checker class and calls the @@ -25,20 +29,31 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc * @param setApid The APID of this receiving Application. * @param setObjectId Object ID of the distributor itself * @param setPacketSource Object ID of the source of TC packets. - * Must implement CCSDSDistributorIF. + * Must implement CcsdsDistributorIF. */ - PusDistributor(uint16_t setApid, object_id_t setObjectId, CCSDSDistributorIF* packetSource, + PusDistributor(uint16_t setApid, object_id_t setObjectId, CcsdsDistributorIF* packetSource, StorageManagerIF* store = nullptr); + [[nodiscard]] const char* getName() const override; /** * The destructor is empty. */ ~PusDistributor() override; - ReturnValue_t registerService(AcceptsTelecommandsIF* service) override; - MessageQueueId_t getRequestQueue() override; + ReturnValue_t registerService(const AcceptsTelecommandsIF& service) override; + [[nodiscard]] MessageQueueId_t getRequestQueue() const override; ReturnValue_t initialize() override; - uint16_t getIdentifier() override; + [[nodiscard]] uint32_t getIdentifier() const override; protected: + struct ServiceInfo { + ServiceInfo(const char* name, MessageQueueId_t destId) : name(name), destId(destId) {} + + const char* name; + MessageQueueId_t destId; + }; + /// PUS recipient map. The key value will generally be the PUS Service + using PusReceiverMap = std::map; + + PusReceiverMap receiverMap; StorageManagerIF* store; /** * This attribute contains the class, that performs a formal packet check. @@ -50,7 +65,7 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc */ VerificationReporterIF* verifyChannel = nullptr; //! Cached for initialization - CCSDSDistributorIF* ccsdsDistributor = nullptr; + CcsdsDistributorIF* ccsdsDistributor = nullptr; PusTcReader reader; /** @@ -67,7 +82,7 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc * @return Iterator to map entry of found service id * or iterator to @c map.end(). */ - TcMqMapIter selectDestination() override; + ReturnValue_t selectDestination(MessageQueueId_t& destId) override; /** * The callback here handles the generation of acceptance * success/failure messages. diff --git a/src/fsfw/tcdistribution/PusPacketChecker.cpp b/src/fsfw/tcdistribution/PusPacketChecker.cpp index dc5b9ab9..55a7934c 100644 --- a/src/fsfw/tcdistribution/PusPacketChecker.cpp +++ b/src/fsfw/tcdistribution/PusPacketChecker.cpp @@ -12,17 +12,17 @@ PusPacketChecker::PusPacketChecker(uint16_t apid, ccsds::PacketType packetType_, ReturnValue_t PusPacketChecker::checkPacket(const PusTcReader& pusPacket, size_t packetLen) { // Other primary header fields are checked by base class if (not pusPacket.hasSecHeader()) { - return tcdistrib::INVALID_SEC_HEADER_FIELD; + return tmtcdistrib::INVALID_SEC_HEADER_FIELD; } uint16_t calculated_crc = CRC::crc16ccitt(pusPacket.getFullData(), pusPacket.getFullPacketLen()); if (calculated_crc != 0) { - return tcdistrib::INCORRECT_CHECKSUM; + return tmtcdistrib::INCORRECT_CHECKSUM; } if (pusPacket.getApid() != apid) { - return tcdistrib::INVALID_APID; + return tmtcdistrib::INVALID_APID; } if (pusPacket.getPusVersion() != pusVersion) { - return tcdistrib::INVALID_PUS_VERSION; + return tmtcdistrib::INVALID_PUS_VERSION; } return returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/definitions.h b/src/fsfw/tcdistribution/definitions.h index 3d455077..01fc3085 100644 --- a/src/fsfw/tcdistribution/definitions.h +++ b/src/fsfw/tcdistribution/definitions.h @@ -3,16 +3,19 @@ #include +#include "fsfw/events/Event.h" +#include "fsfw/events/fwSubsystemIdRanges.h" #include "fsfw/returnvalues/FwClassIds.h" #include "fsfw/returnvalues/returnvalue.h" -namespace tcdistrib { -static const uint8_t INTERFACE_ID = CLASS_ID::PACKET_CHECK; -static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(0); -static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(1); -static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(2); -static constexpr ReturnValue_t INVALID_SEC_HEADER_FIELD = MAKE_RETURN_CODE(3); -static constexpr ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE(4); +namespace tmtcdistrib { +static const uint8_t INTERFACE_ID = CLASS_ID::TMTC_DISTRIBUTION; +static constexpr ReturnValue_t NO_DESTINATION_FOUND = returnvalue::makeCode(INTERFACE_ID, 0); +static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(1); +static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(2); +static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(3); +static constexpr ReturnValue_t INVALID_SEC_HEADER_FIELD = MAKE_RETURN_CODE(4); +static constexpr ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE(5); static constexpr ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE(5); static constexpr ReturnValue_t INVALID_PUS_VERSION = MAKE_RETURN_CODE(6); @@ -20,5 +23,9 @@ static constexpr ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE(7); static constexpr ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE(8); static constexpr ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE(9); -}; // namespace tcdistrib +static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TMTC_DISTRIBUTION; +//! P1: Returnvalue, P2: 0 for TM issues, 1 for TC issues +static constexpr Event HANDLE_PACKET_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); + +}; // namespace tmtcdistrib #endif // FSFW_TMTCPACKET_DEFINITIONS_H diff --git a/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h b/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h index e18a4f3a..6c214b0f 100644 --- a/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h +++ b/src/fsfw/tmtcservices/AcceptsTelecommandsIF.h @@ -21,20 +21,22 @@ class AcceptsTelecommandsIF { * @brief The virtual destructor as it is mandatory for C++ interfaces. */ virtual ~AcceptsTelecommandsIF() = default; + [[nodiscard]] virtual const char* getName() const = 0; + /** - * @brief Getter for the service id. - * @details Any receiving service (at least any PUS service) shall have a - * service ID. If the receiver can handle Telecommands, but for - * some reason has no service id, it shall return 0. - * @return The service ID or 0. + * @brief Getter for a generic identifier ID. + * @details Any receiving service (at least any PUS service) shall have an identifier. For + * example, this could be the APID for a receiver expecting generic PUS packets, or a PUS + * service for a component expecting specific PUS service packets. + * @return The identifier. */ - virtual uint16_t getIdentifier() = 0; + [[nodiscard]] virtual uint32_t getIdentifier() const = 0; /** * @brief This method returns the message queue id of the telecommand * receiving message queue. * @return The telecommand reception message queue id. */ - virtual MessageQueueId_t getRequestQueue() = 0; + [[nodiscard]] virtual MessageQueueId_t getRequestQueue() const = 0; }; #endif /* FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_ */ diff --git a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h index 6f8a6226..c3e3eff3 100644 --- a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h +++ b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h @@ -14,6 +14,8 @@ class AcceptsTelemetryIF { * @brief The virtual destructor as it is mandatory for C++ interfaces. */ virtual ~AcceptsTelemetryIF() = default; + + [[nodiscard]] virtual const char* getName() const = 0; /** * @brief This method returns the message queue id of the telemetry * receiving message queue. diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 63db51ff..1ec5c0d8 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -3,7 +3,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tcdistribution/PUSDistributorIF.h" +#include "fsfw/tcdistribution/PusDistributorIF.h" #include "fsfw/tmtcpacket/pus/tc.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/TmTcMessage.h" @@ -14,7 +14,8 @@ object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; object_id_t CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t apid, - uint8_t service, uint8_t numberOfParallelCommands, + const char* name, uint8_t service, + uint8_t numberOfParallelCommands, uint16_t commandTimeoutSeconds, size_t queueDepth, VerificationReporterIF* verificationReporter) : SystemObject(setObjectId), @@ -24,7 +25,8 @@ CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, uint16_t a tmStoreHelper(apid), tmHelper(service, tmStoreHelper, tmSendHelper), verificationReporter(verificationReporter), - commandMap(numberOfParallelCommands) { + commandMap(numberOfParallelCommands), + name(name) { commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth); } @@ -50,9 +52,9 @@ ReturnValue_t CommandingServiceBase::performOperation(uint8_t opCode) { return returnvalue::OK; } -uint16_t CommandingServiceBase::getIdentifier() { return service; } +uint32_t CommandingServiceBase::getIdentifier() const { return service; } -MessageQueueId_t CommandingServiceBase::getRequestQueue() { return requestQueue->getId(); } +MessageQueueId_t CommandingServiceBase::getRequestQueue() const { return requestQueue->getId(); } ReturnValue_t CommandingServiceBase::initialize() { ReturnValue_t result = SystemObject::initialize(); @@ -68,7 +70,7 @@ ReturnValue_t CommandingServiceBase::initialize() { if (packetSource == objects::NO_OBJECT) { packetSource = defaultPacketSource; } - auto* distributor = ObjectManager::instance()->get(packetSource); + auto* distributor = ObjectManager::instance()->get(packetSource); if (packetForwarding == nullptr or distributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -79,7 +81,7 @@ ReturnValue_t CommandingServiceBase::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - distributor->registerService(this); + distributor->registerService(*this); requestQueue->setDefaultDestination(packetForwarding->getReportReceptionQueue()); ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); @@ -489,3 +491,5 @@ void CommandingServiceBase::prepareVerificationSuccessWithFullInfo( successParams.tcPsc = tcInfo.tcSequenceControl; successParams.ackFlags = tcInfo.ackFlags; } + +const char* CommandingServiceBase::getName() const { return name; } diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 303d6d2e..92369b58 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -75,7 +75,7 @@ class CommandingServiceBase : public SystemObject, * @param setPacketDestination * @param queueDepth */ - CommandingServiceBase(object_id_t setObjectId, uint16_t apid, uint8_t service, + CommandingServiceBase(object_id_t setObjectId, uint16_t apid, const char* name, uint8_t service, uint8_t numberOfParallelCommands, uint16_t commandTimeoutSeconds, size_t queueDepth = 20, VerificationReporterIF* reporter = nullptr); ~CommandingServiceBase() override; @@ -105,7 +105,7 @@ class CommandingServiceBase : public SystemObject, */ ReturnValue_t performOperation(uint8_t opCode) override; - uint16_t getIdentifier() override; + uint32_t getIdentifier() const override; /** * Returns the requestQueue MessageQueueId_t @@ -114,7 +114,7 @@ class CommandingServiceBase : public SystemObject, * * @return requestQueue messageQueueId_t */ - MessageQueueId_t getRequestQueue() override; + MessageQueueId_t getRequestQueue() const override; /** * Returns the commandQueue MessageQueueId_t @@ -133,6 +133,7 @@ class CommandingServiceBase : public SystemObject, * @param task Pointer to the taskIF of this task */ void setTaskIF(PeriodicTaskIF* task) override; + const char* getName() const override; protected: /** @@ -283,6 +284,8 @@ class CommandingServiceBase : public SystemObject, uint32_t failureParameter1 = 0; uint32_t failureParameter2 = 0; + const char* name = ""; + static object_id_t defaultPacketSource; object_id_t packetSource = objects::NO_OBJECT; static object_id_t defaultPacketDestination; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 091ab2f8..9598e536 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -3,7 +3,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tcdistribution/PUSDistributorIF.h" +#include "fsfw/tcdistribution/PusDistributorIF.h" #include "fsfw/timemanager/CdsShortTimeStamper.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" @@ -82,9 +82,9 @@ void PusServiceBase::handleRequestQueue() { } } -uint16_t PusServiceBase::getIdentifier() { return psbParams.serviceId; } +uint32_t PusServiceBase::getIdentifier() const { return psbParams.serviceId; } -MessageQueueId_t PusServiceBase::getRequestQueue() { +MessageQueueId_t PusServiceBase::getRequestQueue() const { if (psbParams.reqQueue == nullptr) { return MessageQueueIF::NO_QUEUE; } @@ -111,7 +111,7 @@ ReturnValue_t PusServiceBase::initialize() { } if (psbParams.pusDistributor == nullptr) { - psbParams.pusDistributor = ObjectManager::instance()->get(PUS_DISTRIBUTOR); + psbParams.pusDistributor = ObjectManager::instance()->get(PUS_DISTRIBUTOR); if (psbParams.pusDistributor != nullptr) { registerService(*psbParams.pusDistributor); } @@ -193,8 +193,8 @@ void PusServiceBase::setVerificationReporter(VerificationReporterIF& reporter) { psbParams.verifReporter = &reporter; } -ReturnValue_t PusServiceBase::registerService(PUSDistributorIF& distributor) { - return distributor.registerService(this); +ReturnValue_t PusServiceBase::registerService(PusDistributorIF& distributor) { + return distributor.registerService(*this); } void PusServiceBase::setTmReceiver(AcceptsTelemetryIF& tmReceiver_) { @@ -202,3 +202,5 @@ void PusServiceBase::setTmReceiver(AcceptsTelemetryIF& tmReceiver_) { } void PusServiceBase::setRequestQueue(MessageQueueIF& reqQueue) { psbParams.reqQueue = &reqQueue; } + +const char* PusServiceBase::getName() const { return psbParams.name; } diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 8a4f3cd0..befd3240 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -22,9 +22,13 @@ class StorageManagerIF; struct PsbParams { PsbParams() = default; PsbParams(uint16_t apid, AcceptsTelemetryIF* tmReceiver) : apid(apid), tmReceiver(tmReceiver) {} + PsbParams(const char* name, uint16_t apid, AcceptsTelemetryIF* tmReceiver) + : name(name), apid(apid), tmReceiver(tmReceiver) {} PsbParams(object_id_t objectId, uint16_t apid, uint8_t serviceId) : objectId(objectId), apid(apid), serviceId(serviceId) {} - + PsbParams(const char* name, object_id_t objectId, uint16_t apid, uint8_t serviceId) + : name(name), objectId(objectId), apid(apid), serviceId(serviceId) {} + const char* name = ""; object_id_t objectId = objects::NO_OBJECT; uint16_t apid = 0; uint8_t serviceId = 0; @@ -187,11 +191,12 @@ class PusServiceBase : public ExecutableObjectIF, * @c returnvalue::FAILED else. */ ReturnValue_t performOperation(uint8_t opCode) override; - uint16_t getIdentifier() override; - MessageQueueId_t getRequestQueue() override; + uint32_t getIdentifier() const override; + MessageQueueId_t getRequestQueue() const override; ReturnValue_t initialize() override; void setTaskIF(PeriodicTaskIF* taskHandle) override; + [[nodiscard]] const char* getName() const override; protected: /** @@ -200,6 +205,7 @@ class PusServiceBase : public ExecutableObjectIF, * Will be set by setTaskIF(), which is called on task creation. */ PeriodicTaskIF* taskHandle = nullptr; + /** * One of two error parameters for additional error information. */ diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index f4ea50d0..0e9f0da4 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -7,9 +7,10 @@ #define TMTCBRIDGE_WIRETAPPING 0 -TmTcBridge::TmTcBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, - object_id_t tcStoreId) +TmTcBridge::TmTcBridge(const char* name, object_id_t objectId, object_id_t tcDestination, + object_id_t tmStoreId, object_id_t tcStoreId) : SystemObject(objectId), + name(name), tmStoreId(tmStoreId), tcStoreId(tcStoreId), tcDestination(tcDestination) @@ -67,8 +68,7 @@ ReturnValue_t TmTcBridge::initialize() { #endif return ObjectManagerIF::CHILD_INIT_FAILED; } - AcceptsTelecommandsIF* tcDistributor = - ObjectManager::instance()->get(tcDestination); + auto* tcDistributor = ObjectManager::instance()->get(tcDestination); if (tcDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::initialize: TC Distributor invalid" << std::endl; @@ -246,14 +246,16 @@ MessageQueueId_t TmTcBridge::getReportReceptionQueue(uint8_t virtualChannel) { void TmTcBridge::printData(uint8_t* data, size_t dataLen) { arrayprinter::print(data, dataLen); } -uint16_t TmTcBridge::getIdentifier() { +uint32_t TmTcBridge::getIdentifier() const { // This is no PUS service, so we just return 0 return 0; } -MessageQueueId_t TmTcBridge::getRequestQueue() { +MessageQueueId_t TmTcBridge::getRequestQueue() const { // Default implementation: Relay TC messages to TC distributor directly. return tmTcReceptionQueue->getDefaultDestination(); } void TmTcBridge::setFifoToOverwriteOldData(bool overwriteOld) { this->overwriteOld = overwriteOld; } + +const char* TmTcBridge::getName() const { return name; } diff --git a/src/fsfw/tmtcservices/TmTcBridge.h b/src/fsfw/tmtcservices/TmTcBridge.h index 9d97ed17..4b90d1d5 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.h +++ b/src/fsfw/tmtcservices/TmTcBridge.h @@ -22,9 +22,9 @@ class TmTcBridge : public AcceptsTelemetryIF, static constexpr uint8_t DEFAULT_STORED_DATA_SENT_PER_CYCLE = 5; static constexpr uint8_t DEFAULT_DOWNLINK_PACKETS_STORED = 10; - TmTcBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, - object_id_t tcStoreId); - virtual ~TmTcBridge(); + TmTcBridge(const char* name, object_id_t objectId, object_id_t tcDestination, + object_id_t tmStoreId, object_id_t tcStoreId); + ~TmTcBridge() override; /** * Set number of packets sent per performOperation().Please note that this @@ -57,21 +57,24 @@ class TmTcBridge : public AcceptsTelemetryIF, * Initializes necessary FSFW components for the TMTC Bridge * @return */ - virtual ReturnValue_t initialize() override; + ReturnValue_t initialize() override; /** * @brief Handles TMTC reception */ - virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t performOperation(uint8_t operationCode = 0) override; /** AcceptsTelemetryIF override */ - virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; /** AcceptsTelecommandsIF override */ - virtual uint16_t getIdentifier() override; - virtual MessageQueueId_t getRequestQueue() override; + uint32_t getIdentifier() const override; + MessageQueueId_t getRequestQueue() const override; + const char* getName() const override; protected: + const char* name = ""; + //! Cached for initialize function. object_id_t tmStoreId = objects::NO_OBJECT; object_id_t tcStoreId = objects::NO_OBJECT; diff --git a/unittests/mocks/AcceptsTmMock.cpp b/unittests/mocks/AcceptsTmMock.cpp index 5b1e0d05..7b997047 100644 --- a/unittests/mocks/AcceptsTmMock.cpp +++ b/unittests/mocks/AcceptsTmMock.cpp @@ -9,3 +9,5 @@ AcceptsTmMock::AcceptsTmMock(MessageQueueId_t queueToReturn) MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) { return returnedQueue; } + +const char* AcceptsTmMock::getName() const { return "TM Acceptor Mock"; } diff --git a/unittests/mocks/AcceptsTmMock.h b/unittests/mocks/AcceptsTmMock.h index a9422eb4..d6cc7f85 100644 --- a/unittests/mocks/AcceptsTmMock.h +++ b/unittests/mocks/AcceptsTmMock.h @@ -10,6 +10,7 @@ class AcceptsTmMock : public SystemObject, public AcceptsTelemetryIF { explicit AcceptsTmMock(MessageQueueId_t queueToReturn); MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override; + const char* getName() const override; MessageQueueId_t returnedQueue; }; From 237e29cc593ade15dc7ef942eab091257e601685 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Sep 2022 20:21:03 +0200 Subject: [PATCH 372/532] all necessary modifications --- src/fsfw/osal/common/TcpTmTcBridge.cpp | 2 +- src/fsfw/osal/common/UdpTmTcBridge.cpp | 2 +- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 4 +- src/fsfw/tcdistribution/CCSDSDistributor.h | 4 +- src/fsfw/tcdistribution/CMakeLists.txt | 4 +- .../tcdistribution/CcsdsPacketChecker.cpp | 8 +- src/fsfw/tcdistribution/PusDistributor.cpp | 97 ++++++++++--------- src/fsfw/tcdistribution/PusDistributor.h | 37 +++---- src/fsfw/tcdistribution/PusPacketChecker.cpp | 8 +- src/fsfw/tcdistribution/definitions.h | 23 ++--- .../tmtcservices/CommandingServiceBase.cpp | 6 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 8 +- 12 files changed, 91 insertions(+), 112 deletions(-) diff --git a/src/fsfw/osal/common/TcpTmTcBridge.cpp b/src/fsfw/osal/common/TcpTmTcBridge.cpp index 6b3561ba..f99a8bc1 100644 --- a/src/fsfw/osal/common/TcpTmTcBridge.cpp +++ b/src/fsfw/osal/common/TcpTmTcBridge.cpp @@ -18,7 +18,7 @@ TcpTmTcBridge::TcpTmTcBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, object_id_t tcStoreId) - : TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { + : TmTcBridge("TCP TMTC Bridge", objectId, tcDestination, tmStoreId, tcStoreId) { mutex = MutexFactory::instance()->createMutex(); // Connection is always up, TM is requested by connecting to server and receiving packets registerCommConnect(); diff --git a/src/fsfw/osal/common/UdpTmTcBridge.cpp b/src/fsfw/osal/common/UdpTmTcBridge.cpp index 0a847271..c0848ceb 100644 --- a/src/fsfw/osal/common/UdpTmTcBridge.cpp +++ b/src/fsfw/osal/common/UdpTmTcBridge.cpp @@ -22,7 +22,7 @@ const std::string UdpTmTcBridge::DEFAULT_SERVER_PORT = tcpip::DEFAULT_SERVER_POR UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, const std::string &udpServerPort_, object_id_t tmStoreId, object_id_t tcStoreId) - : TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { + : TmTcBridge("UDP TMTC Bridge", objectId, tcDestination, tmStoreId, tcStoreId) { if (udpServerPort_.empty()) { udpServerPort = DEFAULT_SERVER_PORT; } else { diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index db408e6d..22cc31cd 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -59,7 +59,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { } } -MessageQueueId_t CCSDSDistributor::getRequestQueue() { return tcQueue->getId(); } +MessageQueueId_t CCSDSDistributor::getRequestQueue() const { return tcQueue->getId(); } ReturnValue_t CCSDSDistributor::registerApplication(AcceptsTelecommandsIF* application) { ReturnValue_t returnValue = returnvalue::OK; @@ -80,7 +80,7 @@ ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid, MessageQueueI return returnValue; } -uint16_t CCSDSDistributor::getIdentifier() { return 0; } +uint32_t CCSDSDistributor::getIdentifier() const { return 0; } ReturnValue_t CCSDSDistributor::initialize() { if (packetChecker == nullptr) { diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.h b/src/fsfw/tcdistribution/CCSDSDistributor.h index d6e4f0e7..a7a54004 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.h +++ b/src/fsfw/tcdistribution/CCSDSDistributor.h @@ -35,10 +35,10 @@ class CCSDSDistributor : public TcDistributor, */ ~CCSDSDistributor() override; - MessageQueueId_t getRequestQueue() override; + MessageQueueId_t getRequestQueue() const override; ReturnValue_t registerApplication(uint16_t apid, MessageQueueId_t id) override; ReturnValue_t registerApplication(AcceptsTelecommandsIF* application) override; - uint16_t getIdentifier() override; + uint32_t getIdentifier() const override; ReturnValue_t initialize() override; protected: diff --git a/src/fsfw/tcdistribution/CMakeLists.txt b/src/fsfw/tcdistribution/CMakeLists.txt index bcad563a..2f7ee235 100644 --- a/src/fsfw/tcdistribution/CMakeLists.txt +++ b/src/fsfw/tcdistribution/CMakeLists.txt @@ -1,4 +1,4 @@ target_sources( ${LIB_FSFW_NAME} - PRIVATE CcsdsDistributor.cpp PusDistributor.cpp TcDistributorBase.cpp - PusPacketChecker.cpp TcPacketCheckCFDP.cpp CcsdsPacketChecker.cpp) + PRIVATE CCSDSDistributor.cpp PusDistributor.cpp TcDistributor.cpp + TcPacketCheckCFDP.cpp CcsdsPacketChecker.cpp) diff --git a/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp b/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp index 977a90a2..08ec1811 100644 --- a/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp +++ b/src/fsfw/tcdistribution/CcsdsPacketChecker.cpp @@ -10,19 +10,19 @@ ReturnValue_t CcsdsPacketChecker::checkPacket(const SpacePacketReader& currentPa size_t packetLen) { if (checkApid) { if (currentPacket.getApid() != apid) { - return tmtcdistrib::INVALID_APID; + return tcdistrib::INVALID_APID; } } if (currentPacket.getVersion() != ccsdsVersion) { - return tmtcdistrib::INVALID_CCSDS_VERSION; + return tcdistrib::INVALID_CCSDS_VERSION; } if (currentPacket.getPacketType() != packetType) { - return tmtcdistrib::INVALID_PACKET_TYPE; + return tcdistrib::INVALID_PACKET_TYPE; } // This assumes that the getFullPacketLen version uses the space packet data length field if (currentPacket.getFullPacketLen() != packetLen) { - return tmtcdistrib::INCOMPLETE_PACKET; + return tcdistrib::INCOMPLETE_PACKET; } return returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 7599114b..eb6850e5 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -3,14 +3,14 @@ #include "definitions.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tcdistribution/CcsdsDistributorIF.h" +#include "fsfw/tcdistribution/CCSDSDistributorIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" #define PUS_DISTRIBUTOR_DEBUGGING 0 PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, - CcsdsDistributorIF* distributor, StorageManagerIF* store_) - : TcDistributorBase(setObjectId), + CCSDSDistributorIF* distributor, StorageManagerIF* store_) + : TcDistributor(setObjectId), store(store_), checker(setApid, ccsds::PacketType::TC), ccsdsDistributor(distributor), @@ -18,59 +18,61 @@ PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, PusDistributor::~PusDistributor() = default; -ReturnValue_t PusDistributor::selectDestination(MessageQueueId_t& destId) { +PusDistributor::TcMqMapIter PusDistributor::selectDestination() { #if FSFW_CPP_OSTREAM_ENABLED == 1 && PUS_DISTRIBUTOR_DEBUGGING == 1 store_address_t storeId = currentMessage.getStorageId(); sif::debug << "PUSDistributor::handlePacket received: " << storeId.poolIndex << ", " << storeId.packetIndex << std::endl; #endif + auto queueMapIt = queueMap.end(); // TODO: Need to set the data const uint8_t* packetPtr = nullptr; size_t packetLen = 0; - ReturnValue_t result = - store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != returnvalue::OK; - if (result != returnvalue::OK) { - tcStatus = PACKET_LOST; - return result; + if (store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != returnvalue::OK) { + return queueMapIt; } - result = reader.setReadOnlyData(packetPtr, packetLen); + ReturnValue_t result = reader.setReadOnlyData(packetPtr, packetLen); if (result != returnvalue::OK) { tcStatus = PACKET_LOST; - return result; + return queueMapIt; } // CRC check done by checker result = reader.parseDataWithoutCrcCheck(); if (result != returnvalue::OK) { tcStatus = PACKET_LOST; - return result; + return queueMapIt; } - if (reader.getFullData() != nullptr) { tcStatus = checker.checkPacket(reader, reader.getFullPacketLen()); if (tcStatus != returnvalue::OK) { checkerFailurePrinter(); } - uint8_t pusId = reader.getService(); - auto iter = receiverMap.find(pusId); - if (iter == receiverMap.end()) { - tcStatus = DESTINATION_NOT_FOUND; -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl; -#else - sif::printDebug("PUSDistributor::handlePacket: Destination not found\n"); -#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif - } - destId = iter->second.destId; + uint32_t queue_id = reader.getService(); + queueMapIt = queueMap.find(queue_id); } else { tcStatus = PACKET_LOST; } - return tcStatus; + + if (queueMapIt == this->queueMap.end()) { + tcStatus = DESTINATION_NOT_FOUND; +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl; +#else + sif::printDebug("PUSDistributor::handlePacket: Destination not found\n"); +#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */ +#endif + } + + if (tcStatus != returnvalue::OK) { + return this->queueMap.end(); + } else { + return queueMapIt; + } } -ReturnValue_t PusDistributor::registerService(const AcceptsTelecommandsIF& service) { - uint16_t serviceId = service.getIdentifier(); +ReturnValue_t PusDistributor::registerService(AcceptsTelecommandsIF* service) { + uint16_t serviceId = service->getIdentifier(); #if PUS_DISTRIBUTOR_DEBUGGING == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "Service ID: " << static_cast(serviceId) << std::endl; @@ -78,8 +80,8 @@ ReturnValue_t PusDistributor::registerService(const AcceptsTelecommandsIF& servi sif::printInfo("Service ID: %d\n", static_cast(serviceId)); #endif #endif - MessageQueueId_t queue = service.getRequestQueue(); - auto returnPair = receiverMap.emplace(serviceId, ServiceInfo(service.getName(), queue)); + MessageQueueId_t queue = service->getRequestQueue(); + auto returnPair = queueMap.emplace(serviceId, queue); if (not returnPair.second) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -128,7 +130,7 @@ ReturnValue_t PusDistributor::initialize() { sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; #else sif::printError("PusDistributor::initialize: Packet source invalid\n"); - sif::printError("Make sure it exists and implements CcsdsDistributorIF\n"); + sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); #endif return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -139,29 +141,28 @@ ReturnValue_t PusDistributor::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } } - return ccsdsDistributor->registerApplication(CcsdsDistributorIF::DestInfo(*this, false)); + return ccsdsDistributor->registerApplication(this); } void PusDistributor::checkerFailurePrinter() const { #if FSFW_VERBOSE_LEVEL >= 1 - const char* reason = "Unknown reason"; - if (tcStatus == tmtcdistrib::INCORRECT_CHECKSUM) { - reason = "Checksum Error"; - } else if (tcStatus == tmtcdistrib::INCORRECT_PRIMARY_HEADER) { - reason = "Incorrect Primary Header"; - } else if (tcStatus == tmtcdistrib::INVALID_APID) { - reason = "Illegal APID"; - } else if (tcStatus == tmtcdistrib::INCORRECT_SECONDARY_HEADER) { - reason = "Incorrect Secondary Header"; - } else if (tcStatus == tmtcdistrib::INCOMPLETE_PACKET) { - reason = "Incomplete packet"; + const char* keyword = "unnamed error"; + if (tcStatus == tcdistrib::INCORRECT_CHECKSUM) { + keyword = "checksum"; + } else if (tcStatus == tcdistrib::INCORRECT_PRIMARY_HEADER) { + keyword = "incorrect primary header"; + } else if (tcStatus == tcdistrib::INVALID_APID) { + keyword = "illegal APID"; + } else if (tcStatus == tcdistrib::INCORRECT_SECONDARY_HEADER) { + keyword = "incorrect secondary header"; + } else if (tcStatus == tcdistrib::INCOMPLETE_PACKET) { + keyword = "incomplete packet"; } #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "PUSDistributor::handlePacket: Check failed: " << reason << std::endl; + sif::warning << "PUSDistributor::handlePacket: Packet format invalid, " << keyword << " error" + << std::endl; #else - sif::printWarning("PUSDistributor::handlePacket: Check failed: %s\n", reason); + sif::printWarning("PUSDistributor::handlePacket: Packet format invalid, %s error\n", keyword); #endif #endif } - -const char* PusDistributor::getName() const { return "PUS Distributor"; } diff --git a/src/fsfw/tcdistribution/PusDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h index 206f112a..39a50d9a 100644 --- a/src/fsfw/tcdistribution/PusDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -1,17 +1,15 @@ #ifndef FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ #define FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ -#include - -#include "PusDistributorIF.h" +#include "PUSDistributorIF.h" #include "PusPacketChecker.h" -#include "TcDistributorBase.h" +#include "TcDistributor.h" #include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tmtcpacket/pus/tc.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/VerificationReporter.h" -class CcsdsDistributorIF; +class CCSDSDistributorIF; /** * This class accepts PUS Telecommands and forwards them to Application @@ -19,9 +17,7 @@ class CcsdsDistributorIF; * sends acceptance success or failure messages. * @ingroup tc_distribution */ -class PusDistributor : public TcDistributorBase, - public PusDistributorIF, - public AcceptsTelecommandsIF { +class PusDistributor : public TcDistributor, public PUSDistributorIF, public AcceptsTelecommandsIF { public: /** * The ctor passes @c set_apid to the checker class and calls the @@ -29,31 +25,20 @@ class PusDistributor : public TcDistributorBase, * @param setApid The APID of this receiving Application. * @param setObjectId Object ID of the distributor itself * @param setPacketSource Object ID of the source of TC packets. - * Must implement CcsdsDistributorIF. + * Must implement CCSDSDistributorIF. */ - PusDistributor(uint16_t setApid, object_id_t setObjectId, CcsdsDistributorIF* packetSource, + PusDistributor(uint16_t setApid, object_id_t setObjectId, CCSDSDistributorIF* packetSource, StorageManagerIF* store = nullptr); - [[nodiscard]] const char* getName() const override; /** * The destructor is empty. */ ~PusDistributor() override; - ReturnValue_t registerService(const AcceptsTelecommandsIF& service) override; - [[nodiscard]] MessageQueueId_t getRequestQueue() const override; + ReturnValue_t registerService(AcceptsTelecommandsIF* service) override; + MessageQueueId_t getRequestQueue() const override; ReturnValue_t initialize() override; - [[nodiscard]] uint32_t getIdentifier() const override; + uint32_t getIdentifier() const override; protected: - struct ServiceInfo { - ServiceInfo(const char* name, MessageQueueId_t destId) : name(name), destId(destId) {} - - const char* name; - MessageQueueId_t destId; - }; - /// PUS recipient map. The key value will generally be the PUS Service - using PusReceiverMap = std::map; - - PusReceiverMap receiverMap; StorageManagerIF* store; /** * This attribute contains the class, that performs a formal packet check. @@ -65,7 +50,7 @@ class PusDistributor : public TcDistributorBase, */ VerificationReporterIF* verifyChannel = nullptr; //! Cached for initialization - CcsdsDistributorIF* ccsdsDistributor = nullptr; + CCSDSDistributorIF* ccsdsDistributor = nullptr; PusTcReader reader; /** @@ -82,7 +67,7 @@ class PusDistributor : public TcDistributorBase, * @return Iterator to map entry of found service id * or iterator to @c map.end(). */ - ReturnValue_t selectDestination(MessageQueueId_t& destId) override; + TcMqMapIter selectDestination() override; /** * The callback here handles the generation of acceptance * success/failure messages. diff --git a/src/fsfw/tcdistribution/PusPacketChecker.cpp b/src/fsfw/tcdistribution/PusPacketChecker.cpp index 55a7934c..dc5b9ab9 100644 --- a/src/fsfw/tcdistribution/PusPacketChecker.cpp +++ b/src/fsfw/tcdistribution/PusPacketChecker.cpp @@ -12,17 +12,17 @@ PusPacketChecker::PusPacketChecker(uint16_t apid, ccsds::PacketType packetType_, ReturnValue_t PusPacketChecker::checkPacket(const PusTcReader& pusPacket, size_t packetLen) { // Other primary header fields are checked by base class if (not pusPacket.hasSecHeader()) { - return tmtcdistrib::INVALID_SEC_HEADER_FIELD; + return tcdistrib::INVALID_SEC_HEADER_FIELD; } uint16_t calculated_crc = CRC::crc16ccitt(pusPacket.getFullData(), pusPacket.getFullPacketLen()); if (calculated_crc != 0) { - return tmtcdistrib::INCORRECT_CHECKSUM; + return tcdistrib::INCORRECT_CHECKSUM; } if (pusPacket.getApid() != apid) { - return tmtcdistrib::INVALID_APID; + return tcdistrib::INVALID_APID; } if (pusPacket.getPusVersion() != pusVersion) { - return tmtcdistrib::INVALID_PUS_VERSION; + return tcdistrib::INVALID_PUS_VERSION; } return returnvalue::OK; } diff --git a/src/fsfw/tcdistribution/definitions.h b/src/fsfw/tcdistribution/definitions.h index 01fc3085..3d455077 100644 --- a/src/fsfw/tcdistribution/definitions.h +++ b/src/fsfw/tcdistribution/definitions.h @@ -3,19 +3,16 @@ #include -#include "fsfw/events/Event.h" -#include "fsfw/events/fwSubsystemIdRanges.h" #include "fsfw/returnvalues/FwClassIds.h" #include "fsfw/returnvalues/returnvalue.h" -namespace tmtcdistrib { -static const uint8_t INTERFACE_ID = CLASS_ID::TMTC_DISTRIBUTION; -static constexpr ReturnValue_t NO_DESTINATION_FOUND = returnvalue::makeCode(INTERFACE_ID, 0); -static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(1); -static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(2); -static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(3); -static constexpr ReturnValue_t INVALID_SEC_HEADER_FIELD = MAKE_RETURN_CODE(4); -static constexpr ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE(5); +namespace tcdistrib { +static const uint8_t INTERFACE_ID = CLASS_ID::PACKET_CHECK; +static constexpr ReturnValue_t INVALID_CCSDS_VERSION = MAKE_RETURN_CODE(0); +static constexpr ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(1); +static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(2); +static constexpr ReturnValue_t INVALID_SEC_HEADER_FIELD = MAKE_RETURN_CODE(3); +static constexpr ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE(4); static constexpr ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE(5); static constexpr ReturnValue_t INVALID_PUS_VERSION = MAKE_RETURN_CODE(6); @@ -23,9 +20,5 @@ static constexpr ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE(7); static constexpr ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE(8); static constexpr ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE(9); -static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TMTC_DISTRIBUTION; -//! P1: Returnvalue, P2: 0 for TM issues, 1 for TC issues -static constexpr Event HANDLE_PACKET_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); - -}; // namespace tmtcdistrib +}; // namespace tcdistrib #endif // FSFW_TMTCPACKET_DEFINITIONS_H diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 1ec5c0d8..ae7771d8 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -3,7 +3,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tcdistribution/PusDistributorIF.h" +#include "fsfw/tcdistribution/PUSDistributorIF.h" #include "fsfw/tmtcpacket/pus/tc.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/TmTcMessage.h" @@ -70,7 +70,7 @@ ReturnValue_t CommandingServiceBase::initialize() { if (packetSource == objects::NO_OBJECT) { packetSource = defaultPacketSource; } - auto* distributor = ObjectManager::instance()->get(packetSource); + auto* distributor = ObjectManager::instance()->get(packetSource); if (packetForwarding == nullptr or distributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -81,7 +81,7 @@ ReturnValue_t CommandingServiceBase::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - distributor->registerService(*this); + distributor->registerService(this); requestQueue->setDefaultDestination(packetForwarding->getReportReceptionQueue()); ipcStore = ObjectManager::instance()->get(objects::IPC_STORE); diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 9598e536..d0c3b905 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -3,7 +3,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tcdistribution/PusDistributorIF.h" +#include "fsfw/tcdistribution/PUSDistributorIF.h" #include "fsfw/timemanager/CdsShortTimeStamper.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" @@ -111,7 +111,7 @@ ReturnValue_t PusServiceBase::initialize() { } if (psbParams.pusDistributor == nullptr) { - psbParams.pusDistributor = ObjectManager::instance()->get(PUS_DISTRIBUTOR); + psbParams.pusDistributor = ObjectManager::instance()->get(PUS_DISTRIBUTOR); if (psbParams.pusDistributor != nullptr) { registerService(*psbParams.pusDistributor); } @@ -193,8 +193,8 @@ void PusServiceBase::setVerificationReporter(VerificationReporterIF& reporter) { psbParams.verifReporter = &reporter; } -ReturnValue_t PusServiceBase::registerService(PusDistributorIF& distributor) { - return distributor.registerService(*this); +ReturnValue_t PusServiceBase::registerService(PUSDistributorIF& distributor) { + return distributor.registerService(this); } void PusServiceBase::setTmReceiver(AcceptsTelemetryIF& tmReceiver_) { From ab7c3480f58009afb2feb584f684870a158b97e6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 10:30:22 +0200 Subject: [PATCH 373/532] storage manager update --- .../storagemanager/ConstStorageAccessor.cpp | 8 +-- .../storagemanager/ConstStorageAccessor.h | 13 ++-- src/fsfw/storagemanager/LocalPool.cpp | 59 ++++++++----------- src/fsfw/storagemanager/LocalPool.h | 24 ++++---- src/fsfw/storagemanager/PoolManager.h | 8 +-- src/fsfw/storagemanager/StorageAccessor.cpp | 4 +- src/fsfw/storagemanager/StorageAccessor.h | 7 ++- src/fsfw/storagemanager/StorageManagerIF.h | 56 ++++++++++++++---- 8 files changed, 103 insertions(+), 76 deletions(-) diff --git a/src/fsfw/storagemanager/ConstStorageAccessor.cpp b/src/fsfw/storagemanager/ConstStorageAccessor.cpp index f64334f7..e39fa36b 100644 --- a/src/fsfw/storagemanager/ConstStorageAccessor.cpp +++ b/src/fsfw/storagemanager/ConstStorageAccessor.cpp @@ -19,7 +19,7 @@ ConstStorageAccessor::~ConstStorageAccessor() { } } -ConstStorageAccessor::ConstStorageAccessor(ConstStorageAccessor&& other) +ConstStorageAccessor::ConstStorageAccessor(ConstStorageAccessor&& other) noexcept : constDataPointer(other.constDataPointer), storeId(other.storeId), size_(other.size_), @@ -30,7 +30,7 @@ ConstStorageAccessor::ConstStorageAccessor(ConstStorageAccessor&& other) other.store = nullptr; } -ConstStorageAccessor& ConstStorageAccessor::operator=(ConstStorageAccessor&& other) { +ConstStorageAccessor& ConstStorageAccessor::operator=(ConstStorageAccessor&& other) noexcept { constDataPointer = other.constDataPointer; storeId = other.storeId; store = other.store; @@ -84,7 +84,7 @@ void ConstStorageAccessor::print() const { arrayprinter::print(constDataPointer, size_); } -void ConstStorageAccessor::assignStore(StorageManagerIF* store) { +void ConstStorageAccessor::assignStore(StorageManagerIF* store_) { internalState = AccessState::ASSIGNED; - this->store = store; + store = store_; } diff --git a/src/fsfw/storagemanager/ConstStorageAccessor.h b/src/fsfw/storagemanager/ConstStorageAccessor.h index 9cad346c..0911c6d9 100644 --- a/src/fsfw/storagemanager/ConstStorageAccessor.h +++ b/src/fsfw/storagemanager/ConstStorageAccessor.h @@ -23,6 +23,7 @@ class ConstStorageAccessor { //! StorageManager classes have exclusive access to private variables. friend class PoolManager; friend class LocalPool; + friend class StorageManagerIF; public: /** @@ -30,7 +31,7 @@ class ConstStorageAccessor { * entry to access. * @param storeId */ - ConstStorageAccessor(store_address_t storeId); + explicit ConstStorageAccessor(store_address_t storeId); ConstStorageAccessor(store_address_t storeId, StorageManagerIF* store); /** @@ -43,7 +44,7 @@ class ConstStorageAccessor { * @brief Returns a pointer to the read-only data * @return */ - const uint8_t* data() const; + [[nodiscard]] const uint8_t* data() const; /** * @brief Copies the read-only data to the supplied pointer @@ -61,13 +62,13 @@ class ConstStorageAccessor { * Get the size of the data * @return */ - size_t size() const; + [[nodiscard]] size_t size() const; /** * Get the storage ID. * @return */ - store_address_t getId() const; + [[nodiscard]] store_address_t getId() const; void print() const; @@ -79,8 +80,8 @@ class ConstStorageAccessor { * @param * @return */ - ConstStorageAccessor& operator=(ConstStorageAccessor&&); - ConstStorageAccessor(ConstStorageAccessor&&); + ConstStorageAccessor& operator=(ConstStorageAccessor&&) noexcept; + ConstStorageAccessor(ConstStorageAccessor&&) noexcept; //! The copy ctor and copy assignemnt should be deleted implicitely //! according to https://foonathan.net/2019/02/special-member-functions/ diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index d907a9b3..970b05f5 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -29,7 +29,7 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig, } } -LocalPool::~LocalPool(void) {} +LocalPool::~LocalPool() = default; ReturnValue_t LocalPool::addData(store_address_t* storageId, const uint8_t* data, size_t size, bool ignoreFault) { @@ -48,22 +48,6 @@ ReturnValue_t LocalPool::getData(store_address_t packetId, const uint8_t** packe return status; } -ReturnValue_t LocalPool::getData(store_address_t storeId, ConstStorageAccessor& storeAccessor) { - uint8_t* tempData = nullptr; - ReturnValue_t status = modifyData(storeId, &tempData, &storeAccessor.size_); - storeAccessor.assignStore(this); - storeAccessor.constDataPointer = tempData; - return status; -} - -ConstAccessorPair LocalPool::getData(store_address_t storeId) { - uint8_t* tempData = nullptr; - ConstStorageAccessor constAccessor(storeId, this); - ReturnValue_t status = modifyData(storeId, &tempData, &constAccessor.size_); - constAccessor.constDataPointer = tempData; - return ConstAccessorPair(status, std::move(constAccessor)); -} - ReturnValue_t LocalPool::getFreeElement(store_address_t* storageId, const size_t size, uint8_t** pData, bool ignoreFault) { ReturnValue_t status = reserveSpace(size, storageId, ignoreFault); @@ -75,20 +59,6 @@ ReturnValue_t LocalPool::getFreeElement(store_address_t* storageId, const size_t return status; } -AccessorPair LocalPool::modifyData(store_address_t storeId) { - StorageAccessor accessor(storeId, this); - ReturnValue_t status = modifyData(storeId, &accessor.dataPointer, &accessor.size_); - accessor.assignConstPointer(); - return AccessorPair(status, std::move(accessor)); -} - -ReturnValue_t LocalPool::modifyData(store_address_t storeId, StorageAccessor& storeAccessor) { - storeAccessor.assignStore(this); - ReturnValue_t status = modifyData(storeId, &storeAccessor.dataPointer, &storeAccessor.size_); - storeAccessor.assignConstPointer(); - return status; -} - ReturnValue_t LocalPool::modifyData(store_address_t storeId, uint8_t** packetPtr, size_t* size) { ReturnValue_t status = returnvalue::FAILED; if (storeId.poolIndex >= NUMBER_OF_SUBPOOLS) { @@ -197,8 +167,7 @@ void LocalPool::clearStore() { } } -ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeId, - bool ignoreFault) { +ReturnValue_t LocalPool::reserveSpace(size_t size, store_address_t* storeId, bool ignoreFault) { ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -349,3 +318,27 @@ bool LocalPool::hasDataAtId(store_address_t storeId) const { } return false; } + +ReturnValue_t LocalPool::getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData) { + return StorageManagerIF::getFreeElement(storeId, size, pData); +} + +ConstAccessorPair LocalPool::getData(store_address_t storeId) { + return StorageManagerIF::getData(storeId); +} + +ReturnValue_t LocalPool::addData(store_address_t* storeId, const uint8_t* data, size_t size) { + return StorageManagerIF::addData(storeId, data, size); +} + +ReturnValue_t LocalPool::getData(store_address_t storeId, ConstStorageAccessor& accessor) { + return StorageManagerIF::getData(storeId, accessor); +} + +ReturnValue_t LocalPool::modifyData(store_address_t storeId, StorageAccessor& accessor) { + return StorageManagerIF::modifyData(storeId, accessor); +} + +AccessorPair LocalPool::modifyData(store_address_t storeId) { + return StorageManagerIF::modifyData(storeId); +} diff --git a/src/fsfw/storagemanager/LocalPool.h b/src/fsfw/storagemanager/LocalPool.h index a82da971..54d704e6 100644 --- a/src/fsfw/storagemanager/LocalPool.h +++ b/src/fsfw/storagemanager/LocalPool.h @@ -87,21 +87,23 @@ class LocalPool : public SystemObject, public StorageManagerIF { * Documentation: See StorageManagerIF.h */ ReturnValue_t addData(store_address_t* storeId, const uint8_t* data, size_t size, - bool ignoreFault = false) override; - ReturnValue_t getFreeElement(store_address_t* storeId, const size_t size, uint8_t** pData, - bool ignoreFault = false) override; + bool ignoreFault) override; + ReturnValue_t addData(store_address_t* storeId, const uint8_t* data, size_t size) override; + + ReturnValue_t getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData) override; + ReturnValue_t getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData, + bool ignoreFault) override; ConstAccessorPair getData(store_address_t storeId) override; - ReturnValue_t getData(store_address_t storeId, ConstStorageAccessor& constAccessor) override; + ReturnValue_t getData(store_address_t storeId, ConstStorageAccessor& accessor) override; ReturnValue_t getData(store_address_t storeId, const uint8_t** packet_ptr, size_t* size) override; AccessorPair modifyData(store_address_t storeId) override; - ReturnValue_t modifyData(store_address_t storeId, StorageAccessor& storeAccessor) override; ReturnValue_t modifyData(store_address_t storeId, uint8_t** packet_ptr, size_t* size) override; + ReturnValue_t modifyData(store_address_t storeId, StorageAccessor& accessor) override; - virtual ReturnValue_t deleteData(store_address_t storeId) override; - virtual ReturnValue_t deleteData(uint8_t* ptr, size_t size, - store_address_t* storeId = nullptr) override; + ReturnValue_t deleteData(store_address_t storeId) override; + ReturnValue_t deleteData(uint8_t* ptr, size_t size, store_address_t* storeId) override; /** * Get the total size of allocated memory for pool data. @@ -131,8 +133,8 @@ class LocalPool : public SystemObject, public StorageManagerIF { * Get number sub pools. Each pool has pages with a specific bucket size. * @return */ - max_subpools_t getNumberOfSubPools() const override; - bool hasDataAtId(store_address_t storeId) const override; + [[nodiscard]] max_subpools_t getNumberOfSubPools() const override; + [[nodiscard]] bool hasDataAtId(store_address_t storeId) const override; protected: /** @@ -142,7 +144,7 @@ class LocalPool : public SystemObject, public StorageManagerIF { * @return - returnvalue::OK on success, * - the return codes of #getPoolIndex or #findEmpty otherwise. */ - virtual ReturnValue_t reserveSpace(const size_t size, store_address_t* address, bool ignoreFault); + virtual ReturnValue_t reserveSpace(size_t size, store_address_t* address, bool ignoreFault); private: /** diff --git a/src/fsfw/storagemanager/PoolManager.h b/src/fsfw/storagemanager/PoolManager.h index 0951a518..eaa978ef 100644 --- a/src/fsfw/storagemanager/PoolManager.h +++ b/src/fsfw/storagemanager/PoolManager.h @@ -27,7 +27,7 @@ class PoolManager : public LocalPool { * @brief In the PoolManager's destructor all allocated memory * is freed. */ - virtual ~PoolManager(); + ~PoolManager() override; /** * Set the default mutex timeout for internal calls. @@ -40,8 +40,7 @@ class PoolManager : public LocalPool { * which wraps LocalPool calls with a mutex protection. */ ReturnValue_t deleteData(store_address_t) override; - ReturnValue_t deleteData(uint8_t* buffer, size_t size, - store_address_t* storeId = nullptr) override; + ReturnValue_t deleteData(uint8_t* buffer, size_t size, store_address_t* storeId) override; /** * The developer is allowed to lock the mutex in case the lock needs @@ -58,8 +57,7 @@ class PoolManager : public LocalPool { //! Default mutex timeout value to prevent permanent blocking. uint32_t mutexTimeoutMs = 20; - ReturnValue_t reserveSpace(const size_t size, store_address_t* address, - bool ignoreFault) override; + ReturnValue_t reserveSpace(size_t size, store_address_t* address, bool ignoreFault) override; /** * @brief The mutex is created in the constructor and makes diff --git a/src/fsfw/storagemanager/StorageAccessor.cpp b/src/fsfw/storagemanager/StorageAccessor.cpp index 8a96dcec..b576a113 100644 --- a/src/fsfw/storagemanager/StorageAccessor.cpp +++ b/src/fsfw/storagemanager/StorageAccessor.cpp @@ -10,7 +10,7 @@ StorageAccessor::StorageAccessor(store_address_t storeId) : ConstStorageAccessor StorageAccessor::StorageAccessor(store_address_t storeId, StorageManagerIF* store) : ConstStorageAccessor(storeId, store) {} -StorageAccessor& StorageAccessor::operator=(StorageAccessor&& other) { +StorageAccessor& StorageAccessor::operator=(StorageAccessor&& other) noexcept { // Call the parent move assignment and also assign own member. dataPointer = other.dataPointer; ConstStorageAccessor::operator=(std::move(other)); @@ -18,7 +18,7 @@ StorageAccessor& StorageAccessor::operator=(StorageAccessor&& other) { } // Call the parent move ctor and also transfer own member. -StorageAccessor::StorageAccessor(StorageAccessor&& other) +StorageAccessor::StorageAccessor(StorageAccessor&& other) noexcept : ConstStorageAccessor(std::move(other)), dataPointer(other.dataPointer) {} ReturnValue_t StorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) { diff --git a/src/fsfw/storagemanager/StorageAccessor.h b/src/fsfw/storagemanager/StorageAccessor.h index 5e8b25e4..b6c5dc14 100644 --- a/src/fsfw/storagemanager/StorageAccessor.h +++ b/src/fsfw/storagemanager/StorageAccessor.h @@ -12,9 +12,10 @@ class StorageAccessor : public ConstStorageAccessor { //! StorageManager classes have exclusive access to private variables. friend class PoolManager; friend class LocalPool; + friend class StorageManagerIF; public: - StorageAccessor(store_address_t storeId); + explicit StorageAccessor(store_address_t storeId); StorageAccessor(store_address_t storeId, StorageManagerIF* store); /** @@ -25,8 +26,8 @@ class StorageAccessor : public ConstStorageAccessor { * @param * @return */ - StorageAccessor& operator=(StorageAccessor&&); - StorageAccessor(StorageAccessor&&); + StorageAccessor& operator=(StorageAccessor&&) noexcept; + StorageAccessor(StorageAccessor&&) noexcept; ReturnValue_t write(uint8_t* data, size_t size, uint16_t offset = 0); uint8_t* data(); diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index 228d380b..2845e581 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -67,7 +67,12 @@ class StorageManagerIF { * @returnvalue::FAILED if data could not be added, storageId is unchanged then. */ virtual ReturnValue_t addData(store_address_t* storageId, const uint8_t* data, size_t size, - bool ignoreFault = false) = 0; + bool ignoreFault) = 0; + + virtual ReturnValue_t addData(store_address_t* storageId, const uint8_t* data, size_t size) { + return addData(storageId, data, size, false); + } + /** * @brief With deleteData, the storageManager frees the memory region * identified by packet_id. @@ -86,9 +91,10 @@ class StorageManagerIF { * @return @li returnvalue::OK on success. * @li failure code if deletion did not work */ - virtual ReturnValue_t deleteData(uint8_t* buffer, size_t size, - store_address_t* storeId = nullptr) = 0; - + virtual ReturnValue_t deleteData(uint8_t* buffer, size_t size, store_address_t* storeId) = 0; + virtual ReturnValue_t deleteData(uint8_t* buffer, size_t size) { + return deleteData(buffer, size, nullptr); + } /** * @brief Access the data by supplying a store ID. * @details @@ -97,7 +103,13 @@ class StorageManagerIF { * @param storeId * @return Pair of return value and a ConstStorageAccessor instance */ - virtual ConstAccessorPair getData(store_address_t storeId) = 0; + virtual ConstAccessorPair getData(store_address_t storeId) { + uint8_t* tempData = nullptr; + ConstStorageAccessor constAccessor(storeId, this); + ReturnValue_t status = modifyData(storeId, &tempData, &constAccessor.size_); + constAccessor.constDataPointer = tempData; + return {status, std::move(constAccessor)}; + } /** * @brief Access the data by supplying a store ID and a helper @@ -106,7 +118,13 @@ class StorageManagerIF { * @param constAccessor Wrapper function to access store data. * @return */ - virtual ReturnValue_t getData(store_address_t storeId, ConstStorageAccessor& constAccessor) = 0; + virtual ReturnValue_t getData(store_address_t storeId, ConstStorageAccessor& accessor) { + uint8_t* tempData = nullptr; + ReturnValue_t status = modifyData(storeId, &tempData, &accessor.size_); + accessor.assignStore(this); + accessor.constDataPointer = tempData; + return status; + } /** * @brief getData returns an address to data and the size of the data @@ -127,7 +145,12 @@ class StorageManagerIF { * @param storeId * @return Pair of return value and StorageAccessor helper */ - virtual AccessorPair modifyData(store_address_t storeId) = 0; + virtual AccessorPair modifyData(store_address_t storeId) { + StorageAccessor accessor(storeId, this); + ReturnValue_t status = modifyData(storeId, &accessor.dataPointer, &accessor.size_); + accessor.assignConstPointer(); + return {status, std::move(accessor)}; + } /** * Modify data by supplying a store ID and a StorageAccessor helper instance. @@ -135,7 +158,12 @@ class StorageManagerIF { * @param accessor Helper class to access the modifiable data. * @return */ - virtual ReturnValue_t modifyData(store_address_t storeId, StorageAccessor& accessor) = 0; + virtual ReturnValue_t modifyData(store_address_t storeId, StorageAccessor& accessor) { + accessor.assignStore(this); + ReturnValue_t status = modifyData(storeId, &accessor.dataPointer, &accessor.size_); + accessor.assignConstPointer(); + return status; + } /** * Get pointer and size of modifiable data by supplying the storeId @@ -154,12 +182,16 @@ class StorageManagerIF { * written to p_data! * @param storageId A pointer to the storageId to retrieve. * @param size The size of the space to be reserved. - * @param p_data A pointer to the element data is returned here. - * @return Returns @li returnvalue::OK if data was added. + * @param dataPtr A pointer to the element data is returned here. + * @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** p_data, - bool ignoreFault = false) = 0; + virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** dataPtr, + bool ignoreFault) = 0; + + virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** dataPtr) { + return getFreeElement(storageId, size, dataPtr, false); + } [[nodiscard]] virtual bool hasDataAtId(store_address_t storeId) const = 0; From b3c0e2461154dcbacbd7ba958dff58fdd9289f44 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 10:31:55 +0200 Subject: [PATCH 374/532] bump changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fe567de..da557d70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). for other modules PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/655 which also includes a migration guide +- Move some generic `StorageManagerIF` implementations from `LocalPool` to + interface itself so it can be re-used more easily. Also add new + abstract function `bool hasDataAtId(store_address_t storeId) const`. + PR: # [v5.0.0] 25.07.2022 From e063b44899a3e6a74b0a54b9ae1533af723cec83 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 10:32:38 +0200 Subject: [PATCH 375/532] add link to PR --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da557d70..476632df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Move some generic `StorageManagerIF` implementations from `LocalPool` to interface itself so it can be re-used more easily. Also add new abstract function `bool hasDataAtId(store_address_t storeId) const`. - PR: + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/685 # [v5.0.0] 25.07.2022 From 1efc0d285541345dedbc22f778c731898ebe178d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 10:38:40 +0200 Subject: [PATCH 376/532] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fe567de..b181fef8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). for other modules PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/655 which also includes a migration guide +- Improvements for `AcceptsTelemetryIF` and `AcceptsTelecommandsIF`: + - Make functions `const` where it makes sense + - Add `const char* getName const` abstract function + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/684 # [v5.0.0] 25.07.2022 From 37390dfc746f09ab63e456e881ac669055a0f3ba Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 10:42:35 +0200 Subject: [PATCH 377/532] add missing changelog entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fe567de..844e15c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [v6.0.0] +## Fixes + +- Bugfix for Serial Buffer Stream: Setting `doActive` to false now + actually fully disables printing. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/680/files + ## Added - Add new `UnsignedByteField` class From 2e310fca8d8adc987248fcd2e54a978e6ec2b379 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 10:43:45 +0200 Subject: [PATCH 378/532] add another missing changelog entry --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 844e15c3..6a5c40f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Bugfix for Serial Buffer Stream: Setting `doActive` to false now actually fully disables printing. - PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/680/files + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/680 ## Added @@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). for other modules PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/655 which also includes a migration guide +- Bump Catch2 dependency to regular version `v3.1.0` + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/678 # [v5.0.0] 25.07.2022 From 655c944c0e114f8fa6aca6bcbe5d012c0b49600d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 10:45:35 +0200 Subject: [PATCH 379/532] another missing changelog entry --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a5c40f8..40b446b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). which also includes a migration guide - Bump Catch2 dependency to regular version `v3.1.0` PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/678 - +- `SerialBufferAdapter`: Rename `setBuffer` to `setConstBuffer` and update + API to expect `const uint8_t*` accordingly. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/677 + # [v5.0.0] 25.07.2022 ## Changes From 9a181aa6a8246e3d813b319f919e2f687e58ec34 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 10:47:50 +0200 Subject: [PATCH 380/532] another missing changelog entry --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40b446b3..08690560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `SerialBufferAdapter`: Rename `setBuffer` to `setConstBuffer` and update API to expect `const uint8_t*` accordingly. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/677 - +- Remove the following user includes from `fsfw/events/Event.h` and + `fsfw/returnvalues/returnvalue.h`: + - `#include "events/subsystemIdRanges.h"` + - `#include "returnvalues/classIds.h"` + The user has to include those themselves now + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/675 + # [v5.0.0] 25.07.2022 ## Changes From 53638681207e43f44333fea994787f2074300c75 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 10:54:45 +0200 Subject: [PATCH 381/532] added another missing changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08690560..c239b819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Bugfix for Serial Buffer Stream: Setting `doActive` to false now actually fully disables printing. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/680 +- `TcpTmTcServer.cpp`: The server was actually not able to handle + CCSDS packets which were clumped together. This has been fixed now. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/673 ## Added From 8df6d934d7a42f4ca4b9c4c7732a718c5e22913f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 10:56:52 +0200 Subject: [PATCH 382/532] another missing changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c239b819..b676e953 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `#include "returnvalues/classIds.h"` The user has to include those themselves now PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/675 +- `DeviceHandlerBase`: Set command sender before calling `buildCommandFromCommand`. + This allows finishing action commands immediately inside the function. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/672 # [v5.0.0] 25.07.2022 From 1a833e2d450ffb36598f8ef94b8d3a342b959d41 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 10:59:10 +0200 Subject: [PATCH 383/532] another missing changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b676e953..03cc0613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `DeviceHandlerBase`: Set command sender before calling `buildCommandFromCommand`. This allows finishing action commands immediately inside the function. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/672 +- `DeviceHandlerBase`: New signature of `handleDeviceTm` which expects + a `const SerializeIF&` and additional helper variant which expects `const uint8_t*` + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/671 # [v5.0.0] 25.07.2022 From a681a4a797cbec134d03289e0845a13eb79d5925 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:37:10 +0200 Subject: [PATCH 384/532] better error printout --- src/fsfw/datapoollocal/LocalPoolObjectBase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp index 82aefc18..9edf02c5 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp @@ -48,12 +48,12 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, if (hkOwner == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVariable: The supplied pool owner 0x" << std::hex << poolOwner - << std::dec << " did not implement the correct interface " + << std::dec << " does not exists or did not implement the correct interface " << "HasLocalDataPoolIF" << std::endl; #else sif::printError( - "LocalPoolVariable: The supplied pool owner 0x%08x did not implement the correct " - "interface HasLocalDataPoolIF\n", + "LocalPoolVariable: The supplied pool owner 0x%08x does not exists or does not implement " + "the correct interface HasLocalDataPoolIF\n", poolOwner); #endif return; From ce7146e468dbe7cb1ad5073e5374288b366105c5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:40:12 +0200 Subject: [PATCH 385/532] printout tweak --- src/fsfw/datapoollocal/LocalPoolObjectBase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp index 9edf02c5..5575c3d8 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp @@ -48,11 +48,11 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, if (hkOwner == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVariable: The supplied pool owner 0x" << std::hex << poolOwner - << std::dec << " does not exists or did not implement the correct interface " + << std::dec << " does not exist or does not implement the correct interface " << "HasLocalDataPoolIF" << std::endl; #else sif::printError( - "LocalPoolVariable: The supplied pool owner 0x%08x does not exists or does not implement " + "LocalPoolVariable: The supplied pool owner 0x%08x does not exist or does not implement " "the correct interface HasLocalDataPoolIF\n", poolOwner); #endif From 423a9540edaad417416479b02f47e3c603bd4b16 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:51:59 +0200 Subject: [PATCH 386/532] doc corrections --- docs/README-highlevel.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md index 9005af8d..cf2daee7 100644 --- a/docs/README-highlevel.md +++ b/docs/README-highlevel.md @@ -4,12 +4,14 @@ High-level overview # Structure The general structure is driven by the usage of interfaces provided by objects. -The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be -widely available, even with older compilers. -The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. -This simplifies the instantiation of objects and allows the usage of some standard containers. -Dynamic Allocation after initialization is discouraged and different solutions are provided in the -FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed. +The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this +standard, even for micocontrollers. + +The FSFW uses dynamic allocation during the initialization but provides static containers during +runtime.This simplifies the instantiation of objects and allows the usage of some standard +containers. Dynamic Allocation after initialization is discouraged and different solutions are +provided in the FSFW to achieve that. The fsfw uses run-time type information but will not throw +exceptions. # Failure Handling From 131e3ff1e3fb7f9846b39aac4c6ff06db57da1d0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:52:28 +0200 Subject: [PATCH 387/532] Revert "doc corrections" This reverts commit 423a9540edaad417416479b02f47e3c603bd4b16. --- docs/README-highlevel.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md index cf2daee7..9005af8d 100644 --- a/docs/README-highlevel.md +++ b/docs/README-highlevel.md @@ -4,14 +4,12 @@ High-level overview # Structure The general structure is driven by the usage of interfaces provided by objects. -The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this -standard, even for micocontrollers. - -The FSFW uses dynamic allocation during the initialization but provides static containers during -runtime.This simplifies the instantiation of objects and allows the usage of some standard -containers. Dynamic Allocation after initialization is discouraged and different solutions are -provided in the FSFW to achieve that. The fsfw uses run-time type information but will not throw -exceptions. +The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be +widely available, even with older compilers. +The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. +This simplifies the instantiation of objects and allows the usage of some standard containers. +Dynamic Allocation after initialization is discouraged and different solutions are provided in the +FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed. # Failure Handling From 0f027d29d27fd111a0be1e9ba3d683781ad4d6b0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:51:59 +0200 Subject: [PATCH 388/532] doc corrections --- docs/README-highlevel.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md index 9005af8d..cf2daee7 100644 --- a/docs/README-highlevel.md +++ b/docs/README-highlevel.md @@ -4,12 +4,14 @@ High-level overview # Structure The general structure is driven by the usage of interfaces provided by objects. -The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be -widely available, even with older compilers. -The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. -This simplifies the instantiation of objects and allows the usage of some standard containers. -Dynamic Allocation after initialization is discouraged and different solutions are provided in the -FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed. +The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this +standard, even for micocontrollers. + +The FSFW uses dynamic allocation during the initialization but provides static containers during +runtime.This simplifies the instantiation of objects and allows the usage of some standard +containers. Dynamic Allocation after initialization is discouraged and different solutions are +provided in the FSFW to achieve that. The fsfw uses run-time type information but will not throw +exceptions. # Failure Handling From 8dea13742fa9f469507945f8cacf369eba4f7cfd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:57:39 +0200 Subject: [PATCH 389/532] update rst file --- docs/README-highlevel.md | 9 ++++----- docs/highlevel.rst | 15 ++++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md index cf2daee7..23e27da3 100644 --- a/docs/README-highlevel.md +++ b/docs/README-highlevel.md @@ -7,11 +7,10 @@ The general structure is driven by the usage of interfaces provided by objects. The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this standard, even for micocontrollers. -The FSFW uses dynamic allocation during the initialization but provides static containers during -runtime.This simplifies the instantiation of objects and allows the usage of some standard -containers. Dynamic Allocation after initialization is discouraged and different solutions are -provided in the FSFW to achieve that. The fsfw uses run-time type information but will not throw -exceptions. +The FSFW might use dynamic allocation during program initialization but not during runtime. +It offers pool objects, static containers and it also exposes the Embedded Template Library +to allow writing code which does not perform allocation during runtime. The fsfw uses run-time type +information but will not throw exceptions. # Failure Handling diff --git a/docs/highlevel.rst b/docs/highlevel.rst index 3c9baae2..ee35c549 100644 --- a/docs/highlevel.rst +++ b/docs/highlevel.rst @@ -6,13 +6,14 @@ High-level overview Structure ---------- -The general structure is driven by the usage of interfaces provided by objects. -The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be -widely available, even with older compilers. -The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. -This simplifies the instantiation of objects and allows the usage of some standard containers. -Dynamic Allocation after initialization is discouraged and different solutions are provided in the -FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed. +The general structure is driven by the usage of interfaces provided by objects. +The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this +standard, even for micocontrollers. + +The FSFW might use dynamic allocation during program initialization but not during runtime. +It offers pool objects, static containers and it also exposes the +`Embedded Template Library `_ to allow writing code which does not perform +allocation during runtime. The fsfw uses run-time type information but will not throw exceptions. Failure Handling ----------------- From 0042372cb6426f92ab56e93e37ae63015c2d2609 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:58:13 +0200 Subject: [PATCH 390/532] now that doc server is up, remove markdown files --- docs/README-config.md | 40 -------- docs/README-controllers.md | 1 - docs/README-core.md | 55 ----------- docs/README-devicehandlers.md | 1 - docs/README-highlevel.md | 135 -------------------------- docs/README-localpools.md | 174 ---------------------------------- docs/README-osal.md | 32 ------- docs/README-pus.md | 1 - 8 files changed, 439 deletions(-) delete mode 100644 docs/README-config.md delete mode 100644 docs/README-controllers.md delete mode 100644 docs/README-core.md delete mode 100644 docs/README-devicehandlers.md delete mode 100644 docs/README-highlevel.md delete mode 100644 docs/README-localpools.md delete mode 100644 docs/README-osal.md delete mode 100644 docs/README-pus.md diff --git a/docs/README-config.md b/docs/README-config.md deleted file mode 100644 index d71feb97..00000000 --- a/docs/README-config.md +++ /dev/null @@ -1,40 +0,0 @@ -Configuring the FSFW -====== - -The FSFW can be configured via the `fsfwconfig` folder. A template folder has -been provided to have a starting point for this. The folder should be added -to the include path. The primary configuration file is the `FSFWConfig.h` folder. Some -of the available options will be explained in more detail here. - -# Auto-Translation of Events - -The FSFW allows the automatic translation of events, which allows developers to track triggered -events directly via console output. Using this feature requires: - -1. `FSFW_OBJ_EVENT_TRANSLATION` set to 1 in the configuration file. -2. Special auto-generated translation files which translate event IDs and object IDs into - human readable strings. These files can be generated using the - [modgen Python scripts](https://git.ksat-stuttgart.de/source/modgen.git). -3. The generated translation files for the object IDs should be named `translatesObjects.cpp` - and `translateObjects.h` and should be copied to the `fsfwconfig/objects` folder -4. The generated translation files for the event IDs should be named `translateEvents.cpp` and - `translateEvents.h` and should be copied to the `fsfwconfig/events` folder - -An example implementations of these translation file generators can be found as part -of the [SOURCE project here](https://git.ksat-stuttgart.de/source/sourceobsw/-/tree/development/generators) -or the [FSFW example](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example_public/src/branch/master/generators) - -## Configuring the Event Manager - -The number of allowed subscriptions can be modified with the following -parameters: - -``` c++ -namespace fsfwconfig { -//! Configure the allocated pool sizes for the event manager. -static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; -static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; -static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; -} -``` - diff --git a/docs/README-controllers.md b/docs/README-controllers.md deleted file mode 100644 index 7af0652d..00000000 --- a/docs/README-controllers.md +++ /dev/null @@ -1 +0,0 @@ -## Controllers diff --git a/docs/README-core.md b/docs/README-core.md deleted file mode 100644 index e34890ae..00000000 --- a/docs/README-core.md +++ /dev/null @@ -1,55 +0,0 @@ -## FSFW Core Modules - -These core modules provide the most important functionalities of the -Flight Software Framework - -### Clock - - * This is a class of static functions that can be used at anytime - * Leap Seconds must be set if any time conversions from UTC to other times is used - -### ObjectManager - -* Must be created during program startup -* The component which handles all references. All SystemObjects register at this component. -* Any SystemObject needs to have a unique ObjectId. Those can be managed like objects::framework_objects. -* A reference to an object can be get by calling the following function. T must be the specific Interface you want to call. -A nullptr check of the returning Pointer must be done. This function is based on Run-time type information. - -```cpp -template T* ObjectManagerIF::get( object_id_t id ) -``` -* A typical way to create all objects on startup is a handing a static produce function to the - ObjectManager on creation. By calling objectManager->initialize() the produce function will be - called and all SystemObjects will be initialized afterwards. - -### Event Manager - -* Component which allows routing of events -* Other objects can subscribe to specific events, ranges of events or all events of an object. -* Subscriptions can be done during runtime but should be done during initialization -* Amounts of allowed subscriptions can be configured in `FSFWConfig.h` - -### Health Table - -* A component which holds every health state -* Provides a thread safe way to access all health states without the need of message exchanges - -### Stores - -* The message based communication can only exchange a few bytes of information inside the message - itself. Therefore, additional information can be exchanged with Stores. With this, only the - store address must be exchanged in the message. -* Internally, the FSFW uses an IPC Store to exchange data between processes. For incoming TCs a TC - Store is used. For outgoing TM a TM store is used. -* All of them should use the Thread Safe Class storagemanager/PoolManager - -### Tasks - -There are two different types of tasks: - * The PeriodicTask just executes objects that are of type ExecutableObjectIF in the order of the - insertion to the Tasks. - * FixedTimeslotTask executes a list of calls in the order of the given list. This is intended for - DeviceHandlers, where polling should be in a defined order. An example can be found in - `defaultcfg/fsfwconfig/pollingSequence` folder - diff --git a/docs/README-devicehandlers.md b/docs/README-devicehandlers.md deleted file mode 100644 index 8b6551aa..00000000 --- a/docs/README-devicehandlers.md +++ /dev/null @@ -1 +0,0 @@ -## Device Handlers diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md deleted file mode 100644 index 9005af8d..00000000 --- a/docs/README-highlevel.md +++ /dev/null @@ -1,135 +0,0 @@ -High-level overview -====== - -# Structure - -The general structure is driven by the usage of interfaces provided by objects. -The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be -widely available, even with older compilers. -The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. -This simplifies the instantiation of objects and allows the usage of some standard containers. -Dynamic Allocation after initialization is discouraged and different solutions are provided in the -FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed. - -# Failure Handling - -Functions should return a defined `ReturnValue_t` to signal to the caller that something has -gone wrong. Returnvalues must be unique. For this the function `returnvalue::makeCode` -or the macro `MAKE_RETURN` can be used. The `CLASS_ID` is a unique id for that type of object. -See `returnvalues/FwClassIds` folder. The user can add custom `CLASS_ID`s via the -`fsfwconfig` folder. - -# OSAL - -The FSFW provides operation system abstraction layers for Linux, FreeRTOS and RTEMS. -The OSAL provides periodic tasks, message queues, clocks and semaphores as well as mutexes. -The [OSAL README](doc/README-osal.md#top) provides more detailed information on provided components -and how to use them. - -# Core Components - -The FSFW has following core components. More detailed informations can be found in the -[core component section](doc/README-core.md#top): - -1. Tasks: Abstraction for different (periodic) task types like periodic tasks or tasks - with fixed timeslots -2. ObjectManager: This module stores all `SystemObjects` by mapping a provided unique object ID - to the object handles. -3. Static Stores: Different stores are provided to store data of variable size (like telecommands - or small telemetry) in a pool structure without using dynamic memory allocation. - These pools are allocated up front. -3. Clock: This module provided common time related functions -4. EventManager: This module allows routing of events generated by `SystemObjects` -5. HealthTable: A component which stores the health states of objects - -# Static IDs in the framework - -Some parts of the framework use a static routing address for communication. -An example setup of ids can be found in the example config in `defaultcft/fsfwconfig/objects` - inside the function `Factory::setStaticFrameworkObjectIds()`. - -# Events - -Events are tied to objects. EventIds can be generated by calling the Macro MAKE_EVENT. -This works analog to the returnvalues. Every object that needs own EventIds has to get a -unique SUBSYSTEM_ID. Every SystemObject can call triggerEvent from the parent class. -Therefore, event messages contain the specific EventId and the objectId of the object that -has triggered. - -# Internal Communication - -Components communicate mostly via Messages through Queues. -Those queues are created by calling the singleton `QueueFactory::instance()->create()` which -will create `MessageQueue` instances for the used OSAL. - -# External Communication - -The external communication with the mission control system is mostly up to the user implementation. -The FSFW provides PUS Services which can be used to but don't need to be used. -The services can be seen as a conversion from a TC to a message based communication and back. - -## TMTC Communication - -The FSFW provides some components to facilitate TMTC handling via the PUS commands. -For example, a UDP or TCP PUS server socket can be opened on a specific port using the -files located in `osal/common`. The FSFW example uses this functionality to allow sending telecommands -and receiving telemetry using the [TMTC commander application](https://github.com/spacefisch/tmtccmd). -Simple commands like the PUS Service 17 ping service can be tested by simply running the -`tmtc_client_cli.py` or `tmtc_client_gui.py` utility in -the [example tmtc folder](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example_public/src/branch/master/tmtc) -while the `fsfw_example` application is running. - -More generally, any class responsible for handling incoming telecommands and sending telemetry -can implement the generic `TmTcBridge` class located in `tmtcservices`. Many applications -also use a dedicated polling task for reading telecommands which passes telecommands -to the `TmTcBridge` implementation. - -## CCSDS Frames, CCSDS Space Packets and PUS - -If the communication is based on CCSDS Frames and Space Packets, several classes can be used to -distributed the packets to the corresponding services. Those can be found in `tcdistribution`. -If Space Packets are used, a timestamper has to be provided by the user. -An example can be found in the `timemanager` folder, which uses `CCSDSTime::CDS_short`. - -# Device Handlers - -DeviceHandlers are another important component of the FSFW. -The idea is, to have a software counterpart of every physical device to provide a simple mode, -health and commanding interface. By separating the underlying Communication Interface with -`DeviceCommunicationIF`, a device handler (DH) can be tested on different hardware. -The DH has mechanisms to monitor the communication with the physical device which allow -for FDIR reaction. Device Handlers can be created by implementing `DeviceHandlerBase`. -A standard FDIR component for the DH will be created automatically but can -be overwritten by the user. More information on DeviceHandlers can be found in the -related [documentation section](doc/README-devicehandlers.md#top). - -# Modes and Health - -The two interfaces `HasModesIF` and `HasHealthIF` provide access for commanding and monitoring -of components. On-board Mode Management is implement in hierarchy system. -DeviceHandlers and Controllers are the lowest part of the hierarchy. -The next layer are Assemblies. Those assemblies act as a component which handle -redundancies of handlers. Assemblies share a common core with the next level which -are the Subsystems. - -Those Assemblies are intended to act as auto-generated components from a database which describes -the subsystem modes. The definitions contain transition and target tables which contain the DH, -Assembly and Controller Modes to be commanded. -Transition tables contain as many steps as needed to reach the mode from any other mode, e.g. a -switch into any higher AOCS mode might first turn on the sensors, than the actuators and the -controller as last component. -The target table is used to describe the state that is checked continuously by the subsystem. -All of this allows System Modes to be generated as Subsystem object as well from the same database. -This System contains list of subsystem modes in the transition and target tables. -Therefore, it allows a modular system to create system modes and easy commanding of those, because -only the highest components must be commanded. - -The health state represents if the component is able to perform its tasks. -This can be used to signal the system to avoid using this component instead of a redundant one. -The on-board FDIR uses the health state for isolation and recovery. - -# Unit Tests - -Unit Tests are provided in the unittest folder. Those use the catch2 framework but do not include -catch2 itself. More information on how to run these tests can be found in the separate -[`fsfw_tests` reposoitory](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_tests) diff --git a/docs/README-localpools.md b/docs/README-localpools.md deleted file mode 100644 index 1770efb9..00000000 --- a/docs/README-localpools.md +++ /dev/null @@ -1,174 +0,0 @@ -## Local Data Pools Developer Information - -The following text is targeted towards mission software developers which would like -to use the local data pools provided by the FSFW to store data like sensor values so they can be -used by other software objects like controllers as well. If a custom class should have a local -pool which can be used by other software objects as well, following steps have to be performed: - -1. Create a `LocalDataPoolManager` member object in the custom class -2. Implement the `HasLocalDataPoolIF` with specifies the interface between the local pool manager -and the class owning the local pool. - -The local data pool manager is also able to process housekeeping service requests in form -of messages, generate periodic housekeeping packet, generate notification and snapshots of changed -variables and datasets and process notifications and snapshots coming from other objects. -The two former tasks are related to the external interface using telemetry and telecommands (TMTC) -while the later two are related to data consumers like controllers only acting on data change -detected by the data creator instead of checking the data manually each cycle. Two important -framework classes `DeviceHandlerBase` and `ExtendedControllerBase` already perform the two steps -shown above so the steps required are altered slightly. - -### Storing and Accessing pool data - -The pool manager is responsible for thread-safe access of the pool data, but the actual -access to the pool data from the point of view of a mission software developer happens via proxy -classes like pool variable classes. These classes store a copy -of the pool variable with the matching datatype and copy the actual data from the local pool -on a `read` call. Changed variables can then be written to the local pool with a `commit` call. -The `read` and `commit` calls are thread-safe and can be called concurrently from data creators -and data consumers. Generally, a user will create a dataset class which in turn groups all -cohesive pool variables. These sets simply iterator over the list of variables and call the -`read` and `commit` functions of each variable. The following diagram shows the -high-level architecture of the local data pools. - -.. image:: ../misc/logo/FSFW_Logo_V3_bw.png - :alt: FSFW Logo - - -An example is shown for using the local data pools with a Gyroscope. -For example, the following code shows an implementation to access data from a Gyroscope taken -from the SOURCE CubeSat project: - -```cpp -class GyroPrimaryDataset: public StaticLocalDataSet<3 * sizeof(float)> { -public: - /** - * Constructor for data users - * @param gyroId - */ - GyroPrimaryDataset(object_id_t gyroId): - StaticLocalDataSet(sid_t(gyroId, gyrodefs::GYRO_DATA_SET_ID)) { - setAllVariablesReadOnly(); - } - - lp_var_t angVelocityX = lp_var_t(sid.objectId, - gyrodefs::ANGULAR_VELOCITY_X, this); - lp_var_t angVelocityY = lp_var_t(sid.objectId, - gyrodefs::ANGULAR_VELOCITY_Y, this); - lp_var_t angVelocityZ = lp_var_t(sid.objectId, - gyrodefs::ANGULAR_VELOCITY_Z, this); -private: - - friend class GyroHandler; - /** - * Constructor for data creator - * @param hkOwner - */ - GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, gyrodefs::GYRO_DATA_SET_ID) {} -}; -``` - -There is a public constructor for users which sets all variables to read-only and there is a -constructor for the GyroHandler data creator by marking it private and declaring the `GyroHandler` -as a friend class. Both the atittude controller and the `GyroHandler` can now -use the same class definition to access the pool variables with `read` and `commit` semantics -in a thread-safe way. Generally, each class requiring access will have the set class as a member -class. The data creator will also be generally a `DeviceHandlerBase` subclass and some additional -steps are necessary to expose the set for housekeeping purposes. - -### Using the local data pools in a `DeviceHandlerBase` subclass - -It is very common to store data generated by devices like a sensor into a pool which can -then be used by other objects. Therefore, the `DeviceHandlerBase` already has a -local pool. Using the aforementioned example, our `GyroHandler` will now have the set class -as a member: - -```cpp -class GyroHandler: ... { - -public: - ... -private: - ... - GyroPrimaryDataset gyroData; - ... -}; -``` - -The constructor used for the creators expects the owner class as a parameter, so we initialize -the object in the `GyroHandler` constructor like this: - -```cpp -GyroHandler::GyroHandler(object_id_t objectId, object_id_t comIF, - CookieIF *comCookie, uint8_t switchId): - DeviceHandlerBase(objectId, comIF, comCookie), switchId(switchId), - gyroData(this) {} -``` - -We need to assign the set to a reply ID used in the `DeviceHandlerBase`. -The combination of the `GyroHandler` object ID and the reply ID will be the 64-bit structure ID -`sid_t` and is used to globally identify the set, for example when requesting housekeeping data or -generating update messages. We need to assign our custom set class in some way so that the local -pool manager can access the custom data sets as well. -By default, the `getDataSetHandle` will take care of this tasks. The default implementation for a -`DeviceHandlerBase` subclass will use the internal command map to retrieve -a handle to a dataset from a given reply ID. Therefore, -we assign the set in the `fillCommandAndReplyMap` function: - -```cpp -void GyroHandler::fillCommandAndReplyMap() { - ... - this->insertInCommandAndReplyMap(gyrodefs::GYRO_DATA, 3, &gyroData); - ... -} -``` - -Now, we need to create the actual pool entries as well, using the `initializeLocalDataPool` -function. Here, we also immediately subscribe for periodic housekeeping packets -with an interval of 4 seconds. They are still disabled in this example and can be enabled -with a housekeeping service command. - -```cpp -ReturnValue_t GyroHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_X, - new PoolEntry({0.0})); - localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_Y, - new PoolEntry({0.0})); - localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_Z, - new PoolEntry({0.0})); - localDataPoolMap.emplace(gyrodefs::GENERAL_CONFIG_REG42, - new PoolEntry({0})); - localDataPoolMap.emplace(gyrodefs::RANGE_CONFIG_REG43, - new PoolEntry({0})); - - poolManager.subscribeForPeriodicPacket(gyroData.getSid(), false, 4.0, false); - return returnvalue::OK; -} -``` - -Now, if we receive some sensor data and converted them into the right format, -we can write it into the pool like this, using a guard class to ensure the set is commited back -in any case: - -```cpp -PoolReadGuard readHelper(&gyroData); -if(readHelper.getReadResult() == returnvalue::OK) { - if(not gyroData.isValid()) { - gyroData.setValidity(true, true); - } - - gyroData.angVelocityX = angularVelocityX; - gyroData.angVelocityY = angularVelocityY; - gyroData.angVelocityZ = angularVelocityZ; -} -``` - -The guard class will commit the changed data on destruction automatically. - -### Using the local data pools in a `ExtendedControllerBase` subclass - -Coming soon - - diff --git a/docs/README-osal.md b/docs/README-osal.md deleted file mode 100644 index 6f8ce60f..00000000 --- a/docs/README-osal.md +++ /dev/null @@ -1,32 +0,0 @@ -# Operating System Abstraction Layer (OSAL) - -Some specific information on the provided OSALs are provided. - -## Linux OSAL - -This OSAL can be used to compile for Linux host systems like Ubuntu 20.04 or for -embedded Linux targets like the Raspberry Pi. This OSAL generally requires threading support -and real-time functionalities. For most UNIX systems, this is done by adding `-lrt` and `-lpthread` to the linked libraries in the compilation process. The CMake build support provided will do this automatically for the `fsfw` target. It should be noted that most UNIX systems need to be configured specifically to allow the real-time functionalities required by the FSFW. - -More information on how to set up a Linux system accordingly can be found in the -[Linux README of the FSFW example application](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example/src/branch/master/doc/README-linux.md#top) - -## Hosted OSAL - -This is the newest OSAL. Support for Semaphores has not been implemented yet and will propably be implemented as soon as C++20 with Semaphore support has matured. This OSAL can be used to run the FSFW on any host system, but currently has only been tested on Windows 10 and Ubuntu 20.04. Unlike the other OSALs, it uses dynamic memory allocation (e.g. for the message queue implementation). Cross-platform serial port (USB) support might be added soon. - -## FreeRTOS OSAL - -FreeRTOS is not included and the developer needs to take care of compiling the FreeRTOS sources and adding the `FreeRTOSConfig.h` file location to the include path. This OSAL has only been tested extensively with the pre-emptive scheduler configuration so far but it should in principle also be possible to use a cooperative scheduler. It is recommended to use the `heap_4` allocation scheme. When using newlib (nano), it is also recommended to add `#define configUSE_NEWLIB_REENTRANT` to the FreeRTOS configuration file to ensure thread-safety. - -When using this OSAL, developers also need to provide an implementation for the `vRequestContextSwitchFromISR` function. This has been done because the call to request a context switch from an ISR is generally located in the `portmacro.h` header and is different depending on the target architecture or device. - -## RTEMS OSAL - -The RTEMS OSAL was the first implemented OSAL which is also used on the active satellite Flying Laptop. - -## TCP/IP socket abstraction - -The Linux and Host OSAL provide abstraction layers for the socket API. Currently, only UDP sockets have been imlemented. This is very useful to test TMTC handling either on the host computer directly (targeting localhost with a TMTC application) or on embedded Linux devices, sending TMTC packets via Ethernet. - - diff --git a/docs/README-pus.md b/docs/README-pus.md deleted file mode 100644 index 928d2eda..00000000 --- a/docs/README-pus.md +++ /dev/null @@ -1 +0,0 @@ -## PUS Services From bcbbc9763a80af27e7ccd0d1ebd0342d13ad5eb0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 14:00:01 +0200 Subject: [PATCH 391/532] markdown update not required, will be removed --- docs/README-highlevel.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md index 23e27da3..9005af8d 100644 --- a/docs/README-highlevel.md +++ b/docs/README-highlevel.md @@ -4,13 +4,12 @@ High-level overview # Structure The general structure is driven by the usage of interfaces provided by objects. -The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this -standard, even for micocontrollers. - -The FSFW might use dynamic allocation during program initialization but not during runtime. -It offers pool objects, static containers and it also exposes the Embedded Template Library -to allow writing code which does not perform allocation during runtime. The fsfw uses run-time type -information but will not throw exceptions. +The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be +widely available, even with older compilers. +The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. +This simplifies the instantiation of objects and allows the usage of some standard containers. +Dynamic Allocation after initialization is discouraged and different solutions are provided in the +FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed. # Failure Handling From 954c749de023934f73272a2dcfe07fcfdd40dae7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 16:02:46 +0200 Subject: [PATCH 392/532] additional docs --- src/fsfw/filesystem/HasFileSystemIF.h | 6 +++++- src/fsfw_hal/host/HostFilesystem.cpp | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index ee8c5f91..c86d12b9 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -83,7 +83,11 @@ class HasFileSystemIF { virtual ReturnValue_t truncateFile(FilesystemParams params) = 0; /** - * @brief Generic function to append to file. + * @brief Generic function to write to a file. + * + * @details + * Implementations should not truncate the file. This is equivalent to opening a file with "r+" on Unix systems + * or using ios::out | ios::in with the C++ API. * @param fileOpInfo General information: File name, size to write, offset, additional arguments * @param data The data to write to the file */ diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp index 6dc099b1..fe593f27 100644 --- a/src/fsfw_hal/host/HostFilesystem.cpp +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -18,7 +18,9 @@ ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *da if (not exists(path)) { return HasFileSystemIF::FILE_DOES_NOT_EXIST; } - ofstream file(path, ios::binary | ios::out); + // This is equivalent to "r+" mode, which is what we need here. Only using ::out would truncate + // the file + ofstream file(path, ios::binary | ios::out | ios::in); if (file.fail()) { return HasFileSystemIF::GENERIC_FILE_ERROR; } From 2fee2fdff591c0ca44480b493d90b4c86f78a622 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 16:20:52 +0200 Subject: [PATCH 393/532] unittest which would have caught this --- src/fsfw/filesystem/HasFileSystemIF.h | 4 ++-- unittests/hal/testHostFilesystem.cpp | 34 ++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index c86d12b9..6f7112ad 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -86,8 +86,8 @@ class HasFileSystemIF { * @brief Generic function to write to a file. * * @details - * Implementations should not truncate the file. This is equivalent to opening a file with "r+" on Unix systems - * or using ios::out | ios::in with the C++ API. + * Implementations should not truncate the file. This is equivalent to opening a file with "r+" + * on Unix systems or using ios::out | ios::in with the C++ API. * @param fileOpInfo General information: File name, size to write, offset, additional arguments * @param data The data to write to the file */ diff --git a/unittests/hal/testHostFilesystem.cpp b/unittests/hal/testHostFilesystem.cpp index 3873d5e9..e33b30cc 100644 --- a/unittests/hal/testHostFilesystem.cpp +++ b/unittests/hal/testHostFilesystem.cpp @@ -1,6 +1,9 @@ +#include + #include #include #include +#include #include "fsfw/serialize/SerializeIF.h" #include "fsfw_hal/host/HostFilesystem.h" @@ -70,12 +73,37 @@ TEST_CASE("Host Filesystem", "[hal][host]") { returnvalue::OK); CHECK(fs::file_size(file0) == data.size()); ifstream ifile(file0); - char readBuf[524]{}; - ifile.read(readBuf, sizeof(readBuf)); - std::string readBackString(readBuf); + std::array readBuf{}; + ifile.read(readBuf.data(), sizeof(readBuf)); + std::string readBackString(readBuf.data()); CHECK(data == readBackString); } + SECTION("Write To File, Check Not Truncated") { + std::random_device dev; + std::mt19937 rng(dev()); + std::uniform_int_distribution distU8(1, 255); + std::array randData{}; + for (uint8_t& byte : randData) { + byte = distU8(rng); + } + FileOpParams params(file0.c_str(), randData.size() - 256); + REQUIRE(hostFs.createFile(params.fsParams) == returnvalue::OK); + CHECK(fs::is_regular_file(file0)); + REQUIRE(fs::exists(file0)); + // Write first file chunk + CHECK(hostFs.writeToFile(params, randData.cbegin()) == returnvalue::OK); + params.offset = 256; + CHECK(hostFs.writeToFile(params, randData.cbegin() + 256) == returnvalue::OK); + std::ifstream rf(file0, ios::binary); + std::array readBack{}; + REQUIRE(std::filesystem::file_size(file0) == 512); + rf.read(reinterpret_cast(readBack.data()), readBack.size()); + for (size_t i = 0; i < 512; i++) { + CHECK(randData[i] == readBack[i]); + } + } + SECTION("Read From File") { std::string data = "hello world!"; FileOpParams params(file0.c_str(), data.size()); From 54762232a412b32d8451821741501bad3c52b858 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 16:46:09 +0200 Subject: [PATCH 394/532] refactoring and condition code to strin converter --- src/fsfw/cfdp/CMakeLists.txt | 2 +- src/fsfw/cfdp/definitions.h | 3 +- src/fsfw/cfdp/handler/FaultHandlerBase.cpp | 14 ++--- src/fsfw/cfdp/handler/FaultHandlerBase.h | 37 ++++++------- src/fsfw/cfdp/handler/UserBase.h | 10 ++-- src/fsfw/cfdp/helpers.cpp | 52 +++++++++++++++++++ src/fsfw/cfdp/helpers.h | 11 ++++ src/fsfw/cfdp/pdu/AckInfo.cpp | 6 +-- src/fsfw/cfdp/pdu/AckInfo.h | 8 +-- src/fsfw/cfdp/pdu/AckPduCreator.cpp | 2 +- src/fsfw/cfdp/pdu/AckPduReader.cpp | 2 +- src/fsfw/cfdp/pdu/EofInfo.cpp | 10 ++-- src/fsfw/cfdp/pdu/EofInfo.h | 8 +-- src/fsfw/cfdp/pdu/EofPduCreator.cpp | 2 +- src/fsfw/cfdp/pdu/EofPduReader.cpp | 4 +- src/fsfw/cfdp/pdu/FinishedInfo.cpp | 6 +-- src/fsfw/cfdp/pdu/FinishedInfo.h | 8 +-- src/fsfw/cfdp/pdu/FinishedPduReader.cpp | 8 +-- src/fsfw/cfdp/pdu/FinishedPduReader.h | 2 +- src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp | 4 +- src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h | 4 +- 21 files changed, 134 insertions(+), 69 deletions(-) create mode 100644 src/fsfw/cfdp/helpers.cpp create mode 100644 src/fsfw/cfdp/helpers.h diff --git a/src/fsfw/cfdp/CMakeLists.txt b/src/fsfw/cfdp/CMakeLists.txt index 30a7c700..f4d60201 100644 --- a/src/fsfw/cfdp/CMakeLists.txt +++ b/src/fsfw/cfdp/CMakeLists.txt @@ -1,5 +1,5 @@ target_sources(${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp - VarLenFields.cpp) + VarLenFields.cpp helpers.cpp) add_subdirectory(pdu) add_subdirectory(tlv) diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 35c4c5f8..e6297bd7 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -82,7 +82,7 @@ enum FileDirectives : uint8_t { KEEP_ALIVE = 0x0c }; -enum ConditionCode : uint8_t { +enum ConditionCodes : uint8_t { NO_CONDITION_FIELD = 0xff, NO_ERROR = 0b0000, POSITIVE_ACK_LIMIT_REACHED = 0b0001, @@ -99,6 +99,7 @@ enum ConditionCode : uint8_t { CANCEL_REQUEST_RECEIVED = 0b1111 }; + enum FaultHandlerCodes { RESERVED = 0b0000, NOTICE_OF_CANCELLATION = 0b0001, diff --git a/src/fsfw/cfdp/handler/FaultHandlerBase.cpp b/src/fsfw/cfdp/handler/FaultHandlerBase.cpp index 1dbfce0d..0531846c 100644 --- a/src/fsfw/cfdp/handler/FaultHandlerBase.cpp +++ b/src/fsfw/cfdp/handler/FaultHandlerBase.cpp @@ -5,7 +5,7 @@ namespace cfdp { FaultHandlerBase::FaultHandlerBase() = default; FaultHandlerBase::~FaultHandlerBase() = default; -bool FaultHandlerBase::getFaultHandler(cfdp::ConditionCode code, +bool FaultHandlerBase::getFaultHandler(cfdp::ConditionCodes code, cfdp::FaultHandlerCodes& handler) const { auto iter = faultHandlerMap.find(code); if (iter == faultHandlerMap.end()) { @@ -15,7 +15,7 @@ bool FaultHandlerBase::getFaultHandler(cfdp::ConditionCode code, return true; } -bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes handler) { +bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCodes code, cfdp::FaultHandlerCodes handler) { if (not faultHandlerMap.contains(code)) { return false; } @@ -29,19 +29,19 @@ bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHand return true; } -bool FaultHandlerBase::reportFault(cfdp::ConditionCode code) { +bool FaultHandlerBase::reportFault(cfdp::TransactionId& id, cfdp::ConditionCodes code) { if (not faultHandlerMap.contains(code)) { return false; } cfdp::FaultHandlerCodes fh = faultHandlerMap[code]; if (fh == cfdp::FaultHandlerCodes::IGNORE_ERROR) { - ignoreCb(code); + ignoreCb(id, code); } else if (fh == cfdp::FaultHandlerCodes::ABANDON_TRANSACTION) { - abandonCb(code); + abandonCb(id, code); } else if (fh == cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION) { - noticeOfCancellationCb(code); + noticeOfCancellationCb(id, code); } else if (fh == cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION) { - noticeOfSuspensionCb(code); + noticeOfSuspensionCb(id, code); } else { // Should never happen, but use defensive programming return false; diff --git a/src/fsfw/cfdp/handler/FaultHandlerBase.h b/src/fsfw/cfdp/handler/FaultHandlerBase.h index 48b9c42e..0c7f534c 100644 --- a/src/fsfw/cfdp/handler/FaultHandlerBase.h +++ b/src/fsfw/cfdp/handler/FaultHandlerBase.h @@ -3,6 +3,7 @@ #include +#include "fsfw/cfdp/VarLenFields.h" #include "fsfw/cfdp/definitions.h" namespace cfdp { @@ -42,33 +43,33 @@ class FaultHandlerBase { * - true if the condition code is valid * - false otherwise */ - bool getFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes& handler) const; + bool getFaultHandler(cfdp::ConditionCodes code, cfdp::FaultHandlerCodes& handler) const; - bool setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes handler); + bool setFaultHandler(cfdp::ConditionCodes code, cfdp::FaultHandlerCodes handler); - bool reportFault(cfdp::ConditionCode code); + bool reportFault(cfdp::TransactionId& id, cfdp::ConditionCodes code); - virtual void noticeOfSuspensionCb(cfdp::ConditionCode code) = 0; - virtual void noticeOfCancellationCb(cfdp::ConditionCode code) = 0; - virtual void abandonCb(cfdp::ConditionCode code) = 0; - virtual void ignoreCb(cfdp::ConditionCode code) = 0; + virtual void noticeOfSuspensionCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0; + virtual void noticeOfCancellationCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0; + virtual void abandonCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0; + virtual void ignoreCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0; private: - etl::flat_map faultHandlerMap = { - etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED, + etl::flat_map faultHandlerMap = { + etl::pair{cfdp::ConditionCodes::POSITIVE_ACK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED, + etl::pair{cfdp::ConditionCodes::KEEP_ALIVE_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCode::INVALID_TRANSMISSION_MODE, + etl::pair{cfdp::ConditionCodes::INVALID_TRANSMISSION_MODE, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCode::FILE_CHECKSUM_FAILURE, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCode::FILE_SIZE_ERROR, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCode::NAK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCode::INACTIVITY_DETECTED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE, + etl::pair{cfdp::ConditionCodes::FILE_CHECKSUM_FAILURE, cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCodes::FILE_SIZE_ERROR, cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCodes::NAK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCodes::INACTIVITY_DETECTED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCodes::UNSUPPORTED_CHECKSUM_TYPE, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCode::FILESTORE_REJECTION, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCode::CHECK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}}; + etl::pair{cfdp::ConditionCodes::FILESTORE_REJECTION, cfdp::FaultHandlerCodes::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCodes::CHECK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}}; }; } // namespace cfdp diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index e367b4a8..4ff5eb96 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -14,12 +14,12 @@ namespace cfdp { struct TransactionFinishedParams { - TransactionFinishedParams(const TransactionId& id, ConditionCode code, FileDeliveryCode delivCode, + TransactionFinishedParams(const TransactionId& id, ConditionCodes code, FileDeliveryCode delivCode, FileDeliveryStatus status) : id(id), condCode(code), status(status), deliveryCode(delivCode) {} const TransactionId& id; - ConditionCode condCode; + ConditionCodes condCode; FileDeliveryStatus status; FileDeliveryCode deliveryCode; std::vector fsResponses; @@ -85,10 +85,10 @@ class UserBase { virtual void metadataRecvdIndication(const MetadataRecvdParams& params) = 0; virtual void fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) = 0; virtual void reportIndication(const TransactionId& id, StatusReportIF& report) = 0; - virtual void suspendedIndication(const TransactionId& id, ConditionCode code) = 0; + virtual void suspendedIndication(const TransactionId& id, ConditionCodes code) = 0; virtual void resumedIndication(const TransactionId& id, size_t progress) = 0; - virtual void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) = 0; - virtual void abandonedIndication(const TransactionId& id, ConditionCode code, + virtual void faultIndication(const TransactionId& id, ConditionCodes code, size_t progress) = 0; + virtual void abandonedIndication(const TransactionId& id, ConditionCodes code, size_t progress) = 0; virtual void eofRecvIndication(const TransactionId& id) = 0; diff --git a/src/fsfw/cfdp/helpers.cpp b/src/fsfw/cfdp/helpers.cpp new file mode 100644 index 00000000..49839e1f --- /dev/null +++ b/src/fsfw/cfdp/helpers.cpp @@ -0,0 +1,52 @@ +#include "helpers.h" + +const char* COND_CODE_STRINGS[14] = { + "Unknown", + "No Error", + "Positive ACK Limit Reached", + "Keep Alive Limit Reached", + "Invalid Transmission Mode", + "Filestore Rejection", + "File Checksum Failure", + "File Size Error", + "NAK limit reached", + "Inactivity Detected", + "Check Limit Reached", + "Unsupported Checksum Type", + "Suspend Request Received", + "Cancel Request Received" +}; + +const char* cfdp::getConditionCodeString(cfdp::ConditionCodes code) { + switch (code) { + case NO_CONDITION_FIELD: + return COND_CODE_STRINGS[0]; + case NO_ERROR: + return COND_CODE_STRINGS[1]; + case POSITIVE_ACK_LIMIT_REACHED: + return COND_CODE_STRINGS[2]; + case KEEP_ALIVE_LIMIT_REACHED: + return COND_CODE_STRINGS[3]; + case INVALID_TRANSMISSION_MODE: + return COND_CODE_STRINGS[4]; + case FILESTORE_REJECTION: + return COND_CODE_STRINGS[5]; + case FILE_CHECKSUM_FAILURE: + return COND_CODE_STRINGS[6]; + case FILE_SIZE_ERROR: + return COND_CODE_STRINGS[7]; + case NAK_LIMIT_REACHED: + return COND_CODE_STRINGS[8]; + case INACTIVITY_DETECTED: + return COND_CODE_STRINGS[9]; + case CHECK_LIMIT_REACHED: + return COND_CODE_STRINGS[10]; + case UNSUPPORTED_CHECKSUM_TYPE: + return COND_CODE_STRINGS[11]; + case SUSPEND_REQUEST_RECEIVED: + return COND_CODE_STRINGS[12]; + case CANCEL_REQUEST_RECEIVED: + return COND_CODE_STRINGS[13]; + } + return "Unknown"; +} diff --git a/src/fsfw/cfdp/helpers.h b/src/fsfw/cfdp/helpers.h new file mode 100644 index 00000000..df64c847 --- /dev/null +++ b/src/fsfw/cfdp/helpers.h @@ -0,0 +1,11 @@ +#ifndef FSFW_EXAMPLE_HOSTED_HELPER_H +#define FSFW_EXAMPLE_HOSTED_HELPER_H + +#include "definitions.h" + +namespace cfdp { + +const char* getConditionCodeString(cfdp::ConditionCodes code); + +} +#endif // FSFW_EXAMPLE_HOSTED_HELPER_H diff --git a/src/fsfw/cfdp/pdu/AckInfo.cpp b/src/fsfw/cfdp/pdu/AckInfo.cpp index f35cfbb1..240f1bfb 100644 --- a/src/fsfw/cfdp/pdu/AckInfo.cpp +++ b/src/fsfw/cfdp/pdu/AckInfo.cpp @@ -1,6 +1,6 @@ #include "AckInfo.h" -AckInfo::AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCode ackedConditionCode, +AckInfo::AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCodes ackedConditionCode, cfdp::AckTransactionStatus transactionStatus, uint8_t directiveSubtypeCode) : ackedDirective(ackedDirective), ackedConditionCode(ackedConditionCode), @@ -13,9 +13,9 @@ AckInfo::AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCode ackedC } } -cfdp::ConditionCode AckInfo::getAckedConditionCode() const { return ackedConditionCode; } +cfdp::ConditionCodes AckInfo::getAckedConditionCode() const { return ackedConditionCode; } -void AckInfo::setAckedConditionCode(cfdp::ConditionCode ackedConditionCode) { +void AckInfo::setAckedConditionCode(cfdp::ConditionCodes ackedConditionCode) { this->ackedConditionCode = ackedConditionCode; if (ackedDirective == cfdp::FileDirectives::FINISH) { this->directiveSubtypeCode = 0b0001; diff --git a/src/fsfw/cfdp/pdu/AckInfo.h b/src/fsfw/cfdp/pdu/AckInfo.h index 572fc59f..2781ee73 100644 --- a/src/fsfw/cfdp/pdu/AckInfo.h +++ b/src/fsfw/cfdp/pdu/AckInfo.h @@ -6,11 +6,11 @@ class AckInfo { public: AckInfo(); - AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCode ackedConditionCode, + AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCodes ackedConditionCode, cfdp::AckTransactionStatus transactionStatus, uint8_t directiveSubtypeCode = 0); - cfdp::ConditionCode getAckedConditionCode() const; - void setAckedConditionCode(cfdp::ConditionCode ackedConditionCode); + cfdp::ConditionCodes getAckedConditionCode() const; + void setAckedConditionCode(cfdp::ConditionCodes ackedConditionCode); cfdp::FileDirectives getAckedDirective() const; void setAckedDirective(cfdp::FileDirectives ackedDirective); @@ -23,7 +23,7 @@ class AckInfo { private: cfdp::FileDirectives ackedDirective = cfdp::FileDirectives::INVALID_DIRECTIVE; - cfdp::ConditionCode ackedConditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD; + cfdp::ConditionCodes ackedConditionCode = cfdp::ConditionCodes::NO_CONDITION_FIELD; cfdp::AckTransactionStatus transactionStatus = cfdp::AckTransactionStatus::UNDEFINED; uint8_t directiveSubtypeCode = 0; }; diff --git a/src/fsfw/cfdp/pdu/AckPduCreator.cpp b/src/fsfw/cfdp/pdu/AckPduCreator.cpp index 88fcedc9..8683c65f 100644 --- a/src/fsfw/cfdp/pdu/AckPduCreator.cpp +++ b/src/fsfw/cfdp/pdu/AckPduCreator.cpp @@ -13,7 +13,7 @@ ReturnValue_t AckPduCreator::serialize(uint8_t **buffer, size_t *size, size_t ma } cfdp::FileDirectives ackedDirective = ackInfo.getAckedDirective(); uint8_t directiveSubtypeCode = ackInfo.getDirectiveSubtypeCode(); - cfdp::ConditionCode ackedConditionCode = ackInfo.getAckedConditionCode(); + cfdp::ConditionCodes ackedConditionCode = ackInfo.getAckedConditionCode(); cfdp::AckTransactionStatus transactionStatus = ackInfo.getTransactionStatus(); if (ackedDirective != cfdp::FileDirectives::FINISH and ackedDirective != cfdp::FileDirectives::EOF_DIRECTIVE) { diff --git a/src/fsfw/cfdp/pdu/AckPduReader.cpp b/src/fsfw/cfdp/pdu/AckPduReader.cpp index 4f75a2b8..efa6f6df 100644 --- a/src/fsfw/cfdp/pdu/AckPduReader.cpp +++ b/src/fsfw/cfdp/pdu/AckPduReader.cpp @@ -29,7 +29,7 @@ bool AckPduReader::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) { return false; } this->info.setDirectiveSubtypeCode(directiveSubtypeCode); - this->info.setAckedConditionCode(static_cast(secondByte >> 4)); + this->info.setAckedConditionCode(static_cast(secondByte >> 4)); this->info.setTransactionStatus(static_cast(secondByte & 0x0f)); return true; } diff --git a/src/fsfw/cfdp/pdu/EofInfo.cpp b/src/fsfw/cfdp/pdu/EofInfo.cpp index 98e79df7..b19a709b 100644 --- a/src/fsfw/cfdp/pdu/EofInfo.cpp +++ b/src/fsfw/cfdp/pdu/EofInfo.cpp @@ -1,18 +1,18 @@ #include "EofInfo.h" -EofInfo::EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::FileSize fileSize, +EofInfo::EofInfo(cfdp::ConditionCodes conditionCode, uint32_t checksum, cfdp::FileSize fileSize, EntityIdTlv* faultLoc) : conditionCode(conditionCode), checksum(checksum), fileSize(fileSize), faultLoc(faultLoc) {} EofInfo::EofInfo(EntityIdTlv* faultLoc) - : conditionCode(cfdp::ConditionCode::NO_CONDITION_FIELD), + : conditionCode(cfdp::ConditionCodes::NO_CONDITION_FIELD), checksum(0), fileSize(0), faultLoc(faultLoc) {} uint32_t EofInfo::getChecksum() const { return checksum; } -cfdp::ConditionCode EofInfo::getConditionCode() const { return conditionCode; } +cfdp::ConditionCodes EofInfo::getConditionCode() const { return conditionCode; } EntityIdTlv* EofInfo::getFaultLoc() const { return faultLoc; } @@ -20,7 +20,7 @@ cfdp::FileSize& EofInfo::getFileSize() { return fileSize; } void EofInfo::setChecksum(uint32_t checksum) { this->checksum = checksum; } -void EofInfo::setConditionCode(cfdp::ConditionCode conditionCode) { +void EofInfo::setConditionCode(cfdp::ConditionCodes conditionCode) { this->conditionCode = conditionCode; } @@ -36,7 +36,7 @@ size_t EofInfo::getSerializedSize(bool fssLarge) { } // Do not account for fault location if the condition code is NO_ERROR. We assume that // a serializer will not serialize the fault location here. - if (getFaultLoc() != nullptr and getConditionCode() != cfdp::ConditionCode::NO_ERROR) { + if (getFaultLoc() != nullptr and getConditionCode() != cfdp::ConditionCodes::NO_ERROR) { size += faultLoc->getSerializedSize(); } return size; diff --git a/src/fsfw/cfdp/pdu/EofInfo.h b/src/fsfw/cfdp/pdu/EofInfo.h index 4b4fb057..bd6e6493 100644 --- a/src/fsfw/cfdp/pdu/EofInfo.h +++ b/src/fsfw/cfdp/pdu/EofInfo.h @@ -8,23 +8,23 @@ struct EofInfo { public: explicit EofInfo(EntityIdTlv* faultLoc = nullptr); - EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::FileSize fileSize, + EofInfo(cfdp::ConditionCodes conditionCode, uint32_t checksum, cfdp::FileSize fileSize, EntityIdTlv* faultLoc = nullptr); size_t getSerializedSize(bool fssLarge = false); [[nodiscard]] uint32_t getChecksum() const; - [[nodiscard]] cfdp::ConditionCode getConditionCode() const; + [[nodiscard]] cfdp::ConditionCodes getConditionCode() const; [[nodiscard]] EntityIdTlv* getFaultLoc() const; cfdp::FileSize& getFileSize(); void setChecksum(uint32_t checksum); - void setConditionCode(cfdp::ConditionCode conditionCode); + void setConditionCode(cfdp::ConditionCodes conditionCode); void setFaultLoc(EntityIdTlv* faultLoc); ReturnValue_t setFileSize(size_t size, bool isLarge); private: - cfdp::ConditionCode conditionCode; + cfdp::ConditionCodes conditionCode; uint32_t checksum; cfdp::FileSize fileSize; EntityIdTlv* faultLoc = nullptr; diff --git a/src/fsfw/cfdp/pdu/EofPduCreator.cpp b/src/fsfw/cfdp/pdu/EofPduCreator.cpp index 20b8c64a..3e196e02 100644 --- a/src/fsfw/cfdp/pdu/EofPduCreator.cpp +++ b/src/fsfw/cfdp/pdu/EofPduCreator.cpp @@ -33,7 +33,7 @@ ReturnValue_t EofPduCreator::serialize(uint8_t **buffer, size_t *size, size_t ma uint32_t fileSizeValue = info.getFileSize().getSize(); result = SerializeAdapter::serialize(&fileSizeValue, buffer, size, maxSize, streamEndianness); } - if (info.getFaultLoc() != nullptr and info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) { + if (info.getFaultLoc() != nullptr and info.getConditionCode() != cfdp::ConditionCodes::NO_ERROR) { result = info.getFaultLoc()->serialize(buffer, size, maxSize, streamEndianness); } return result; diff --git a/src/fsfw/cfdp/pdu/EofPduReader.cpp b/src/fsfw/cfdp/pdu/EofPduReader.cpp index c80c501c..333e1224 100644 --- a/src/fsfw/cfdp/pdu/EofPduReader.cpp +++ b/src/fsfw/cfdp/pdu/EofPduReader.cpp @@ -25,7 +25,7 @@ ReturnValue_t EofPduReader::parseData() { bufPtr += currentIdx; deserLen -= currentIdx; - info.setConditionCode(static_cast(*bufPtr >> 4)); + info.setConditionCode(static_cast(*bufPtr >> 4)); bufPtr += 1; deserLen -= 1; uint32_t checksum = 0; @@ -47,7 +47,7 @@ ReturnValue_t EofPduReader::parseData() { if (result != returnvalue::OK) { return result; } - if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) { + if (info.getConditionCode() != cfdp::ConditionCodes::NO_ERROR) { EntityIdTlv* tlvPtr = info.getFaultLoc(); if (tlvPtr == nullptr) { #if FSFW_VERBOSE_LEVEL >= 1 diff --git a/src/fsfw/cfdp/pdu/FinishedInfo.cpp b/src/fsfw/cfdp/pdu/FinishedInfo.cpp index 2f986e85..5b4ae0ca 100644 --- a/src/fsfw/cfdp/pdu/FinishedInfo.cpp +++ b/src/fsfw/cfdp/pdu/FinishedInfo.cpp @@ -2,7 +2,7 @@ FinishedInfo::FinishedInfo() {} -FinishedInfo::FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FileDeliveryCode deliveryCode, +FinishedInfo::FinishedInfo(cfdp::ConditionCodes conditionCode, cfdp::FileDeliveryCode deliveryCode, cfdp::FileDeliveryStatus fileStatus) : conditionCode(conditionCode), deliveryCode(deliveryCode), fileStatus(fileStatus) {} @@ -76,9 +76,9 @@ ReturnValue_t FinishedInfo::getFaultLocation(EntityIdTlv** faultLocation) { return returnvalue::OK; } -cfdp::ConditionCode FinishedInfo::getConditionCode() const { return conditionCode; } +cfdp::ConditionCodes FinishedInfo::getConditionCode() const { return conditionCode; } -void FinishedInfo::setConditionCode(cfdp::ConditionCode conditionCode) { +void FinishedInfo::setConditionCode(cfdp::ConditionCodes conditionCode) { this->conditionCode = conditionCode; } diff --git a/src/fsfw/cfdp/pdu/FinishedInfo.h b/src/fsfw/cfdp/pdu/FinishedInfo.h index 49d7c64d..1a2beade 100644 --- a/src/fsfw/cfdp/pdu/FinishedInfo.h +++ b/src/fsfw/cfdp/pdu/FinishedInfo.h @@ -8,7 +8,7 @@ class FinishedInfo { public: FinishedInfo(); - FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FileDeliveryCode deliveryCode, + FinishedInfo(cfdp::ConditionCodes conditionCode, cfdp::FileDeliveryCode deliveryCode, cfdp::FileDeliveryStatus fileStatus); [[nodiscard]] size_t getSerializedSize() const; @@ -25,15 +25,15 @@ class FinishedInfo { [[nodiscard]] size_t getFsResponsesLen() const; void setFilestoreResponsesArrayLen(size_t fsResponsesLen); ReturnValue_t getFaultLocation(EntityIdTlv** entityId); - [[nodiscard]] cfdp::ConditionCode getConditionCode() const; - void setConditionCode(cfdp::ConditionCode conditionCode); + [[nodiscard]] cfdp::ConditionCodes getConditionCode() const; + void setConditionCode(cfdp::ConditionCodes conditionCode); [[nodiscard]] cfdp::FileDeliveryCode getDeliveryCode() const; void setDeliveryCode(cfdp::FileDeliveryCode deliveryCode); [[nodiscard]] cfdp::FileDeliveryStatus getFileStatus() const; void setFileStatus(cfdp::FileDeliveryStatus fileStatus); private: - cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD; + cfdp::ConditionCodes conditionCode = cfdp::ConditionCodes::NO_CONDITION_FIELD; cfdp::FileDeliveryCode deliveryCode = cfdp::FileDeliveryCode::DATA_COMPLETE; cfdp::FileDeliveryStatus fileStatus = cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY; FilestoreResponseTlv** fsResponses = nullptr; diff --git a/src/fsfw/cfdp/pdu/FinishedPduReader.cpp b/src/fsfw/cfdp/pdu/FinishedPduReader.cpp index 475942e0..a34abf07 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduReader.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduReader.cpp @@ -15,7 +15,7 @@ ReturnValue_t FinishPduReader::parseData() { return SerializeIF::STREAM_TOO_SHORT; } uint8_t firstByte = *buf; - auto condCode = static_cast((firstByte >> 4) & 0x0f); + auto condCode = static_cast((firstByte >> 4) & 0x0f); finishedInfo.setConditionCode(condCode); finishedInfo.setDeliveryCode(static_cast(firstByte >> 2 & 0b1)); finishedInfo.setFileStatus(static_cast(firstByte & 0b11)); @@ -31,7 +31,7 @@ ReturnValue_t FinishPduReader::parseData() { FinishedInfo& FinishPduReader::getInfo() { return finishedInfo; } ReturnValue_t FinishPduReader::parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf, - cfdp::ConditionCode conditionCode) { + cfdp::ConditionCodes conditionCode) { ReturnValue_t result = returnvalue::OK; size_t fsResponsesIdx = 0; auto endianness = getEndianness(); @@ -66,8 +66,8 @@ ReturnValue_t FinishPduReader::parseTlvs(size_t remLen, size_t currentIdx, const } else if (nextTlv == cfdp::TlvTypes::ENTITY_ID) { // This needs to be the last TLV and it should not be here if the condition code // is "No Error" or "Unsupported Checksum Type" - if (conditionCode == cfdp::ConditionCode::NO_ERROR or - conditionCode == cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE) { + if (conditionCode == cfdp::ConditionCodes::NO_ERROR or + conditionCode == cfdp::ConditionCodes::UNSUPPORTED_CHECKSUM_TYPE) { return cfdp::INVALID_TLV_TYPE; } result = finishedInfo.getFaultLocation(&faultLocation); diff --git a/src/fsfw/cfdp/pdu/FinishedPduReader.h b/src/fsfw/cfdp/pdu/FinishedPduReader.h index 791a2ef4..ce489fcd 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduReader.h +++ b/src/fsfw/cfdp/pdu/FinishedPduReader.h @@ -16,7 +16,7 @@ class FinishPduReader : public FileDirectiveReader { FinishedInfo& finishedInfo; ReturnValue_t parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf, - cfdp::ConditionCode conditionCode); + cfdp::ConditionCodes conditionCode); }; #endif /* FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp index 89c12974..684d47c2 100644 --- a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp +++ b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp @@ -1,6 +1,6 @@ #include "FaultHandlerOverrideTlv.h" -FaultHandlerOverrideTlv::FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode, +FaultHandlerOverrideTlv::FaultHandlerOverrideTlv(cfdp::ConditionCodes conditionCode, cfdp::FaultHandlerCodes handlerCode) : conditionCode(conditionCode), handlerCode(handlerCode) {} @@ -44,7 +44,7 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_ } *buffer += 1; *size += 1; - this->conditionCode = static_cast((**buffer >> 4) & 0x0f); + this->conditionCode = static_cast((**buffer >> 4) & 0x0f); this->handlerCode = static_cast(**buffer & 0x0f); *buffer += 1; *size += 1; diff --git a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h index a9cee9e6..33a7fdab 100644 --- a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h +++ b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h @@ -6,7 +6,7 @@ class FaultHandlerOverrideTlv : public TlvIF { public: FaultHandlerOverrideTlv(); - FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode, cfdp::FaultHandlerCodes handlerCode); + FaultHandlerOverrideTlv(cfdp::ConditionCodes conditionCode, cfdp::FaultHandlerCodes handlerCode); ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; @@ -19,7 +19,7 @@ class FaultHandlerOverrideTlv : public TlvIF { [[nodiscard]] cfdp::TlvTypes getType() const override; private: - cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD; + cfdp::ConditionCodes conditionCode = cfdp::ConditionCodes::NO_CONDITION_FIELD; cfdp::FaultHandlerCodes handlerCode = cfdp::FaultHandlerCodes::RESERVED; }; From 6f8ccf83e71b8e08b76b27dbb3528ee9e2fa88cb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 18:41:15 +0200 Subject: [PATCH 395/532] use singular enum names --- src/fsfw/cfdp/definitions.h | 15 +++-- src/fsfw/cfdp/handler/FaultHandlerBase.cpp | 26 ++++----- src/fsfw/cfdp/handler/FaultHandlerBase.h | 44 +++++++------- src/fsfw/cfdp/handler/UserBase.h | 10 ++-- src/fsfw/cfdp/handler/mib.h | 4 +- src/fsfw/cfdp/helpers.cpp | 32 +++++------ src/fsfw/cfdp/helpers.h | 2 +- src/fsfw/cfdp/pdu/AckInfo.cpp | 14 ++--- src/fsfw/cfdp/pdu/AckInfo.h | 14 ++--- src/fsfw/cfdp/pdu/AckPduCreator.cpp | 10 ++-- src/fsfw/cfdp/pdu/AckPduReader.cpp | 14 ++--- src/fsfw/cfdp/pdu/AckPduReader.h | 2 +- src/fsfw/cfdp/pdu/EofInfo.cpp | 10 ++-- src/fsfw/cfdp/pdu/EofInfo.h | 8 +-- src/fsfw/cfdp/pdu/EofPduCreator.cpp | 4 +- src/fsfw/cfdp/pdu/EofPduReader.cpp | 4 +- src/fsfw/cfdp/pdu/FileDataCreator.cpp | 2 +- src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp | 6 +- src/fsfw/cfdp/pdu/FileDirectiveCreator.h | 6 +- src/fsfw/cfdp/pdu/FileDirectiveReader.cpp | 10 ++-- src/fsfw/cfdp/pdu/FileDirectiveReader.h | 6 +- src/fsfw/cfdp/pdu/FinishedInfo.cpp | 6 +- src/fsfw/cfdp/pdu/FinishedInfo.h | 8 +-- src/fsfw/cfdp/pdu/FinishedPduCreator.cpp | 2 +- src/fsfw/cfdp/pdu/FinishedPduReader.cpp | 16 +++--- src/fsfw/cfdp/pdu/FinishedPduReader.h | 2 +- src/fsfw/cfdp/pdu/HeaderCreator.cpp | 8 +-- src/fsfw/cfdp/pdu/HeaderCreator.h | 10 ++-- src/fsfw/cfdp/pdu/HeaderReader.cpp | 8 +-- src/fsfw/cfdp/pdu/KeepAlivePduCreator.cpp | 2 +- src/fsfw/cfdp/pdu/MetadataInfo.cpp | 6 +- src/fsfw/cfdp/pdu/MetadataInfo.h | 8 +-- src/fsfw/cfdp/pdu/MetadataPduCreator.cpp | 2 +- src/fsfw/cfdp/pdu/MetadataPduReader.cpp | 2 +- src/fsfw/cfdp/pdu/NakPduCreator.cpp | 2 +- src/fsfw/cfdp/pdu/PduConfig.cpp | 2 +- src/fsfw/cfdp/pdu/PduConfig.h | 4 +- src/fsfw/cfdp/pdu/PduHeaderIF.h | 4 +- src/fsfw/cfdp/pdu/PduHeaderReader.h | 4 +- src/fsfw/cfdp/pdu/PromptPduCreator.cpp | 2 +- src/fsfw/cfdp/tlv/EntityIdTlv.cpp | 8 +-- src/fsfw/cfdp/tlv/EntityIdTlv.h | 2 +- src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp | 14 ++--- src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h | 8 +-- src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp | 2 +- src/fsfw/cfdp/tlv/FilestoreRequestTlv.h | 2 +- src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp | 2 +- src/fsfw/cfdp/tlv/FilestoreResponseTlv.h | 2 +- src/fsfw/cfdp/tlv/FilestoreTlvBase.h | 2 +- src/fsfw/cfdp/tlv/FlowLabelTlv.cpp | 2 +- src/fsfw/cfdp/tlv/MessageToUserTlv.cpp | 4 +- src/fsfw/cfdp/tlv/Tlv.cpp | 10 ++-- src/fsfw/cfdp/tlv/Tlv.h | 8 +-- src/fsfw/cfdp/tlv/TlvIF.h | 2 +- unittests/cfdp/handler/testDistributor.cpp | 4 +- unittests/cfdp/handler/testFaultHandler.cpp | 57 ++++++++++--------- unittests/cfdp/pdu/testAckPdu.cpp | 32 +++++------ unittests/cfdp/pdu/testCfdpHeader.cpp | 32 +++++------ unittests/cfdp/pdu/testEofPdu.cpp | 10 ++-- unittests/cfdp/pdu/testFileData.cpp | 2 +- unittests/cfdp/pdu/testFileDirective.cpp | 10 ++-- unittests/cfdp/pdu/testFinishedPdu.cpp | 6 +- unittests/cfdp/pdu/testKeepAlivePdu.cpp | 4 +- unittests/cfdp/pdu/testMetadataPdu.cpp | 18 +++--- unittests/cfdp/pdu/testNakPdu.cpp | 4 +- unittests/cfdp/pdu/testPromptPdu.cpp | 4 +- unittests/cfdp/testCfdp.cpp | 10 ++-- unittests/cfdp/testOtherTlvs.cpp | 10 ++-- unittests/cfdp/testTlv.cpp | 24 ++++---- unittests/mocks/cfdp/FaultHandlerMock.cpp | 20 +++---- unittests/mocks/cfdp/FaultHandlerMock.h | 20 +++---- 71 files changed, 337 insertions(+), 339 deletions(-) diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index e6297bd7..2d7a37fc 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -41,7 +41,7 @@ static constexpr ReturnValue_t INVALID_PDU_FORMAT = returnvalue::makeCode(CFDP_C //! Checksum types according to the SANA Checksum Types registry //! https://sanaregistry.org/r/checksum_identifiers/ -enum ChecksumTypes { +enum ChecksumType { // Modular legacy checksum MODULAR = 0, CRC_32_PROXIMITY_1 = 1, @@ -50,9 +50,9 @@ enum ChecksumTypes { NULL_CHECKSUM = 15 }; -enum PduTypes : uint8_t { FILE_DIRECTIVE = 0, FILE_DATA = 1 }; +enum PduType : uint8_t { FILE_DIRECTIVE = 0, FILE_DATA = 1 }; -enum TransmissionModes : uint8_t { ACKNOWLEDGED = 0, UNACKNOWLEDGED = 1 }; +enum TransmissionMode : uint8_t { ACKNOWLEDGED = 0, UNACKNOWLEDGED = 1 }; enum SegmentMetadataFlag : bool { NOT_PRESENT = false, PRESENT = true }; @@ -70,7 +70,7 @@ enum WidthInBytes : uint8_t { FOUR_BYTES = 4, }; -enum FileDirectives : uint8_t { +enum FileDirective : uint8_t { INVALID_DIRECTIVE = 0x0f, // The _DIRECTIVE suffix is mandatory here because of some nameclash! EOF_DIRECTIVE = 0x04, @@ -82,7 +82,7 @@ enum FileDirectives : uint8_t { KEEP_ALIVE = 0x0c }; -enum ConditionCodes : uint8_t { +enum ConditionCode : uint8_t { NO_CONDITION_FIELD = 0xff, NO_ERROR = 0b0000, POSITIVE_ACK_LIMIT_REACHED = 0b0001, @@ -99,8 +99,7 @@ enum ConditionCodes : uint8_t { CANCEL_REQUEST_RECEIVED = 0b1111 }; - -enum FaultHandlerCodes { +enum FaultHandlerCode { RESERVED = 0b0000, NOTICE_OF_CANCELLATION = 0b0001, NOTICE_OF_SUSPENSION = 0b0010, @@ -126,7 +125,7 @@ enum FileDeliveryStatus { enum PromptResponseRequired : uint8_t { PROMPT_NAK = 0, PROMPT_KEEP_ALIVE = 1 }; -enum TlvTypes : uint8_t { +enum TlvType : uint8_t { FILESTORE_REQUEST = 0x00, FILESTORE_RESPONSE = 0x01, MSG_TO_USER = 0x02, diff --git a/src/fsfw/cfdp/handler/FaultHandlerBase.cpp b/src/fsfw/cfdp/handler/FaultHandlerBase.cpp index 0531846c..4e16692e 100644 --- a/src/fsfw/cfdp/handler/FaultHandlerBase.cpp +++ b/src/fsfw/cfdp/handler/FaultHandlerBase.cpp @@ -5,8 +5,8 @@ namespace cfdp { FaultHandlerBase::FaultHandlerBase() = default; FaultHandlerBase::~FaultHandlerBase() = default; -bool FaultHandlerBase::getFaultHandler(cfdp::ConditionCodes code, - cfdp::FaultHandlerCodes& handler) const { +bool FaultHandlerBase::getFaultHandler(cfdp::ConditionCode code, + cfdp::FaultHandlerCode& handler) const { auto iter = faultHandlerMap.find(code); if (iter == faultHandlerMap.end()) { return false; @@ -15,32 +15,32 @@ bool FaultHandlerBase::getFaultHandler(cfdp::ConditionCodes code, return true; } -bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCodes code, cfdp::FaultHandlerCodes handler) { +bool FaultHandlerBase::setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCode handler) { if (not faultHandlerMap.contains(code)) { return false; } - if (handler != FaultHandlerCodes::NOTICE_OF_SUSPENSION and - handler != FaultHandlerCodes::ABANDON_TRANSACTION and - handler != FaultHandlerCodes::NOTICE_OF_CANCELLATION and - handler != FaultHandlerCodes::IGNORE_ERROR) { + if (handler != FaultHandlerCode::NOTICE_OF_SUSPENSION and + handler != FaultHandlerCode::ABANDON_TRANSACTION and + handler != FaultHandlerCode::NOTICE_OF_CANCELLATION and + handler != FaultHandlerCode::IGNORE_ERROR) { return false; } faultHandlerMap[code] = handler; return true; } -bool FaultHandlerBase::reportFault(cfdp::TransactionId& id, cfdp::ConditionCodes code) { +bool FaultHandlerBase::reportFault(cfdp::TransactionId& id, cfdp::ConditionCode code) { if (not faultHandlerMap.contains(code)) { return false; } - cfdp::FaultHandlerCodes fh = faultHandlerMap[code]; - if (fh == cfdp::FaultHandlerCodes::IGNORE_ERROR) { + cfdp::FaultHandlerCode fh = faultHandlerMap[code]; + if (fh == cfdp::FaultHandlerCode::IGNORE_ERROR) { ignoreCb(id, code); - } else if (fh == cfdp::FaultHandlerCodes::ABANDON_TRANSACTION) { + } else if (fh == cfdp::FaultHandlerCode::ABANDON_TRANSACTION) { abandonCb(id, code); - } else if (fh == cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION) { + } else if (fh == cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION) { noticeOfCancellationCb(id, code); - } else if (fh == cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION) { + } else if (fh == cfdp::FaultHandlerCode::NOTICE_OF_SUSPENSION) { noticeOfSuspensionCb(id, code); } else { // Should never happen, but use defensive programming diff --git a/src/fsfw/cfdp/handler/FaultHandlerBase.h b/src/fsfw/cfdp/handler/FaultHandlerBase.h index 0c7f534c..39b8e180 100644 --- a/src/fsfw/cfdp/handler/FaultHandlerBase.h +++ b/src/fsfw/cfdp/handler/FaultHandlerBase.h @@ -43,33 +43,33 @@ class FaultHandlerBase { * - true if the condition code is valid * - false otherwise */ - bool getFaultHandler(cfdp::ConditionCodes code, cfdp::FaultHandlerCodes& handler) const; + bool getFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCode& handler) const; - bool setFaultHandler(cfdp::ConditionCodes code, cfdp::FaultHandlerCodes handler); + bool setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCode handler); - bool reportFault(cfdp::TransactionId& id, cfdp::ConditionCodes code); + bool reportFault(cfdp::TransactionId& id, cfdp::ConditionCode code); - virtual void noticeOfSuspensionCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0; - virtual void noticeOfCancellationCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0; - virtual void abandonCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0; - virtual void ignoreCb(cfdp::TransactionId& id, cfdp::ConditionCodes code) = 0; + virtual void noticeOfSuspensionCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0; + virtual void noticeOfCancellationCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0; + virtual void abandonCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0; + virtual void ignoreCb(cfdp::TransactionId& id, cfdp::ConditionCode code) = 0; private: - etl::flat_map faultHandlerMap = { - etl::pair{cfdp::ConditionCodes::POSITIVE_ACK_LIMIT_REACHED, - cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCodes::KEEP_ALIVE_LIMIT_REACHED, - cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCodes::INVALID_TRANSMISSION_MODE, - cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCodes::FILE_CHECKSUM_FAILURE, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCodes::FILE_SIZE_ERROR, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCodes::NAK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCodes::INACTIVITY_DETECTED, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCodes::UNSUPPORTED_CHECKSUM_TYPE, - cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCodes::FILESTORE_REJECTION, cfdp::FaultHandlerCodes::IGNORE_ERROR}, - etl::pair{cfdp::ConditionCodes::CHECK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR}}; + etl::flat_map faultHandlerMap = { + etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED, + cfdp::FaultHandlerCode::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED, + cfdp::FaultHandlerCode::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::INVALID_TRANSMISSION_MODE, + cfdp::FaultHandlerCode::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::FILE_CHECKSUM_FAILURE, cfdp::FaultHandlerCode::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::FILE_SIZE_ERROR, cfdp::FaultHandlerCode::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::NAK_LIMIT_REACHED, cfdp::FaultHandlerCode::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::INACTIVITY_DETECTED, cfdp::FaultHandlerCode::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE, + cfdp::FaultHandlerCode::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::FILESTORE_REJECTION, cfdp::FaultHandlerCode::IGNORE_ERROR}, + etl::pair{cfdp::ConditionCode::CHECK_LIMIT_REACHED, cfdp::FaultHandlerCode::IGNORE_ERROR}}; }; } // namespace cfdp diff --git a/src/fsfw/cfdp/handler/UserBase.h b/src/fsfw/cfdp/handler/UserBase.h index 4ff5eb96..e367b4a8 100644 --- a/src/fsfw/cfdp/handler/UserBase.h +++ b/src/fsfw/cfdp/handler/UserBase.h @@ -14,12 +14,12 @@ namespace cfdp { struct TransactionFinishedParams { - TransactionFinishedParams(const TransactionId& id, ConditionCodes code, FileDeliveryCode delivCode, + TransactionFinishedParams(const TransactionId& id, ConditionCode code, FileDeliveryCode delivCode, FileDeliveryStatus status) : id(id), condCode(code), status(status), deliveryCode(delivCode) {} const TransactionId& id; - ConditionCodes condCode; + ConditionCode condCode; FileDeliveryStatus status; FileDeliveryCode deliveryCode; std::vector fsResponses; @@ -85,10 +85,10 @@ class UserBase { virtual void metadataRecvdIndication(const MetadataRecvdParams& params) = 0; virtual void fileSegmentRecvdIndication(const FileSegmentRecvdParams& params) = 0; virtual void reportIndication(const TransactionId& id, StatusReportIF& report) = 0; - virtual void suspendedIndication(const TransactionId& id, ConditionCodes code) = 0; + virtual void suspendedIndication(const TransactionId& id, ConditionCode code) = 0; virtual void resumedIndication(const TransactionId& id, size_t progress) = 0; - virtual void faultIndication(const TransactionId& id, ConditionCodes code, size_t progress) = 0; - virtual void abandonedIndication(const TransactionId& id, ConditionCodes code, + virtual void faultIndication(const TransactionId& id, ConditionCode code, size_t progress) = 0; + virtual void abandonedIndication(const TransactionId& id, ConditionCode code, size_t progress) = 0; virtual void eofRecvIndication(const TransactionId& id) = 0; diff --git a/src/fsfw/cfdp/handler/mib.h b/src/fsfw/cfdp/handler/mib.h index 76284f2d..553596a6 100644 --- a/src/fsfw/cfdp/handler/mib.h +++ b/src/fsfw/cfdp/handler/mib.h @@ -32,8 +32,8 @@ struct RemoteEntityCfg { size_t maxFileSegmentLen = 2048; bool closureRequested = false; bool crcOnTransmission = false; - TransmissionModes defaultTransmissionMode = TransmissionModes::UNACKNOWLEDGED; - ChecksumTypes defaultChecksum = ChecksumTypes::NULL_CHECKSUM; + TransmissionMode defaultTransmissionMode = TransmissionMode::UNACKNOWLEDGED; + ChecksumType defaultChecksum = ChecksumType::NULL_CHECKSUM; const uint8_t version = CFDP_VERSION_2; }; diff --git a/src/fsfw/cfdp/helpers.cpp b/src/fsfw/cfdp/helpers.cpp index 49839e1f..fdb7d5ff 100644 --- a/src/fsfw/cfdp/helpers.cpp +++ b/src/fsfw/cfdp/helpers.cpp @@ -1,23 +1,21 @@ #include "helpers.h" -const char* COND_CODE_STRINGS[14] = { - "Unknown", - "No Error", - "Positive ACK Limit Reached", - "Keep Alive Limit Reached", - "Invalid Transmission Mode", - "Filestore Rejection", - "File Checksum Failure", - "File Size Error", - "NAK limit reached", - "Inactivity Detected", - "Check Limit Reached", - "Unsupported Checksum Type", - "Suspend Request Received", - "Cancel Request Received" -}; +const char* COND_CODE_STRINGS[14] = {"Unknown", + "No Error", + "Positive ACK Limit Reached", + "Keep Alive Limit Reached", + "Invalid Transmission Mode", + "Filestore Rejection", + "File Checksum Failure", + "File Size Error", + "NAK limit reached", + "Inactivity Detected", + "Check Limit Reached", + "Unsupported Checksum Type", + "Suspend Request Received", + "Cancel Request Received"}; -const char* cfdp::getConditionCodeString(cfdp::ConditionCodes code) { +const char* cfdp::getConditionCodeString(cfdp::ConditionCode code) { switch (code) { case NO_CONDITION_FIELD: return COND_CODE_STRINGS[0]; diff --git a/src/fsfw/cfdp/helpers.h b/src/fsfw/cfdp/helpers.h index df64c847..37428108 100644 --- a/src/fsfw/cfdp/helpers.h +++ b/src/fsfw/cfdp/helpers.h @@ -5,7 +5,7 @@ namespace cfdp { -const char* getConditionCodeString(cfdp::ConditionCodes code); +const char* getConditionCodeString(cfdp::ConditionCode code); } #endif // FSFW_EXAMPLE_HOSTED_HELPER_H diff --git a/src/fsfw/cfdp/pdu/AckInfo.cpp b/src/fsfw/cfdp/pdu/AckInfo.cpp index 240f1bfb..963f7cbb 100644 --- a/src/fsfw/cfdp/pdu/AckInfo.cpp +++ b/src/fsfw/cfdp/pdu/AckInfo.cpp @@ -1,32 +1,32 @@ #include "AckInfo.h" -AckInfo::AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCodes ackedConditionCode, +AckInfo::AckInfo(cfdp::FileDirective ackedDirective, cfdp::ConditionCode ackedConditionCode, cfdp::AckTransactionStatus transactionStatus, uint8_t directiveSubtypeCode) : ackedDirective(ackedDirective), ackedConditionCode(ackedConditionCode), transactionStatus(transactionStatus), directiveSubtypeCode(directiveSubtypeCode) { - if (ackedDirective == cfdp::FileDirectives::FINISH) { + if (ackedDirective == cfdp::FileDirective::FINISH) { this->directiveSubtypeCode = 0b0001; } else { this->directiveSubtypeCode = 0b0000; } } -cfdp::ConditionCodes AckInfo::getAckedConditionCode() const { return ackedConditionCode; } +cfdp::ConditionCode AckInfo::getAckedConditionCode() const { return ackedConditionCode; } -void AckInfo::setAckedConditionCode(cfdp::ConditionCodes ackedConditionCode) { +void AckInfo::setAckedConditionCode(cfdp::ConditionCode ackedConditionCode) { this->ackedConditionCode = ackedConditionCode; - if (ackedDirective == cfdp::FileDirectives::FINISH) { + if (ackedDirective == cfdp::FileDirective::FINISH) { this->directiveSubtypeCode = 0b0001; } else { this->directiveSubtypeCode = 0b0000; } } -cfdp::FileDirectives AckInfo::getAckedDirective() const { return ackedDirective; } +cfdp::FileDirective AckInfo::getAckedDirective() const { return ackedDirective; } -void AckInfo::setAckedDirective(cfdp::FileDirectives ackedDirective) { +void AckInfo::setAckedDirective(cfdp::FileDirective ackedDirective) { this->ackedDirective = ackedDirective; } diff --git a/src/fsfw/cfdp/pdu/AckInfo.h b/src/fsfw/cfdp/pdu/AckInfo.h index 2781ee73..23e4d6ab 100644 --- a/src/fsfw/cfdp/pdu/AckInfo.h +++ b/src/fsfw/cfdp/pdu/AckInfo.h @@ -6,14 +6,14 @@ class AckInfo { public: AckInfo(); - AckInfo(cfdp::FileDirectives ackedDirective, cfdp::ConditionCodes ackedConditionCode, + AckInfo(cfdp::FileDirective ackedDirective, cfdp::ConditionCode ackedConditionCode, cfdp::AckTransactionStatus transactionStatus, uint8_t directiveSubtypeCode = 0); - cfdp::ConditionCodes getAckedConditionCode() const; - void setAckedConditionCode(cfdp::ConditionCodes ackedConditionCode); + cfdp::ConditionCode getAckedConditionCode() const; + void setAckedConditionCode(cfdp::ConditionCode ackedConditionCode); - cfdp::FileDirectives getAckedDirective() const; - void setAckedDirective(cfdp::FileDirectives ackedDirective); + cfdp::FileDirective getAckedDirective() const; + void setAckedDirective(cfdp::FileDirective ackedDirective); uint8_t getDirectiveSubtypeCode() const; void setDirectiveSubtypeCode(uint8_t directiveSubtypeCode); @@ -22,8 +22,8 @@ class AckInfo { void setTransactionStatus(cfdp::AckTransactionStatus transactionStatus); private: - cfdp::FileDirectives ackedDirective = cfdp::FileDirectives::INVALID_DIRECTIVE; - cfdp::ConditionCodes ackedConditionCode = cfdp::ConditionCodes::NO_CONDITION_FIELD; + cfdp::FileDirective ackedDirective = cfdp::FileDirective::INVALID_DIRECTIVE; + cfdp::ConditionCode ackedConditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD; cfdp::AckTransactionStatus transactionStatus = cfdp::AckTransactionStatus::UNDEFINED; uint8_t directiveSubtypeCode = 0; }; diff --git a/src/fsfw/cfdp/pdu/AckPduCreator.cpp b/src/fsfw/cfdp/pdu/AckPduCreator.cpp index 8683c65f..f7623e57 100644 --- a/src/fsfw/cfdp/pdu/AckPduCreator.cpp +++ b/src/fsfw/cfdp/pdu/AckPduCreator.cpp @@ -1,7 +1,7 @@ #include "AckPduCreator.h" AckPduCreator::AckPduCreator(AckInfo &ackInfo, PduConfig &pduConf) - : FileDirectiveCreator(pduConf, cfdp::FileDirectives::ACK, 2), ackInfo(ackInfo) {} + : FileDirectiveCreator(pduConf, cfdp::FileDirective::ACK, 2), ackInfo(ackInfo) {} size_t AckPduCreator::getSerializedSize() const { return FileDirectiveCreator::getWholePduSize(); } @@ -11,12 +11,12 @@ ReturnValue_t AckPduCreator::serialize(uint8_t **buffer, size_t *size, size_t ma if (result != returnvalue::OK) { return result; } - cfdp::FileDirectives ackedDirective = ackInfo.getAckedDirective(); + cfdp::FileDirective ackedDirective = ackInfo.getAckedDirective(); uint8_t directiveSubtypeCode = ackInfo.getDirectiveSubtypeCode(); - cfdp::ConditionCodes ackedConditionCode = ackInfo.getAckedConditionCode(); + cfdp::ConditionCode ackedConditionCode = ackInfo.getAckedConditionCode(); cfdp::AckTransactionStatus transactionStatus = ackInfo.getTransactionStatus(); - if (ackedDirective != cfdp::FileDirectives::FINISH and - ackedDirective != cfdp::FileDirectives::EOF_DIRECTIVE) { + if (ackedDirective != cfdp::FileDirective::FINISH and + ackedDirective != cfdp::FileDirective::EOF_DIRECTIVE) { // TODO: better returncode return returnvalue::FAILED; } diff --git a/src/fsfw/cfdp/pdu/AckPduReader.cpp b/src/fsfw/cfdp/pdu/AckPduReader.cpp index efa6f6df..7204ced0 100644 --- a/src/fsfw/cfdp/pdu/AckPduReader.cpp +++ b/src/fsfw/cfdp/pdu/AckPduReader.cpp @@ -19,7 +19,7 @@ ReturnValue_t AckPduReader::parseData() { } bool AckPduReader::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) { - cfdp::FileDirectives directive; + cfdp::FileDirective directive; if (not checkAckedDirectiveField(firstByte, directive)) { return false; } @@ -29,17 +29,17 @@ bool AckPduReader::checkAndSetCodes(uint8_t firstByte, uint8_t secondByte) { return false; } this->info.setDirectiveSubtypeCode(directiveSubtypeCode); - this->info.setAckedConditionCode(static_cast(secondByte >> 4)); + this->info.setAckedConditionCode(static_cast(secondByte >> 4)); this->info.setTransactionStatus(static_cast(secondByte & 0x0f)); return true; } bool AckPduReader::checkAckedDirectiveField(uint8_t firstPduDataByte, - cfdp::FileDirectives& ackedDirective) { - uint8_t ackedDirectiveRaw = static_cast(firstPduDataByte >> 4); - if (ackedDirectiveRaw != cfdp::FileDirectives::EOF_DIRECTIVE and - ackedDirectiveRaw != cfdp::FileDirectives::FINISH) { + cfdp::FileDirective& ackedDirective) { + uint8_t ackedDirectiveRaw = static_cast(firstPduDataByte >> 4); + if (ackedDirectiveRaw != cfdp::FileDirective::EOF_DIRECTIVE and + ackedDirectiveRaw != cfdp::FileDirective::FINISH) { return false; } - ackedDirective = (static_cast(ackedDirectiveRaw)); + ackedDirective = (static_cast(ackedDirectiveRaw)); return true; } diff --git a/src/fsfw/cfdp/pdu/AckPduReader.h b/src/fsfw/cfdp/pdu/AckPduReader.h index 2b5dd411..8f8b515b 100644 --- a/src/fsfw/cfdp/pdu/AckPduReader.h +++ b/src/fsfw/cfdp/pdu/AckPduReader.h @@ -16,7 +16,7 @@ class AckPduReader : public FileDirectiveReader { ReturnValue_t parseData() override; static bool checkAckedDirectiveField(uint8_t firstPduDataByte, - cfdp::FileDirectives& ackedDirective); + cfdp::FileDirective& ackedDirective); private: bool checkAndSetCodes(uint8_t rawAckedByte, uint8_t rawAckedConditionCode); diff --git a/src/fsfw/cfdp/pdu/EofInfo.cpp b/src/fsfw/cfdp/pdu/EofInfo.cpp index b19a709b..98e79df7 100644 --- a/src/fsfw/cfdp/pdu/EofInfo.cpp +++ b/src/fsfw/cfdp/pdu/EofInfo.cpp @@ -1,18 +1,18 @@ #include "EofInfo.h" -EofInfo::EofInfo(cfdp::ConditionCodes conditionCode, uint32_t checksum, cfdp::FileSize fileSize, +EofInfo::EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::FileSize fileSize, EntityIdTlv* faultLoc) : conditionCode(conditionCode), checksum(checksum), fileSize(fileSize), faultLoc(faultLoc) {} EofInfo::EofInfo(EntityIdTlv* faultLoc) - : conditionCode(cfdp::ConditionCodes::NO_CONDITION_FIELD), + : conditionCode(cfdp::ConditionCode::NO_CONDITION_FIELD), checksum(0), fileSize(0), faultLoc(faultLoc) {} uint32_t EofInfo::getChecksum() const { return checksum; } -cfdp::ConditionCodes EofInfo::getConditionCode() const { return conditionCode; } +cfdp::ConditionCode EofInfo::getConditionCode() const { return conditionCode; } EntityIdTlv* EofInfo::getFaultLoc() const { return faultLoc; } @@ -20,7 +20,7 @@ cfdp::FileSize& EofInfo::getFileSize() { return fileSize; } void EofInfo::setChecksum(uint32_t checksum) { this->checksum = checksum; } -void EofInfo::setConditionCode(cfdp::ConditionCodes conditionCode) { +void EofInfo::setConditionCode(cfdp::ConditionCode conditionCode) { this->conditionCode = conditionCode; } @@ -36,7 +36,7 @@ size_t EofInfo::getSerializedSize(bool fssLarge) { } // Do not account for fault location if the condition code is NO_ERROR. We assume that // a serializer will not serialize the fault location here. - if (getFaultLoc() != nullptr and getConditionCode() != cfdp::ConditionCodes::NO_ERROR) { + if (getFaultLoc() != nullptr and getConditionCode() != cfdp::ConditionCode::NO_ERROR) { size += faultLoc->getSerializedSize(); } return size; diff --git a/src/fsfw/cfdp/pdu/EofInfo.h b/src/fsfw/cfdp/pdu/EofInfo.h index bd6e6493..4b4fb057 100644 --- a/src/fsfw/cfdp/pdu/EofInfo.h +++ b/src/fsfw/cfdp/pdu/EofInfo.h @@ -8,23 +8,23 @@ struct EofInfo { public: explicit EofInfo(EntityIdTlv* faultLoc = nullptr); - EofInfo(cfdp::ConditionCodes conditionCode, uint32_t checksum, cfdp::FileSize fileSize, + EofInfo(cfdp::ConditionCode conditionCode, uint32_t checksum, cfdp::FileSize fileSize, EntityIdTlv* faultLoc = nullptr); size_t getSerializedSize(bool fssLarge = false); [[nodiscard]] uint32_t getChecksum() const; - [[nodiscard]] cfdp::ConditionCodes getConditionCode() const; + [[nodiscard]] cfdp::ConditionCode getConditionCode() const; [[nodiscard]] EntityIdTlv* getFaultLoc() const; cfdp::FileSize& getFileSize(); void setChecksum(uint32_t checksum); - void setConditionCode(cfdp::ConditionCodes conditionCode); + void setConditionCode(cfdp::ConditionCode conditionCode); void setFaultLoc(EntityIdTlv* faultLoc); ReturnValue_t setFileSize(size_t size, bool isLarge); private: - cfdp::ConditionCodes conditionCode; + cfdp::ConditionCode conditionCode; uint32_t checksum; cfdp::FileSize fileSize; EntityIdTlv* faultLoc = nullptr; diff --git a/src/fsfw/cfdp/pdu/EofPduCreator.cpp b/src/fsfw/cfdp/pdu/EofPduCreator.cpp index 3e196e02..12a3e696 100644 --- a/src/fsfw/cfdp/pdu/EofPduCreator.cpp +++ b/src/fsfw/cfdp/pdu/EofPduCreator.cpp @@ -3,7 +3,7 @@ #include "fsfw/FSFW.h" EofPduCreator::EofPduCreator(PduConfig &conf, EofInfo &info) - : FileDirectiveCreator(conf, cfdp::FileDirectives::EOF_DIRECTIVE, 9), info(info) { + : FileDirectiveCreator(conf, cfdp::FileDirective::EOF_DIRECTIVE, 9), info(info) { setDirectiveDataFieldLen(info.getSerializedSize(HeaderCreator::getLargeFileFlag())); } @@ -33,7 +33,7 @@ ReturnValue_t EofPduCreator::serialize(uint8_t **buffer, size_t *size, size_t ma uint32_t fileSizeValue = info.getFileSize().getSize(); result = SerializeAdapter::serialize(&fileSizeValue, buffer, size, maxSize, streamEndianness); } - if (info.getFaultLoc() != nullptr and info.getConditionCode() != cfdp::ConditionCodes::NO_ERROR) { + if (info.getFaultLoc() != nullptr and info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) { result = info.getFaultLoc()->serialize(buffer, size, maxSize, streamEndianness); } return result; diff --git a/src/fsfw/cfdp/pdu/EofPduReader.cpp b/src/fsfw/cfdp/pdu/EofPduReader.cpp index 333e1224..c80c501c 100644 --- a/src/fsfw/cfdp/pdu/EofPduReader.cpp +++ b/src/fsfw/cfdp/pdu/EofPduReader.cpp @@ -25,7 +25,7 @@ ReturnValue_t EofPduReader::parseData() { bufPtr += currentIdx; deserLen -= currentIdx; - info.setConditionCode(static_cast(*bufPtr >> 4)); + info.setConditionCode(static_cast(*bufPtr >> 4)); bufPtr += 1; deserLen -= 1; uint32_t checksum = 0; @@ -47,7 +47,7 @@ ReturnValue_t EofPduReader::parseData() { if (result != returnvalue::OK) { return result; } - if (info.getConditionCode() != cfdp::ConditionCodes::NO_ERROR) { + if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) { EntityIdTlv* tlvPtr = info.getFaultLoc(); if (tlvPtr == nullptr) { #if FSFW_VERBOSE_LEVEL >= 1 diff --git a/src/fsfw/cfdp/pdu/FileDataCreator.cpp b/src/fsfw/cfdp/pdu/FileDataCreator.cpp index b9a45b5a..956752fb 100644 --- a/src/fsfw/cfdp/pdu/FileDataCreator.cpp +++ b/src/fsfw/cfdp/pdu/FileDataCreator.cpp @@ -3,7 +3,7 @@ #include FileDataCreator::FileDataCreator(PduConfig& conf, FileDataInfo& info) - : HeaderCreator(conf, cfdp::PduTypes::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) { + : HeaderCreator(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) { update(); } diff --git a/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp index 1e4da14d..20f93df9 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.cpp @@ -1,8 +1,8 @@ #include "FileDirectiveCreator.h" -FileDirectiveCreator::FileDirectiveCreator(PduConfig &pduConf, cfdp::FileDirectives directiveCode, +FileDirectiveCreator::FileDirectiveCreator(PduConfig &pduConf, cfdp::FileDirective directiveCode, size_t directiveParamFieldLen) - : HeaderCreator(pduConf, cfdp::PduTypes::FILE_DIRECTIVE, directiveParamFieldLen + 1), + : HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1), directiveCode(directiveCode) {} size_t FileDirectiveCreator::getSerializedSize() const { @@ -36,4 +36,4 @@ void FileDirectiveCreator::setDirectiveDataFieldLen(size_t len) { HeaderCreator::setPduDataFieldLen(len + 1); } -cfdp::FileDirectives FileDirectiveCreator::getDirectiveCode() const { return directiveCode; } +cfdp::FileDirective FileDirectiveCreator::getDirectiveCode() const { return directiveCode; } diff --git a/src/fsfw/cfdp/pdu/FileDirectiveCreator.h b/src/fsfw/cfdp/pdu/FileDirectiveCreator.h index a3b676b0..9b7f2f52 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveCreator.h +++ b/src/fsfw/cfdp/pdu/FileDirectiveCreator.h @@ -5,10 +5,10 @@ class FileDirectiveCreator : public HeaderCreator { public: - FileDirectiveCreator(PduConfig& pduConf, cfdp::FileDirectives directiveCode, + FileDirectiveCreator(PduConfig& pduConf, cfdp::FileDirective directiveCode, size_t directiveParamFieldLen); - [[nodiscard]] cfdp::FileDirectives getDirectiveCode() const; + [[nodiscard]] cfdp::FileDirective getDirectiveCode() const; /** * This only returns the size of the PDU header + 1 for the directive code octet. @@ -28,7 +28,7 @@ class FileDirectiveCreator : public HeaderCreator { void setDirectiveDataFieldLen(size_t len); private: - cfdp::FileDirectives directiveCode = cfdp::FileDirectives::INVALID_DIRECTIVE; + cfdp::FileDirective directiveCode = cfdp::FileDirective::INVALID_DIRECTIVE; }; #endif /* FSFW_SRC_FSFW_CFDP_PDU_FILEDIRECTIVESERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp index 748ac830..f5fc6e58 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp @@ -3,7 +3,7 @@ FileDirectiveReader::FileDirectiveReader(const uint8_t *pduBuf, size_t maxSize) : PduHeaderReader(pduBuf, maxSize) {} -cfdp::FileDirectives FileDirectiveReader::getFileDirective() const { return fileDirective; } +cfdp::FileDirective FileDirectiveReader::getFileDirective() const { return fileDirective; } ReturnValue_t FileDirectiveReader::parseData() { ReturnValue_t result = PduHeaderReader::parseData(); @@ -20,7 +20,7 @@ ReturnValue_t FileDirectiveReader::parseData() { if (not checkFileDirective(pointers.rawPtr[currentIdx])) { return cfdp::INVALID_DIRECTIVE_FIELD; } - setFileDirective(static_cast(pointers.rawPtr[currentIdx])); + setFileDirective(static_cast(pointers.rawPtr[currentIdx])); return returnvalue::OK; } @@ -30,15 +30,15 @@ size_t FileDirectiveReader::getHeaderSize() const { } bool FileDirectiveReader::checkFileDirective(uint8_t rawByte) { - if (rawByte < cfdp::FileDirectives::EOF_DIRECTIVE or - (rawByte > cfdp::FileDirectives::PROMPT and rawByte != cfdp::FileDirectives::KEEP_ALIVE)) { + if (rawByte < cfdp::FileDirective::EOF_DIRECTIVE or + (rawByte > cfdp::FileDirective::PROMPT and rawByte != cfdp::FileDirective::KEEP_ALIVE)) { // Invalid directive field return false; } return true; } -void FileDirectiveReader::setFileDirective(cfdp::FileDirectives fileDirective_) { +void FileDirectiveReader::setFileDirective(cfdp::FileDirective fileDirective_) { fileDirective = fileDirective_; } diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.h b/src/fsfw/cfdp/pdu/FileDirectiveReader.h index 5bec486c..9e88e006 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveReader.h +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.h @@ -22,7 +22,7 @@ class FileDirectiveReader : public PduHeaderReader { ReturnValue_t parseData() override; [[nodiscard]] size_t getHeaderSize() const override; - [[nodiscard]] cfdp::FileDirectives getFileDirective() const; + [[nodiscard]] cfdp::FileDirective getFileDirective() const; void setEndianness(SerializeIF::Endianness endianness); [[nodiscard]] SerializeIF::Endianness getEndianness() const; @@ -30,8 +30,8 @@ class FileDirectiveReader : public PduHeaderReader { protected: private: - void setFileDirective(cfdp::FileDirectives fileDirective); - cfdp::FileDirectives fileDirective = cfdp::FileDirectives::INVALID_DIRECTIVE; + void setFileDirective(cfdp::FileDirective fileDirective); + cfdp::FileDirective fileDirective = cfdp::FileDirective::INVALID_DIRECTIVE; SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK; }; diff --git a/src/fsfw/cfdp/pdu/FinishedInfo.cpp b/src/fsfw/cfdp/pdu/FinishedInfo.cpp index 5b4ae0ca..2f986e85 100644 --- a/src/fsfw/cfdp/pdu/FinishedInfo.cpp +++ b/src/fsfw/cfdp/pdu/FinishedInfo.cpp @@ -2,7 +2,7 @@ FinishedInfo::FinishedInfo() {} -FinishedInfo::FinishedInfo(cfdp::ConditionCodes conditionCode, cfdp::FileDeliveryCode deliveryCode, +FinishedInfo::FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FileDeliveryCode deliveryCode, cfdp::FileDeliveryStatus fileStatus) : conditionCode(conditionCode), deliveryCode(deliveryCode), fileStatus(fileStatus) {} @@ -76,9 +76,9 @@ ReturnValue_t FinishedInfo::getFaultLocation(EntityIdTlv** faultLocation) { return returnvalue::OK; } -cfdp::ConditionCodes FinishedInfo::getConditionCode() const { return conditionCode; } +cfdp::ConditionCode FinishedInfo::getConditionCode() const { return conditionCode; } -void FinishedInfo::setConditionCode(cfdp::ConditionCodes conditionCode) { +void FinishedInfo::setConditionCode(cfdp::ConditionCode conditionCode) { this->conditionCode = conditionCode; } diff --git a/src/fsfw/cfdp/pdu/FinishedInfo.h b/src/fsfw/cfdp/pdu/FinishedInfo.h index 1a2beade..49d7c64d 100644 --- a/src/fsfw/cfdp/pdu/FinishedInfo.h +++ b/src/fsfw/cfdp/pdu/FinishedInfo.h @@ -8,7 +8,7 @@ class FinishedInfo { public: FinishedInfo(); - FinishedInfo(cfdp::ConditionCodes conditionCode, cfdp::FileDeliveryCode deliveryCode, + FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FileDeliveryCode deliveryCode, cfdp::FileDeliveryStatus fileStatus); [[nodiscard]] size_t getSerializedSize() const; @@ -25,15 +25,15 @@ class FinishedInfo { [[nodiscard]] size_t getFsResponsesLen() const; void setFilestoreResponsesArrayLen(size_t fsResponsesLen); ReturnValue_t getFaultLocation(EntityIdTlv** entityId); - [[nodiscard]] cfdp::ConditionCodes getConditionCode() const; - void setConditionCode(cfdp::ConditionCodes conditionCode); + [[nodiscard]] cfdp::ConditionCode getConditionCode() const; + void setConditionCode(cfdp::ConditionCode conditionCode); [[nodiscard]] cfdp::FileDeliveryCode getDeliveryCode() const; void setDeliveryCode(cfdp::FileDeliveryCode deliveryCode); [[nodiscard]] cfdp::FileDeliveryStatus getFileStatus() const; void setFileStatus(cfdp::FileDeliveryStatus fileStatus); private: - cfdp::ConditionCodes conditionCode = cfdp::ConditionCodes::NO_CONDITION_FIELD; + cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD; cfdp::FileDeliveryCode deliveryCode = cfdp::FileDeliveryCode::DATA_COMPLETE; cfdp::FileDeliveryStatus fileStatus = cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY; FilestoreResponseTlv** fsResponses = nullptr; diff --git a/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp b/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp index 88f4491c..8ac22e0a 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp @@ -1,7 +1,7 @@ #include "FinishedPduCreator.h" FinishPduCreator::FinishPduCreator(PduConfig &conf, FinishedInfo &finishInfo) - : FileDirectiveCreator(conf, cfdp::FileDirectives::FINISH, 0), finishInfo(finishInfo) { + : FileDirectiveCreator(conf, cfdp::FileDirective::FINISH, 0), finishInfo(finishInfo) { updateDirectiveFieldLen(); } diff --git a/src/fsfw/cfdp/pdu/FinishedPduReader.cpp b/src/fsfw/cfdp/pdu/FinishedPduReader.cpp index a34abf07..08dd3a82 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduReader.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduReader.cpp @@ -15,7 +15,7 @@ ReturnValue_t FinishPduReader::parseData() { return SerializeIF::STREAM_TOO_SHORT; } uint8_t firstByte = *buf; - auto condCode = static_cast((firstByte >> 4) & 0x0f); + auto condCode = static_cast((firstByte >> 4) & 0x0f); finishedInfo.setConditionCode(condCode); finishedInfo.setDeliveryCode(static_cast(firstByte >> 2 & 0b1)); finishedInfo.setFileStatus(static_cast(firstByte & 0b11)); @@ -31,14 +31,14 @@ ReturnValue_t FinishPduReader::parseData() { FinishedInfo& FinishPduReader::getInfo() { return finishedInfo; } ReturnValue_t FinishPduReader::parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf, - cfdp::ConditionCodes conditionCode) { + cfdp::ConditionCode conditionCode) { ReturnValue_t result = returnvalue::OK; size_t fsResponsesIdx = 0; auto endianness = getEndianness(); FilestoreResponseTlv** fsResponseArray = nullptr; size_t fsResponseMaxArrayLen = 0; EntityIdTlv* faultLocation = nullptr; - cfdp::TlvTypes nextTlv = cfdp::TlvTypes::INVALID_TLV; + cfdp::TlvType nextTlv = cfdp::TlvType::INVALID_TLV; while (remLen > 0) { // Simply forward parse the TLV type. Every TLV type except the last one must be a Filestore // Response TLV, and even the last one can be a Filestore Response TLV if the fault @@ -46,8 +46,8 @@ ReturnValue_t FinishPduReader::parseTlvs(size_t remLen, size_t currentIdx, const if (currentIdx + 2 > maxSize) { return SerializeIF::STREAM_TOO_SHORT; } - nextTlv = static_cast(*buf); - if (nextTlv == cfdp::TlvTypes::FILESTORE_RESPONSE) { + nextTlv = static_cast(*buf); + if (nextTlv == cfdp::TlvType::FILESTORE_RESPONSE) { if (fsResponseArray == nullptr) { if (not finishedInfo.canHoldFsResponses()) { return cfdp::FINISHED_CANT_PARSE_FS_RESPONSES; @@ -63,11 +63,11 @@ ReturnValue_t FinishPduReader::parseTlvs(size_t remLen, size_t currentIdx, const return result; } fsResponsesIdx += 1; - } else if (nextTlv == cfdp::TlvTypes::ENTITY_ID) { + } else if (nextTlv == cfdp::TlvType::ENTITY_ID) { // This needs to be the last TLV and it should not be here if the condition code // is "No Error" or "Unsupported Checksum Type" - if (conditionCode == cfdp::ConditionCodes::NO_ERROR or - conditionCode == cfdp::ConditionCodes::UNSUPPORTED_CHECKSUM_TYPE) { + if (conditionCode == cfdp::ConditionCode::NO_ERROR or + conditionCode == cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE) { return cfdp::INVALID_TLV_TYPE; } result = finishedInfo.getFaultLocation(&faultLocation); diff --git a/src/fsfw/cfdp/pdu/FinishedPduReader.h b/src/fsfw/cfdp/pdu/FinishedPduReader.h index ce489fcd..791a2ef4 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduReader.h +++ b/src/fsfw/cfdp/pdu/FinishedPduReader.h @@ -16,7 +16,7 @@ class FinishPduReader : public FileDirectiveReader { FinishedInfo& finishedInfo; ReturnValue_t parseTlvs(size_t remLen, size_t currentIdx, const uint8_t* buf, - cfdp::ConditionCodes conditionCode); + cfdp::ConditionCode conditionCode); }; #endif /* FSFW_CFDP_PDU_FINISHEDPDUDESERIALIZER_H_ */ diff --git a/src/fsfw/cfdp/pdu/HeaderCreator.cpp b/src/fsfw/cfdp/pdu/HeaderCreator.cpp index 3c50c396..29688575 100644 --- a/src/fsfw/cfdp/pdu/HeaderCreator.cpp +++ b/src/fsfw/cfdp/pdu/HeaderCreator.cpp @@ -1,6 +1,6 @@ #include "HeaderCreator.h" -HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduTypes pduType, size_t initPduDataFieldLen, +HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen, cfdp::SegmentMetadataFlag segmentMetadataFlag, cfdp::SegmentationControl segCtrl) : pduType(pduType), @@ -65,17 +65,17 @@ void HeaderCreator::setPduDataFieldLen(size_t pduDataFieldLen_) { pduDataFieldLen = pduDataFieldLen_; } -void HeaderCreator::setPduType(cfdp::PduTypes pduType_) { pduType = pduType_; } +void HeaderCreator::setPduType(cfdp::PduType pduType_) { pduType = pduType_; } void HeaderCreator::setSegmentMetadataFlag(cfdp::SegmentMetadataFlag segmentMetadataFlag_) { segmentMetadataFlag = segmentMetadataFlag_; } -cfdp::PduTypes HeaderCreator::getPduType() const { return pduType; } +cfdp::PduType HeaderCreator::getPduType() const { return pduType; } cfdp::Direction HeaderCreator::getDirection() const { return pduConf.direction; } -cfdp::TransmissionModes HeaderCreator::getTransmissionMode() const { return pduConf.mode; } +cfdp::TransmissionMode HeaderCreator::getTransmissionMode() const { return pduConf.mode; } bool HeaderCreator::getCrcFlag() const { return pduConf.crcFlag; } diff --git a/src/fsfw/cfdp/pdu/HeaderCreator.h b/src/fsfw/cfdp/pdu/HeaderCreator.h index a4b5c7ff..173a6239 100644 --- a/src/fsfw/cfdp/pdu/HeaderCreator.h +++ b/src/fsfw/cfdp/pdu/HeaderCreator.h @@ -9,7 +9,7 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF { public: HeaderCreator( - PduConfig& pduConf, cfdp::PduTypes pduType, size_t initPduDataFieldLen, + PduConfig& pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen, cfdp::SegmentMetadataFlag segmentMetadataFlag = cfdp::SegmentMetadataFlag::NOT_PRESENT, cfdp::SegmentationControl segCtrl = cfdp::SegmentationControl::NO_RECORD_BOUNDARIES_PRESERVATION); @@ -29,15 +29,15 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF { Endianness streamEndianness) override; void setPduDataFieldLen(size_t pduDataFieldLen); - void setPduType(cfdp::PduTypes pduType); + void setPduType(cfdp::PduType pduType); void setSegmentMetadataFlag(cfdp::SegmentMetadataFlag); [[nodiscard]] size_t getPduDataFieldLen() const override; [[nodiscard]] size_t getWholePduSize() const override; - [[nodiscard]] cfdp::PduTypes getPduType() const override; + [[nodiscard]] cfdp::PduType getPduType() const override; [[nodiscard]] cfdp::Direction getDirection() const override; - [[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override; + [[nodiscard]] cfdp::TransmissionMode getTransmissionMode() const override; [[nodiscard]] bool getCrcFlag() const override; [[nodiscard]] bool getLargeFileFlag() const override; [[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const override; @@ -52,7 +52,7 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF { void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const override; private: - cfdp::PduTypes pduType; + cfdp::PduType pduType; cfdp::SegmentMetadataFlag segmentMetadataFlag; cfdp::SegmentationControl segmentationCtrl; size_t pduDataFieldLen; diff --git a/src/fsfw/cfdp/pdu/HeaderReader.cpp b/src/fsfw/cfdp/pdu/HeaderReader.cpp index f8b19ce2..9edf2394 100644 --- a/src/fsfw/cfdp/pdu/HeaderReader.cpp +++ b/src/fsfw/cfdp/pdu/HeaderReader.cpp @@ -57,16 +57,16 @@ size_t PduHeaderReader::getWholePduSize() const { return getPduDataFieldLen() + PduHeaderReader::getHeaderSize(); } -cfdp::PduTypes PduHeaderReader::getPduType() const { - return static_cast((pointers.fixedHeader->firstByte >> 4) & 0x01); +cfdp::PduType PduHeaderReader::getPduType() const { + return static_cast((pointers.fixedHeader->firstByte >> 4) & 0x01); } cfdp::Direction PduHeaderReader::getDirection() const { return static_cast((pointers.fixedHeader->firstByte >> 3) & 0x01); } -cfdp::TransmissionModes PduHeaderReader::getTransmissionMode() const { - return static_cast((pointers.fixedHeader->firstByte >> 2) & 0x01); +cfdp::TransmissionMode PduHeaderReader::getTransmissionMode() const { + return static_cast((pointers.fixedHeader->firstByte >> 2) & 0x01); } bool PduHeaderReader::getCrcFlag() const { return (pointers.fixedHeader->firstByte >> 1) & 0x01; } diff --git a/src/fsfw/cfdp/pdu/KeepAlivePduCreator.cpp b/src/fsfw/cfdp/pdu/KeepAlivePduCreator.cpp index 8b0ad6c8..40747751 100644 --- a/src/fsfw/cfdp/pdu/KeepAlivePduCreator.cpp +++ b/src/fsfw/cfdp/pdu/KeepAlivePduCreator.cpp @@ -1,7 +1,7 @@ #include "KeepAlivePduCreator.h" KeepAlivePduCreator::KeepAlivePduCreator(PduConfig &conf, cfdp::FileSize &progress) - : FileDirectiveCreator(conf, cfdp::FileDirectives::KEEP_ALIVE, 4), progress(progress) { + : FileDirectiveCreator(conf, cfdp::FileDirective::KEEP_ALIVE, 4), progress(progress) { updateDirectiveFieldLen(); } diff --git a/src/fsfw/cfdp/pdu/MetadataInfo.cpp b/src/fsfw/cfdp/pdu/MetadataInfo.cpp index e1eb3ad8..d88bdd87 100644 --- a/src/fsfw/cfdp/pdu/MetadataInfo.cpp +++ b/src/fsfw/cfdp/pdu/MetadataInfo.cpp @@ -1,6 +1,6 @@ #include "MetadataInfo.h" -MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumTypes checksumType, +MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumType, cfdp::FileSize& fileSize, cfdp::StringLv& sourceFileName, cfdp::StringLv& destFileName) : MetadataInfo(fileSize, sourceFileName, destFileName) { @@ -23,9 +23,9 @@ void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray_, std::optional optionsLen, std::optional maxOptionsLen); - [[nodiscard]] cfdp::ChecksumTypes getChecksumType() const; - void setChecksumType(cfdp::ChecksumTypes checksumType); + [[nodiscard]] cfdp::ChecksumType getChecksumType() const; + void setChecksumType(cfdp::ChecksumType checksumType); [[nodiscard]] bool isClosureRequested() const; void setClosureRequested(bool closureRequested = false); @@ -42,7 +42,7 @@ class MetadataInfo { private: bool closureRequested = false; - cfdp::ChecksumTypes checksumType = cfdp::ChecksumTypes::NULL_CHECKSUM; + cfdp::ChecksumType checksumType = cfdp::ChecksumType::NULL_CHECKSUM; cfdp::FileSize& fileSize; cfdp::StringLv& sourceFileName; cfdp::StringLv& destFileName; diff --git a/src/fsfw/cfdp/pdu/MetadataPduCreator.cpp b/src/fsfw/cfdp/pdu/MetadataPduCreator.cpp index fe0d04c2..536a48f4 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduCreator.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduCreator.cpp @@ -1,7 +1,7 @@ #include "MetadataPduCreator.h" MetadataPduCreator::MetadataPduCreator(PduConfig &conf, MetadataInfo &info) - : FileDirectiveCreator(conf, cfdp::FileDirectives::METADATA, 5), info(info) { + : FileDirectiveCreator(conf, cfdp::FileDirective::METADATA, 5), info(info) { updateDirectiveFieldLen(); } diff --git a/src/fsfw/cfdp/pdu/MetadataPduReader.cpp b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp index caf8287b..66025140 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduReader.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp @@ -15,7 +15,7 @@ ReturnValue_t MetadataPduReader::parseData() { return SerializeIF::STREAM_TOO_SHORT; } info.setClosureRequested((*buf >> 6) & 0x01); - info.setChecksumType(static_cast(*buf & 0x0f)); + info.setChecksumType(static_cast(*buf & 0x0f)); remSize -= 1; buf += 1; auto endianness = getEndianness(); diff --git a/src/fsfw/cfdp/pdu/NakPduCreator.cpp b/src/fsfw/cfdp/pdu/NakPduCreator.cpp index c4493fcb..11f3aba9 100644 --- a/src/fsfw/cfdp/pdu/NakPduCreator.cpp +++ b/src/fsfw/cfdp/pdu/NakPduCreator.cpp @@ -1,7 +1,7 @@ #include "NakPduCreator.h" NakPduCreator::NakPduCreator(PduConfig &pduConf, NakInfo &nakInfo) - : FileDirectiveCreator(pduConf, cfdp::FileDirectives::NAK, 0), nakInfo(nakInfo) { + : FileDirectiveCreator(pduConf, cfdp::FileDirective::NAK, 0), nakInfo(nakInfo) { updateDirectiveFieldLen(); } diff --git a/src/fsfw/cfdp/pdu/PduConfig.cpp b/src/fsfw/cfdp/pdu/PduConfig.cpp index dd04e986..ccb20f51 100644 --- a/src/fsfw/cfdp/pdu/PduConfig.cpp +++ b/src/fsfw/cfdp/pdu/PduConfig.cpp @@ -2,7 +2,7 @@ #include -PduConfig::PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionModes mode, +PduConfig::PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionMode mode, cfdp::TransactionSeqNum seqNum, bool crcFlag, bool largeFile, cfdp::Direction direction) : mode(mode), diff --git a/src/fsfw/cfdp/pdu/PduConfig.h b/src/fsfw/cfdp/pdu/PduConfig.h index 368999cc..70f37e38 100644 --- a/src/fsfw/cfdp/pdu/PduConfig.h +++ b/src/fsfw/cfdp/pdu/PduConfig.h @@ -7,11 +7,11 @@ class PduConfig { public: PduConfig() = default; - PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionModes mode, + PduConfig(cfdp::EntityId sourceId, cfdp::EntityId destId, cfdp::TransmissionMode mode, cfdp::TransactionSeqNum seqNum, bool crcFlag = false, bool largeFile = false, cfdp::Direction direction = cfdp::Direction::TOWARDS_RECEIVER); - cfdp::TransmissionModes mode = cfdp::TransmissionModes::ACKNOWLEDGED; + cfdp::TransmissionMode mode = cfdp::TransmissionMode::ACKNOWLEDGED; cfdp::TransactionSeqNum seqNum; cfdp::EntityId sourceId; cfdp::EntityId destId; diff --git a/src/fsfw/cfdp/pdu/PduHeaderIF.h b/src/fsfw/cfdp/pdu/PduHeaderIF.h index d9e4017d..341b0335 100644 --- a/src/fsfw/cfdp/pdu/PduHeaderIF.h +++ b/src/fsfw/cfdp/pdu/PduHeaderIF.h @@ -17,9 +17,9 @@ class PduHeaderIF { [[nodiscard]] virtual size_t getWholePduSize() const = 0; [[nodiscard]] virtual size_t getPduDataFieldLen() const = 0; - [[nodiscard]] virtual cfdp::PduTypes getPduType() const = 0; + [[nodiscard]] virtual cfdp::PduType getPduType() const = 0; [[nodiscard]] virtual cfdp::Direction getDirection() const = 0; - [[nodiscard]] virtual cfdp::TransmissionModes getTransmissionMode() const = 0; + [[nodiscard]] virtual cfdp::TransmissionMode getTransmissionMode() const = 0; [[nodiscard]] virtual bool getCrcFlag() const = 0; [[nodiscard]] virtual bool getLargeFileFlag() const = 0; [[nodiscard]] virtual cfdp::SegmentationControl getSegmentationControl() const = 0; diff --git a/src/fsfw/cfdp/pdu/PduHeaderReader.h b/src/fsfw/cfdp/pdu/PduHeaderReader.h index a36b2145..a2e122cd 100644 --- a/src/fsfw/cfdp/pdu/PduHeaderReader.h +++ b/src/fsfw/cfdp/pdu/PduHeaderReader.h @@ -56,9 +56,9 @@ class PduHeaderReader : public RedirectableDataPointerIF, public PduHeaderIF { [[nodiscard]] size_t getPduDataFieldLen() const override; [[nodiscard]] size_t getWholePduSize() const override; - [[nodiscard]] cfdp::PduTypes getPduType() const override; + [[nodiscard]] cfdp::PduType getPduType() const override; [[nodiscard]] cfdp::Direction getDirection() const override; - [[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override; + [[nodiscard]] cfdp::TransmissionMode getTransmissionMode() const override; [[nodiscard]] bool getCrcFlag() const override; [[nodiscard]] bool getLargeFileFlag() const override; [[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const override; diff --git a/src/fsfw/cfdp/pdu/PromptPduCreator.cpp b/src/fsfw/cfdp/pdu/PromptPduCreator.cpp index 43077cf6..f4141fdb 100644 --- a/src/fsfw/cfdp/pdu/PromptPduCreator.cpp +++ b/src/fsfw/cfdp/pdu/PromptPduCreator.cpp @@ -1,7 +1,7 @@ #include "PromptPduCreator.h" PromptPduCreator::PromptPduCreator(PduConfig &conf, cfdp::PromptResponseRequired responseRequired) - : FileDirectiveCreator(conf, cfdp::FileDirectives::PROMPT, 1), + : FileDirectiveCreator(conf, cfdp::FileDirective::PROMPT, 1), responseRequired(responseRequired) {} size_t PromptPduCreator::getSerializedSize() const { diff --git a/src/fsfw/cfdp/tlv/EntityIdTlv.cpp b/src/fsfw/cfdp/tlv/EntityIdTlv.cpp index 87f55db8..d4c4d6a8 100644 --- a/src/fsfw/cfdp/tlv/EntityIdTlv.cpp +++ b/src/fsfw/cfdp/tlv/EntityIdTlv.cpp @@ -11,7 +11,7 @@ ReturnValue_t EntityIdTlv::serialize(uint8_t **buffer, size_t *size, size_t maxS if (maxSize < this->getSerializedSize()) { return BUFFER_TOO_SHORT; } - **buffer = cfdp::TlvTypes::ENTITY_ID; + **buffer = cfdp::TlvType::ENTITY_ID; *size += 1; *buffer += 1; size_t serLen = entityId.getSerializedSize(); @@ -28,8 +28,8 @@ ReturnValue_t EntityIdTlv::deSerialize(const uint8_t **buffer, size_t *size, if (*size < 3) { return STREAM_TOO_SHORT; } - cfdp::TlvTypes type = static_cast(**buffer); - if (type != cfdp::TlvTypes::ENTITY_ID) { + cfdp::TlvType type = static_cast(**buffer); + if (type != cfdp::TlvType::ENTITY_ID) { return cfdp::INVALID_TLV_TYPE; } *buffer += 1; @@ -54,6 +54,6 @@ ReturnValue_t EntityIdTlv::deSerialize(cfdp::Tlv &tlv, Endianness endianness) { uint8_t EntityIdTlv::getLengthField() const { return 1 + entityId.getSerializedSize(); } -cfdp::TlvTypes EntityIdTlv::getType() const { return cfdp::TlvTypes::ENTITY_ID; } +cfdp::TlvType EntityIdTlv::getType() const { return cfdp::TlvType::ENTITY_ID; } cfdp::EntityId &EntityIdTlv::getEntityId() { return entityId; } diff --git a/src/fsfw/cfdp/tlv/EntityIdTlv.h b/src/fsfw/cfdp/tlv/EntityIdTlv.h index 1443cc17..ac310899 100644 --- a/src/fsfw/cfdp/tlv/EntityIdTlv.h +++ b/src/fsfw/cfdp/tlv/EntityIdTlv.h @@ -27,7 +27,7 @@ class EntityIdTlv : public TlvIF { Endianness streamEndianness) override; uint8_t getLengthField() const override; - cfdp::TlvTypes getType() const override; + cfdp::TlvType getType() const override; cfdp::EntityId& getEntityId(); diff --git a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp index 684d47c2..90b71361 100644 --- a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp +++ b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.cpp @@ -1,7 +1,7 @@ #include "FaultHandlerOverrideTlv.h" -FaultHandlerOverrideTlv::FaultHandlerOverrideTlv(cfdp::ConditionCodes conditionCode, - cfdp::FaultHandlerCodes handlerCode) +FaultHandlerOverrideTlv::FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode, + cfdp::FaultHandlerCode handlerCode) : conditionCode(conditionCode), handlerCode(handlerCode) {} FaultHandlerOverrideTlv::FaultHandlerOverrideTlv() = default; @@ -32,8 +32,8 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_ if (*size < 3) { return SerializeIF::STREAM_TOO_SHORT; } - auto detectedType = static_cast(**buffer); - if (detectedType != cfdp::TlvTypes::FAULT_HANDLER) { + auto detectedType = static_cast(**buffer); + if (detectedType != cfdp::TlvType::FAULT_HANDLER) { return cfdp::INVALID_TLV_TYPE; } *buffer += 1; @@ -44,11 +44,11 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_ } *buffer += 1; *size += 1; - this->conditionCode = static_cast((**buffer >> 4) & 0x0f); - this->handlerCode = static_cast(**buffer & 0x0f); + this->conditionCode = static_cast((**buffer >> 4) & 0x0f); + this->handlerCode = static_cast(**buffer & 0x0f); *buffer += 1; *size += 1; return returnvalue::OK; } -cfdp::TlvTypes FaultHandlerOverrideTlv::getType() const { return cfdp::TlvTypes::FAULT_HANDLER; } +cfdp::TlvType FaultHandlerOverrideTlv::getType() const { return cfdp::TlvType::FAULT_HANDLER; } diff --git a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h index 33a7fdab..9f5cd486 100644 --- a/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h +++ b/src/fsfw/cfdp/tlv/FaultHandlerOverrideTlv.h @@ -6,7 +6,7 @@ class FaultHandlerOverrideTlv : public TlvIF { public: FaultHandlerOverrideTlv(); - FaultHandlerOverrideTlv(cfdp::ConditionCodes conditionCode, cfdp::FaultHandlerCodes handlerCode); + FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode, cfdp::FaultHandlerCode handlerCode); ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override; @@ -16,11 +16,11 @@ class FaultHandlerOverrideTlv : public TlvIF { ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) override; [[nodiscard]] uint8_t getLengthField() const override; - [[nodiscard]] cfdp::TlvTypes getType() const override; + [[nodiscard]] cfdp::TlvType getType() const override; private: - cfdp::ConditionCodes conditionCode = cfdp::ConditionCodes::NO_CONDITION_FIELD; - cfdp::FaultHandlerCodes handlerCode = cfdp::FaultHandlerCodes::RESERVED; + cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD; + cfdp::FaultHandlerCode handlerCode = cfdp::FaultHandlerCode::RESERVED; }; #endif /* FSFW_SRC_FSFW_CFDP_TLV_FAULTHANDLEROVERRIDETLV_H_ */ diff --git a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp index 744d79c1..1022a7d1 100644 --- a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp +++ b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.cpp @@ -76,4 +76,4 @@ ReturnValue_t FilestoreRequestTlv::deSerializeFromValue(const uint8_t **buffer, return result; } -cfdp::TlvTypes FilestoreRequestTlv::getType() const { return cfdp::TlvTypes::FILESTORE_REQUEST; } +cfdp::TlvType FilestoreRequestTlv::getType() const { return cfdp::TlvType::FILESTORE_REQUEST; } diff --git a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h index 94faaa07..02e639b8 100644 --- a/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h +++ b/src/fsfw/cfdp/tlv/FilestoreRequestTlv.h @@ -30,7 +30,7 @@ class FilestoreRequestTlv : public cfdp::FilestoreTlvBase { Endianness streamEndianness) override; [[nodiscard]] uint8_t getLengthField() const override; - [[nodiscard]] cfdp::TlvTypes getType() const override; + [[nodiscard]] cfdp::TlvType getType() const override; private: cfdp::Lv *secondFileName = nullptr; diff --git a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp index 51dccfb7..38b56077 100644 --- a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp +++ b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.cpp @@ -112,4 +112,4 @@ ReturnValue_t FilestoreResponseTlv::deSerialize(const cfdp::Tlv &tlv, Endianness uint8_t FilestoreResponseTlv::getStatusCode() const { return statusCode; } -cfdp::TlvTypes FilestoreResponseTlv::getType() const { return cfdp::TlvTypes::FILESTORE_RESPONSE; } +cfdp::TlvType FilestoreResponseTlv::getType() const { return cfdp::TlvType::FILESTORE_RESPONSE; } diff --git a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h index 47868693..110f1bb4 100644 --- a/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h +++ b/src/fsfw/cfdp/tlv/FilestoreResponseTlv.h @@ -33,7 +33,7 @@ class FilestoreResponseTlv : public cfdp::FilestoreTlvBase { Endianness streamEndianness) override; [[nodiscard]] uint8_t getLengthField() const override; - [[nodiscard]] cfdp::TlvTypes getType() const override; + [[nodiscard]] cfdp::TlvType getType() const override; private: uint8_t statusCode; diff --git a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h index 4aa47c7e..a5974087 100644 --- a/src/fsfw/cfdp/tlv/FilestoreTlvBase.h +++ b/src/fsfw/cfdp/tlv/FilestoreTlvBase.h @@ -102,7 +102,7 @@ class FilestoreTlvBase : public TlvIF { if (*size < 3) { return SerializeIF::STREAM_TOO_SHORT; } - auto type = static_cast(**buffer); + auto type = static_cast(**buffer); if (type != getType()) { return cfdp::INVALID_TLV_TYPE; } diff --git a/src/fsfw/cfdp/tlv/FlowLabelTlv.cpp b/src/fsfw/cfdp/tlv/FlowLabelTlv.cpp index 938af9f4..5f225669 100644 --- a/src/fsfw/cfdp/tlv/FlowLabelTlv.cpp +++ b/src/fsfw/cfdp/tlv/FlowLabelTlv.cpp @@ -1,4 +1,4 @@ #include "FlowLabelTlv.h" FlowLabelTlv::FlowLabelTlv(uint8_t* value, size_t size) - : Tlv(cfdp::TlvTypes::FLOW_LABEL, value, size) {} + : Tlv(cfdp::TlvType::FLOW_LABEL, value, size) {} diff --git a/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp b/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp index c6bf3633..9a3e55ff 100644 --- a/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp +++ b/src/fsfw/cfdp/tlv/MessageToUserTlv.cpp @@ -1,9 +1,9 @@ #include "MessageToUserTlv.h" MessageToUserTlv::MessageToUserTlv(uint8_t* value, size_t size) - : Tlv(cfdp::TlvTypes::MSG_TO_USER, value, size) {} + : Tlv(cfdp::TlvType::MSG_TO_USER, value, size) {} MessageToUserTlv::MessageToUserTlv() : Tlv() {} MessageToUserTlv::MessageToUserTlv(const std::vector& data) - : Tlv(cfdp::TlvTypes::MSG_TO_USER, data.data(), data.size()) {} + : Tlv(cfdp::TlvType::MSG_TO_USER, data.data(), data.size()) {} diff --git a/src/fsfw/cfdp/tlv/Tlv.cpp b/src/fsfw/cfdp/tlv/Tlv.cpp index 9d5f7f15..c3fce612 100644 --- a/src/fsfw/cfdp/tlv/Tlv.cpp +++ b/src/fsfw/cfdp/tlv/Tlv.cpp @@ -1,6 +1,6 @@ #include "Tlv.h" -cfdp::Tlv::Tlv(TlvTypes type, const uint8_t *value, size_t size) +cfdp::Tlv::Tlv(TlvType type, const uint8_t *value, size_t size) : type(type), value(value, size, true) { if (size > 0) { zeroLen = false; @@ -17,7 +17,7 @@ ReturnValue_t cfdp::Tlv::serialize(uint8_t **buffer, size_t *size, size_t maxSiz if (*size + 2 > maxSize) { return BUFFER_TOO_SHORT; } - if (type == TlvTypes::INVALID_TLV) { + if (type == TlvType::INVALID_TLV) { return INVALID_TLV_TYPE; } **buffer = type; @@ -59,7 +59,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, return INVALID_TLV_TYPE; } - type = static_cast(rawType); + type = static_cast(rawType); *buffer += 1; *size -= 1; @@ -83,7 +83,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, const uint8_t *cfdp::Tlv::getValue() const { return value.getConstBuffer(); } -cfdp::TlvTypes cfdp::Tlv::getType() const { return type; } +cfdp::TlvType cfdp::Tlv::getType() const { return type; } bool cfdp::Tlv::checkType(uint8_t rawType) { if (rawType != 0x03 and rawType <= 6) { @@ -101,4 +101,4 @@ void cfdp::Tlv::setValue(uint8_t *value, size_t len) { uint8_t cfdp::Tlv::getLengthField() const { return this->value.getSerializedSize() - 1; } -void cfdp::Tlv::setType(TlvTypes type) { this->type = type; } +void cfdp::Tlv::setType(TlvType type) { this->type = type; } diff --git a/src/fsfw/cfdp/tlv/Tlv.h b/src/fsfw/cfdp/tlv/Tlv.h index ef39f88b..786a3b79 100644 --- a/src/fsfw/cfdp/tlv/Tlv.h +++ b/src/fsfw/cfdp/tlv/Tlv.h @@ -13,7 +13,7 @@ namespace cfdp { */ class Tlv : public TlvIF { public: - Tlv(TlvTypes type, const uint8_t *value, size_t size); + Tlv(TlvType type, const uint8_t *value, size_t size); Tlv(); /** @@ -47,15 +47,15 @@ class Tlv : public TlvIF { void setValue(uint8_t *value, size_t len); [[nodiscard]] const uint8_t *getValue() const; - void setType(TlvTypes type); - [[nodiscard]] TlvTypes getType() const override; + void setType(TlvType type); + [[nodiscard]] TlvType getType() const override; [[nodiscard]] uint8_t getLengthField() const override; private: bool checkType(uint8_t rawType); bool zeroLen = true; - TlvTypes type = TlvTypes::INVALID_TLV; + TlvType type = TlvType::INVALID_TLV; SerialBufferAdapter value; }; diff --git a/src/fsfw/cfdp/tlv/TlvIF.h b/src/fsfw/cfdp/tlv/TlvIF.h index 9a02b241..317d970a 100644 --- a/src/fsfw/cfdp/tlv/TlvIF.h +++ b/src/fsfw/cfdp/tlv/TlvIF.h @@ -8,7 +8,7 @@ class TlvIF : public SerializeIF { virtual ~TlvIF(){}; virtual uint8_t getLengthField() const = 0; - virtual cfdp::TlvTypes getType() const = 0; + virtual cfdp::TlvType getType() const = 0; }; #endif /* FSFW_SRC_FSFW_CFDP_TLVIF_H_ */ diff --git a/unittests/cfdp/handler/testDistributor.cpp b/unittests/cfdp/handler/testDistributor.cpp index f33e1115..8b6c46af 100644 --- a/unittests/cfdp/handler/testDistributor.cpp +++ b/unittests/cfdp/handler/testDistributor.cpp @@ -25,12 +25,12 @@ TEST_CASE("CFDP Distributor", "[cfdp][distributor]") { const cfdp::EntityId& sourceId(groundEntityId); const cfdp::EntityId& destId(obswEntityId); cfdp::TransactionSeqNum seqNum(UnsignedByteField(12)); - auto pduConf = PduConfig(sourceId, destId, cfdp::TransmissionModes::UNACKNOWLEDGED, seqNum); + auto pduConf = PduConfig(sourceId, destId, cfdp::TransmissionMode::UNACKNOWLEDGED, seqNum); std::string sourceFileString = "hello.txt"; cfdp::StringLv sourceFileName(sourceFileString); std::string destFileString = "hello2.txt"; cfdp::StringLv destFileName(destFileString); - MetadataInfo metadataInfo(false, cfdp::ChecksumTypes::CRC_32, fileSize, sourceFileName, + MetadataInfo metadataInfo(false, cfdp::ChecksumType::CRC_32, fileSize, sourceFileName, destFileName); MetadataPduCreator creator(pduConf, metadataInfo); uint8_t* dataPtr = nullptr; diff --git a/unittests/cfdp/handler/testFaultHandler.cpp b/unittests/cfdp/handler/testFaultHandler.cpp index 559744d7..5da9a70d 100644 --- a/unittests/cfdp/handler/testFaultHandler.cpp +++ b/unittests/cfdp/handler/testFaultHandler.cpp @@ -5,80 +5,81 @@ TEST_CASE("CFDP Fault Handler", "[cfdp]") { using namespace cfdp; auto fhMock = FaultHandlerMock(); - cfdp::FaultHandlerCodes fhCode; + cfdp::FaultHandlerCode fhCode; + cfdp::TransactionId id; SECTION("State") { // Verify initial condition CHECK(fhMock.getFaultHandler(ConditionCode::UNSUPPORTED_CHECKSUM_TYPE, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR); CHECK(fhMock.getFaultHandler(ConditionCode::POSITIVE_ACK_LIMIT_REACHED, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR); CHECK(fhMock.getFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR); CHECK(fhMock.getFaultHandler(ConditionCode::INVALID_TRANSMISSION_MODE, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR); CHECK(fhMock.getFaultHandler(ConditionCode::FILESTORE_REJECTION, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR); CHECK(fhMock.getFaultHandler(ConditionCode::FILE_CHECKSUM_FAILURE, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR); CHECK(fhMock.getFaultHandler(ConditionCode::FILE_SIZE_ERROR, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR); CHECK(fhMock.getFaultHandler(ConditionCode::NAK_LIMIT_REACHED, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR); CHECK(fhMock.getFaultHandler(ConditionCode::INACTIVITY_DETECTED, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR); CHECK(fhMock.getFaultHandler(ConditionCode::CHECK_LIMIT_REACHED, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); + CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR); } SECTION("Call Handler, Ignore Fault") { - auto& info = fhMock.getFhInfo(FaultHandlerCodes::IGNORE_ERROR); - CHECK(fhMock.reportFault(ConditionCode::CHECK_LIMIT_REACHED)); + auto& info = fhMock.getFhInfo(FaultHandlerCode::IGNORE_ERROR); + CHECK(fhMock.reportFault(id, ConditionCode::CHECK_LIMIT_REACHED)); CHECK(info.callCount == 1); CHECK(info.condCodes.back() == ConditionCode::CHECK_LIMIT_REACHED); - fhMock.reportFault(ConditionCode::FILE_CHECKSUM_FAILURE); + fhMock.reportFault(id, ConditionCode::FILE_CHECKSUM_FAILURE); CHECK(info.callCount == 2); CHECK(info.condCodes.back() == ConditionCode::FILE_CHECKSUM_FAILURE); } - SECTION("Invalid Reported Code") { CHECK(not fhMock.reportFault(ConditionCode::NO_ERROR)); } + SECTION("Invalid Reported Code") { CHECK(not fhMock.reportFault(id, ConditionCode::NO_ERROR)); } SECTION("Invalid FH code") { CHECK(not fhMock.setFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, - FaultHandlerCodes::RESERVED)); + FaultHandlerCode::RESERVED)); CHECK(fhMock.getFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, fhCode)); - CHECK(fhCode == FaultHandlerCodes::IGNORE_ERROR); - CHECK(not fhMock.setFaultHandler(ConditionCode::NO_ERROR, FaultHandlerCodes::IGNORE_ERROR)); + CHECK(fhCode == FaultHandlerCode::IGNORE_ERROR); + CHECK(not fhMock.setFaultHandler(ConditionCode::NO_ERROR, FaultHandlerCode::IGNORE_ERROR)); CHECK(not fhMock.getFaultHandler(ConditionCode::NO_ERROR, fhCode)); } SECTION("Set Other Fault Handler") { CHECK(fhMock.setFaultHandler(ConditionCode::FILE_CHECKSUM_FAILURE, - FaultHandlerCodes::NOTICE_OF_CANCELLATION)); + FaultHandlerCode::NOTICE_OF_CANCELLATION)); CHECK(fhMock.setFaultHandler(ConditionCode::INACTIVITY_DETECTED, - FaultHandlerCodes::ABANDON_TRANSACTION)); + FaultHandlerCode::ABANDON_TRANSACTION)); CHECK(fhMock.setFaultHandler(ConditionCode::KEEP_ALIVE_LIMIT_REACHED, - FaultHandlerCodes::NOTICE_OF_SUSPENSION)); - auto& ignoreInfo = fhMock.getFhInfo(FaultHandlerCodes::IGNORE_ERROR); - auto& cancellationInfo = fhMock.getFhInfo(FaultHandlerCodes::NOTICE_OF_CANCELLATION); - auto& suspensionInfo = fhMock.getFhInfo(FaultHandlerCodes::NOTICE_OF_SUSPENSION); - auto& abandonInfo = fhMock.getFhInfo(FaultHandlerCodes::ABANDON_TRANSACTION); + FaultHandlerCode::NOTICE_OF_SUSPENSION)); + auto& ignoreInfo = fhMock.getFhInfo(FaultHandlerCode::IGNORE_ERROR); + auto& cancellationInfo = fhMock.getFhInfo(FaultHandlerCode::NOTICE_OF_CANCELLATION); + auto& suspensionInfo = fhMock.getFhInfo(FaultHandlerCode::NOTICE_OF_SUSPENSION); + auto& abandonInfo = fhMock.getFhInfo(FaultHandlerCode::ABANDON_TRANSACTION); - CHECK(fhMock.reportFault(ConditionCode::FILE_CHECKSUM_FAILURE)); + CHECK(fhMock.reportFault(id, ConditionCode::FILE_CHECKSUM_FAILURE)); CHECK(cancellationInfo.callCount == 1); CHECK(cancellationInfo.condCodes.back() == ConditionCode::FILE_CHECKSUM_FAILURE); CHECK(ignoreInfo.callCount == 0); CHECK(suspensionInfo.callCount == 0); CHECK(abandonInfo.callCount == 0); - CHECK(fhMock.reportFault(ConditionCode::INACTIVITY_DETECTED)); + CHECK(fhMock.reportFault(id, ConditionCode::INACTIVITY_DETECTED)); CHECK(cancellationInfo.callCount == 1); CHECK(ignoreInfo.callCount == 0); CHECK(suspensionInfo.callCount == 0); CHECK(abandonInfo.callCount == 1); CHECK(abandonInfo.condCodes.back() == ConditionCode::INACTIVITY_DETECTED); - CHECK(fhMock.reportFault(ConditionCode::KEEP_ALIVE_LIMIT_REACHED)); + CHECK(fhMock.reportFault(id, ConditionCode::KEEP_ALIVE_LIMIT_REACHED)); CHECK(cancellationInfo.callCount == 1); CHECK(ignoreInfo.callCount == 0); CHECK(suspensionInfo.callCount == 1); diff --git a/unittests/cfdp/pdu/testAckPdu.cpp b/unittests/cfdp/pdu/testAckPdu.cpp index 44b66bd5..10b264ec 100644 --- a/unittests/cfdp/pdu/testAckPdu.cpp +++ b/unittests/cfdp/pdu/testAckPdu.cpp @@ -15,19 +15,19 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { auto seqNum = TransactionSeqNum(WidthInBytes::TWO_BYTES, 15); auto sourceId = EntityId(WidthInBytes::TWO_BYTES, 1); auto destId = EntityId(WidthInBytes::TWO_BYTES, 2); - auto pduConf = PduConfig(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); - AckInfo ackInfo(FileDirectives::EOF_DIRECTIVE, ConditionCode::NO_ERROR, + auto pduConf = PduConfig(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum); + AckInfo ackInfo(FileDirective::EOF_DIRECTIVE, ConditionCode::NO_ERROR, AckTransactionStatus::ACTIVE); auto ackSerializer = AckPduCreator(ackInfo, pduConf); result = ackSerializer.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); SECTION("Serialize") { - REQUIRE(buf[sz - 3] == cfdp::FileDirectives::ACK); - REQUIRE((buf[sz - 2] >> 4) == FileDirectives::EOF_DIRECTIVE); + REQUIRE(buf[sz - 3] == cfdp::FileDirective::ACK); + REQUIRE((buf[sz - 2] >> 4) == FileDirective::EOF_DIRECTIVE); REQUIRE((buf[sz - 2] & 0x0f) == 0); REQUIRE(buf[sz - 1] == AckTransactionStatus::ACTIVE); - ackInfo.setAckedDirective(FileDirectives::FINISH); + ackInfo.setAckedDirective(FileDirective::FINISH); ackInfo.setAckedConditionCode(ConditionCode::FILESTORE_REJECTION); ackInfo.setTransactionStatus(AckTransactionStatus::TERMINATED); auto ackSerializer2 = AckPduCreator(ackInfo, pduConf); @@ -35,21 +35,21 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { sz = 0; result = ackSerializer2.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); - REQUIRE(buf[sz - 3] == cfdp::FileDirectives::ACK); - REQUIRE((buf[sz - 2] >> 4) == FileDirectives::FINISH); + REQUIRE(buf[sz - 3] == cfdp::FileDirective::ACK); + REQUIRE((buf[sz - 2] >> 4) == FileDirective::FINISH); REQUIRE((buf[sz - 2] & 0x0f) == 0b0001); REQUIRE((buf[sz - 1] >> 4) == ConditionCode::FILESTORE_REJECTION); REQUIRE((buf[sz - 1] & 0b11) == AckTransactionStatus::TERMINATED); bufptr = buf.data(); sz = 0; - ackInfo.setAckedDirective(FileDirectives::KEEP_ALIVE); + ackInfo.setAckedDirective(FileDirective::KEEP_ALIVE); auto ackSerializer3 = AckPduCreator(ackInfo, pduConf); result = ackSerializer3.serialize(&bufptr, &sz, maxsz, SerializeIF::Endianness::NETWORK); // Invalid file directive REQUIRE(result != returnvalue::OK); - ackInfo.setAckedDirective(FileDirectives::FINISH); + ackInfo.setAckedDirective(FileDirective::FINISH); // buffer too small result = ackSerializer.serialize(&bufptr, &sz, 8, SerializeIF::Endianness::NETWORK); REQUIRE(result == SerializeIF::BUFFER_TOO_SHORT); @@ -60,12 +60,12 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { auto reader = AckPduReader(buf.data(), sz, ackInfo2); result = reader.parseData(); REQUIRE(result == returnvalue::OK); - REQUIRE(ackInfo2.getAckedDirective() == FileDirectives::EOF_DIRECTIVE); + REQUIRE(ackInfo2.getAckedDirective() == FileDirective::EOF_DIRECTIVE); REQUIRE(ackInfo2.getAckedConditionCode() == ConditionCode::NO_ERROR); REQUIRE(ackInfo2.getDirectiveSubtypeCode() == 0); REQUIRE(ackInfo2.getTransactionStatus() == AckTransactionStatus::ACTIVE); - AckInfo newInfo = AckInfo(FileDirectives::FINISH, ConditionCode::FILESTORE_REJECTION, + AckInfo newInfo = AckInfo(FileDirective::FINISH, ConditionCode::FILESTORE_REJECTION, AckTransactionStatus::TERMINATED); auto ackSerializer2 = AckPduCreator(newInfo, pduConf); bufptr = buf.data(); @@ -76,23 +76,23 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { auto reader2 = AckPduReader(buf.data(), sz, ackInfo2); result = reader2.parseData(); REQUIRE(result == returnvalue::OK); - REQUIRE(ackInfo2.getAckedDirective() == FileDirectives::FINISH); + REQUIRE(ackInfo2.getAckedDirective() == FileDirective::FINISH); REQUIRE(ackInfo2.getAckedConditionCode() == ConditionCode::FILESTORE_REJECTION); REQUIRE(ackInfo2.getDirectiveSubtypeCode() == 0b0001); REQUIRE(ackInfo2.getTransactionStatus() == AckTransactionStatus::TERMINATED); uint8_t prevVal = buf[sz - 2]; - buf[sz - 2] = FileDirectives::INVALID_DIRECTIVE << 4; + buf[sz - 2] = FileDirective::INVALID_DIRECTIVE << 4; result = reader2.parseData(); REQUIRE(result == cfdp::INVALID_ACK_DIRECTIVE_FIELDS); - buf[sz - 2] = FileDirectives::FINISH << 4 | 0b1111; + buf[sz - 2] = FileDirective::FINISH << 4 | 0b1111; result = reader2.parseData(); REQUIRE(result == cfdp::INVALID_ACK_DIRECTIVE_FIELDS); buf[sz - 2] = prevVal; - buf[sz - 3] = cfdp::FileDirectives::INVALID_DIRECTIVE; + buf[sz - 3] = cfdp::FileDirective::INVALID_DIRECTIVE; result = reader2.parseData(); REQUIRE(result == cfdp::INVALID_DIRECTIVE_FIELD); - buf[sz - 3] = cfdp::FileDirectives::ACK; + buf[sz - 3] = cfdp::FileDirective::ACK; auto maxSizeTooSmall = AckPduReader(buf.data(), sz - 2, ackInfo2); result = maxSizeTooSmall.parseData(); REQUIRE(result == SerializeIF::STREAM_TOO_SHORT); diff --git a/unittests/cfdp/pdu/testCfdpHeader.cpp b/unittests/cfdp/pdu/testCfdpHeader.cpp index b51450ec..5f81bec9 100644 --- a/unittests/cfdp/pdu/testCfdpHeader.cpp +++ b/unittests/cfdp/pdu/testCfdpHeader.cpp @@ -17,11 +17,11 @@ TEST_CASE("CFDP Header", "[cfdp]") { cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0); cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1); PduConfig pduConf = - PduConfig(sourceId, destId, cfdp::TransmissionModes::ACKNOWLEDGED, seqNum, false); + PduConfig(sourceId, destId, cfdp::TransmissionMode::ACKNOWLEDGED, seqNum, false); uint8_t* serTarget = serBuf.data(); const uint8_t* deserTarget = serTarget; size_t serSize = 0; - auto creator = HeaderCreator(pduConf, cfdp::PduTypes::FILE_DIRECTIVE, 0); + auto creator = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0); SECTION("Header State") { REQUIRE(seqNum.getSerializedSize() == 1); @@ -33,10 +33,10 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(creator.getLargeFileFlag() == false); REQUIRE(creator.getLenEntityIds() == 1); REQUIRE(creator.getLenSeqNum() == 1); - REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE); + REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DIRECTIVE); REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); REQUIRE(creator.getSegmentationControl() == false); - REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); + REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionMode::ACKNOWLEDGED); cfdp::TransactionSeqNum seqNumLocal; creator.getTransactionSeqNum(seqNumLocal); REQUIRE(seqNumLocal.getWidth() == cfdp::WidthInBytes::ONE_BYTE); @@ -85,9 +85,9 @@ TEST_CASE("CFDP Header", "[cfdp]") { pduConf.crcFlag = true; pduConf.largeFile = true; pduConf.direction = cfdp::Direction::TOWARDS_SENDER; - pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; + pduConf.mode = cfdp::TransmissionMode::UNACKNOWLEDGED; creator.setSegmentationControl(cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); - creator.setPduType(cfdp::PduTypes::FILE_DATA); + creator.setPduType(cfdp::PduType::FILE_DATA); creator.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); serTarget = serBuf.data(); serSize = 0; @@ -103,9 +103,9 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(creator.getLargeFileFlag() == true); REQUIRE(creator.getLenEntityIds() == 1); REQUIRE(creator.getLenSeqNum() == 1); - REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DATA); + REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DATA); REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); - REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); + REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionMode::UNACKNOWLEDGED); REQUIRE(creator.getSegmentationControl() == true); } @@ -122,9 +122,9 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(creator.getLargeFileFlag() == true); REQUIRE(creator.getLenEntityIds() == 4); REQUIRE(creator.getLenSeqNum() == 2); - REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DATA); + REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DATA); REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); - REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); + REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionMode::UNACKNOWLEDGED); REQUIRE(creator.getSegmentationControl() == true); // Last three bits are 2 now (length of seq number) and bit 1 to bit 3 is 4 (len entity IDs) REQUIRE(serBuf[3] == 0b11001010); @@ -235,10 +235,10 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(reader.getLargeFileFlag() == false); REQUIRE(reader.getLenEntityIds() == 1); REQUIRE(reader.getLenSeqNum() == 1); - REQUIRE(reader.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE); + REQUIRE(reader.getPduType() == cfdp::PduType::FILE_DIRECTIVE); REQUIRE(reader.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT); REQUIRE(reader.getSegmentationControl() == false); - REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED); + REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionMode::ACKNOWLEDGED); // No PDU data contained, so the PDU data field is empty REQUIRE(reader.getPduDataField() == nullptr); @@ -253,9 +253,9 @@ TEST_CASE("CFDP Header", "[cfdp]") { pduConf.crcFlag = true; pduConf.largeFile = true; pduConf.direction = cfdp::Direction::TOWARDS_SENDER; - pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED; + pduConf.mode = cfdp::TransmissionMode::UNACKNOWLEDGED; creator.setSegmentationControl(cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION); - creator.setPduType(cfdp::PduTypes::FILE_DATA); + creator.setPduType(cfdp::PduType::FILE_DATA); creator.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT); result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff); REQUIRE(result == returnvalue::OK); @@ -278,10 +278,10 @@ TEST_CASE("CFDP Header", "[cfdp]") { REQUIRE(reader.getLargeFileFlag() == true); REQUIRE(reader.getLenEntityIds() == 4); REQUIRE(reader.getLenSeqNum() == 2); - REQUIRE(reader.getPduType() == cfdp::PduTypes::FILE_DATA); + REQUIRE(reader.getPduType() == cfdp::PduType::FILE_DATA); REQUIRE(reader.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT); REQUIRE(reader.getSegmentationControl() == true); - REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED); + REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionMode::UNACKNOWLEDGED); // Again, no data field set because this is a header only REQUIRE(reader.getPduDataField() == nullptr); diff --git a/unittests/cfdp/pdu/testEofPdu.cpp b/unittests/cfdp/pdu/testEofPdu.cpp index c6718e20..83e61780 100644 --- a/unittests/cfdp/pdu/testEofPdu.cpp +++ b/unittests/cfdp/pdu/testEofPdu.cpp @@ -20,7 +20,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") { TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); + PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum); auto eofSerializer = EofPduCreator(pduConf, eofInfo); SECTION("Serialize") { @@ -37,7 +37,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") { SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); REQUIRE(fileSizeVal == 12); - REQUIRE(buf[sz - 10] == cfdp::FileDirectives::EOF_DIRECTIVE); + REQUIRE(buf[sz - 10] == cfdp::FileDirective::EOF_DIRECTIVE); REQUIRE(buf[sz - 9] == 0x00); REQUIRE(sz == 20); @@ -52,13 +52,13 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") { SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); REQUIRE(sz == 28); - REQUIRE(buf[10] == cfdp::FileDirectives::EOF_DIRECTIVE); + REQUIRE(buf[10] == cfdp::FileDirective::EOF_DIRECTIVE); REQUIRE(buf[11] >> 4 == cfdp::ConditionCode::FILESTORE_REJECTION); uint64_t fileSizeLarge = 0; result = SerializeAdapter::deSerialize(&fileSizeLarge, buf.data() + 16, nullptr, SerializeIF::Endianness::NETWORK); REQUIRE(fileSizeLarge == 0x10ffffff10); - REQUIRE(buf[sz - 4] == cfdp::TlvTypes::ENTITY_ID); + REQUIRE(buf[sz - 4] == cfdp::TlvType::ENTITY_ID); // width of entity ID is 2 REQUIRE(buf[sz - 3] == 2); uint16_t entityIdRaw = 0; @@ -105,7 +105,7 @@ TEST_CASE("EOF PDU", "[cfdp][pdu]") { REQUIRE(emptyInfo.getConditionCode() == cfdp::ConditionCode::FILESTORE_REJECTION); REQUIRE(emptyInfo.getChecksum() == 5); REQUIRE(emptyInfo.getFileSize().getSize() == 0x10ffffff10); - REQUIRE(emptyInfo.getFaultLoc()->getType() == cfdp::TlvTypes::ENTITY_ID); + REQUIRE(emptyInfo.getFaultLoc()->getType() == cfdp::TlvType::ENTITY_ID); REQUIRE(emptyInfo.getFaultLoc()->getSerializedSize() == 4); uint16_t destId = emptyInfo.getFaultLoc()->getEntityId().getValue(); REQUIRE(destId == 2); diff --git a/unittests/cfdp/pdu/testFileData.cpp b/unittests/cfdp/pdu/testFileData.cpp index 8dfd7db3..258ef9c1 100644 --- a/unittests/cfdp/pdu/testFileData.cpp +++ b/unittests/cfdp/pdu/testFileData.cpp @@ -17,7 +17,7 @@ TEST_CASE("File Data PDU", "[cfdp][pdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); + PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum); for (uint8_t idx = 0; idx < 10; idx++) { fileBuffer[idx] = idx; diff --git a/unittests/cfdp/pdu/testFileDirective.cpp b/unittests/cfdp/pdu/testFileDirective.cpp index 31e627a6..e1158a1a 100644 --- a/unittests/cfdp/pdu/testFileDirective.cpp +++ b/unittests/cfdp/pdu/testFileDirective.cpp @@ -12,11 +12,11 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0); cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1); PduConfig pduConf = - PduConfig(sourceId, destId, cfdp::TransmissionModes::ACKNOWLEDGED, seqNum, false); + PduConfig(sourceId, destId, cfdp::TransmissionMode::ACKNOWLEDGED, seqNum, false); uint8_t* serTarget = serBuf.data(); const uint8_t* deserTarget = serTarget; size_t serSize = 0; - auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4); + auto fdSer = FileDirectiveCreator(pduConf, FileDirective::ACK, 4); SECTION("Serialization") { REQUIRE(fdSer.getSerializedSize() == 8); @@ -37,7 +37,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { REQUIRE(serBuf[5] == 2); // Dest ID REQUIRE(serBuf[6] == 1); - REQUIRE(serBuf[7] == FileDirectives::ACK); + REQUIRE(serBuf[7] == FileDirective::ACK); } SECTION("Serialization fails") { @@ -73,10 +73,10 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { REQUIRE(fdDeser.parseData() == returnvalue::OK); REQUIRE(not fdDeser.isNull()); REQUIRE(fdDeser); - REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK); + REQUIRE(fdDeser.getFileDirective() == FileDirective::ACK); REQUIRE(fdDeser.getPduDataFieldLen() == 5); REQUIRE(fdDeser.getHeaderSize() == 8); - REQUIRE(fdDeser.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE); + REQUIRE(fdDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE); serBuf[7] = 0xff; // Invalid file directive diff --git a/unittests/cfdp/pdu/testFinishedPdu.cpp b/unittests/cfdp/pdu/testFinishedPdu.cpp index 194e4252..b8b395cb 100644 --- a/unittests/cfdp/pdu/testFinishedPdu.cpp +++ b/unittests/cfdp/pdu/testFinishedPdu.cpp @@ -14,7 +14,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); + PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum); cfdp::Lv emptyFsMsg; FinishedInfo info(cfdp::ConditionCode::INACTIVITY_DETECTED, @@ -27,7 +27,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { REQUIRE(result == returnvalue::OK); REQUIRE(serializer.getSerializedSize() == 12); REQUIRE(((fnBuffer[1] << 8) | fnBuffer[2]) == 2); - REQUIRE(fnBuffer[10] == cfdp::FileDirectives::FINISH); + REQUIRE(fnBuffer[10] == cfdp::FileDirective::FINISH); REQUIRE(((fnBuffer[sz - 1] >> 4) & 0x0f) == cfdp::ConditionCode::INACTIVITY_DETECTED); REQUIRE(((fnBuffer[sz - 1] >> 2) & 0x01) == cfdp::FileDeliveryCode::DATA_INCOMPLETE); REQUIRE((fnBuffer[sz - 1] & 0b11) == cfdp::FileDeliveryStatus::DISCARDED_DELIBERATELY); @@ -176,7 +176,7 @@ TEST_CASE("Finished PDU", "[cfdp][pdu]") { fnBuffer[11] = tmp; // Invalid TLV type, should be entity ID - fnBuffer[sz - 4] = cfdp::TlvTypes::FILESTORE_REQUEST; + fnBuffer[sz - 4] = cfdp::TlvType::FILESTORE_REQUEST; result = deserializer3.parseData(); REQUIRE(result == cfdp::INVALID_TLV_TYPE); diff --git a/unittests/cfdp/pdu/testKeepAlivePdu.cpp b/unittests/cfdp/pdu/testKeepAlivePdu.cpp index 9b0e9669..d07bccae 100644 --- a/unittests/cfdp/pdu/testKeepAlivePdu.cpp +++ b/unittests/cfdp/pdu/testKeepAlivePdu.cpp @@ -14,7 +14,7 @@ TEST_CASE("Keep Alive PDU", "[cfdp][pdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); + PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum); FileSize progress(0x50); @@ -22,7 +22,7 @@ TEST_CASE("Keep Alive PDU", "[cfdp][pdu]") { KeepAlivePduCreator serializer(pduConf, progress); result = serializer.serialize(&buffer, &sz, kaBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); - REQUIRE(kaBuffer[10] == cfdp::FileDirectives::KEEP_ALIVE); + REQUIRE(kaBuffer[10] == cfdp::FileDirective::KEEP_ALIVE); uint32_t fsRaw = 0; result = SerializeAdapter::deSerialize(&fsRaw, kaBuffer.data() + 11, nullptr, SerializeIF::Endianness::NETWORK); diff --git a/unittests/cfdp/pdu/testMetadataPdu.cpp b/unittests/cfdp/pdu/testMetadataPdu.cpp index 18b60409..a9f8bf86 100644 --- a/unittests/cfdp/pdu/testMetadataPdu.cpp +++ b/unittests/cfdp/pdu/testMetadataPdu.cpp @@ -17,13 +17,13 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); + PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum); std::string firstFileName = "hello.txt"; cfdp::StringLv sourceFileName(firstFileName); cfdp::StringLv destFileName; FileSize fileSize(35); - MetadataInfo info(false, ChecksumTypes::MODULAR, fileSize, sourceFileName, destFileName); + MetadataInfo info(false, ChecksumType::MODULAR, fileSize, sourceFileName, destFileName); FilestoreResponseTlv response(FilestoreActionCode::CREATE_DIRECTORY, FSR_CREATE_NOT_ALLOWED, sourceFileName, nullptr); @@ -46,7 +46,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { REQUIRE(info.getDestFileName().getSerializedSize() == 1); REQUIRE(info.getSerializedSize() == 16); REQUIRE((mdBuffer[1] << 8 | mdBuffer[2]) == 17); - REQUIRE(mdBuffer[10] == FileDirectives::METADATA); + REQUIRE(mdBuffer[10] == FileDirective::METADATA); // no closure requested and checksum type is modular => 0x00 REQUIRE(mdBuffer[11] == 0x00); uint32_t fileSizeRaw = 0; @@ -74,7 +74,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { REQUIRE(info.getMaxOptionsLen() == 2); info.setMaxOptionsLen(3); REQUIRE(info.getMaxOptionsLen() == 3); - info.setChecksumType(cfdp::ChecksumTypes::CRC_32C); + info.setChecksumType(cfdp::ChecksumType::CRC_32C); info.setClosureRequested(true); uint8_t* buffer = mdBuffer.data(); size_t sz = 0; @@ -83,8 +83,8 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); REQUIRE((mdBuffer[1] << 8 | mdBuffer[2]) == 37); - auto checksumType = static_cast(mdBuffer[11] & 0x0f); - REQUIRE(checksumType == cfdp::ChecksumTypes::CRC_32C); + auto checksumType = static_cast(mdBuffer[11] & 0x0f); + REQUIRE(checksumType == cfdp::ChecksumType::CRC_32C); bool closureRequested = mdBuffer[11] >> 6 & 0x01; REQUIRE(closureRequested == true); // The size of the two options is 19. Summing up: @@ -130,7 +130,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { size_t maxSize = 4; info.setOptionsArray(options.data(), sizeOfOptions, maxSize); REQUIRE(info.getOptionsLen() == 2); - info.setChecksumType(cfdp::ChecksumTypes::CRC_32C); + info.setChecksumType(cfdp::ChecksumType::CRC_32C); info.setClosureRequested(true); uint8_t* buffer = mdBuffer.data(); size_t sz = 0; @@ -143,9 +143,9 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") { MetadataPduReader deserializer2(mdBuffer.data(), mdBuffer.size(), info); result = deserializer2.parseData(); REQUIRE(result == returnvalue::OK); - REQUIRE(options[0]->getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); + REQUIRE(options[0]->getType() == cfdp::TlvType::FILESTORE_RESPONSE); REQUIRE(options[0]->getSerializedSize() == 14); - REQUIRE(options[1]->getType() == cfdp::TlvTypes::MSG_TO_USER); + REQUIRE(options[1]->getType() == cfdp::TlvType::MSG_TO_USER); REQUIRE(options[1]->getSerializedSize() == 5); for (size_t invalidFieldLen = 0; invalidFieldLen < 36; invalidFieldLen++) { diff --git a/unittests/cfdp/pdu/testNakPdu.cpp b/unittests/cfdp/pdu/testNakPdu.cpp index f2779788..7974dab1 100644 --- a/unittests/cfdp/pdu/testNakPdu.cpp +++ b/unittests/cfdp/pdu/testNakPdu.cpp @@ -15,7 +15,7 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); + PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum); FileSize startOfScope(50); FileSize endOfScope(1050); @@ -29,7 +29,7 @@ TEST_CASE("NAK PDU", "[cfdp][pdu]") { REQUIRE(sz == 19); REQUIRE(serializer.getPduDataFieldLen() == 9); REQUIRE(((nakBuffer[1] << 8) | nakBuffer[2]) == 0x09); - REQUIRE(nakBuffer[10] == cfdp::FileDirectives::NAK); + REQUIRE(nakBuffer[10] == cfdp::FileDirective::NAK); uint32_t scope = 0; result = SerializeAdapter::deSerialize(&scope, nakBuffer.data() + 11, nullptr, SerializeIF::Endianness::NETWORK); diff --git a/unittests/cfdp/pdu/testPromptPdu.cpp b/unittests/cfdp/pdu/testPromptPdu.cpp index 538f6459..6032f44e 100644 --- a/unittests/cfdp/pdu/testPromptPdu.cpp +++ b/unittests/cfdp/pdu/testPromptPdu.cpp @@ -14,7 +14,7 @@ TEST_CASE("Prompt PDU", "[cfdp][pdu]") { EntityId destId(WidthInBytes::TWO_BYTES, 2); TransactionSeqNum seqNum(WidthInBytes::TWO_BYTES, 15); EntityId sourceId(WidthInBytes::TWO_BYTES, 1); - PduConfig pduConf(sourceId, destId, TransmissionModes::ACKNOWLEDGED, seqNum); + PduConfig pduConf(sourceId, destId, TransmissionMode::ACKNOWLEDGED, seqNum); SECTION("Serialize") { PromptPduCreator serializer(pduConf, cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); @@ -23,7 +23,7 @@ TEST_CASE("Prompt PDU", "[cfdp][pdu]") { REQUIRE(serializer.getWholePduSize() == 12); REQUIRE(sz == 12); REQUIRE(serializer.getPduDataFieldLen() == 2); - REQUIRE(rawBuf[10] == FileDirectives::PROMPT); + REQUIRE(rawBuf[10] == FileDirective::PROMPT); REQUIRE(((rawBuf[sz - 1] >> 7) & 0x01) == cfdp::PromptResponseRequired::PROMPT_KEEP_ALIVE); for (size_t invalidMaxSz = 0; invalidMaxSz < sz; invalidMaxSz++) { diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 38504a5b..eacc83de 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -16,13 +16,13 @@ TEST_CASE("CFDP Base", "[cfdp]") { cfdp::EntityId sourceId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 0); cfdp::EntityId destId = EntityId(cfdp::WidthInBytes::ONE_BYTE, 1); PduConfig pduConf = - PduConfig(sourceId, destId, cfdp::TransmissionModes::ACKNOWLEDGED, seqNum, false); + PduConfig(sourceId, destId, cfdp::TransmissionMode::ACKNOWLEDGED, seqNum, false); uint8_t* serTarget = serBuf.data(); const uint8_t* deserTarget = serTarget; size_t serSize = 0; SECTION("File Directive") { - auto fdSer = FileDirectiveCreator(pduConf, FileDirectives::ACK, 4); + auto fdSer = FileDirectiveCreator(pduConf, FileDirective::ACK, 4); REQUIRE(fdSer.getSerializedSize() == 8); serTarget = serBuf.data(); serSize = 0; @@ -41,7 +41,7 @@ TEST_CASE("CFDP Base", "[cfdp]") { REQUIRE(serBuf[5] == 2); // Dest ID REQUIRE(serBuf[6] == 1); - REQUIRE(serBuf[7] == FileDirectives::ACK); + REQUIRE(serBuf[7] == FileDirective::ACK); serTarget = serBuf.data(); size_t deserSize = 20; @@ -65,10 +65,10 @@ TEST_CASE("CFDP Base", "[cfdp]") { REQUIRE(fdDeser.getEndianness() == SerializeIF::Endianness::MACHINE); fdDeser.setEndianness(SerializeIF::Endianness::NETWORK); REQUIRE(fdDeser.parseData() == returnvalue::OK); - REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK); + REQUIRE(fdDeser.getFileDirective() == FileDirective::ACK); REQUIRE(fdDeser.getPduDataFieldLen() == 5); REQUIRE(fdDeser.getHeaderSize() == 8); - REQUIRE(fdDeser.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE); + REQUIRE(fdDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE); serBuf[7] = 0xff; // Invalid file directive diff --git a/unittests/cfdp/testOtherTlvs.cpp b/unittests/cfdp/testOtherTlvs.cpp index 4eb51a7c..88413195 100644 --- a/unittests/cfdp/testOtherTlvs.cpp +++ b/unittests/cfdp/testOtherTlvs.cpp @@ -41,7 +41,7 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { result = response.convertToTlv(rawResponse, serBuf.data(), serBuf.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); - REQUIRE(rawResponse.getType() == cfdp::TlvTypes::FILESTORE_RESPONSE); + REQUIRE(rawResponse.getType() == cfdp::TlvType::FILESTORE_RESPONSE); cfdp::StringLv emptyMsg; cfdp::StringLv emptySecondName; FilestoreResponseTlv emptyTlv(firstName, &emptyMsg); @@ -96,12 +96,12 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { result = request.convertToTlv(rawRequest, serBuf.data(), serBuf.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); - REQUIRE(rawRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); + REQUIRE(rawRequest.getType() == cfdp::TlvType::FILESTORE_REQUEST); emptyRequest.setActionCode(cfdp::FilestoreActionCode::DELETE_FILE); result = emptyRequest.deSerialize(rawRequest, SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); - REQUIRE(emptyRequest.getType() == cfdp::TlvTypes::FILESTORE_REQUEST); + REQUIRE(emptyRequest.getType() == cfdp::TlvType::FILESTORE_REQUEST); REQUIRE(emptyRequest.getActionCode() == cfdp::FilestoreActionCode::APPEND_FILE); } @@ -111,7 +111,7 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { FlowLabelTlv flowLabelTlv(&flowLabel, 1); FaultHandlerOverrideTlv faultOverrideTlv(cfdp::ConditionCode::FILESTORE_REJECTION, - cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION); + cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION); size_t sz = 0; result = faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK); @@ -128,7 +128,7 @@ TEST_CASE("CFDP Other TLVs", "[cfdp][tlv]") { EntityIdTlv idTlv(emptyId); serPtr = rawBuf.data(); result = idTlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); - cfdp::Tlv rawTlv(cfdp::TlvTypes::ENTITY_ID, rawBuf.data() + 2, 2); + cfdp::Tlv rawTlv(cfdp::TlvType::ENTITY_ID, rawBuf.data() + 2, 2); REQUIRE(result == returnvalue::OK); deserPtr = rawBuf.data(); result = idTlv.deSerialize(rawTlv, SerializeIF::Endianness::NETWORK); diff --git a/unittests/cfdp/testTlv.cpp b/unittests/cfdp/testTlv.cpp index b78d8a80..979bfac5 100644 --- a/unittests/cfdp/testTlv.cpp +++ b/unittests/cfdp/testTlv.cpp @@ -22,14 +22,14 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { SECTION("TLV Serialization") { std::array tlvBuf{}; REQUIRE(sourceId.serializeBe(tlvBuf.data(), deserSize, tlvBuf.size()) == returnvalue::OK); - auto tlv = Tlv(TlvTypes::ENTITY_ID, tlvBuf.data(), deserSize); + auto tlv = Tlv(TlvType::ENTITY_ID, tlvBuf.data(), deserSize); REQUIRE(tlv.getSerializedSize() == 4); REQUIRE(tlv.getLengthField() == 2); deserSize = 0; REQUIRE(tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == returnvalue::OK); REQUIRE(deserSize == 4); - REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); + REQUIRE(rawBuf[0] == TlvType::ENTITY_ID); REQUIRE(rawBuf[1] == 2); uint16_t entityId = 0; REQUIRE(SerializeAdapter::deSerialize(&entityId, rawBuf.data() + 2, &deserSize, @@ -38,7 +38,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { } SECTION("TLV Other Value") { - auto tlv = Tlv(TlvTypes::ENTITY_ID, rawBuf.data(), deserSize); + auto tlv = Tlv(TlvType::ENTITY_ID, rawBuf.data(), deserSize); // Set new value sourceId.setValue(cfdp::WidthInBytes::FOUR_BYTES, 12); REQUIRE(sourceId.serialize(&serPtr, &deserSize, rawBuf.size(), @@ -48,17 +48,17 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { deserSize = 0; result = tlv.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); - REQUIRE(rawBuf[0] == TlvTypes::ENTITY_ID); + REQUIRE(rawBuf[0] == TlvType::ENTITY_ID); REQUIRE(rawBuf[1] == 4); REQUIRE(result == returnvalue::OK); } SECTION("TLV Invalid") { - auto tlvInvalid = Tlv(cfdp::TlvTypes::INVALID_TLV, rawBuf.data(), 0); + auto tlvInvalid = Tlv(cfdp::TlvType::INVALID_TLV, rawBuf.data(), 0); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) != returnvalue::OK); - tlvInvalid = Tlv(cfdp::TlvTypes::ENTITY_ID, nullptr, 3); + tlvInvalid = Tlv(cfdp::TlvType::ENTITY_ID, nullptr, 3); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) != returnvalue::OK); REQUIRE(tlvInvalid.serialize(&serPtr, &deserSize, 0, SerializeIF::Endianness::NETWORK) != @@ -69,13 +69,13 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { } SECTION("TLV Zero Length Field") { - Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); + Tlv zeroLenField(TlvType::FAULT_HANDLER, nullptr, 0); REQUIRE(zeroLenField.getSerializedSize() == 2); serPtr = rawBuf.data(); deserSize = 0; REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), SerializeIF::Endianness::NETWORK) == returnvalue::OK); - REQUIRE(rawBuf[0] == TlvTypes::FAULT_HANDLER); + REQUIRE(rawBuf[0] == TlvType::FAULT_HANDLER); REQUIRE(rawBuf[1] == 0); } @@ -85,7 +85,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { serPtr = tlvRawBuf.data(); result = sourceId.serialize(&serPtr, &deserSize, tlvRawBuf.size(), SerializeIF::Endianness::NETWORK); - auto tlvSerialization = Tlv(TlvTypes::ENTITY_ID, tlvRawBuf.data(), deserSize); + auto tlvSerialization = Tlv(TlvType::ENTITY_ID, tlvRawBuf.data(), deserSize); serPtr = rawBuf.data(); deserSize = 0; result = tlvSerialization.serialize(&serPtr, &deserSize, rawBuf.size(), @@ -95,7 +95,7 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { result = tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK); REQUIRE(result == returnvalue::OK); REQUIRE(tlv.getSerializedSize() == 4); - REQUIRE(tlv.getType() == TlvTypes::ENTITY_ID); + REQUIRE(tlv.getType() == TlvType::ENTITY_ID); deserPtr = tlv.getValue(); uint16_t entityId = 0; deserSize = 0; @@ -109,12 +109,12 @@ TEST_CASE("CFDP TLV", "[cfdp][tlv]") { REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) == SerializeIF::STREAM_TOO_SHORT); // Set invalid TLV - rawBuf[0] = TlvTypes::INVALID_TLV; + rawBuf[0] = TlvType::INVALID_TLV; deserSize = 4; REQUIRE(tlv.deSerialize(&deserPtr, &deserSize, SerializeIF::Endianness::NETWORK) != returnvalue::OK); - Tlv zeroLenField(TlvTypes::FAULT_HANDLER, nullptr, 0); + Tlv zeroLenField(TlvType::FAULT_HANDLER, nullptr, 0); serPtr = rawBuf.data(); deserSize = 0; REQUIRE(zeroLenField.serialize(&serPtr, &deserSize, rawBuf.size(), diff --git a/unittests/mocks/cfdp/FaultHandlerMock.cpp b/unittests/mocks/cfdp/FaultHandlerMock.cpp index 26bebda5..03736f71 100644 --- a/unittests/mocks/cfdp/FaultHandlerMock.cpp +++ b/unittests/mocks/cfdp/FaultHandlerMock.cpp @@ -2,31 +2,31 @@ namespace cfdp { -void FaultHandlerMock::noticeOfSuspensionCb(cfdp::ConditionCode code) { - auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION); +void FaultHandlerMock::noticeOfSuspensionCb(TransactionId& id, cfdp::ConditionCode code) { + auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::NOTICE_OF_SUSPENSION); info.callCount++; info.condCodes.push(code); } -void FaultHandlerMock::noticeOfCancellationCb(cfdp::ConditionCode code) { - auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION); +void FaultHandlerMock::noticeOfCancellationCb(TransactionId& id, cfdp::ConditionCode code) { + auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION); info.callCount++; info.condCodes.push(code); } -void FaultHandlerMock::abandonCb(cfdp::ConditionCode code) { - auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::ABANDON_TRANSACTION); +void FaultHandlerMock::abandonCb(TransactionId& id, cfdp::ConditionCode code) { + auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::ABANDON_TRANSACTION); info.callCount++; info.condCodes.push(code); } -void FaultHandlerMock::ignoreCb(cfdp::ConditionCode code) { - auto& info = fhInfoMap.at(cfdp::FaultHandlerCodes::IGNORE_ERROR); +void FaultHandlerMock::ignoreCb(TransactionId& id, cfdp::ConditionCode code) { + auto& info = fhInfoMap.at(cfdp::FaultHandlerCode::IGNORE_ERROR); info.callCount++; info.condCodes.push(code); } -FaultHandlerMock::FaultInfo& FaultHandlerMock::getFhInfo(cfdp::FaultHandlerCodes fhCode) { +FaultHandlerMock::FaultInfo& FaultHandlerMock::getFhInfo(cfdp::FaultHandlerCode fhCode) { return fhInfoMap.at(fhCode); } @@ -34,7 +34,7 @@ void FaultHandlerMock::reset() { fhInfoMap.clear(); } bool FaultHandlerMock::faultCbWasCalled() const { return std::any_of(fhInfoMap.begin(), fhInfoMap.end(), - [](const std::pair& pair) { + [](const std::pair& pair) { return pair.second.callCount > 0; }); } diff --git a/unittests/mocks/cfdp/FaultHandlerMock.h b/unittests/mocks/cfdp/FaultHandlerMock.h index a35d3d2b..1c59485c 100644 --- a/unittests/mocks/cfdp/FaultHandlerMock.h +++ b/unittests/mocks/cfdp/FaultHandlerMock.h @@ -15,21 +15,21 @@ class FaultHandlerMock : public FaultHandlerBase { std::queue condCodes; }; - void noticeOfSuspensionCb(ConditionCode code) override; - void noticeOfCancellationCb(ConditionCode code) override; - void abandonCb(ConditionCode code) override; - void ignoreCb(ConditionCode code) override; + void noticeOfSuspensionCb(TransactionId& id, ConditionCode code) override; + void noticeOfCancellationCb(TransactionId& id, ConditionCode code) override; + void abandonCb(TransactionId& id,ConditionCode code) override; + void ignoreCb(TransactionId& id, ConditionCode code) override; - FaultInfo& getFhInfo(FaultHandlerCodes fhCode); + FaultInfo& getFhInfo(FaultHandlerCode fhCode); [[nodiscard]] bool faultCbWasCalled() const; void reset(); private: - std::map fhInfoMap = { - std::pair{cfdp::FaultHandlerCodes::IGNORE_ERROR, FaultInfo()}, - std::pair{cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION, FaultInfo()}, - std::pair{cfdp::FaultHandlerCodes::NOTICE_OF_SUSPENSION, FaultInfo()}, - std::pair{cfdp::FaultHandlerCodes::ABANDON_TRANSACTION, FaultInfo()}}; + std::map fhInfoMap = { + std::pair{cfdp::FaultHandlerCode::IGNORE_ERROR, FaultInfo()}, + std::pair{cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION, FaultInfo()}, + std::pair{cfdp::FaultHandlerCode::NOTICE_OF_SUSPENSION, FaultInfo()}, + std::pair{cfdp::FaultHandlerCode::ABANDON_TRANSACTION, FaultInfo()}}; }; } // namespace cfdp From b4b11ebd3b46603584a9f4d7722b66715a4c3e6a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 16 Sep 2022 18:08:20 +0200 Subject: [PATCH 396/532] fixes and tweaks --- src/fsfw/tcdistribution/definitions.h | 10 +++++----- src/fsfw/tmtcpacket/ccsds/defs.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fsfw/tcdistribution/definitions.h b/src/fsfw/tcdistribution/definitions.h index 3d455077..1da1f8ab 100644 --- a/src/fsfw/tcdistribution/definitions.h +++ b/src/fsfw/tcdistribution/definitions.h @@ -14,11 +14,11 @@ static constexpr ReturnValue_t INVALID_PACKET_TYPE = MAKE_RETURN_CODE(2); static constexpr ReturnValue_t INVALID_SEC_HEADER_FIELD = MAKE_RETURN_CODE(3); static constexpr ReturnValue_t INCORRECT_PRIMARY_HEADER = MAKE_RETURN_CODE(4); -static constexpr ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE(5); -static constexpr ReturnValue_t INVALID_PUS_VERSION = MAKE_RETURN_CODE(6); -static constexpr ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE(7); -static constexpr ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE(8); -static constexpr ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE(9); +static constexpr ReturnValue_t INCOMPLETE_PACKET = MAKE_RETURN_CODE(7); +static constexpr ReturnValue_t INVALID_PUS_VERSION = MAKE_RETURN_CODE(8); +static constexpr ReturnValue_t INCORRECT_CHECKSUM = MAKE_RETURN_CODE(9); +static constexpr ReturnValue_t ILLEGAL_PACKET_SUBTYPE = MAKE_RETURN_CODE(10); +static constexpr ReturnValue_t INCORRECT_SECONDARY_HEADER = MAKE_RETURN_CODE(11); }; // namespace tcdistrib #endif // FSFW_TMTCPACKET_DEFINITIONS_H diff --git a/src/fsfw/tmtcpacket/ccsds/defs.h b/src/fsfw/tmtcpacket/ccsds/defs.h index 1c7de540..da7c524d 100644 --- a/src/fsfw/tmtcpacket/ccsds/defs.h +++ b/src/fsfw/tmtcpacket/ccsds/defs.h @@ -23,11 +23,11 @@ constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid, return ((isTc << 4) | (secondaryHeaderFlag << 3) | ((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff); } -constexpr uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { +constexpr uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag) { return getSpacePacketIdFromApid(true, apid, secondaryHeaderFlag); } -constexpr uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { +constexpr uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag) { return getSpacePacketIdFromApid(false, apid, secondaryHeaderFlag); } From 72172a972bca7a2026a30d5a87289ab0510b1e31 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 16 Sep 2022 18:24:23 +0200 Subject: [PATCH 397/532] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03cc0613..44e2262b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changes +- Remove default secondary header argument for + `uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag)` and + `uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag)` + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/689 - Removed `HasReturnvaluesIF` class in favor of `returnvalue` namespace with `OK` and `FAILED` constants. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/659 From 9a2146fa2df0a5e5e5a5d5bc61e24c7b344b06d3 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 11:36:29 +0200 Subject: [PATCH 398/532] added impressum and datenschutz in sphinx documentation --- docs/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 62b17192..eb0f94cd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -50,6 +50,11 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] # html_theme = 'alabaster' +html_theme_options = { + "extra_nav_links": {"Impressum" : "https://www.uni-stuttgart.de/impressum", "Datenschutz": "https://info.irs.uni-stuttgart.de/datenschutz/datenschutzWebmit.html"} +} + + # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". From 3b8ca09299cbe3de03364c0f622a8d8cf2ecebce Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 13:46:03 +0200 Subject: [PATCH 399/532] prepared docker for documentation rsync --- automation/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/automation/Dockerfile b/automation/Dockerfile index 5bd7d382..1bd39b3f 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get --yes upgrade #tzdata is a dependency, won't install otherwise ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping python3 pip doxygen graphviz +RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping python3 pip doxygen graphviz rsync RUN python3 -m pip install sphinx breathe @@ -23,3 +23,7 @@ RUN git clone https://github.com/ETLCPP/etl.git && \ #ssh needs a valid user to work RUN adduser --uid 114 jenkins + +#add documentation server to known hosts +RUN echo "|1|/LzCV4BuTmTb2wKnD146l9fTKgQ=|NJJtVjvWbtRt8OYqFgcYRnMQyVw= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNL8ssTonYtgiR/6RRlSIK9WU1ywOcJmxFTLcEblAwH7oifZzmYq3XRfwXrgfMpylEfMFYfCU8JRqtmi19xc21A=" >> /etc/ssh/ssh_known_hosts +RUN echo "|1|CcBvBc3EG03G+XM5rqRHs6gK/Gg=|oGeJQ+1I8NGI2THIkJsW92DpTzs= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNL8ssTonYtgiR/6RRlSIK9WU1ywOcJmxFTLcEblAwH7oifZzmYq3XRfwXrgfMpylEfMFYfCU8JRqtmi19xc21A=" >> /etc/ssh/ssh_known_hosts \ No newline at end of file From 0fea22d0319a86304ebe83805f9adfdfeaccc2ee Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 14:06:28 +0200 Subject: [PATCH 400/532] switching to rsync and deploying to web documentation --- automation/Jenkinsfile | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 8b123fa9..63acab58 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -5,7 +5,7 @@ pipeline { } agent { docker { - image 'fsfw-ci:d5' + image 'fsfw-ci:d6' args '--network host' } } @@ -52,14 +52,12 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/development/*' - sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' + sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/development' } } dir(BUILDDIR) { sshagent(credentials: ['documentation-buildfix']) { - sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/coverage/development/*' - sh 'scp -o StrictHostKeyChecking=no -r fsfw-tests_coverage/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/coverage/development' + sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/coverage/development' } } } @@ -73,14 +71,12 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/master/*' - sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' + sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/master' } } dir(BUILDDIR) { sshagent(credentials: ['documentation-buildfix']) { - sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/coverage/master/*' - sh 'scp -o StrictHostKeyChecking=no -r fsfw-tests_coverage/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/coverage/master' + sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/coverage/master' } } } From 5488ee715f9327c9f7d791adb762b8d7d0eebf48 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 14:07:12 +0200 Subject: [PATCH 401/532] testing deployment of documentation --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 63acab58..fcbe1a7b 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'development' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From c0000a863595490d7a6c420c4b8729133bc2c263 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 14:14:10 +0200 Subject: [PATCH 402/532] testing deployment of both development and master doc --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index fcbe1a7b..022bbad0 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -64,7 +64,7 @@ pipeline { } stage('Master Documentation') { when { - branch 'master' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From 33530f2819bb84566f9d105d2284a898d924e219 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 17:04:35 +0200 Subject: [PATCH 403/532] adding Impressum and Datenschutz to lcov output --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5e45a8c..e2572b20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -326,7 +326,8 @@ if(FSFW_BUILD_TESTS) "/usr/local/include/*" "*/fsfw_tests/*" "*/catch2-src/*" - "*/fsfw_hal/*") + "*/fsfw_hal/*" + "unittests/*") endif() target_link_options(${FSFW_TEST_TGT} PRIVATE -fprofile-arcs @@ -345,7 +346,8 @@ if(FSFW_BUILD_TESTS) else() setup_target_for_coverage_lcov( NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT}) + DEPENDENCIES ${FSFW_TEST_TGT} + GENHTML_ARGS --html-epilog ${CMAKE_SOURCE_DIR}/unittests/lcov_epilog.html) endif() endif() endif() From 292fe3e5e4526c5aa35049033dd50c1851f66a93 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 17:11:57 +0200 Subject: [PATCH 404/532] forgot epilog file --- unittests/lcov_epilog.html | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 unittests/lcov_epilog.html diff --git a/unittests/lcov_epilog.html b/unittests/lcov_epilog.html new file mode 100644 index 00000000..6ed9a1b2 --- /dev/null +++ b/unittests/lcov_epilog.html @@ -0,0 +1,2 @@ +
Impressum Datenschutz
+ From 5c3bb13834933dedbaca62013b14776d2ea1221a Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 17:31:07 +0200 Subject: [PATCH 405/532] Revert "testing deployment of both development and master doc" This reverts commit c0000a863595490d7a6c420c4b8729133bc2c263. --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 022bbad0..fcbe1a7b 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -64,7 +64,7 @@ pipeline { } stage('Master Documentation') { when { - branch 'mohr/documentation_ci' + branch 'master' } steps { dir(DOCDDIR) { From 12d0c23c13c36774cadaf8a264f7396497960105 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 17:31:17 +0200 Subject: [PATCH 406/532] Revert "testing deployment of documentation" This reverts commit 5488ee715f9327c9f7d791adb762b8d7d0eebf48. --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index fcbe1a7b..63acab58 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'mohr/documentation_ci' + branch 'development' } steps { dir(DOCDDIR) { From 9e6c1d60e51a927f0e9efe49bbebf1363e6570cd Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 17:54:41 +0200 Subject: [PATCH 407/532] another ci check --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 63acab58..fcbe1a7b 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'development' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From 4f3361eb2b3af9554ac0d2f154a4c434b7eae21c Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 18:33:47 +0200 Subject: [PATCH 408/532] another ci check --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index fcbe1a7b..022bbad0 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -64,7 +64,7 @@ pipeline { } stage('Master Documentation') { when { - branch 'master' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From 775d5632de48fa4c6fb549f0c2b8d1bff4cfd362 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 20:26:45 +0200 Subject: [PATCH 409/532] update to ssh connection to doc server --- automation/Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 022bbad0..0f457213 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -52,12 +52,12 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/development' + sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/development' } } dir(BUILDDIR) { sshagent(credentials: ['documentation-buildfix']) { - sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/coverage/development' + sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/development' } } } @@ -71,12 +71,12 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/master' + sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/master' } } dir(BUILDDIR) { sshagent(credentials: ['documentation-buildfix']) { - sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/coverage/master' + sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/master' } } } From c54d9d7ba684f046d784fe35c3f0eafa7cd5f2e4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 26 Sep 2022 14:15:11 +0200 Subject: [PATCH 410/532] add some tests --- unittests/tmtcpacket/testCcsdsCreator.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/unittests/tmtcpacket/testCcsdsCreator.cpp b/unittests/tmtcpacket/testCcsdsCreator.cpp index 2b043717..d73e5252 100644 --- a/unittests/tmtcpacket/testCcsdsCreator.cpp +++ b/unittests/tmtcpacket/testCcsdsCreator.cpp @@ -14,11 +14,17 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { size_t serLen = 0; SECTION("Constexpr Helpers") { - REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822); - REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822); + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22, true) == 0x1822); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22, true) == 0x0822); - REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); - REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22, false) == 0x1022); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22, false) == 0x0022); + + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff, true) == 0x1fff); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff, true) == 0xfff); + + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff, false) == 0x17ff); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff, false) == 0x7ff); } SECTION("Basic Test") { From 68ce8b5b0899aa907fe62daf8b289526620f3a16 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 27 Sep 2022 21:46:11 +0200 Subject: [PATCH 411/532] tweaks to make windows build again --- src/fsfw/osal/host/Clock.cpp | 1 + src/fsfw/osal/windows/winTaskHelpers.cpp | 1 + src/fsfw/osal/windows/winTaskHelpers.h | 4 +++- src/fsfw/timemanager/ClockCommon.cpp | 8 +++++++- src/fsfw/timemanager/TimeReaderIF.h | 6 ++++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/fsfw/osal/host/Clock.cpp b/src/fsfw/osal/host/Clock.cpp index 29c6c1a6..dbf6529c 100644 --- a/src/fsfw/osal/host/Clock.cpp +++ b/src/fsfw/osal/host/Clock.cpp @@ -8,6 +8,7 @@ #if defined(PLATFORM_WIN) #include +#define timegm _mkgmtime #elif defined(PLATFORM_UNIX) #include #endif diff --git a/src/fsfw/osal/windows/winTaskHelpers.cpp b/src/fsfw/osal/windows/winTaskHelpers.cpp index 206ee7a7..5b4feb86 100644 --- a/src/fsfw/osal/windows/winTaskHelpers.cpp +++ b/src/fsfw/osal/windows/winTaskHelpers.cpp @@ -1,6 +1,7 @@ #include "fsfw/osal/windows/winTaskHelpers.h" #include +#include TaskPriority tasks::makeWinPriority(PriorityClass prioClass, PriorityNumber prioNumber) { return (static_cast(prioClass) << 16) | static_cast(prioNumber); diff --git a/src/fsfw/osal/windows/winTaskHelpers.h b/src/fsfw/osal/windows/winTaskHelpers.h index 87cd92ce..2d6ef9b4 100644 --- a/src/fsfw/osal/windows/winTaskHelpers.h +++ b/src/fsfw/osal/windows/winTaskHelpers.h @@ -1,10 +1,12 @@ #include #include -#include "../../tasks/TaskFactory.h" +#include "fsfw/tasks/TaskFactory.h" #ifdef _WIN32 +#include + namespace tasks { enum PriorityClass : uint16_t { diff --git a/src/fsfw/timemanager/ClockCommon.cpp b/src/fsfw/timemanager/ClockCommon.cpp index 45755f35..d0ac9004 100644 --- a/src/fsfw/timemanager/ClockCommon.cpp +++ b/src/fsfw/timemanager/ClockCommon.cpp @@ -61,10 +61,16 @@ ReturnValue_t Clock::convertTimevalToTimeOfDay(const timeval* from, TimeOfDay_t* if (result != returnvalue::OK) { return result; } - MutexGuard helper(timeMutex); // gmtime writes its output in a global buffer which is not Thread Safe // Therefore we have to use a Mutex here + MutexGuard helper(timeMutex); +#ifdef PLATFORM_WIN + time_t time; + time = from->tv_sec; + timeInfo = gmtime(&time); +#else timeInfo = gmtime(&from->tv_sec); +#endif to->year = timeInfo->tm_year + 1900; to->month = timeInfo->tm_mon + 1; to->day = timeInfo->tm_mday; diff --git a/src/fsfw/timemanager/TimeReaderIF.h b/src/fsfw/timemanager/TimeReaderIF.h index 8fd7415f..6bd763c7 100644 --- a/src/fsfw/timemanager/TimeReaderIF.h +++ b/src/fsfw/timemanager/TimeReaderIF.h @@ -2,6 +2,12 @@ #define FSFW_TIMEMANAGER_TIMEREADERIF_H #include +#include "fsfw/platform.h" + +#ifdef PLATFORM_WIN +// wtf? Required for timeval! +#include +#endif #include "TimeStampIF.h" #include "fsfw/returnvalues/returnvalue.h" From b0ecf87580af6d22bd9535ab8e8782f2ffb89b4a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 27 Sep 2022 23:57:58 +0200 Subject: [PATCH 412/532] last windows tweak --- src/fsfw_hal/common/gpio/gpioDefinitions.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/fsfw_hal/common/gpio/gpioDefinitions.h b/src/fsfw_hal/common/gpio/gpioDefinitions.h index eb90629e..9f5618e4 100644 --- a/src/fsfw_hal/common/gpio/gpioDefinitions.h +++ b/src/fsfw_hal/common/gpio/gpioDefinitions.h @@ -5,6 +5,13 @@ #include #include +#ifdef PLATFORM_WIN +// What is this crap? +#undef IN +#undef OUT +#undef CALLBACK +#endif + using gpioId_t = uint16_t; namespace gpio { From 876815b1c9c897bab7a9d6cc6047957c778b30ad Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 28 Sep 2022 00:03:12 +0200 Subject: [PATCH 413/532] another small windows tweak --- src/fsfw/osal/common/TcpIpBase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/osal/common/TcpIpBase.cpp b/src/fsfw/osal/common/TcpIpBase.cpp index 7e989c36..de0a573d 100644 --- a/src/fsfw/osal/common/TcpIpBase.cpp +++ b/src/fsfw/osal/common/TcpIpBase.cpp @@ -1,5 +1,6 @@ #include "fsfw/osal/common/TcpIpBase.h" +#include "fsfw/serviceinterface.h" #include "fsfw/platform.h" #ifdef PLATFORM_UNIX From e0c780f21c7b2bb575c40b49b1d776d1b5d423a0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 28 Sep 2022 09:56:20 +0200 Subject: [PATCH 414/532] better comment --- src/fsfw_hal/common/gpio/gpioDefinitions.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fsfw_hal/common/gpio/gpioDefinitions.h b/src/fsfw_hal/common/gpio/gpioDefinitions.h index 9f5618e4..9f8b5e32 100644 --- a/src/fsfw_hal/common/gpio/gpioDefinitions.h +++ b/src/fsfw_hal/common/gpio/gpioDefinitions.h @@ -6,7 +6,8 @@ #include #ifdef PLATFORM_WIN -// What is this crap? +// Defined in Windows header for whatever reason, and leads to nameclash issues with +// class enums which have entries of the same name. #undef IN #undef OUT #undef CALLBACK From 3de0ae5a485b8538e178fef1c5bd33441b54ceb7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Sep 2022 17:20:18 +0200 Subject: [PATCH 415/532] DHB bug --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 3968142c..4f1c4367 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -517,16 +517,16 @@ ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandI if (enable) { info->active = true; if (info->countdown != nullptr) { - info->delayCycles = info->maxDelayCycles; - } else { info->countdown->resetTimer(); + } else { + info->delayCycles = info->maxDelayCycles; } } else { info->active = false; if (info->countdown != nullptr) { - info->delayCycles = 0; - } else { info->countdown->timeOut(); + } else { + info->delayCycles = 0; } } } From 7877776e248aad4c2a6fcbc5f51f8f791616e6a0 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 30 Sep 2022 14:34:25 +0200 Subject: [PATCH 416/532] one last check --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 0f457213..ec3148bd 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'mohr/documentation_ci' + branch 'development' } steps { dir(DOCDDIR) { From 8e362a000c56618335145d159ab97883c53b33a0 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 30 Sep 2022 14:36:25 +0200 Subject: [PATCH 417/532] Revert "one last check" This reverts commit 7877776e248aad4c2a6fcbc5f51f8f791616e6a0. --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index ec3148bd..0f457213 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'development' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From 7b5ae6a445d9de7d8f4af57370000d091faee407 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 30 Sep 2022 14:40:59 +0200 Subject: [PATCH 418/532] done? --- automation/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 0f457213..27136606 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'mohr/documentation_ci' + branch 'development' } steps { dir(DOCDDIR) { @@ -64,7 +64,7 @@ pipeline { } stage('Master Documentation') { when { - branch 'mohr/documentation_ci' + branch 'master' } steps { dir(DOCDDIR) { From 6f562e5f3ed6ff971cad6e95f3f689f0a9c6e953 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Oct 2022 10:25:58 +0200 Subject: [PATCH 419/532] missing retval conv --- src/fsfw_tests/integration/devices/TestDeviceHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp index 01f0494b..fdf02a70 100644 --- a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp +++ b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp @@ -646,7 +646,7 @@ ReturnValue_t TestDevice::initializeLocalDataPool(localpool::DataPool& localData /* Subscribe for periodic HK packets but do not enable reporting for now. Non-diangostic with a period of one second */ poolManager.subscribeForRegularPeriodicPacket({sid, false, 1.0}); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, From 448d20f3bd3d8844c0a6ee2a0396ba6765b49302 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Oct 2022 10:55:46 +0200 Subject: [PATCH 420/532] small fix for helper --- scripts/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helper.py b/scripts/helper.py index 0ced7186..1b03161b 100755 --- a/scripts/helper.py +++ b/scripts/helper.py @@ -199,7 +199,7 @@ def check_for_cmake_build_dir(build_dir_list: list) -> list: def perform_lcov_operation(directory: str, chdir: bool): if chdir: os.chdir(directory) - cmd_runner("cmake --build . -- fsfw-tests_coverage -j") + cmd_runner("cmake --build -j . -- fsfw-tests_coverage") def determine_build_dir(build_dir_list: List[str]): From c283e0c98889530ac5779d11d8bec816edd5ed80 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Oct 2022 11:02:08 +0200 Subject: [PATCH 421/532] okay this is correct --- scripts/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helper.py b/scripts/helper.py index 1b03161b..9e7a1607 100755 --- a/scripts/helper.py +++ b/scripts/helper.py @@ -199,7 +199,7 @@ def check_for_cmake_build_dir(build_dir_list: list) -> list: def perform_lcov_operation(directory: str, chdir: bool): if chdir: os.chdir(directory) - cmd_runner("cmake --build -j . -- fsfw-tests_coverage") + cmd_runner("cmake --build . -j -- fsfw-tests_coverage") def determine_build_dir(build_dir_list: List[str]): From 337cb0d6c96ecbeec44ff4b08919dd6a5624dc30 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Oct 2022 10:21:17 +0200 Subject: [PATCH 422/532] hotfix --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 3968142c..046b61a3 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -458,7 +458,7 @@ ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceComm info.expectedReplies = 0; info.isExecuting = false; info.sendReplyTo = NO_COMMANDER; - info.useAlternativeReplyId = alternativeReplyId; + info.useAlternativeReplyId = useAlternativeReply; info.alternativeReplyId = alternativeReplyId; auto resultPair = deviceCommandMap.emplace(deviceCommand, info); if (resultPair.second) { From dd636b186b88af02e883d0ba2a138e510bc93cfa Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Oct 2022 14:01:21 +0200 Subject: [PATCH 423/532] size check bugfix --- src/fsfw/cfdp/pdu/FinishedPduCreator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp b/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp index 8ac22e0a..d002e8aa 100644 --- a/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp +++ b/src/fsfw/cfdp/pdu/FinishedPduCreator.cpp @@ -17,7 +17,7 @@ ReturnValue_t FinishPduCreator::serialize(uint8_t **buffer, size_t *size, size_t if (result != returnvalue::OK) { return result; } - if (*size + 1 >= maxSize) { + if (*size + 1 > maxSize) { return SerializeIF::BUFFER_TOO_SHORT; } **buffer = finishInfo.getConditionCode() << 4 | finishInfo.getDeliveryCode() << 2 | From bfe120636c098c2fea205ff8fecee6cc1d3b92d3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Oct 2022 15:08:46 +0200 Subject: [PATCH 424/532] this should have the same effect --- src/fsfw/storagemanager/LocalPool.cpp | 24 ------------------------ src/fsfw/storagemanager/LocalPool.h | 11 +++++------ 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index 970b05f5..7d37507a 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -318,27 +318,3 @@ bool LocalPool::hasDataAtId(store_address_t storeId) const { } return false; } - -ReturnValue_t LocalPool::getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData) { - return StorageManagerIF::getFreeElement(storeId, size, pData); -} - -ConstAccessorPair LocalPool::getData(store_address_t storeId) { - return StorageManagerIF::getData(storeId); -} - -ReturnValue_t LocalPool::addData(store_address_t* storeId, const uint8_t* data, size_t size) { - return StorageManagerIF::addData(storeId, data, size); -} - -ReturnValue_t LocalPool::getData(store_address_t storeId, ConstStorageAccessor& accessor) { - return StorageManagerIF::getData(storeId, accessor); -} - -ReturnValue_t LocalPool::modifyData(store_address_t storeId, StorageAccessor& accessor) { - return StorageManagerIF::modifyData(storeId, accessor); -} - -AccessorPair LocalPool::modifyData(store_address_t storeId) { - return StorageManagerIF::modifyData(storeId); -} diff --git a/src/fsfw/storagemanager/LocalPool.h b/src/fsfw/storagemanager/LocalPool.h index 54d704e6..d3494f4b 100644 --- a/src/fsfw/storagemanager/LocalPool.h +++ b/src/fsfw/storagemanager/LocalPool.h @@ -88,19 +88,13 @@ class LocalPool : public SystemObject, public StorageManagerIF { */ ReturnValue_t addData(store_address_t* storeId, const uint8_t* data, size_t size, bool ignoreFault) override; - ReturnValue_t addData(store_address_t* storeId, const uint8_t* data, size_t size) override; - ReturnValue_t getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData) override; ReturnValue_t getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData, bool ignoreFault) override; - ConstAccessorPair getData(store_address_t storeId) override; - ReturnValue_t getData(store_address_t storeId, ConstStorageAccessor& accessor) override; ReturnValue_t getData(store_address_t storeId, const uint8_t** packet_ptr, size_t* size) override; - AccessorPair modifyData(store_address_t storeId) override; ReturnValue_t modifyData(store_address_t storeId, uint8_t** packet_ptr, size_t* size) override; - ReturnValue_t modifyData(store_address_t storeId, StorageAccessor& accessor) override; ReturnValue_t deleteData(store_address_t storeId) override; ReturnValue_t deleteData(uint8_t* ptr, size_t size, store_address_t* storeId) override; @@ -136,6 +130,11 @@ class LocalPool : public SystemObject, public StorageManagerIF { [[nodiscard]] max_subpools_t getNumberOfSubPools() const override; [[nodiscard]] bool hasDataAtId(store_address_t storeId) const override; + using StorageManagerIF::getFreeElement; + using StorageManagerIF::getData; + using StorageManagerIF::addData; + using StorageManagerIF::modifyData; + protected: /** * With this helper method, a free element of @c size is reserved. From 652c31a683dc4a66f9929eb569e66201ef5ba446 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Oct 2022 17:24:46 +0200 Subject: [PATCH 425/532] missing validity check --- src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp index b8607079..745d5834 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketCreator.cpp @@ -14,6 +14,7 @@ SpacePacketCreator::SpacePacketCreator(ccsds::PacketType packetType, bool secHea : params(SpacePacketParams(PacketId(packetType, secHeaderFlag, apid), PacketSeqCtrl(seqFlags, seqCount), dataLen)) { params.version = version; + checkFieldValidity(); } uint16_t SpacePacketCreator::getPacketIdRaw() const { return params.packetId.raw(); } From 77b1a85b47c3bd2cb9f36d92ea31689dc4caa674 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 20 Oct 2022 14:24:03 +0200 Subject: [PATCH 426/532] important bugfix for i2c device com IF --- src/fsfw_hal/linux/i2c/I2cComIF.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp index 8edeb8ab..11b826ce 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -214,7 +214,7 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, } *buffer = i2cDeviceMapIter->second.replyBuffer.data(); *size = i2cDeviceMapIter->second.replyLen; - + i2cDeviceMapIter->second.replyLen = 0; return returnvalue::OK; } From 1164c21dddc2fb84126a45f7531116423d5a4753 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 14:23:43 +0200 Subject: [PATCH 427/532] iter not a member anymore, more bugfixes --- src/fsfw_hal/linux/i2c/I2cComIF.cpp | 13 +++++-------- src/fsfw_hal/linux/i2c/I2cComIF.h | 2 -- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp index 11b826ce..4e57852b 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -41,7 +41,7 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { size_t maxReplyLen = i2cCookie->getMaxReplyLen(); I2cInstance i2cInstance = {std::vector(maxReplyLen), 0}; @@ -89,7 +89,7 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s } address_t i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not " @@ -140,20 +140,19 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::requestReceiveMessage: Invalid I2C Cookie!" << std::endl; #endif - i2cDeviceMapIter->second.replyLen = 0; return NULLPOINTER; } address_t i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::requestReceiveMessage: i2cAddress of Cookie not " << "registered in i2cDeviceMap" << std::endl; #endif - i2cDeviceMapIter->second.replyLen = 0; return returnvalue::FAILED; } + i2cDeviceMapIter->second.replyLen = 0; deviceFile = i2cCookie->getDeviceFile(); UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::requestReceiveMessage"); @@ -162,7 +161,6 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe } result = openDevice(deviceFile, i2cAddress, &fd); if (result != returnvalue::OK) { - i2cDeviceMapIter->second.replyLen = 0; return result; } @@ -177,7 +175,6 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe sif::error << "I2cComIF::requestReceiveMessage: Read only " << readLen << " from " << requestLen << " bytes" << std::endl; #endif - i2cDeviceMapIter->second.replyLen = 0; #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen << " bytes" << std::endl; @@ -204,7 +201,7 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, } address_t i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not " diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.h b/src/fsfw_hal/linux/i2c/I2cComIF.h index 0a15c3a4..8c44cee0 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.h +++ b/src/fsfw_hal/linux/i2c/I2cComIF.h @@ -36,12 +36,10 @@ class I2cComIF : public DeviceCommunicationIF, public SystemObject { }; using I2cDeviceMap = std::unordered_map; - using I2cDeviceMapIter = I2cDeviceMap::iterator; /* In this map all i2c devices will be registered with their address and * the appropriate file descriptor will be stored */ I2cDeviceMap i2cDeviceMap; - I2cDeviceMapIter i2cDeviceMapIter; /** * @brief This function opens an I2C device and binds the opened file From d8a4675842c2d913218b2c3c341eb6ba346e05ad Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 14:30:14 +0200 Subject: [PATCH 428/532] bump changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44e2262b..1419c4d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- 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 - Bugfix for Serial Buffer Stream: Setting `doActive` to false now actually fully disables printing. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/680 From 54ad6b30168d7a83940cd97672fb71e9a9dfd657 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 14:39:05 +0200 Subject: [PATCH 429/532] add some docs --- src/fsfw/storagemanager/LocalPool.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fsfw/storagemanager/LocalPool.h b/src/fsfw/storagemanager/LocalPool.h index d3494f4b..1472ee25 100644 --- a/src/fsfw/storagemanager/LocalPool.h +++ b/src/fsfw/storagemanager/LocalPool.h @@ -130,6 +130,9 @@ class LocalPool : public SystemObject, public StorageManagerIF { [[nodiscard]] max_subpools_t getNumberOfSubPools() const override; [[nodiscard]] bool hasDataAtId(store_address_t storeId) const override; + // Using functions provided by StorageManagerIF requires either a fully qualified path + // like for example localPool.StorageManagerIF::getFreeElement(...) or re-exporting + // the fully qualified path with the using directive. using StorageManagerIF::getFreeElement; using StorageManagerIF::getData; using StorageManagerIF::addData; From 4db124c6805d0778f1857a9d6bf6b25c1c37c587 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 15:41:29 +0200 Subject: [PATCH 430/532] ignore fault --- src/fsfw/storagemanager/LocalPool.cpp | 11 +++++------ src/fsfw/storagemanager/LocalPool.h | 11 +++++------ src/fsfw/storagemanager/StorageManagerIF.h | 14 ++------------ 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index 7d37507a..b62c19b6 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -31,9 +31,8 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig, LocalPool::~LocalPool() = default; -ReturnValue_t LocalPool::addData(store_address_t* storageId, const uint8_t* data, size_t size, - bool ignoreFault) { - ReturnValue_t status = reserveSpace(size, storageId, ignoreFault); +ReturnValue_t LocalPool::addData(store_address_t* storageId, const uint8_t* data, size_t size) { + ReturnValue_t status = reserveSpace(size, storageId); if (status == returnvalue::OK) { write(*storageId, data, size); } @@ -49,8 +48,8 @@ ReturnValue_t LocalPool::getData(store_address_t packetId, const uint8_t** packe } ReturnValue_t LocalPool::getFreeElement(store_address_t* storageId, const size_t size, - uint8_t** pData, bool ignoreFault) { - ReturnValue_t status = reserveSpace(size, storageId, ignoreFault); + uint8_t** pData) { + ReturnValue_t status = reserveSpace(size, storageId); if (status == returnvalue::OK) { *pData = &store[storageId->poolIndex][getRawPosition(*storageId)]; } else { @@ -167,7 +166,7 @@ void LocalPool::clearStore() { } } -ReturnValue_t LocalPool::reserveSpace(size_t size, store_address_t* storeId, bool ignoreFault) { +ReturnValue_t LocalPool::reserveSpace(size_t size, store_address_t* storeId) { ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); if (status != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/storagemanager/LocalPool.h b/src/fsfw/storagemanager/LocalPool.h index 1472ee25..bb88842b 100644 --- a/src/fsfw/storagemanager/LocalPool.h +++ b/src/fsfw/storagemanager/LocalPool.h @@ -86,11 +86,9 @@ class LocalPool : public SystemObject, public StorageManagerIF { /** * Documentation: See StorageManagerIF.h */ - ReturnValue_t addData(store_address_t* storeId, const uint8_t* data, size_t size, - bool ignoreFault) override; + ReturnValue_t addData(store_address_t* storeId, const uint8_t* data, size_t size) override; - ReturnValue_t getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData, - bool ignoreFault) override; + ReturnValue_t getFreeElement(store_address_t* storeId, size_t size, uint8_t** pData) override; ReturnValue_t getData(store_address_t storeId, const uint8_t** packet_ptr, size_t* size) override; @@ -135,7 +133,6 @@ class LocalPool : public SystemObject, public StorageManagerIF { // the fully qualified path with the using directive. using StorageManagerIF::getFreeElement; using StorageManagerIF::getData; - using StorageManagerIF::addData; using StorageManagerIF::modifyData; protected: @@ -146,7 +143,7 @@ class LocalPool : public SystemObject, public StorageManagerIF { * @return - returnvalue::OK on success, * - the return codes of #getPoolIndex or #findEmpty otherwise. */ - virtual ReturnValue_t reserveSpace(size_t size, store_address_t* address, bool ignoreFault); + virtual ReturnValue_t reserveSpace(size_t size, store_address_t* address); private: /** @@ -190,6 +187,8 @@ class LocalPool : public SystemObject, public StorageManagerIF { std::vector> sizeLists = std::vector>(NUMBER_OF_SUBPOOLS); + bool ignoreFault = false; + //! A variable to determine whether higher n pools are used if //! the store is full. bool spillsToHigherPools = false; diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index 2845e581..5d804e44 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -66,12 +66,7 @@ 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 addData(store_address_t* storageId, const uint8_t* data, size_t size, - bool ignoreFault) = 0; - - virtual ReturnValue_t addData(store_address_t* storageId, const uint8_t* data, size_t size) { - return addData(storageId, data, size, false); - } + virtual ReturnValue_t addData(store_address_t* storageId, const uint8_t* data, size_t size) = 0; /** * @brief With deleteData, the storageManager frees the memory region @@ -186,12 +181,7 @@ 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, - bool ignoreFault) = 0; - - virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** dataPtr) { - return getFreeElement(storageId, size, dataPtr, false); - } + 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; From d26f230beeec08e72856df64b81966a3f9d840a2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 15:43:20 +0200 Subject: [PATCH 431/532] builds --- src/fsfw/storagemanager/PoolManager.cpp | 5 ++--- src/fsfw/storagemanager/PoolManager.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/fsfw/storagemanager/PoolManager.cpp b/src/fsfw/storagemanager/PoolManager.cpp index 41e140b2..840a7dcc 100644 --- a/src/fsfw/storagemanager/PoolManager.cpp +++ b/src/fsfw/storagemanager/PoolManager.cpp @@ -9,10 +9,9 @@ PoolManager::PoolManager(object_id_t setObjectId, const LocalPoolConfig& localPo PoolManager::~PoolManager() { MutexFactory::instance()->deleteMutex(mutex); } -ReturnValue_t PoolManager::reserveSpace(const size_t size, store_address_t* address, - bool ignoreFault) { +ReturnValue_t PoolManager::reserveSpace(const size_t size, store_address_t* address) { MutexGuard mutexHelper(mutex, MutexIF::TimeoutType::WAITING, mutexTimeoutMs); - ReturnValue_t status = LocalPool::reserveSpace(size, address, ignoreFault); + ReturnValue_t status = LocalPool::reserveSpace(size, address); return status; } diff --git a/src/fsfw/storagemanager/PoolManager.h b/src/fsfw/storagemanager/PoolManager.h index eaa978ef..aa8c93dd 100644 --- a/src/fsfw/storagemanager/PoolManager.h +++ b/src/fsfw/storagemanager/PoolManager.h @@ -57,7 +57,7 @@ class PoolManager : public LocalPool { //! Default mutex timeout value to prevent permanent blocking. uint32_t mutexTimeoutMs = 20; - ReturnValue_t reserveSpace(size_t size, store_address_t* address, bool ignoreFault) override; + ReturnValue_t reserveSpace(size_t size, store_address_t* address) override; /** * @brief The mutex is created in the constructor and makes From 81a7de28147a0c386ff29269c36d0b00db1f9ad7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 16:39:32 +0200 Subject: [PATCH 432/532] make dtor virtual --- src/fsfw/storagemanager/StorageManagerIF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index 5d804e44..f9fb33f5 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -55,7 +55,7 @@ class StorageManagerIF { /** * @brief This is the empty virtual destructor as required for C++ interfaces. */ - ~StorageManagerIF() = default; + virtual ~StorageManagerIF() = default; /** * @brief With addData, a free storage position is allocated and data * stored there. From 11a22577beac11a4e2d1809c3ccb0ae3444ef1e0 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 25 Oct 2022 11:28:13 +0200 Subject: [PATCH 433/532] defaultconfig did not build anymore --- misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp index 4d6e91f1..85a733b4 100644 --- a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp +++ b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -41,13 +40,9 @@ void Factory::setStaticFrameworkObjectIds() { CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; DeviceHandlerBase::rawDataReceiverId = objects::PUS_SERVICE_2_DEVICE_ACCESS; DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT; - - TmPacketBase::timeStamperId = objects::NO_OBJECT; } From ce387deee7602f9c56531104af4cb53a9e2ebb41 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Nov 2022 13:49:12 +0100 Subject: [PATCH 434/532] first improvements and fixes --- CMakeLists.txt | 12 +++++++++--- src/fsfw/datalinklayer/MapPacketExtraction.cpp | 2 +- src/fsfw/osal/freertos/FixedTimeslotTask.cpp | 4 +++- src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp | 1 - src/fsfw/timemanager/TimeReaderIF.h | 1 + src/fsfw_hal/common/CMakeLists.txt | 2 +- src/fsfw_hal/common/printChar.c | 2 +- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2572b20..cccd51a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,9 +345,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/datalinklayer/MapPacketExtraction.cpp b/src/fsfw/datalinklayer/MapPacketExtraction.cpp index c074de73..839209ac 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.cpp +++ b/src/fsfw/datalinklayer/MapPacketExtraction.cpp @@ -88,7 +88,7 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(TcTransferFrame* frame) uint32_t totalLength = frame->getDataLength(); if (totalLength > MAX_PACKET_SIZE) return CONTENT_TOO_LARGE; uint8_t* position = frame->getDataField(); - while ((totalLength > SpacePacketBase::MINIMUM_SIZE)) { + while ((totalLength > ccsds::HEADER_LEN)) { SpacePacketBase packet(position); uint32_t packetSize = packet.getFullSize(); if (packetSize <= totalLength) { diff --git a/src/fsfw/osal/freertos/FixedTimeslotTask.cpp b/src/fsfw/osal/freertos/FixedTimeslotTask.cpp index a0a4ecee..41710e0d 100644 --- a/src/fsfw/osal/freertos/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/freertos/FixedTimeslotTask.cpp @@ -56,7 +56,9 @@ ReturnValue_t FixedTimeslotTask::startTask() { // start time for the first entry. auto slotListIter = pollingSeqTable.current; - pollingSeqTable.intializeSequenceAfterTaskCreation(); + ReturnValue_t result = pollingSeqTable.intializeSequenceAfterTaskCreation(); + // TODO: Proper error handling + static_cast(result); // The start time for the first entry is read. uint32_t intervalMs = slotListIter->pollingTimeMs; diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp index 23892dcc..0e73be83 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp @@ -3,7 +3,6 @@ #if FSFW_CPP_OSTREAM_ENABLED == 1 #include - #include #include "fsfw/serviceinterface/serviceInterfaceDefintions.h" diff --git a/src/fsfw/timemanager/TimeReaderIF.h b/src/fsfw/timemanager/TimeReaderIF.h index 8fd7415f..be03fb2a 100644 --- a/src/fsfw/timemanager/TimeReaderIF.h +++ b/src/fsfw/timemanager/TimeReaderIF.h @@ -1,6 +1,7 @@ #ifndef FSFW_TIMEMANAGER_TIMEREADERIF_H #define FSFW_TIMEMANAGER_TIMEREADERIF_H +#include #include #include "TimeStampIF.h" diff --git a/src/fsfw_hal/common/CMakeLists.txt b/src/fsfw_hal/common/CMakeLists.txt index 1cd9c678..2f4608f8 100644 --- a/src/fsfw_hal/common/CMakeLists.txt +++ b/src/fsfw_hal/common/CMakeLists.txt @@ -1,3 +1,3 @@ add_subdirectory(gpio) -target_sources(${LIB_FSFW_NAME} PRIVATE printChar.c) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE printChar.c) diff --git a/src/fsfw_hal/common/printChar.c b/src/fsfw_hal/common/printChar.c index 6e02c1df..24fba5c8 100644 --- a/src/fsfw_hal/common/printChar.c +++ b/src/fsfw_hal/common/printChar.c @@ -1,5 +1,5 @@ -#include #include +#include void __attribute__((weak)) printChar(const char* character, bool errStream) { if (errStream) { From bee33526a16c565af38c04ef71fb9ae33f558ad4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Nov 2022 13:49:40 +0100 Subject: [PATCH 435/532] missing include --- src/fsfw/timemanager/TimeReaderIF.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/timemanager/TimeReaderIF.h b/src/fsfw/timemanager/TimeReaderIF.h index 8fd7415f..be03fb2a 100644 --- a/src/fsfw/timemanager/TimeReaderIF.h +++ b/src/fsfw/timemanager/TimeReaderIF.h @@ -1,6 +1,7 @@ #ifndef FSFW_TIMEMANAGER_TIMEREADERIF_H #define FSFW_TIMEMANAGER_TIMEREADERIF_H +#include #include #include "TimeStampIF.h" From 31defac17c513d206014ccc919dd3757f3343841 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Nov 2022 14:06:59 +0100 Subject: [PATCH 436/532] bugfix in map packet extraction --- src/fsfw/datalinklayer/MapPacketExtraction.cpp | 17 +++++++++++------ src/fsfw/datalinklayer/MapPacketExtraction.h | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.cpp b/src/fsfw/datalinklayer/MapPacketExtraction.cpp index 839209ac..f2a6c550 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.cpp +++ b/src/fsfw/datalinklayer/MapPacketExtraction.cpp @@ -89,12 +89,17 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(TcTransferFrame* frame) if (totalLength > MAX_PACKET_SIZE) return CONTENT_TOO_LARGE; uint8_t* position = frame->getDataField(); while ((totalLength > ccsds::HEADER_LEN)) { - SpacePacketBase packet(position); - uint32_t packetSize = packet.getFullSize(); + SpacePacketReader packet(position, totalLength); + status = packet.checkSize(); + if(status != returnvalue::OK) { + // TODO: Better error handling + status = DATA_CORRUPTED; + } + uint32_t packetSize = packet.getFullPacketLen(); if (packetSize <= totalLength) { - status = sendCompletePacket(packet.getWholeData(), packet.getFullSize()); - totalLength -= packet.getFullSize(); - position += packet.getFullSize(); + status = sendCompletePacket(packet.getFullData(), packet.getFullPacketLen()); + totalLength -= packet.getFullPacketLen(); + position += packet.getFullPacketLen(); status = returnvalue::OK; } else { status = DATA_CORRUPTED; @@ -107,7 +112,7 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(TcTransferFrame* frame) return status; } -ReturnValue_t MapPacketExtraction::sendCompletePacket(uint8_t* data, uint32_t size) { +ReturnValue_t MapPacketExtraction::sendCompletePacket(const uint8_t* data, uint32_t size) { store_address_t store_id; ReturnValue_t status = this->packetStore->addData(&store_id, data, size); if (status == returnvalue::OK) { diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.h b/src/fsfw/datalinklayer/MapPacketExtraction.h index fab7f3c3..3aa92aeb 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.h +++ b/src/fsfw/datalinklayer/MapPacketExtraction.h @@ -47,7 +47,7 @@ class MapPacketExtraction : public MapPacketExtractionIF { * @param size Complete total size of the packet. * @return Return Code of the Packet Store or the Message Queue. */ - ReturnValue_t sendCompletePacket(uint8_t* data, uint32_t size); + ReturnValue_t sendCompletePacket(const uint8_t* data, uint32_t size); /** * Helper method to reset the internal buffer. */ From c913fe40bf0c7ebcd395ccfb04b3b426a99f2916 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Nov 2022 17:54:08 +0100 Subject: [PATCH 437/532] tweaks --- CMakeLists.txt | 6 +- cmake/cmake-modules/bilke/CodeCoverage.cmake | 2 +- .../globalfunctions/timevalOperations.cpp | 9 +- src/fsfw/osal/common/TcpIpBase.cpp | 2 +- src/fsfw/osal/windows/winTaskHelpers.cpp | 3 +- .../ServiceInterfaceBuffer.cpp | 1 - src/fsfw/timemanager/TimeReaderIF.h | 1 + src/fsfw_hal/common/printChar.c | 2 +- .../globalfunctions/testTimevalOperations.cpp | 100 +++++++++--------- unittests/hal/CMakeLists.txt | 8 +- 10 files changed, 72 insertions(+), 62 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2572b20..df3757ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -340,9 +340,9 @@ if(FSFW_BUILD_TESTS) -ftest-coverage) if(WIN32) - setup_target_for_coverage_gcovr_html( - NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT}) + #setup_target_for_coverage_gcovr_html( + # NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} + # DEPENDENCIES ${FSFW_TEST_TGT}) else() setup_target_for_coverage_lcov( NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} diff --git a/cmake/cmake-modules/bilke/CodeCoverage.cmake b/cmake/cmake-modules/bilke/CodeCoverage.cmake index aef3d943..c8b9e4ae 100644 --- a/cmake/cmake-modules/bilke/CodeCoverage.cmake +++ b/cmake/cmake-modules/bilke/CodeCoverage.cmake @@ -140,7 +140,7 @@ find_program( GCOV_PATH gcov ) find_program( LCOV_PATH NAMES lcov lcov.bat lcov.exe lcov.perl) find_program( FASTCOV_PATH NAMES fastcov fastcov.py ) find_program( GENHTML_PATH NAMES genhtml genhtml.perl genhtml.bat ) -find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test) +find_program( GCOVR_PATH gcovr ) find_program( CPPFILT_PATH NAMES c++filt ) if(NOT GCOV_PATH) diff --git a/src/fsfw/globalfunctions/timevalOperations.cpp b/src/fsfw/globalfunctions/timevalOperations.cpp index e2b35512..f9f0a5c6 100644 --- a/src/fsfw/globalfunctions/timevalOperations.cpp +++ b/src/fsfw/globalfunctions/timevalOperations.cpp @@ -1,9 +1,12 @@ #include "fsfw/globalfunctions/timevalOperations.h" +#include + timeval& operator+=(timeval& lhs, const timeval& rhs) { - int64_t sum = lhs.tv_sec * 1000000. + lhs.tv_usec; - sum += rhs.tv_sec * 1000000. + rhs.tv_usec; - lhs.tv_sec = sum / 1000000; + int64_t sum = static_cast(lhs.tv_sec) * 1000000. + lhs.tv_usec; + sum += static_cast(rhs.tv_sec) * 1000000. + rhs.tv_usec; + int64_t tmp = sum / 1000000; + lhs.tv_sec = tmp; lhs.tv_usec = sum - lhs.tv_sec * 1000000; return lhs; } diff --git a/src/fsfw/osal/common/TcpIpBase.cpp b/src/fsfw/osal/common/TcpIpBase.cpp index de0a573d..486a5171 100644 --- a/src/fsfw/osal/common/TcpIpBase.cpp +++ b/src/fsfw/osal/common/TcpIpBase.cpp @@ -1,7 +1,7 @@ #include "fsfw/osal/common/TcpIpBase.h" -#include "fsfw/serviceinterface.h" #include "fsfw/platform.h" +#include "fsfw/serviceinterface.h" #ifdef PLATFORM_UNIX #include diff --git a/src/fsfw/osal/windows/winTaskHelpers.cpp b/src/fsfw/osal/windows/winTaskHelpers.cpp index 5b4feb86..235dca1e 100644 --- a/src/fsfw/osal/windows/winTaskHelpers.cpp +++ b/src/fsfw/osal/windows/winTaskHelpers.cpp @@ -1,8 +1,9 @@ #include "fsfw/osal/windows/winTaskHelpers.h" -#include #include +#include + TaskPriority tasks::makeWinPriority(PriorityClass prioClass, PriorityNumber prioNumber) { return (static_cast(prioClass) << 16) | static_cast(prioNumber); } diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp index 23892dcc..0e73be83 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp @@ -3,7 +3,6 @@ #if FSFW_CPP_OSTREAM_ENABLED == 1 #include - #include #include "fsfw/serviceinterface/serviceInterfaceDefintions.h" diff --git a/src/fsfw/timemanager/TimeReaderIF.h b/src/fsfw/timemanager/TimeReaderIF.h index 6bd763c7..8dce097f 100644 --- a/src/fsfw/timemanager/TimeReaderIF.h +++ b/src/fsfw/timemanager/TimeReaderIF.h @@ -2,6 +2,7 @@ #define FSFW_TIMEMANAGER_TIMEREADERIF_H #include + #include "fsfw/platform.h" #ifdef PLATFORM_WIN diff --git a/src/fsfw_hal/common/printChar.c b/src/fsfw_hal/common/printChar.c index 6e02c1df..24fba5c8 100644 --- a/src/fsfw_hal/common/printChar.c +++ b/src/fsfw_hal/common/printChar.c @@ -1,5 +1,5 @@ -#include #include +#include void __attribute__((weak)) printChar(const char* character, bool errStream) { if (errStream) { diff --git a/unittests/globalfunctions/testTimevalOperations.cpp b/unittests/globalfunctions/testTimevalOperations.cpp index 155e6b15..0f89338b 100644 --- a/unittests/globalfunctions/testTimevalOperations.cpp +++ b/unittests/globalfunctions/testTimevalOperations.cpp @@ -56,61 +56,65 @@ TEST_CASE("TimevalTest", "[timevalOperations]") { } SECTION("Operators") { timeval t1; - t1.tv_sec = 1648227422; - t1.tv_usec = 123456; - timeval t2; - t2.tv_sec = 1648227422; - t2.tv_usec = 123456; - timeval t3 = t1 - t2; - REQUIRE(t3.tv_sec == 0); - REQUIRE(t3.tv_usec == 0); - timeval t4 = t1 - t3; - REQUIRE(t4.tv_sec == 1648227422); - REQUIRE(t4.tv_usec == 123456); - timeval t5 = t3 - t1; - REQUIRE(t5.tv_sec == -1648227422); - REQUIRE(t5.tv_usec == -123456); + if (sizeof(t1.tv_sec) == 8) { + t1.tv_sec = 1648227422; + t1.tv_usec = 123456; + timeval t2; + t2.tv_sec = 1648227422; + t2.tv_usec = 123456; + timeval t3 = t1 - t2; + REQUIRE(t3.tv_sec == 0); + REQUIRE(t3.tv_usec == 0); + timeval t4 = t1 - t3; + REQUIRE(t4.tv_sec == 1648227422); + REQUIRE(t4.tv_usec == 123456); + timeval t5 = t3 - t1; + REQUIRE(t5.tv_sec == -1648227422); + REQUIRE(t5.tv_usec == -123456); - timeval t6; - t6.tv_sec = 1648227400; - t6.tv_usec = 999999; + timeval t6; + t6.tv_sec = 1648227400; + t6.tv_usec = 999999; - timeval t7 = t6 + t1; - REQUIRE(t7.tv_sec == (1648227422ull + 1648227400ull + 1ull)); - REQUIRE(t7.tv_usec == 123455); + timeval t7 = t6 + t1; + // Overflow test + REQUIRE(t7.tv_sec == (1648227422ull + 1648227400ull + 1ull)); - timeval t8 = t1 - t6; - REQUIRE(t8.tv_sec == 1648227422 - 1648227400 - 1); - REQUIRE(t8.tv_usec == 123457); + REQUIRE(t7.tv_usec == 123455); - double scalar = 2; - timeval t9 = t1 * scalar; - REQUIRE(t9.tv_sec == 3296454844); - REQUIRE(t9.tv_usec == 246912); - timeval t10 = scalar * t1; - REQUIRE(t10.tv_sec == 3296454844); - REQUIRE(t10.tv_usec == 246912); - timeval t11 = t6 * scalar; - REQUIRE(t11.tv_sec == (3296454800 + 1)); - REQUIRE(t11.tv_usec == 999998); + timeval t8 = t1 - t6; + REQUIRE(t8.tv_sec == 1648227422 - 1648227400 - 1); + REQUIRE(t8.tv_usec == 123457); - timeval t12 = t1 / scalar; - REQUIRE(t12.tv_sec == 824113711); - REQUIRE(t12.tv_usec == 61728); + double scalar = 2; + timeval t9 = t1 * scalar; + REQUIRE(t9.tv_sec == 3296454844); + REQUIRE(t9.tv_usec == 246912); + timeval t10 = scalar * t1; + REQUIRE(t10.tv_sec == 3296454844); + REQUIRE(t10.tv_usec == 246912); + timeval t11 = t6 * scalar; + REQUIRE(t11.tv_sec == (3296454800 + 1)); + REQUIRE(t11.tv_usec == 999998); - timeval t13 = t6 / scalar; - REQUIRE(t13.tv_sec == 824113700); - // Rounding issue - REQUIRE(t13.tv_usec == 499999); + timeval t12 = t1 / scalar; + REQUIRE(t12.tv_sec == 824113711); + REQUIRE(t12.tv_usec == 61728); - double scalar2 = t9 / t1; - REQUIRE(scalar2 == Catch::Approx(2.0)); - double scalar3 = t1 / t6; - REQUIRE(scalar3 == Catch::Approx(1.000000013)); - double scalar4 = t3 / t1; - REQUIRE(scalar4 == Catch::Approx(0)); - double scalar5 = t12 / t1; - REQUIRE(scalar5 == Catch::Approx(0.5)); + timeval t13 = t6 / scalar; + REQUIRE(t13.tv_sec == 824113700); + // Rounding issue + REQUIRE(t13.tv_usec == 499999); + + double scalar2 = t9 / t1; + REQUIRE(scalar2 == Catch::Approx(2.0)); + double scalar3 = t1 / t6; + REQUIRE(scalar3 == Catch::Approx(1.000000013)); + double scalar4 = t3 / t1; + REQUIRE(scalar4 == Catch::Approx(0)); + double scalar5 = t12 / t1; + REQUIRE(scalar5 == Catch::Approx(0.5)); + } } SECTION("timevalOperations::toTimeval") { diff --git a/unittests/hal/CMakeLists.txt b/unittests/hal/CMakeLists.txt index ee14a3aa..25691a47 100644 --- a/unittests/hal/CMakeLists.txt +++ b/unittests/hal/CMakeLists.txt @@ -1,3 +1,5 @@ -target_sources(${FSFW_TEST_TGT} PRIVATE - testCommandExecutor.cpp -) +if(UNIX) + target_sources(${FSFW_TEST_TGT} PRIVATE + testCommandExecutor.cpp + ) +endif() From 83c2c4825c1c8f59c99549ee80768742833b612c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Nov 2022 15:53:18 +0100 Subject: [PATCH 438/532] fix compiler error for fixed array list copy ctor --- src/fsfw/container/FixedArrayList.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fsfw/container/FixedArrayList.h b/src/fsfw/container/FixedArrayList.h index fc8be393..78184e35 100644 --- a/src/fsfw/container/FixedArrayList.h +++ b/src/fsfw/container/FixedArrayList.h @@ -20,7 +20,9 @@ class FixedArrayList : public ArrayList { FixedArrayList() : ArrayList(data, MAX_SIZE) {} FixedArrayList(const FixedArrayList& other) : ArrayList(data, MAX_SIZE) { - memcpy(this->data, other.data, sizeof(this->data)); + for (size_t idx = 0; idx < sizeof(data); idx++) { + data[idx] = other.data[idx]; + } this->entries = data; this->size = other.size; } From 5c84f124400e0b3265868c2c7b563ad0cd181ee9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Nov 2022 16:15:28 +0100 Subject: [PATCH 439/532] this not crash --- src/fsfw/container/FixedArrayList.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw/container/FixedArrayList.h b/src/fsfw/container/FixedArrayList.h index 78184e35..6ae7da41 100644 --- a/src/fsfw/container/FixedArrayList.h +++ b/src/fsfw/container/FixedArrayList.h @@ -20,11 +20,11 @@ class FixedArrayList : public ArrayList { FixedArrayList() : ArrayList(data, MAX_SIZE) {} FixedArrayList(const FixedArrayList& other) : ArrayList(data, MAX_SIZE) { - for (size_t idx = 0; idx < sizeof(data); idx++) { - data[idx] = other.data[idx]; - } this->entries = data; this->size = other.size; + for (size_t idx = 0; idx < this->size; idx++) { + data[idx] = other.data[idx]; + } } FixedArrayList& operator=(FixedArrayList other) { From 16246d6ece48e0882142fc9665b9387a1d4d3074 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Nov 2022 16:18:36 +0100 Subject: [PATCH 440/532] replace other memcpy --- src/fsfw/container/FixedArrayList.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fsfw/container/FixedArrayList.h b/src/fsfw/container/FixedArrayList.h index 6ae7da41..97ade7e8 100644 --- a/src/fsfw/container/FixedArrayList.h +++ b/src/fsfw/container/FixedArrayList.h @@ -28,9 +28,11 @@ class FixedArrayList : public ArrayList { } FixedArrayList& operator=(FixedArrayList other) { - memcpy(this->data, other.data, sizeof(this->data)); this->entries = data; this->size = other.size; + for (size_t idx = 0; idx < this->size; idx++) { + data[idx] = other.data[idx]; + } return *this; } From 819a298b19bd620b2373683b82dcefbe727c668e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Nov 2022 17:50:21 +0100 Subject: [PATCH 441/532] refactoring of serial drivers for linux --- CMakeLists.txt | 1 + src/fsfw_hal/linux/CMakeLists.txt | 11 +- src/fsfw_hal/linux/serial/CMakeLists.txt | 2 + .../UartComIF.cpp => serial/SerialComIF.cpp} | 226 +++--------------- .../UartComIF.h => serial/SerialComIF.h} | 34 +-- .../SerialCookie.cpp} | 7 +- .../UartCookie.h => serial/SerialCookie.h} | 46 +--- src/fsfw_hal/linux/serial/helper.cpp | 163 +++++++++++++ src/fsfw_hal/linux/serial/helper.h | 71 ++++++ src/fsfw_hal/linux/uart/CMakeLists.txt | 1 - 10 files changed, 287 insertions(+), 275 deletions(-) create mode 100644 src/fsfw_hal/linux/serial/CMakeLists.txt rename src/fsfw_hal/linux/{uart/UartComIF.cpp => serial/SerialComIF.cpp} (64%) rename src/fsfw_hal/linux/{uart/UartComIF.h => serial/SerialComIF.h} (77%) rename src/fsfw_hal/linux/{uart/UartCookie.cpp => serial/SerialCookie.cpp} (91%) rename src/fsfw_hal/linux/{uart/UartCookie.h => serial/SerialCookie.h} (81%) create mode 100644 src/fsfw_hal/linux/serial/helper.cpp create mode 100644 src/fsfw_hal/linux/serial/helper.h delete mode 100644 src/fsfw_hal/linux/uart/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index e2572b20..c847d47f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,6 +122,7 @@ if(UNIX) option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add Linux peripheral drivers" OFF) option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Attempt to add Linux GPIOD drivers" OFF) + option(FSFW_HAL_LINUX_ADD_SERIAL_DRIVERS "Add serial drivers" ON) endif() # Optional sources diff --git a/src/fsfw_hal/linux/CMakeLists.txt b/src/fsfw_hal/linux/CMakeLists.txt index ffa5f5ee..d22d7ff1 100644 --- a/src/fsfw_hal/linux/CMakeLists.txt +++ b/src/fsfw_hal/linux/CMakeLists.txt @@ -5,11 +5,14 @@ endif() target_sources(${LIB_FSFW_NAME} PRIVATE UnixFileGuard.cpp CommandExecutor.cpp utility.cpp) +if(FSFW_HAL_LINUX_ADD_LIBGPIOD) + add_subdirectory(gpio) +endif() +if(FSFW_HAL_LINUX_ADD_SERIAL_DRIVERS) + add_subdirectory(serial) +endif() + if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS) - if(FSFW_HAL_LINUX_ADD_LIBGPIOD) - add_subdirectory(gpio) - endif() - add_subdirectory(uart) # Adding those does not really make sense on Apple systems which are generally # host systems. It won't even compile as the headers are missing if(NOT APPLE) diff --git a/src/fsfw_hal/linux/serial/CMakeLists.txt b/src/fsfw_hal/linux/serial/CMakeLists.txt new file mode 100644 index 00000000..07d20d29 --- /dev/null +++ b/src/fsfw_hal/linux/serial/CMakeLists.txt @@ -0,0 +1,2 @@ +target_sources(${LIB_FSFW_NAME} PUBLIC SerialComIF.cpp SerialCookie.cpp + helper.cpp) diff --git a/src/fsfw_hal/linux/uart/UartComIF.cpp b/src/fsfw_hal/linux/serial/SerialComIF.cpp similarity index 64% rename from src/fsfw_hal/linux/uart/UartComIF.cpp rename to src/fsfw_hal/linux/serial/SerialComIF.cpp index 8947c562..0fd293a0 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/src/fsfw_hal/linux/serial/SerialComIF.cpp @@ -1,7 +1,6 @@ -#include "UartComIF.h" - #include #include +#include #include #include @@ -11,13 +10,12 @@ #include "fsfw/serviceinterface.h" #include "fsfw_hal/linux/utility.h" -UartComIF::UartComIF(object_id_t objectId) : SystemObject(objectId) {} +SerialComIF::SerialComIF(object_id_t objectId) : SystemObject(objectId) {} -UartComIF::~UartComIF() {} +SerialComIF::~SerialComIF() {} -ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { +ReturnValue_t SerialComIF::initializeInterface(CookieIF* cookie) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; if (cookie == nullptr) { return NULLPOINTER; @@ -33,7 +31,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { int fileDescriptor = configureUartPort(uartCookie); if (fileDescriptor < 0) { @@ -60,7 +58,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { return returnvalue::OK; } -int UartComIF::configureUartPort(UartCookie* uartCookie) { +int SerialComIF::configureUartPort(UartCookie* uartCookie) { struct termios options = {}; std::string deviceFile = uartCookie->getDeviceFile(); @@ -89,11 +87,11 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { return fd; } - setParityOptions(&options, uartCookie); + uart::setParity(options, uartCookie->getParity()); setStopBitOptions(&options, uartCookie); setDatasizeOptions(&options, uartCookie); setFixedOptions(&options); - setUartMode(&options, *uartCookie); + uart::setMode(options, uartCookie->getUartMode()); if (uartCookie->getInputShouldBeFlushed()) { tcflush(fd, TCIFLUSH); } @@ -102,7 +100,7 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { options.c_cc[VTIME] = 0; options.c_cc[VMIN] = 0; - configureBaudrate(&options, uartCookie); + uart::setBaudrate(options, uartCookie->getBaudrate()); /* Save option settings */ if (tcsetattr(fd, TCSANOW, &options) != 0) { @@ -115,24 +113,7 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { return fd; } -void UartComIF::setParityOptions(struct termios* options, UartCookie* uartCookie) { - /* Clear parity bit */ - options->c_cflag &= ~PARENB; - switch (uartCookie->getParity()) { - case Parity::EVEN: - options->c_cflag |= PARENB; - options->c_cflag &= ~PARODD; - break; - case Parity::ODD: - options->c_cflag |= PARENB; - options->c_cflag |= PARODD; - break; - default: - break; - } -} - -void UartComIF::setStopBitOptions(struct termios* options, UartCookie* uartCookie) { +void SerialComIF::setStopBitOptions(struct termios* options, UartCookie* uartCookie) { /* Clear stop field. Sets stop bit to one bit */ options->c_cflag &= ~CSTOPB; switch (uartCookie->getStopBits()) { @@ -144,7 +125,7 @@ void UartComIF::setStopBitOptions(struct termios* options, UartCookie* uartCooki } } -void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCookie) { +void SerialComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCookie) { /* Clear size bits */ options->c_cflag &= ~CSIZE; switch (uartCookie->getBitsPerWord()) { @@ -168,7 +149,7 @@ void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCook } } -void UartComIF::setFixedOptions(struct termios* options) { +void SerialComIF::setFixedOptions(struct termios* options) { /* Disable RTS/CTS hardware flow control */ options->c_cflag &= ~CRTSCTS; /* Turn on READ & ignore ctrl lines (CLOCAL = 1) */ @@ -191,142 +172,9 @@ void UartComIF::setFixedOptions(struct termios* options) { options->c_oflag &= ~ONLCR; } -void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCookie) { - switch (uartCookie->getBaudrate()) { - 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; - } -} - -ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { +ReturnValue_t SerialComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { int fd = 0; std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; if (sendLen == 0) { return returnvalue::OK; @@ -348,7 +196,7 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, } deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "UartComIF::sendMessage: Device file " << deviceFile << "not in UART map" @@ -370,11 +218,10 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, return returnvalue::OK; } -ReturnValue_t UartComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } +ReturnValue_t SerialComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } -ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { +ReturnValue_t SerialComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { @@ -386,7 +233,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL UartModes uartMode = uartCookie->getUartMode(); deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartMode == UartModes::NON_CANONICAL and requestLen == 0) { return returnvalue::OK; @@ -409,8 +256,8 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL } } -ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, - size_t requestLen) { +ReturnValue_t SerialComIF::handleCanonicalRead(UartCookie& uartCookie, + UartDeviceMap::iterator& iter, size_t requestLen) { ReturnValue_t result = returnvalue::OK; uint8_t maxReadCycles = uartCookie.getReadCycles(); uint8_t currentReadCycles = 0; @@ -467,8 +314,9 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM return result; } -ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, - size_t requestLen) { +ReturnValue_t SerialComIF::handleNoncanonicalRead(UartCookie& uartCookie, + UartDeviceMap::iterator& iter, + size_t requestLen) { int fd = iter->second.fileDescriptor; auto bufferPtr = iter->second.replyBuffer.data(); // Size check to prevent buffer overflow @@ -501,9 +349,8 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi return returnvalue::OK; } -ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { +ReturnValue_t SerialComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { @@ -514,7 +361,7 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, } deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "UartComIF::readReceivedMessage: Device file " << deviceFile << " not in uart map" @@ -532,9 +379,8 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, return returnvalue::OK; } -ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { +ReturnValue_t SerialComIF::flushUartRxBuffer(CookieIF* cookie) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -543,7 +389,7 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCIFLUSH); @@ -552,9 +398,8 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { return returnvalue::FAILED; } -ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { +ReturnValue_t SerialComIF::flushUartTxBuffer(CookieIF* cookie) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -563,7 +408,7 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCOFLUSH); @@ -572,9 +417,8 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { return returnvalue::FAILED; } -ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { +ReturnValue_t SerialComIF::flushUartTxAndRxBuf(CookieIF* cookie) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -583,7 +427,7 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCIOFLUSH); @@ -591,13 +435,3 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { } return returnvalue::FAILED; } - -void UartComIF::setUartMode(struct termios* options, UartCookie& uartCookie) { - UartModes uartMode = uartCookie.getUartMode(); - if (uartMode == UartModes::NON_CANONICAL) { - /* Disable canonical mode */ - options->c_lflag &= ~ICANON; - } else if (uartMode == UartModes::CANONICAL) { - options->c_lflag |= ICANON; - } -} diff --git a/src/fsfw_hal/linux/uart/UartComIF.h b/src/fsfw_hal/linux/serial/SerialComIF.h similarity index 77% rename from src/fsfw_hal/linux/uart/UartComIF.h rename to src/fsfw_hal/linux/serial/SerialComIF.h index 77318166..4953884a 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.h +++ b/src/fsfw_hal/linux/serial/SerialComIF.h @@ -3,12 +3,12 @@ #include #include +#include +#include #include #include -#include "UartCookie.h" - /** * @brief This is the communication interface to access serial ports on linux based operating * systems. @@ -18,7 +18,7 @@ * * @author J. Meier */ -class UartComIF : public DeviceCommunicationIF, public SystemObject { +class SerialComIF : public DeviceCommunicationIF, public SystemObject { public: static constexpr uint8_t uartRetvalId = CLASS_ID::HAL_UART; @@ -26,9 +26,9 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject { static constexpr ReturnValue_t UART_READ_SIZE_MISSMATCH = returnvalue::makeCode(uartRetvalId, 2); static constexpr ReturnValue_t UART_RX_BUFFER_TOO_SMALL = returnvalue::makeCode(uartRetvalId, 3); - UartComIF(object_id_t objectId); + SerialComIF(object_id_t objectId); - virtual ~UartComIF(); + virtual ~SerialComIF(); ReturnValue_t initializeInterface(CookieIF* cookie) override; ReturnValue_t sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) override; @@ -62,7 +62,6 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject { }; using UartDeviceMap = std::unordered_map; - using UartDeviceMapIter = UartDeviceMap::iterator; /** * The uart devie map stores informations of initialized uart ports. @@ -78,17 +77,6 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject { */ int configureUartPort(UartCookie* uartCookie); - /** - * @brief This function adds the parity settings to the termios options struct. - * - * @param options Pointer to termios options struct which will be modified to enable or disable - * parity checking. - * @param uartCookie Pointer to uart cookie containing the information about the desired - * parity settings. - * - */ - void setParityOptions(struct termios* options, UartCookie* uartCookie); - void setStopBitOptions(struct termios* options, UartCookie* uartCookie); /** @@ -101,17 +89,9 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject { */ void setDatasizeOptions(struct termios* options, UartCookie* uartCookie); - /** - * @brief This functions adds the baudrate specified in the uartCookie to the termios options - * struct. - */ - void configureBaudrate(struct termios* options, UartCookie* uartCookie); - - void setUartMode(struct termios* options, UartCookie& uartCookie); - - ReturnValue_t handleCanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, + ReturnValue_t handleCanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen); - ReturnValue_t handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, + ReturnValue_t handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen); }; diff --git a/src/fsfw_hal/linux/uart/UartCookie.cpp b/src/fsfw_hal/linux/serial/SerialCookie.cpp similarity index 91% rename from src/fsfw_hal/linux/uart/UartCookie.cpp rename to src/fsfw_hal/linux/serial/SerialCookie.cpp index 3fedc9d4..733d84a5 100644 --- a/src/fsfw_hal/linux/uart/UartCookie.cpp +++ b/src/fsfw_hal/linux/serial/SerialCookie.cpp @@ -1,9 +1,8 @@ -#include "UartCookie.h" - #include +#include -UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartModes uartMode, - UartBaudRate baudrate, size_t maxReplyLen) +UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, + size_t maxReplyLen, UartModes uartMode) : handlerId(handlerId), deviceFile(deviceFile), uartMode(uartMode), diff --git a/src/fsfw_hal/linux/uart/UartCookie.h b/src/fsfw_hal/linux/serial/SerialCookie.h similarity index 81% rename from src/fsfw_hal/linux/uart/UartCookie.h rename to src/fsfw_hal/linux/serial/SerialCookie.h index 6840b352..8d0f5fb4 100644 --- a/src/fsfw_hal/linux/uart/UartCookie.h +++ b/src/fsfw_hal/linux/serial/SerialCookie.h @@ -3,50 +3,10 @@ #include #include +#include #include -enum class Parity { NONE, EVEN, ODD }; - -enum class StopBits { ONE_STOP_BIT, TWO_STOP_BITS }; - -enum class UartModes { CANONICAL, NON_CANONICAL }; - -enum class BitsPerWord { BITS_5, BITS_6, BITS_7, BITS_8 }; - -enum class UartBaudRate { - RATE_50, - RATE_75, - RATE_110, - RATE_134, - RATE_150, - RATE_200, - RATE_300, - RATE_600, - RATE_1200, - RATE_1800, - RATE_2400, - RATE_4800, - RATE_9600, - RATE_19200, - RATE_38400, - RATE_57600, - RATE_115200, - RATE_230400, - RATE_460800, - RATE_500000, - RATE_576000, - RATE_921600, - RATE_1000000, - RATE_1152000, - RATE_1500000, - RATE_2000000, - RATE_2500000, - RATE_3000000, - RATE_3500000, - RATE_4000000 -}; - /** * @brief Cookie for the UartComIF. There are many options available to configure the UART driver. * The constructor only requests for common options like the baudrate. Other options can @@ -69,8 +29,8 @@ class UartCookie : public CookieIF { * 8 databits (number of bits transfered with one uart frame) * One stop bit */ - UartCookie(object_id_t handlerId, std::string deviceFile, UartModes uartMode, - UartBaudRate baudrate, size_t maxReplyLen); + UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, + size_t maxReplyLen, UartModes uartMode = UartModes::NON_CANONICAL); virtual ~UartCookie(); diff --git a/src/fsfw_hal/linux/serial/helper.cpp b/src/fsfw_hal/linux/serial/helper.cpp new file mode 100644 index 00000000..ba975f2f --- /dev/null +++ b/src/fsfw_hal/linux/serial/helper.cpp @@ -0,0 +1,163 @@ +#include +#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: + cfsetspeed(&options, B50); + break; + case UartBaudRate::RATE_75: + cfsetspeed(&options, B75); + break; + case UartBaudRate::RATE_110: + cfsetspeed(&options, B110); + break; + case UartBaudRate::RATE_134: + cfsetspeed(&options, B134); + break; + case UartBaudRate::RATE_150: + cfsetspeed(&options, B150); + break; + case UartBaudRate::RATE_200: + cfsetspeed(&options, B200); + break; + case UartBaudRate::RATE_300: + cfsetspeed(&options, B300); + break; + case UartBaudRate::RATE_600: + cfsetspeed(&options, B600); + break; + case UartBaudRate::RATE_1200: + cfsetspeed(&options, B1200); + break; + case UartBaudRate::RATE_1800: + cfsetspeed(&options, B1800); + break; + case UartBaudRate::RATE_2400: + cfsetspeed(&options, B2400); + break; + case UartBaudRate::RATE_4800: + cfsetspeed(&options, B4800); + break; + case UartBaudRate::RATE_9600: + cfsetspeed(&options, B9600); + break; + case UartBaudRate::RATE_19200: + cfsetspeed(&options, B19200); + break; + case UartBaudRate::RATE_38400: + cfsetspeed(&options, B38400); + break; + case UartBaudRate::RATE_57600: + cfsetspeed(&options, B57600); + break; + case UartBaudRate::RATE_115200: + cfsetspeed(&options, B115200); + break; + case UartBaudRate::RATE_230400: + cfsetspeed(&options, B230400); + break; +#ifndef __APPLE__ + case UartBaudRate::RATE_460800: + cfsetspeed(&options, B460800); + break; + case UartBaudRate::RATE_500000: + cfsetspeed(&options, B500000); + break; + case UartBaudRate::RATE_576000: + cfsetspeed(&options, B576000); + break; + case UartBaudRate::RATE_921600: + cfsetspeed(&options, B921600); + break; + case UartBaudRate::RATE_1000000: + cfsetspeed(&options, B1000000); + break; + case UartBaudRate::RATE_1152000: + cfsetspeed(&options, B1152000); + break; + case UartBaudRate::RATE_1500000: + cfsetspeed(&options, B1500000); + break; + case UartBaudRate::RATE_2000000: + cfsetspeed(&options, B2000000); + break; + case UartBaudRate::RATE_2500000: + cfsetspeed(&options, B2500000); + break; + case UartBaudRate::RATE_3000000: + cfsetspeed(&options, B3000000); + break; + case UartBaudRate::RATE_3500000: + cfsetspeed(&options, B3500000); + break; + case UartBaudRate::RATE_4000000: + cfsetspeed(&options, B4000000); + break; +#endif // ! __APPLE__ + default: +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "UartComIF::configureBaudrate: Baudrate not supported" << std::endl; +#endif + break; + } +} + +void uart::setBitsPerWord(struct termios& options, BitsPerWord bits) { + options.c_cflag &= ~CSIZE; // Clear all the size bits + if (bits == BitsPerWord::BITS_5) { + options.c_cflag |= CS5; + } else if (bits == BitsPerWord::BITS_6) { + options.c_cflag |= CS6; + } else if (bits == BitsPerWord::BITS_7) { + options.c_cflag |= CS7; + } else if (bits == BitsPerWord::BITS_8) { + options.c_cflag |= CS8; + } +} + +void uart::enableRead(struct termios& options) { options.c_cflag |= CREAD; } + +void uart::ignoreCtrlLines(struct termios& options) { options.c_cflag |= CLOCAL; } + +void uart::setParity(struct termios& options, Parity parity) { + /* Clear parity bit */ + options.c_cflag &= ~PARENB; + switch (parity) { + case Parity::EVEN: + options.c_cflag |= PARENB; + options.c_cflag &= ~PARODD; + break; + case Parity::ODD: + options.c_cflag |= PARENB; + options.c_cflag |= PARODD; + break; + default: + break; + } +} + +int uart::readCountersAndErrors(int serialPort, serial_icounter_struct& icounter) { + return ioctl(serialPort, TIOCGICOUNT, &icounter); +} + +void uart::setStopbits(struct termios& options, StopBits bits) { + if (bits == StopBits::TWO_STOP_BITS) { + // Use two stop bits + options.c_cflag |= CSTOPB; + } else { + // Clear stop field, only one stop bit used in communication + options.c_cflag &= ~CSTOPB; + } +} diff --git a/src/fsfw_hal/linux/serial/helper.h b/src/fsfw_hal/linux/serial/helper.h new file mode 100644 index 00000000..7f067d00 --- /dev/null +++ b/src/fsfw_hal/linux/serial/helper.h @@ -0,0 +1,71 @@ +#ifndef FSFW_HAL_LINUX_UART_HELPER_H_ +#define FSFW_HAL_LINUX_UART_HELPER_H_ + +#include +#include + +enum class Parity { NONE, EVEN, ODD }; + +enum class StopBits { ONE_STOP_BIT, TWO_STOP_BITS }; + +enum class UartModes { CANONICAL, NON_CANONICAL }; + +enum class BitsPerWord { BITS_5, BITS_6, BITS_7, BITS_8 }; + +enum class UartBaudRate { + RATE_50, + RATE_75, + RATE_110, + RATE_134, + RATE_150, + RATE_200, + RATE_300, + RATE_600, + RATE_1200, + RATE_1800, + RATE_2400, + RATE_4800, + RATE_9600, + RATE_19200, + RATE_38400, + RATE_57600, + RATE_115200, + RATE_230400, + RATE_460800, + RATE_500000, + RATE_576000, + RATE_921600, + RATE_1000000, + RATE_1152000, + RATE_1500000, + RATE_2000000, + RATE_2500000, + RATE_3000000, + RATE_3500000, + RATE_4000000 +}; + +namespace uart { + +void setMode(struct termios& options, UartModes mode); +/** + * @brief This functions adds the baudrate specified in the uartCookie to the termios options + * struct. + */ +void setBaudrate(struct termios& options, UartBaudRate baud); + +void setStopbits(struct termios& options, StopBits bits); + +void setBitsPerWord(struct termios& options, BitsPerWord bits); + +void enableRead(struct termios& options); + +void setParity(struct termios& options, Parity parity); + +void ignoreCtrlLines(struct termios& options); + +int readCountersAndErrors(int serialPort, serial_icounter_struct& icounter); + +} // namespace uart + +#endif /* FSFW_HAL_LINUX_UART_HELPER_H_ */ diff --git a/src/fsfw_hal/linux/uart/CMakeLists.txt b/src/fsfw_hal/linux/uart/CMakeLists.txt deleted file mode 100644 index 9cad62a4..00000000 --- a/src/fsfw_hal/linux/uart/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC UartComIF.cpp UartCookie.cpp) From 5b352978c5b4fe99f6db7fae5f96c3a462032bb1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Nov 2022 11:33:35 +0100 Subject: [PATCH 442/532] rename cookie class --- src/fsfw_hal/linux/serial/SerialComIF.cpp | 24 ++++++------- src/fsfw_hal/linux/serial/SerialComIF.h | 10 +++--- src/fsfw_hal/linux/serial/SerialCookie.cpp | 42 +++++++++++----------- src/fsfw_hal/linux/serial/SerialCookie.h | 6 ++-- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/fsfw_hal/linux/serial/SerialComIF.cpp b/src/fsfw_hal/linux/serial/SerialComIF.cpp index 0fd293a0..a421326b 100644 --- a/src/fsfw_hal/linux/serial/SerialComIF.cpp +++ b/src/fsfw_hal/linux/serial/SerialComIF.cpp @@ -21,7 +21,7 @@ ReturnValue_t SerialComIF::initializeInterface(CookieIF* cookie) { return NULLPOINTER; } - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "UartComIF::initializeInterface: Invalid UART Cookie!" << std::endl; @@ -58,7 +58,7 @@ ReturnValue_t SerialComIF::initializeInterface(CookieIF* cookie) { return returnvalue::OK; } -int SerialComIF::configureUartPort(UartCookie* uartCookie) { +int SerialComIF::configureUartPort(SerialCookie* uartCookie) { struct termios options = {}; std::string deviceFile = uartCookie->getDeviceFile(); @@ -113,7 +113,7 @@ int SerialComIF::configureUartPort(UartCookie* uartCookie) { return fd; } -void SerialComIF::setStopBitOptions(struct termios* options, UartCookie* uartCookie) { +void SerialComIF::setStopBitOptions(struct termios* options, SerialCookie* uartCookie) { /* Clear stop field. Sets stop bit to one bit */ options->c_cflag &= ~CSTOPB; switch (uartCookie->getStopBits()) { @@ -125,7 +125,7 @@ void SerialComIF::setStopBitOptions(struct termios* options, UartCookie* uartCoo } } -void SerialComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCookie) { +void SerialComIF::setDatasizeOptions(struct termios* options, SerialCookie* uartCookie) { /* Clear size bits */ options->c_cflag &= ~CSIZE; switch (uartCookie->getBitsPerWord()) { @@ -187,7 +187,7 @@ ReturnValue_t SerialComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData return returnvalue::FAILED; } - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::sendMessasge: Invalid UART Cookie!" << std::endl; @@ -223,7 +223,7 @@ ReturnValue_t SerialComIF::getSendSuccess(CookieIF* cookie) { return returnvalue ReturnValue_t SerialComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { std::string deviceFile; - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "UartComIF::requestReceiveMessage: Invalid Uart Cookie!" << std::endl; @@ -256,7 +256,7 @@ ReturnValue_t SerialComIF::requestReceiveMessage(CookieIF* cookie, size_t reques } } -ReturnValue_t SerialComIF::handleCanonicalRead(UartCookie& uartCookie, +ReturnValue_t SerialComIF::handleCanonicalRead(SerialCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen) { ReturnValue_t result = returnvalue::OK; uint8_t maxReadCycles = uartCookie.getReadCycles(); @@ -314,7 +314,7 @@ ReturnValue_t SerialComIF::handleCanonicalRead(UartCookie& uartCookie, return result; } -ReturnValue_t SerialComIF::handleNoncanonicalRead(UartCookie& uartCookie, +ReturnValue_t SerialComIF::handleNoncanonicalRead(SerialCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen) { int fd = iter->second.fileDescriptor; @@ -352,7 +352,7 @@ ReturnValue_t SerialComIF::handleNoncanonicalRead(UartCookie& uartCookie, ReturnValue_t SerialComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { std::string deviceFile; - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "UartComIF::readReceivedMessage: Invalid uart cookie!" << std::endl; @@ -381,7 +381,7 @@ ReturnValue_t SerialComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffe ReturnValue_t SerialComIF::flushUartRxBuffer(CookieIF* cookie) { std::string deviceFile; - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::flushUartRxBuffer: Invalid uart cookie!" << std::endl; @@ -400,7 +400,7 @@ ReturnValue_t SerialComIF::flushUartRxBuffer(CookieIF* cookie) { ReturnValue_t SerialComIF::flushUartTxBuffer(CookieIF* cookie) { std::string deviceFile; - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::flushUartTxBuffer: Invalid uart cookie!" << std::endl; @@ -419,7 +419,7 @@ ReturnValue_t SerialComIF::flushUartTxBuffer(CookieIF* cookie) { ReturnValue_t SerialComIF::flushUartTxAndRxBuf(CookieIF* cookie) { std::string deviceFile; - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::flushUartTxAndRxBuf: Invalid uart cookie!" << std::endl; diff --git a/src/fsfw_hal/linux/serial/SerialComIF.h b/src/fsfw_hal/linux/serial/SerialComIF.h index 4953884a..907da7e0 100644 --- a/src/fsfw_hal/linux/serial/SerialComIF.h +++ b/src/fsfw_hal/linux/serial/SerialComIF.h @@ -75,9 +75,9 @@ class SerialComIF : public DeviceCommunicationIF, public SystemObject { * uart device file, baudrate, parity, stopbits etc. * @return The file descriptor of the configured uart. */ - int configureUartPort(UartCookie* uartCookie); + int configureUartPort(SerialCookie* uartCookie); - void setStopBitOptions(struct termios* options, UartCookie* uartCookie); + void setStopBitOptions(struct termios* options, SerialCookie* uartCookie); /** * @brief This function sets options which are not configurable by the uartCookie. @@ -87,11 +87,11 @@ class SerialComIF : public DeviceCommunicationIF, public SystemObject { /** * @brief With this function the datasize settings are added to the termios options struct. */ - void setDatasizeOptions(struct termios* options, UartCookie* uartCookie); + void setDatasizeOptions(struct termios* options, SerialCookie* uartCookie); - ReturnValue_t handleCanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, + ReturnValue_t handleCanonicalRead(SerialCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen); - ReturnValue_t handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, + ReturnValue_t handleNoncanonicalRead(SerialCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen); }; diff --git a/src/fsfw_hal/linux/serial/SerialCookie.cpp b/src/fsfw_hal/linux/serial/SerialCookie.cpp index 733d84a5..0e2260a5 100644 --- a/src/fsfw_hal/linux/serial/SerialCookie.cpp +++ b/src/fsfw_hal/linux/serial/SerialCookie.cpp @@ -1,7 +1,7 @@ #include #include -UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, +SerialCookie::SerialCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, size_t maxReplyLen, UartModes uartMode) : handlerId(handlerId), deviceFile(deviceFile), @@ -9,42 +9,42 @@ UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRa baudrate(baudrate), maxReplyLen(maxReplyLen) {} -UartCookie::~UartCookie() {} +SerialCookie::~SerialCookie() {} -UartBaudRate UartCookie::getBaudrate() const { return baudrate; } +UartBaudRate SerialCookie::getBaudrate() const { return baudrate; } -size_t UartCookie::getMaxReplyLen() const { return maxReplyLen; } +size_t SerialCookie::getMaxReplyLen() const { return maxReplyLen; } -std::string UartCookie::getDeviceFile() const { return deviceFile; } +std::string SerialCookie::getDeviceFile() const { return deviceFile; } -void UartCookie::setParityOdd() { parity = Parity::ODD; } +void SerialCookie::setParityOdd() { parity = Parity::ODD; } -void UartCookie::setParityEven() { parity = Parity::EVEN; } +void SerialCookie::setParityEven() { parity = Parity::EVEN; } -Parity UartCookie::getParity() const { return parity; } +Parity SerialCookie::getParity() const { return parity; } -void UartCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { bitsPerWord = bitsPerWord_; } +void SerialCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { bitsPerWord = bitsPerWord_; } -BitsPerWord UartCookie::getBitsPerWord() const { return bitsPerWord; } +BitsPerWord SerialCookie::getBitsPerWord() const { return bitsPerWord; } -StopBits UartCookie::getStopBits() const { return stopBits; } +StopBits SerialCookie::getStopBits() const { return stopBits; } -void UartCookie::setTwoStopBits() { stopBits = StopBits::TWO_STOP_BITS; } +void SerialCookie::setTwoStopBits() { stopBits = StopBits::TWO_STOP_BITS; } -void UartCookie::setOneStopBit() { stopBits = StopBits::ONE_STOP_BIT; } +void SerialCookie::setOneStopBit() { stopBits = StopBits::ONE_STOP_BIT; } -UartModes UartCookie::getUartMode() const { return uartMode; } +UartModes SerialCookie::getUartMode() const { return uartMode; } -void UartCookie::setReadCycles(uint8_t readCycles) { this->readCycles = readCycles; } +void SerialCookie::setReadCycles(uint8_t readCycles) { this->readCycles = readCycles; } -void UartCookie::setToFlushInput(bool enable) { this->flushInput = enable; } +void SerialCookie::setToFlushInput(bool enable) { this->flushInput = enable; } -uint8_t UartCookie::getReadCycles() const { return readCycles; } +uint8_t SerialCookie::getReadCycles() const { return readCycles; } -bool UartCookie::getInputShouldBeFlushed() { return this->flushInput; } +bool SerialCookie::getInputShouldBeFlushed() { return this->flushInput; } -object_id_t UartCookie::getHandlerId() const { return this->handlerId; } +object_id_t SerialCookie::getHandlerId() const { return this->handlerId; } -void UartCookie::setNoFixedSizeReply() { replySizeFixed = false; } +void SerialCookie::setNoFixedSizeReply() { replySizeFixed = false; } -bool UartCookie::isReplySizeFixed() { return replySizeFixed; } +bool SerialCookie::isReplySizeFixed() { return replySizeFixed; } diff --git a/src/fsfw_hal/linux/serial/SerialCookie.h b/src/fsfw_hal/linux/serial/SerialCookie.h index 8d0f5fb4..3916e4ca 100644 --- a/src/fsfw_hal/linux/serial/SerialCookie.h +++ b/src/fsfw_hal/linux/serial/SerialCookie.h @@ -14,7 +14,7 @@ * * @author J. Meier */ -class UartCookie : public CookieIF { +class SerialCookie : public CookieIF { public: /** * @brief Constructor for the uart cookie. @@ -29,10 +29,10 @@ class UartCookie : public CookieIF { * 8 databits (number of bits transfered with one uart frame) * One stop bit */ - UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, + SerialCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, size_t maxReplyLen, UartModes uartMode = UartModes::NON_CANONICAL); - virtual ~UartCookie(); + virtual ~SerialCookie(); UartBaudRate getBaudrate() const; size_t getMaxReplyLen() const; From b6a3c206cc80846fc3afec1212c1c86710f697f8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Nov 2022 11:34:58 +0100 Subject: [PATCH 443/532] smaller include tweaks --- src/fsfw_hal/linux/serial/SerialComIF.cpp | 3 ++- src/fsfw_hal/linux/serial/SerialCookie.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fsfw_hal/linux/serial/SerialComIF.cpp b/src/fsfw_hal/linux/serial/SerialComIF.cpp index a421326b..177d74e4 100644 --- a/src/fsfw_hal/linux/serial/SerialComIF.cpp +++ b/src/fsfw_hal/linux/serial/SerialComIF.cpp @@ -1,6 +1,7 @@ +#include "SerialComIF.h" + #include #include -#include #include #include diff --git a/src/fsfw_hal/linux/serial/SerialCookie.cpp b/src/fsfw_hal/linux/serial/SerialCookie.cpp index 0e2260a5..e85d339d 100644 --- a/src/fsfw_hal/linux/serial/SerialCookie.cpp +++ b/src/fsfw_hal/linux/serial/SerialCookie.cpp @@ -1,5 +1,6 @@ +#include "SerialCookie.h" + #include -#include SerialCookie::SerialCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, size_t maxReplyLen, UartModes uartMode) From a9c6c088f25adf1b4b8fca1736276e5e5fe227ba Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Nov 2022 14:08:38 +0100 Subject: [PATCH 444/532] remove leftover debugging code --- src/fsfw/globalfunctions/timevalOperations.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/fsfw/globalfunctions/timevalOperations.cpp b/src/fsfw/globalfunctions/timevalOperations.cpp index f9f0a5c6..79c07eaf 100644 --- a/src/fsfw/globalfunctions/timevalOperations.cpp +++ b/src/fsfw/globalfunctions/timevalOperations.cpp @@ -1,12 +1,9 @@ #include "fsfw/globalfunctions/timevalOperations.h" -#include - timeval& operator+=(timeval& lhs, const timeval& rhs) { int64_t sum = static_cast(lhs.tv_sec) * 1000000. + lhs.tv_usec; sum += static_cast(rhs.tv_sec) * 1000000. + rhs.tv_usec; - int64_t tmp = sum / 1000000; - lhs.tv_sec = tmp; + lhs.tv_sec = sum / 1000000; lhs.tv_usec = sum - lhs.tv_sec * 1000000; return lhs; } From 83a6f0b5f8b80392c54c708358245c1afc95002f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Nov 2022 14:12:26 +0100 Subject: [PATCH 445/532] reenable setup function call --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df3757ea..e2572b20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -340,9 +340,9 @@ if(FSFW_BUILD_TESTS) -ftest-coverage) if(WIN32) - #setup_target_for_coverage_gcovr_html( - # NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} - # DEPENDENCIES ${FSFW_TEST_TGT}) + setup_target_for_coverage_gcovr_html( + NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} + DEPENDENCIES ${FSFW_TEST_TGT}) else() setup_target_for_coverage_lcov( NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} From 1bea2344f68d8d86746dc5416133b8a630fbc6bc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Nov 2022 14:21:00 +0100 Subject: [PATCH 446/532] remove using declaraction --- src/fsfw/storagemanager/LocalPool.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fsfw/storagemanager/LocalPool.h b/src/fsfw/storagemanager/LocalPool.h index bb88842b..f82acd54 100644 --- a/src/fsfw/storagemanager/LocalPool.h +++ b/src/fsfw/storagemanager/LocalPool.h @@ -131,7 +131,6 @@ class LocalPool : public SystemObject, public StorageManagerIF { // Using functions provided by StorageManagerIF requires either a fully qualified path // like for example localPool.StorageManagerIF::getFreeElement(...) or re-exporting // the fully qualified path with the using directive. - using StorageManagerIF::getFreeElement; using StorageManagerIF::getData; using StorageManagerIF::modifyData; From 72d7c4344561d1cb105d663f7c1c2a4d1dbacec3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Nov 2022 14:57:37 +0100 Subject: [PATCH 447/532] updates for storage manager mock --- unittests/mocks/StorageManagerMock.cpp | 8 ++++---- unittests/mocks/StorageManagerMock.h | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/unittests/mocks/StorageManagerMock.cpp b/unittests/mocks/StorageManagerMock.cpp index 5cd3a575..8a287cd1 100644 --- a/unittests/mocks/StorageManagerMock.cpp +++ b/unittests/mocks/StorageManagerMock.cpp @@ -1,11 +1,11 @@ #include "StorageManagerMock.h" ReturnValue_t StorageManagerMock::addData(store_address_t *storageId, const uint8_t *data, - size_t size, bool ignoreFault) { + size_t size) { if (nextAddDataCallFails.first) { return nextAddDataCallFails.second; } - return LocalPool::addData(storageId, data, size, ignoreFault); + return LocalPool::addData(storageId, data, size); } ReturnValue_t StorageManagerMock::deleteData(store_address_t packet_id) { if (nextDeleteDataCallFails.first) { @@ -36,11 +36,11 @@ ReturnValue_t StorageManagerMock::modifyData(store_address_t packet_id, uint8_t } ReturnValue_t StorageManagerMock::getFreeElement(store_address_t *storageId, size_t size, - uint8_t **p_data, bool ignoreFault) { + uint8_t **p_data) { if (nextFreeElementCallFails.first) { return nextFreeElementCallFails.second; } - return LocalPool::getFreeElement(storageId, size, p_data, ignoreFault); + return LocalPool::getFreeElement(storageId, size, p_data); } bool StorageManagerMock::hasDataAtId(store_address_t storeId) const { diff --git a/unittests/mocks/StorageManagerMock.h b/unittests/mocks/StorageManagerMock.h index a52e46db..a0a59a47 100644 --- a/unittests/mocks/StorageManagerMock.h +++ b/unittests/mocks/StorageManagerMock.h @@ -8,15 +8,13 @@ class StorageManagerMock : public LocalPool { public: StorageManagerMock(object_id_t setObjectId, const LocalPoolConfig &poolConfig); - ReturnValue_t addData(store_address_t *storageId, const uint8_t *data, size_t size, - bool ignoreFault) override; + ReturnValue_t addData(store_address_t *storageId, const uint8_t *data, size_t size) override; ReturnValue_t deleteData(store_address_t packet_id) override; ReturnValue_t deleteData(uint8_t *buffer, size_t size, store_address_t *storeId) override; ReturnValue_t getData(store_address_t packet_id, const uint8_t **packet_ptr, size_t *size) override; ReturnValue_t modifyData(store_address_t packet_id, uint8_t **packet_ptr, size_t *size) override; - ReturnValue_t getFreeElement(store_address_t *storageId, size_t size, uint8_t **p_data, - bool ignoreFault) override; + ReturnValue_t getFreeElement(store_address_t *storageId, size_t size, uint8_t **p_data) override; [[nodiscard]] bool hasDataAtId(store_address_t storeId) const override; void clearStore() override; void clearSubPool(uint8_t poolIndex) override; From c013fcc1f5b257f7de6fc57668b6cfdc6fd183d7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 10:01:37 +0100 Subject: [PATCH 448/532] move container retvals to namespace --- src/fsfw/container/ArrayList.h | 6 ++---- src/fsfw/container/FixedMap.h | 17 ++++++----------- src/fsfw/container/definitions.h | 14 ++++++++++++++ unittests/container/TestArrayList.cpp | 2 +- unittests/container/TestFixedArrayList.cpp | 2 +- unittests/container/TestFixedMap.cpp | 20 ++++++++++---------- 6 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 src/fsfw/container/definitions.h diff --git a/src/fsfw/container/ArrayList.h b/src/fsfw/container/ArrayList.h index f5f74cf1..92834558 100644 --- a/src/fsfw/container/ArrayList.h +++ b/src/fsfw/container/ArrayList.h @@ -4,6 +4,7 @@ #include "../returnvalues/returnvalue.h" #include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeIF.h" +#include "definitions.h" /** * @brief A List that stores its values in an array. @@ -19,9 +20,6 @@ class ArrayList { friend class SerialArrayListAdapter; public: - static const uint8_t INTERFACE_ID = CLASS_ID::ARRAY_LIST; - static const ReturnValue_t FULL = MAKE_RETURN_CODE(0x01); - /** * This is the allocating constructor. * It allocates an array of the specified size. @@ -187,7 +185,7 @@ class ArrayList { */ ReturnValue_t insert(T entry) { if (size >= maxSize_) { - return FULL; + return containers::LIST_FULL; } entries[size] = entry; ++size; diff --git a/src/fsfw/container/FixedMap.h b/src/fsfw/container/FixedMap.h index def219d1..ce90d814 100644 --- a/src/fsfw/container/FixedMap.h +++ b/src/fsfw/container/FixedMap.h @@ -4,8 +4,8 @@ #include #include -#include "../returnvalues/returnvalue.h" #include "ArrayList.h" +#include "definitions.h" /** * @brief Map implementation for maps with a pre-defined size. @@ -24,11 +24,6 @@ class FixedMap : public SerializeIF { "derived class from SerializeIF to be serialize-able"); public: - static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MAP; - static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01); - static const ReturnValue_t MAP_FULL = MAKE_RETURN_CODE(0x02); - static const ReturnValue_t KEY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03); - private: static const key_t EMPTY_SLOT = -1; ArrayList, uint32_t> theMap; @@ -76,10 +71,10 @@ class FixedMap : public SerializeIF { ReturnValue_t insert(key_t key, T value, Iterator* storedValue = nullptr) { if (exists(key) == returnvalue::OK) { - return KEY_ALREADY_EXISTS; + return containers::KEY_ALREADY_EXISTS; } if (_size == theMap.maxSize()) { - return MAP_FULL; + return containers::MAP_FULL; } theMap[_size].first = key; theMap[_size].second = value; @@ -93,7 +88,7 @@ class FixedMap : public SerializeIF { ReturnValue_t insert(std::pair pair) { return insert(pair.first, pair.second); } ReturnValue_t exists(key_t key) const { - ReturnValue_t result = KEY_DOES_NOT_EXIST; + ReturnValue_t result = containers::KEY_DOES_NOT_EXIST; if (findIndex(key) < _size) { result = returnvalue::OK; } @@ -103,7 +98,7 @@ class FixedMap : public SerializeIF { ReturnValue_t erase(Iterator* iter) { uint32_t i; if ((i = findIndex((*iter).value->first)) >= _size) { - return KEY_DOES_NOT_EXIST; + return containers::KEY_DOES_NOT_EXIST; } theMap[i] = theMap[_size - 1]; --_size; @@ -114,7 +109,7 @@ class FixedMap : public SerializeIF { ReturnValue_t erase(key_t key) { uint32_t i; if ((i = findIndex(key)) >= _size) { - return KEY_DOES_NOT_EXIST; + return containers::KEY_DOES_NOT_EXIST; } theMap[i] = theMap[_size - 1]; --_size; diff --git a/src/fsfw/container/definitions.h b/src/fsfw/container/definitions.h new file mode 100644 index 00000000..b50ea45d --- /dev/null +++ b/src/fsfw/container/definitions.h @@ -0,0 +1,14 @@ +#ifndef FSFW_CONTAINER_DEFINITIONS_H_ +#define FSFW_CONTAINER_DEFINITIONS_H_ + +#include "fsfw/retval.h" + +namespace containers { +static const ReturnValue_t KEY_ALREADY_EXISTS = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x01); +static const ReturnValue_t MAP_FULL = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x02); +static const ReturnValue_t KEY_DOES_NOT_EXIST = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x03); + +static const ReturnValue_t LIST_FULL = returnvalue::makeCode(CLASS_ID::ARRAY_LIST, 0x01); +} // namespace containers + +#endif /* FSFW_CONTAINER_DEFINITIONS_H_ */ diff --git a/unittests/container/TestArrayList.cpp b/unittests/container/TestArrayList.cpp index 69b08faa..0c327685 100644 --- a/unittests/container/TestArrayList.cpp +++ b/unittests/container/TestArrayList.cpp @@ -43,7 +43,7 @@ TEST_CASE("Array List", "[containers]") { for (auto i = 0; i < 20; i++) { REQUIRE(list.insert(i) == static_cast(returnvalue::OK)); } - REQUIRE(list.insert(20) == static_cast(ArrayList::FULL)); + REQUIRE(list.insert(20) == static_cast(containers::LIST_FULL)); ArrayList::Iterator it = list.begin(); REQUIRE((*it) == 0); it++; diff --git a/unittests/container/TestFixedArrayList.cpp b/unittests/container/TestFixedArrayList.cpp index 876d6792..f3131c64 100644 --- a/unittests/container/TestFixedArrayList.cpp +++ b/unittests/container/TestFixedArrayList.cpp @@ -31,7 +31,7 @@ TEST_CASE("FixedArrayList Tests", "[containers]") { for (auto i = 1; i < 260; i++) { REQUIRE(list.insert(i) == static_cast(returnvalue::OK)); } - REQUIRE(list.insert(260) == static_cast(ArrayList::FULL)); + REQUIRE(list.insert(260) == static_cast(containers::LIST_FULL)); list.clear(); REQUIRE(list.size == 0); } diff --git a/unittests/container/TestFixedMap.cpp b/unittests/container/TestFixedMap.cpp index 8bfe9fed..83ff975d 100644 --- a/unittests/container/TestFixedMap.cpp +++ b/unittests/container/TestFixedMap.cpp @@ -7,6 +7,8 @@ template class FixedMap; +using namespace returnvalue; + TEST_CASE("FixedMap Tests", "[containers]") { INFO("FixedMap Tests"); @@ -24,9 +26,9 @@ TEST_CASE("FixedMap Tests", "[containers]") { REQUIRE(map.find(i)->second == i + 1); REQUIRE(not map.empty()); } - REQUIRE(map.insert(0, 0) == static_cast(FixedMap::KEY_ALREADY_EXISTS)); - REQUIRE(map.insert(31, 0) == static_cast(FixedMap::MAP_FULL)); - REQUIRE(map.exists(31) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); + REQUIRE(map.insert(0, 0) == static_cast(containers::KEY_ALREADY_EXISTS)); + REQUIRE(map.insert(31, 0) == static_cast(containers::MAP_FULL)); + REQUIRE(map.exists(31) == static_cast(containers::KEY_DOES_NOT_EXIST)); REQUIRE(map.size() == 30); REQUIRE(map.full()); { @@ -34,15 +36,14 @@ TEST_CASE("FixedMap Tests", "[containers]") { REQUIRE(map.find(5, &ptr) == static_cast(returnvalue::OK)); REQUIRE(*ptr == 6); REQUIRE(*(map.findValue(6)) == 7); - REQUIRE(map.find(31, &ptr) == - static_cast(FixedMap::KEY_DOES_NOT_EXIST)); + REQUIRE(map.find(31, &ptr) == static_cast(containers::KEY_DOES_NOT_EXIST)); } REQUIRE(map.getSerializedSize() == (sizeof(uint32_t) + 30 * (sizeof(uint32_t) + sizeof(uint16_t)))); REQUIRE(map.erase(2) == static_cast(returnvalue::OK)); - REQUIRE(map.erase(31) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); - REQUIRE(map.exists(2) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); + REQUIRE(map.erase(31) == static_cast(containers::KEY_DOES_NOT_EXIST)); + REQUIRE(map.exists(2) == static_cast(containers::KEY_DOES_NOT_EXIST)); REQUIRE(map.size() == 29); for (auto element : map) { @@ -79,8 +80,7 @@ TEST_CASE("FixedMap Tests", "[containers]") { REQUIRE(map.insert(37, 38, nullptr) == static_cast(returnvalue::OK)); REQUIRE(map.find(37)->second == 38); REQUIRE(map.size() == 2); - REQUIRE(map.insert(37, 24, nullptr) == - static_cast(FixedMap::KEY_ALREADY_EXISTS)); + REQUIRE(map.insert(37, 24, nullptr) == static_cast(containers::KEY_ALREADY_EXISTS)); REQUIRE(map.find(37)->second != 24); REQUIRE(map.size() == 2); }; @@ -137,7 +137,7 @@ TEST_CASE("FixedMap Tests", "[containers]") { FixedMap::Iterator it; std::pair pair = std::make_pair(44, 43); it = FixedMap::Iterator(&pair); - REQUIRE(map.erase(&it) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); + REQUIRE(map.erase(&it) == static_cast(containers::KEY_DOES_NOT_EXIST)); REQUIRE(map.find(45) == map.end()); size_t toLargeMap = 100; const uint8_t* ptr = reinterpret_cast(&toLargeMap); From 2a842666d5e182d1491a40fafbc77405774f1f9a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 10:46:46 +0100 Subject: [PATCH 449/532] SP reader getPacketData is const now --- src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp | 2 +- src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp index 605bbd21..262653c9 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp @@ -21,7 +21,7 @@ SpacePacketReader::~SpacePacketReader() = default; inline uint16_t SpacePacketReader::getPacketIdRaw() const { return ccsds::getPacketId(*spHeader); } -const uint8_t* SpacePacketReader::getPacketData() { return packetDataField; } +const uint8_t* SpacePacketReader::getPacketData() const { return packetDataField; } ReturnValue_t SpacePacketReader::setData(uint8_t* data, size_t maxSize_, void* args) { return setInternalFields(data, maxSize_); diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h index ff22510c..61939217 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h @@ -71,7 +71,7 @@ class SpacePacketReader : public SpacePacketIF, // Helper methods: [[nodiscard]] ReturnValue_t checkSize() const; - const uint8_t* getPacketData(); + const uint8_t* getPacketData() const; ReturnValue_t setReadOnlyData(const uint8_t* data, size_t maxSize); From fe3d6bd4320ca12e53c11feb7448aa181b5f66a6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 10:56:46 +0100 Subject: [PATCH 450/532] 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 3d7e5987..e34c209a 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 9483c2809d2a8c573b56dafac2e820b016021178 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:26:53 +0100 Subject: [PATCH 451/532] DLE parser --- src/fsfw/globalfunctions/CMakeLists.txt | 1 + src/fsfw/globalfunctions/DleParser.cpp | 173 ++++++++++++++++++++++++ src/fsfw/globalfunctions/DleParser.h | 127 +++++++++++++++++ 3 files changed, 301 insertions(+) create mode 100644 src/fsfw/globalfunctions/DleParser.cpp create mode 100644 src/fsfw/globalfunctions/DleParser.h diff --git a/src/fsfw/globalfunctions/CMakeLists.txt b/src/fsfw/globalfunctions/CMakeLists.txt index cfa02696..cf8a25d5 100644 --- a/src/fsfw/globalfunctions/CMakeLists.txt +++ b/src/fsfw/globalfunctions/CMakeLists.txt @@ -4,6 +4,7 @@ target_sources( AsciiConverter.cpp CRC.cpp DleEncoder.cpp + DleParser.cpp PeriodicOperationDivider.cpp timevalOperations.cpp Type.cpp diff --git a/src/fsfw/globalfunctions/DleParser.cpp b/src/fsfw/globalfunctions/DleParser.cpp new file mode 100644 index 00000000..cc695bab --- /dev/null +++ b/src/fsfw/globalfunctions/DleParser.cpp @@ -0,0 +1,173 @@ +#include "DleParser.h" + +#include + +#include +#include +#include + +DleParser::DleParser(SimpleRingBuffer& decodeRingBuf, DleEncoder& decoder, BufPair encodedBuf, + BufPair decodedBuf) + : decodeRingBuf(decodeRingBuf), + decoder(decoder), + encodedBuf(encodedBuf), + decodedBuf(decodedBuf) {} + +ReturnValue_t DleParser::passData(const uint8_t* data, size_t len) { + if (data == nullptr or len == 0) { + return returnvalue::FAILED; + } + return decodeRingBuf.writeData(data, len); +} + +ReturnValue_t DleParser::parseRingBuf(size_t& readSize) { + ctx.setType(DleParser::ContextType::NONE); + size_t availableData = decodeRingBuf.getAvailableReadData(); + if (availableData == 0) { + return NO_PACKET_FOUND; + } + if (availableData > encodedBuf.second) { + ErrorInfo info; + info.len = decodeRingBuf.getAvailableReadData(); + setErrorContext(ErrorTypes::DECODING_BUF_TOO_SMALL, info); + return returnvalue::FAILED; + } + ReturnValue_t result = decodeRingBuf.readData(encodedBuf.first, availableData); + if (result != returnvalue::OK) { + ErrorInfo info; + info.res = result; + setErrorContext(ErrorTypes::RING_BUF_ERROR, info); + return result; + } + bool stxFound = false; + size_t stxIdx = 0; + for (size_t vectorIdx = 0; vectorIdx < availableData; vectorIdx++) { + // handle STX char + if (encodedBuf.first[vectorIdx] == DleEncoder::STX_CHAR) { + if (not stxFound) { + stxFound = true; + stxIdx = vectorIdx; + } else { + // might be lost packet, so we should advance the read pointer + // without skipping the STX + readSize = vectorIdx; + ErrorInfo info; + setErrorContext(ErrorTypes::CONSECUTIVE_STX_CHARS, info); + return POSSIBLE_PACKET_LOSS; + } + } + // handle ETX char + if (encodedBuf.first[vectorIdx] == DleEncoder::ETX_CHAR) { + if (stxFound) { + // This is propably a packet, so we decode it. + size_t decodedLen = 0; + size_t dummy = 0; + + ReturnValue_t result = + decoder.decode(&encodedBuf.first[stxIdx], availableData - stxIdx, &dummy, + decodedBuf.first, decodedBuf.second, &decodedLen); + if (result == returnvalue::OK) { + ctx.setType(ContextType::PACKET_FOUND); + ctx.decodedPacket.first = decodedBuf.first; + ctx.decodedPacket.second = decodedLen; + readSize = ++vectorIdx; + return returnvalue::OK; + } else { + // invalid packet, skip. + readSize = ++vectorIdx; + ErrorInfo info; + info.res = result; + setErrorContext(ErrorTypes::DECODE_ERROR, info); + return POSSIBLE_PACKET_LOSS; + } + } else { + // might be lost packet, so we should advance the read pointer + readSize = ++vectorIdx; + ErrorInfo info; + info.len = 0; + setErrorContext(ErrorTypes::CONSECUTIVE_ETX_CHARS, info); + return POSSIBLE_PACKET_LOSS; + } + } + } + return NO_PACKET_FOUND; +} + +void DleParser::defaultFoundPacketHandler(uint8_t* packet, size_t len, void* args) { +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::info << "DleParserBase::handleFoundPacket: Detected DLE packet with " << len << " bytes" + << std::endl; +#else + sif::printInfo("DleParserBase::handleFoundPacket: Detected DLE packet with %d bytes\n", len); +#endif +#endif +} + +void DleParser::defaultErrorHandler() { + if (ctx.getType() != DleParser::ContextType::ERROR) { + errorPrinter("No error"); + return; + } + switch (ctx.error.first) { + case (ErrorTypes::NONE): { + errorPrinter("No error"); + break; + } + case (ErrorTypes::DECODE_ERROR): { + errorPrinter("Decode Error"); + break; + } + case (ErrorTypes::RING_BUF_ERROR): { + errorPrinter("Ring Buffer Error"); + break; + } + 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); + if (ctx.error.first == ErrorTypes::ENCODED_BUF_TOO_SMALL) { + errorPrinter("Encoded buf too small", opt); + } else { + errorPrinter("Decoding buf too small", opt); + } + break; + } + case (ErrorTypes::CONSECUTIVE_STX_CHARS): { + errorPrinter("Consecutive STX chars detected"); + break; + } + case (ErrorTypes::CONSECUTIVE_ETX_CHARS): { + errorPrinter("Consecutive ETX chars detected"); + break; + } + } +} + +void DleParser::errorPrinter(const char* str, const char* opt) { + if (opt == nullptr) { + opt = ""; + } +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::info << "DleParserBase::handleParseError: " << str << opt << std::endl; +#else + sif::printInfo("DleParserBase::handleParseError: %s%s\n", str, opt); +#endif +#endif +} + +void DleParser::setErrorContext(ErrorTypes err, ErrorInfo info) { + ctx.setType(ContextType::ERROR); + ctx.error.first = err; + ctx.error.second = info; +} + +ReturnValue_t DleParser::confirmBytesRead(size_t bytesRead) { + return decodeRingBuf.deleteData(bytesRead); +} + +const DleParser::Context& DleParser::getContext() { return ctx; } + +void DleParser::reset() { decodeRingBuf.clear(); } diff --git a/src/fsfw/globalfunctions/DleParser.h b/src/fsfw/globalfunctions/DleParser.h new file mode 100644 index 00000000..9802017a --- /dev/null +++ b/src/fsfw/globalfunctions/DleParser.h @@ -0,0 +1,127 @@ +#pragma once + +#include +#include +#include + +#include +#include + +/** + * @brief This base helper class can be used to extract DLE encoded packets from a data stream + * @details + * The core API of the parser takes received packets which can contains DLE packets. The parser + * can deal with DLE packets split across multiple packets. It does so by using a dedicated + * decoding ring buffer. The user can process received packets and detect errors by + * overriding two provided virtual methods. This also allows detecting multiple DLE packets + * inside one passed packet. + */ +class DleParser { + public: + static constexpr ReturnValue_t NO_PACKET_FOUND = returnvalue::makeCode(1, 1); + static constexpr ReturnValue_t POSSIBLE_PACKET_LOSS = returnvalue::makeCode(1, 2); + using BufPair = std::pair; + + enum class ContextType { NONE, PACKET_FOUND, ERROR }; + + enum class ErrorTypes { + NONE, + ENCODED_BUF_TOO_SMALL, + DECODING_BUF_TOO_SMALL, + DECODE_ERROR, + RING_BUF_ERROR, + CONSECUTIVE_STX_CHARS, + CONSECUTIVE_ETX_CHARS + }; + + union ErrorInfo { + size_t len; + ReturnValue_t res; + }; + + using ErrorPair = std::pair; + + struct Context { + public: + Context() { setType(ContextType::PACKET_FOUND); } + + void setType(ContextType type) { + this->type = type; + if (type == ContextType::PACKET_FOUND) { + error.first = ErrorTypes::NONE; + error.second.len = 0; + } else { + decodedPacket.first = nullptr; + decodedPacket.second = 0; + } + } + + ContextType getType() const { return type; } + + BufPair decodedPacket = {}; + ErrorPair error; + + private: + ContextType type; + }; + + /** + * Base class constructor + * @param decodeRingBuf Ring buffer used to store multiple packets to allow detecting DLE packets + * split across multiple packets + * @param decoder Decoder instance + * @param encodedBuf Buffer used to store encoded packets. It has to be large enough to hold + * the largest expected encoded DLE packet size + * @param decodedBuf Buffer used to store decoded packets. It has to be large enough to hold the + * largest expected decoded DLE packet size + * @param handler Function which will be called on a found packet + * @param args Arbitrary user argument + */ + DleParser(SimpleRingBuffer& decodeRingBuf, DleEncoder& decoder, BufPair encodedBuf, + BufPair decodedBuf); + + /** + * This function allows to pass new data into the parser. It then scans for DLE packets + * automatically and inserts (part of) the packet into a ring buffer if necessary. + * @param data + * @param len + * @return + */ + ReturnValue_t passData(const uint8_t* data, size_t len); + + ReturnValue_t parseRingBuf(size_t& bytesRead); + + ReturnValue_t confirmBytesRead(size_t bytesRead); + + const Context& getContext(); + /** + * Example found packet handler + * function call + * @param packet Decoded packet + * @param len Length of detected packet + */ + void defaultFoundPacketHandler(uint8_t* packet, size_t len, void* args); + /** + * Will be called if an error occured in the #passData call + * @param err + * @param ctx Context information depending on the error type + * - For buffer length errors, will be set to the detected packet length which is too large + * - For decode or ring buffer errors, will be set to the result returned from the failed call + */ + void defaultErrorHandler(); + + static void errorPrinter(const char* str, const char* opt = nullptr); + + void setErrorContext(ErrorTypes err, ErrorInfo ctx); + /** + * Resets the parser by resetting the internal states and clearing the decoding ring buffer + */ + void reset(); + + private: + SimpleRingBuffer& decodeRingBuf; + DleEncoder& decoder; + BufPair encodedBuf; + BufPair decodedBuf; + Context ctx; +}; From 8fe8d810e977e88b3ce22a2f4332527892457377 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:27:31 +0100 Subject: [PATCH 452/532] 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 bf1a92d2..f6077ea1 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 453/532] 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 c3e3eff3..5b421cf9 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 454/532] 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 0e9f0da4..f22d70d6 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 4b90d1d5..ed4d254e 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 455/532] 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 7b997047..2f718e61 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 d6cc7f85..b12e1094 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 456/532] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7ab45e..bfecc685 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 8199b8f3590382aa0bd40f30bf4a4287e309533b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:45:39 +0100 Subject: [PATCH 457/532] bump changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7ab45e..f0d6120a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Added +- `DleParser` helper class to parse DLE encoded packets from a byte stream. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/711 - Add new `UnsignedByteField` class PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/660 From f8c07ec9cf2589547f4a706f0651557a6a689943 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:46:43 +0100 Subject: [PATCH 458/532] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7ab45e..9545c63e 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 459/532] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7ab45e..0f4a9e3a 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 b85ca6469014c9ff4dbb2ba60c79d729d2b3fba3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:48:28 +0100 Subject: [PATCH 460/532] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7ab45e..cd5cdf47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changes +- Moved some container returnvalues to dedicated header and namespace + to they can be used without template specification. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/707 - Remove default secondary header argument for `uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag)` and `uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag)` From f05295bada20f3b15b552c73b5fa16770e1cd6ec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 17 Nov 2022 15:09:08 +0100 Subject: [PATCH 461/532] small fix to allow teardown handling --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 8ab540a0..60966501 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -359,6 +359,8 @@ void DeviceHandlerBase::doStateMachine() { if ((switchState == PowerSwitchIF::SWITCH_ON) || (switchState == NO_SWITCH)) { // NOTE: TransitionSourceMode and -SubMode are set by handleCommandedModeTransition childTransitionFailure = CHILD_TIMEOUT; + transitionSourceMode = _MODE_SHUT_DOWN; + transitionSourceSubMode = SUBMODE_NONE; setMode(_MODE_START_UP); callChildStatemachine(); } From 65a5abab495ad07f5aca25f27569537fea6a577a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Nov 2022 14:56:08 +0100 Subject: [PATCH 462/532] 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 dd01510e..8308f523 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 f9fb33f5..e48e19db 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 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(); diff --git a/src/fsfw_hal/linux/uio/UioMapper.cpp b/src/fsfw_hal/linux/uio/UioMapper.cpp index e34c209a..9e16ce67 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 2a6c012b..76aabd51 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 1c59485c..5e094509 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 463/532] 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 9e16ce67..33e4fd97 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); } } From ecde164f68370e3624f314a53b09691a61f53931 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Nov 2022 08:30:45 +0100 Subject: [PATCH 464/532] updates for source sequence counter --- src/fsfw/tmtcservices/SourceSequenceCounter.h | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/fsfw/tmtcservices/SourceSequenceCounter.h b/src/fsfw/tmtcservices/SourceSequenceCounter.h index da96dc4e..43b6945c 100644 --- a/src/fsfw/tmtcservices/SourceSequenceCounter.h +++ b/src/fsfw/tmtcservices/SourceSequenceCounter.h @@ -5,20 +5,28 @@ class SourceSequenceCounter { private: - uint16_t sequenceCount; + uint16_t sequenceCount = 0; public: - SourceSequenceCounter() : sequenceCount(0) {} - void increment() { - sequenceCount = (sequenceCount + 1) % (SpacePacketBase::LIMIT_SEQUENCE_COUNT); - } - void decrement() { - sequenceCount = (sequenceCount - 1) % (SpacePacketBase::LIMIT_SEQUENCE_COUNT); - } + SourceSequenceCounter(uint16_t initialSequenceCount = 0) : sequenceCount(initialSequenceCount) {} + void increment() { sequenceCount = (sequenceCount + 1) % (ccsds::LIMIT_SEQUENCE_COUNT); } + void decrement() { sequenceCount = (sequenceCount - 1) % (ccsds::LIMIT_SEQUENCE_COUNT); } uint16_t get() { return this->sequenceCount; } - void reset(uint16_t toValue = 0) { - sequenceCount = toValue % (SpacePacketBase::LIMIT_SEQUENCE_COUNT); + void reset(uint16_t toValue = 0) { sequenceCount = toValue % (ccsds::LIMIT_SEQUENCE_COUNT); } + SourceSequenceCounter& operator++(int) { + this->increment(); + return *this; } + SourceSequenceCounter& operator--(int) { + this->decrement(); + return *this; + } + SourceSequenceCounter& operator=(const uint16_t& newCount) { + sequenceCount = newCount; + return *this; + } + + operator uint16_t() { return this->get(); } }; #endif /* FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ */ From d0e322d7e2a54c4fb05947721793d47d2bc69d2d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Nov 2022 08:42:08 +0100 Subject: [PATCH 465/532] printout handling improvements --- src/fsfw_hal/linux/i2c/I2cComIF.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp index 4e57852b..1ad19e82 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -168,12 +168,18 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe int readLen = read(fd, replyBuffer, requestLen); if (readLen != static_cast(requestLen)) { -#if FSFW_VERBOSE_LEVEL >= 1 and FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "I2cComIF::requestReceiveMessage: Reading from I2C " - << "device failed with error code " << errno << ". Description" - << " of error: " << strerror(errno) << std::endl; - sif::error << "I2cComIF::requestReceiveMessage: Read only " << readLen << " from " << requestLen - << " bytes" << std::endl; +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + if (readLen < 0) { + sif::warning << "I2cComIF::requestReceiveMessage: Reading from I2C " + << "device failed with error code " << errno << " | " << strerror(errno) + << std::endl; + } else { + sif::warning << "I2cComIF::requestReceiveMessage: Read only " << readLen << " from " + << requestLen << " bytes" << std::endl; + } +#else +#endif #endif #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen From b13453f46b8c0c1bd446d136c4a1348c8a03ab5f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Nov 2022 08:43:54 +0100 Subject: [PATCH 466/532] vec getter, reset for content --- src/fsfw_hal/linux/CommandExecutor.cpp | 4 ++++ src/fsfw_hal/linux/CommandExecutor.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/fsfw_hal/linux/CommandExecutor.cpp b/src/fsfw_hal/linux/CommandExecutor.cpp index 8b81d94f..27cf8aca 100644 --- a/src/fsfw_hal/linux/CommandExecutor.cpp +++ b/src/fsfw_hal/linux/CommandExecutor.cpp @@ -32,6 +32,8 @@ ReturnValue_t CommandExecutor::execute() { } else if (state == States::PENDING) { return COMMAND_PENDING; } + // Reset data in read vector + std::memset(readVec.data(), 0, readVec.size()); currentCmdFile = popen(currentCmd.c_str(), "r"); if (currentCmdFile == nullptr) { lastError = errno; @@ -205,3 +207,5 @@ ReturnValue_t CommandExecutor::executeBlocking() { } return returnvalue::OK; } + +const std::vector& CommandExecutor::getReadVector() const { return readVec; } diff --git a/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h index 81f989e7..80996bae 100644 --- a/src/fsfw_hal/linux/CommandExecutor.h +++ b/src/fsfw_hal/linux/CommandExecutor.h @@ -107,6 +107,8 @@ class CommandExecutor { */ void reset(); + const std::vector& getReadVector() const; + private: std::string currentCmd; bool blocking = true; From ca80589233a9872e23db44b1af94d26df5f7c236 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 19 Dec 2022 14:58:08 +0100 Subject: [PATCH 467/532] make get const --- src/fsfw/tmtcservices/SourceSequenceCounter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/tmtcservices/SourceSequenceCounter.h b/src/fsfw/tmtcservices/SourceSequenceCounter.h index 43b6945c..f530b444 100644 --- a/src/fsfw/tmtcservices/SourceSequenceCounter.h +++ b/src/fsfw/tmtcservices/SourceSequenceCounter.h @@ -11,7 +11,7 @@ class SourceSequenceCounter { SourceSequenceCounter(uint16_t initialSequenceCount = 0) : sequenceCount(initialSequenceCount) {} void increment() { sequenceCount = (sequenceCount + 1) % (ccsds::LIMIT_SEQUENCE_COUNT); } void decrement() { sequenceCount = (sequenceCount - 1) % (ccsds::LIMIT_SEQUENCE_COUNT); } - uint16_t get() { return this->sequenceCount; } + uint16_t get() const { return this->sequenceCount; } void reset(uint16_t toValue = 0) { sequenceCount = toValue % (ccsds::LIMIT_SEQUENCE_COUNT); } SourceSequenceCounter& operator++(int) { this->increment(); From 7adb47aecb5f5e0b6e20a46128f44b4f44e4e49a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 10 Jan 2023 11:55:54 +0100 Subject: [PATCH 468/532] remove duplicate printout --- src/fsfw_hal/linux/i2c/I2cComIF.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp index 1ad19e82..e3e50040 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -180,10 +180,6 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe } #else #endif -#endif -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen - << " bytes" << std::endl; #endif return returnvalue::FAILED; } From ba62c28b64f9ff38fd9e09026e3d0daa62e36dad Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 12 Jan 2023 15:40:52 +0100 Subject: [PATCH 469/532] adding linux ci and fixing problems --- automation/Jenkinsfile | 96 +++++++++++++------ src/fsfw/events/EventManager.cpp | 6 ++ src/fsfw/events/EventManager.h | 1 + src/fsfw/events/EventManagerIF.h | 1 + src/fsfw/fdir/FailureIsolationBase.cpp | 2 +- src/fsfw/globalfunctions/matching/MatchTree.h | 41 +++++++- src/fsfw/health/HealthTable.cpp | 2 - .../internalerror/InternalErrorReporter.cpp | 7 +- src/fsfw/objectmanager/ObjectManager.cpp | 18 +++- src/fsfw/objectmanager/ObjectManager.h | 10 +- src/fsfw/osal/CMakeLists.txt | 10 +- src/fsfw/osal/linux/MessageQueue.cpp | 2 +- src/fsfw/osal/osal.h.in | 36 +++++++ unittests/CatchSetup.cpp | 5 +- .../devicehandler/DeviceHandlerCommander.cpp | 4 +- unittests/osal/TestSemaphore.cpp | 68 ++++++------- 16 files changed, 230 insertions(+), 79 deletions(-) create mode 100644 src/fsfw/osal/osal.h.in diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 27136606..64c32237 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,45 +1,87 @@ pipeline { environment { - BUILDDIR = 'cmake-build-tests' + BUILDDIR_HOST = 'cmake-build-tests-host' + BUILDDIR_LINUX = 'cmake-build-tests-linux' DOCDDIR = 'cmake-build-documentation' } agent { docker { image 'fsfw-ci:d6' - args '--network host' + args '--network host --sysctl fs.mqueue.msg_max=100' } } stages { - stage('Clean') { - steps { - sh 'rm -rf $BUILDDIR' - } - } - stage('Configure') { - steps { - dir(BUILDDIR) { - sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..' + stage('Host') { + stages{ + stage('Clean') { + steps { + sh 'rm -rf $BUILDDIR_HOST' + } + } + stage('Configure') { + steps { + dir(BUILDDIR_HOST) { + sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..' + } + } + } + stage('Build') { + steps { + dir(BUILDDIR_HOST) { + sh 'cmake --build . -j4' + } + } + } + stage('Unittests') { + steps { + dir(BUILDDIR_HOST) { + sh 'cmake --build . -- fsfw-tests_coverage -j4' + } + } + } + stage('Valgrind') { + steps { + dir(BUILDDIR_HOST) { + sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests' + } + } } } } - stage('Build') { - steps { - dir(BUILDDIR) { - sh 'cmake --build . -j4' + stage('Linux') { + stages{ + stage('Clean') { + steps { + sh 'rm -rf $BUILDDIR_LINUX' + } } - } - } - stage('Unittests') { - steps { - dir(BUILDDIR) { - sh 'cmake --build . -- fsfw-tests_coverage -j4' + stage('Configure') { + steps { + dir(BUILDDIR_LINUX) { + sh 'cmake -DFSFW_OSAL=linux -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..' + } + } } - } - } - stage('Valgrind') { - steps { - dir(BUILDDIR) { - sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests' + stage('Build') { + steps { + dir(BUILDDIR_LINUX) { + sh 'cmake --build . -j4' + } + } + } + stage('Unittests') { + steps { + dir(BUILDDIR_LINUX) { + sh 'cmake --build . -- fsfw-tests_coverage -j4' + } + } + } + stage('Valgrind') { + steps { + dir(BUILDDIR_LINUX) { + sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests' + } + } } } } diff --git a/src/fsfw/events/EventManager.cpp b/src/fsfw/events/EventManager.cpp index f4466817..8bd26282 100644 --- a/src/fsfw/events/EventManager.cpp +++ b/src/fsfw/events/EventManager.cpp @@ -23,6 +23,7 @@ EventManager::EventManager(object_id_t setObjectId) } EventManager::~EventManager() { + listenerList.clear(); QueueFactory::instance()->deleteMessageQueue(eventReportQueue); MutexFactory::instance()->deleteMutex(mutex); } @@ -61,9 +62,14 @@ ReturnValue_t EventManager::registerListener(MessageQueueId_t listener, if (!result.second) { return returnvalue::FAILED; } + return returnvalue::OK; } +ReturnValue_t EventManager::unregisterListener(MessageQueueId_t listener) { + return listenerList.erase(listener) == 1 ? returnvalue::OK : returnvalue::FAILED; +} + ReturnValue_t EventManager::subscribeToEvent(MessageQueueId_t listener, EventId_t event) { return subscribeToEventRange(listener, event); } diff --git a/src/fsfw/events/EventManager.h b/src/fsfw/events/EventManager.h index 70245f5d..0e6dace0 100644 --- a/src/fsfw/events/EventManager.h +++ b/src/fsfw/events/EventManager.h @@ -31,6 +31,7 @@ class EventManager : public EventManagerIF, public ExecutableObjectIF, public Sy MessageQueueId_t getEventReportQueue(); ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false); + ReturnValue_t unregisterListener(MessageQueueId_t listener) override; ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event); ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener, object_id_t object); ReturnValue_t subscribeToEventRange(MessageQueueId_t listener, EventId_t idFrom = 0, diff --git a/src/fsfw/events/EventManagerIF.h b/src/fsfw/events/EventManagerIF.h index adb61f2b..12014090 100644 --- a/src/fsfw/events/EventManagerIF.h +++ b/src/fsfw/events/EventManagerIF.h @@ -18,6 +18,7 @@ class EventManagerIF { virtual ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false) = 0; + virtual ReturnValue_t unregisterListener(MessageQueueId_t listener) = 0; virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event) = 0; virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener, object_id_t object) = 0; virtual ReturnValue_t unsubscribeFromAllEvents(MessageQueueId_t listener, object_id_t object) = 0; diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index 28df16d8..0d3b0214 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -23,7 +23,7 @@ FailureIsolationBase::~FailureIsolationBase() { #endif return; } - manager->unsubscribeFromAllEvents(eventQueue->getId(), ownerId); + manager->unregisterListener(eventQueue->getId()); QueueFactory::instance()->deleteMessageQueue(eventQueue); } diff --git a/src/fsfw/globalfunctions/matching/MatchTree.h b/src/fsfw/globalfunctions/matching/MatchTree.h index 0c31cf2a..69f660d3 100644 --- a/src/fsfw/globalfunctions/matching/MatchTree.h +++ b/src/fsfw/globalfunctions/matching/MatchTree.h @@ -24,7 +24,7 @@ class MatchTree : public SerializeableMatcherIF, public BinaryTree>(root.element), maxDepth(maxDepth) {} MatchTree() : BinaryTree>(), maxDepth(-1) {} - virtual ~MatchTree() {} + virtual ~MatchTree() { clear(); } virtual bool match(T number) override { return matchesTree(number); } bool matchesTree(T number) { iterator iter = this->begin(); @@ -176,6 +176,45 @@ class MatchTree : public SerializeableMatcherIF, public BinaryTree>::rootNode; + + if (localRoot == nullptr) { + return; + } + + Node* node = localRoot->left; + + while (true) { + if (node->left != nullptr) { + node = node->left; + continue; + } + if (node->right != nullptr) { + node = node->right; + continue; + } + if (node->parent == nullptr) { + // this is the root node with no children + if (node->value != nullptr) { + cleanUpElement(iterator(node)); + } + return; + } + // leaf + { + Node* parent = node->parent; + if (parent->left == node) { + parent->left = nullptr; + } else { + parent->right = nullptr; + } + cleanUpElement(iterator(node)); + node = parent; + } + } + } + virtual ReturnValue_t cleanUpElement(iterator position) { return returnvalue::OK; } bool matchSubtree(iterator iter, T number) { diff --git a/src/fsfw/health/HealthTable.cpp b/src/fsfw/health/HealthTable.cpp index 5fb45fb9..3fcf7f77 100644 --- a/src/fsfw/health/HealthTable.cpp +++ b/src/fsfw/health/HealthTable.cpp @@ -6,8 +6,6 @@ HealthTable::HealthTable(object_id_t objectid) : SystemObject(objectid) { mutex = MutexFactory::instance()->createMutex(); - ; - mapIterator = healthMap.begin(); } diff --git a/src/fsfw/internalerror/InternalErrorReporter.cpp b/src/fsfw/internalerror/InternalErrorReporter.cpp index b3b77366..fb2dc8a6 100644 --- a/src/fsfw/internalerror/InternalErrorReporter.cpp +++ b/src/fsfw/internalerror/InternalErrorReporter.cpp @@ -7,14 +7,17 @@ InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId, uint32_t messageQueueDepth) : SystemObject(setObjectId), - commandQueue(QueueFactory::instance()->createMessageQueue(messageQueueDepth)), poolManager(this, commandQueue), internalErrorSid(setObjectId, InternalErrorDataset::ERROR_SET_ID), internalErrorDataset(this) { + commandQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); mutex = MutexFactory::instance()->createMutex(); } -InternalErrorReporter::~InternalErrorReporter() { MutexFactory::instance()->deleteMutex(mutex); } +InternalErrorReporter::~InternalErrorReporter() { + MutexFactory::instance()->deleteMutex(mutex); + QueueFactory::instance()->deleteMessageQueue(commandQueue); +} void InternalErrorReporter::setDiagnosticPrintout(bool enable) { this->diagnosticPrintout = enable; diff --git a/src/fsfw/objectmanager/ObjectManager.cpp b/src/fsfw/objectmanager/ObjectManager.cpp index ddf5ab80..29c1b2fc 100644 --- a/src/fsfw/objectmanager/ObjectManager.cpp +++ b/src/fsfw/objectmanager/ObjectManager.cpp @@ -23,9 +23,17 @@ void ObjectManager::setObjectFactoryFunction(produce_function_t objFactoryFunc, ObjectManager::ObjectManager() = default; +void ObjectManager::clear() { + if (objManagerInstance != nullptr) { + delete objManagerInstance; + objManagerInstance = nullptr; + } +} + ObjectManager::~ObjectManager() { - for (auto const& iter : objectList) { - delete iter.second; + teardown = true; + for (auto iter = objectList.begin(); iter != objectList.end(); iter = objectList.erase(iter)) { + delete iter->second; } } @@ -53,6 +61,12 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) { } ReturnValue_t ObjectManager::remove(object_id_t id) { + // this function is called during destruction of System Objects + // disabeld for teardown to avoid iterator invalidation and + // double free + if (teardown) { + return returnvalue::OK; + } if (this->getSystemObject(id) != nullptr) { this->objectList.erase(id); #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/src/fsfw/objectmanager/ObjectManager.h b/src/fsfw/objectmanager/ObjectManager.h index e0e74792..355f5d0a 100644 --- a/src/fsfw/objectmanager/ObjectManager.h +++ b/src/fsfw/objectmanager/ObjectManager.h @@ -24,12 +24,17 @@ class ObjectManager : public ObjectManagerIF { using produce_function_t = void (*)(void* args); /** - * Returns the single instance of TaskFactory. + * Returns the single instance of ObjectManager. * The implementation of #instance is found in its subclasses. * Thus, we choose link-time variability of the instance. */ static ObjectManager* instance(); + /** + * Deletes the single instance of ObjectManager + */ + static void clear(); + void setObjectFactoryFunction(produce_function_t prodFunc, void* args); template @@ -66,6 +71,9 @@ class ObjectManager : public ObjectManagerIF { */ std::map objectList; static ObjectManager* objManagerInstance; + // used when the OM itself is deleted to modify behaviour of remove() + // to avoid iterator invalidation and double free + bool teardown = false; }; // Documentation can be found in the class method declaration above diff --git a/src/fsfw/osal/CMakeLists.txt b/src/fsfw/osal/CMakeLists.txt index 50fd6102..a4097649 100644 --- a/src/fsfw/osal/CMakeLists.txt +++ b/src/fsfw/osal/CMakeLists.txt @@ -1,10 +1,13 @@ # Check the OS_FSFW variable if(FSFW_OSAL MATCHES "freertos") add_subdirectory(freertos) + set(FSFW_OSAL_FREERTOS 1) elseif(FSFW_OSAL MATCHES "rtems") add_subdirectory(rtems) + set(FSFW_OSAL_RTEMS 1) elseif(FSFW_OSAL MATCHES "linux") add_subdirectory(linux) + set(FSFW_OSAL_LINUX 1) elseif(FSFW_OSAL MATCHES "host") add_subdirectory(host) if(WIN32) @@ -13,16 +16,17 @@ elseif(FSFW_OSAL MATCHES "host") # We still need to pull in some Linux specific sources target_sources(${LIB_FSFW_NAME} PUBLIC linux/tcpipHelpers.cpp) endif() - + set(FSFW_OSAL_HOST 1) else() - message(WARNING "The OS_FSFW variable was not set. Assuming host OS..") # Not set. Assumuing this is a host build, try to determine host OS if(WIN32) add_subdirectory(host) add_subdirectory(windows) + set(FSFW_OSAL_HOST 1) elseif(UNIX) add_subdirectory(linux) + set(FSFW_OSAL_LINUX 1) else() # MacOS or other OSes have not been tested yet / are not supported. message(FATAL_ERROR "The host OS could not be determined! Aborting.") @@ -31,3 +35,5 @@ else() endif() add_subdirectory(common) + +configure_file(osal.h.in ${CMAKE_BINARY_DIR}/fsfw/osal/osal.h) diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index b2cca3f1..c08e3775 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -21,7 +21,7 @@ MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize, MqArgs* attributes.mq_msgsize = maxMessageSize; attributes.mq_flags = 0; // Flags are ignored on Linux during mq_open // Set the name of the queue. The slash is mandatory! - sprintf(name, "/FSFW_MQ%u\n", queueCounter++); + sprintf(name, "/FSFW_MQ%u", queueCounter++); // Create a nonblocking queue if the name is available (the queue is read // and writable for the owner as well as the group) diff --git a/src/fsfw/osal/osal.h.in b/src/fsfw/osal/osal.h.in new file mode 100644 index 00000000..8e48c31a --- /dev/null +++ b/src/fsfw/osal/osal.h.in @@ -0,0 +1,36 @@ +#pragma once + +namespace osal { + enum osalTarget{ + HOST, + LINUX, + WINDOWS, + FREERTOS, + RTEMS, + }; + +#cmakedefine FSFW_OSAL_HOST +#cmakedefine FSFW_OSAL_LINUX +#cmakedefine FSFW_OSAL_WINDOWS +#cmakedefine FSFW_OSAL_FREERTOS +#cmakedefine FSFW_OSAL_RTEMS + + + constexpr osalTarget getTarget() { +#ifdef FSFW_OSAL_HOST + return HOST; +#endif +#ifdef FSFW_OSAL_LINUX + return LINUX; +#endif +#ifdef FSFW_OSAL_WINDOWS + return WINDOWS; +#endif +#ifdef FSFW_OSAL_FREERTOS + return FREERTOS; +#endif +#ifdef FSFW_OSAL_RTEMS + return RTEMS; +#endif + } +}; \ No newline at end of file diff --git a/unittests/CatchSetup.cpp b/unittests/CatchSetup.cpp index 4f2a4a54..fc5bb3f5 100644 --- a/unittests/CatchSetup.cpp +++ b/unittests/CatchSetup.cpp @@ -31,4 +31,7 @@ int customSetup() { return 0; } -int customTeardown() { return 0; } +int customTeardown() { + ObjectManager::clear(); + return 0; +} diff --git a/unittests/devicehandler/DeviceHandlerCommander.cpp b/unittests/devicehandler/DeviceHandlerCommander.cpp index 03ff992c..835faf2b 100644 --- a/unittests/devicehandler/DeviceHandlerCommander.cpp +++ b/unittests/devicehandler/DeviceHandlerCommander.cpp @@ -9,7 +9,9 @@ DeviceHandlerCommander::DeviceHandlerCommander(object_id_t objectId) QUEUE_SIZE, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } -DeviceHandlerCommander::~DeviceHandlerCommander() {} +DeviceHandlerCommander::~DeviceHandlerCommander() { + QueueFactory::instance()->deleteMessageQueue(commandQueue); +} ReturnValue_t DeviceHandlerCommander::performOperation(uint8_t operationCode) { readCommandQueue(); diff --git a/unittests/osal/TestSemaphore.cpp b/unittests/osal/TestSemaphore.cpp index 376b08db..1d8758b1 100644 --- a/unittests/osal/TestSemaphore.cpp +++ b/unittests/osal/TestSemaphore.cpp @@ -1,46 +1,38 @@ - -#ifdef LINUX - -/* +#include #include #include -#include "catch.hpp" -#include "core/CatchDefinitions.h" +#include -TEST_CASE("Binary Semaphore Test" , "[BinSemaphore]") { - //perform set-up here - SemaphoreIF* binSemaph = SemaphoreFactory::instance()-> - createBinarySemaphore(); - REQUIRE(binSemaph != nullptr); - SECTION("Simple Test") { - // set-up is run for each section - REQUIRE(binSemaph->getSemaphoreCounter() == 1); - REQUIRE(binSemaph->release() == - static_cast(SemaphoreIF::SEMAPHORE_NOT_OWNED)); - REQUIRE(binSemaph->acquire(SemaphoreIF::POLLING) == - result::OK); - { - // not precise enough on linux.. should use clock instead.. - //Stopwatch stopwatch(false); - //REQUIRE(binSemaph->acquire(SemaphoreIF::TimeoutType::WAITING, 5) == - // SemaphoreIF::SEMAPHORE_TIMEOUT); - //dur_millis_t time = stopwatch.stop(); - //CHECK(time == 5); - } - REQUIRE(binSemaph->getSemaphoreCounter() == 0); - REQUIRE(binSemaph->release() == result::OK); - } - SemaphoreFactory::instance()->deleteSemaphore(binSemaph); - // perform tear-down here +// binary semaphores currently only supported on linux +#ifdef FSFW_OSAL_LINUX + +TEST_CASE("Binary Semaphore Test", "[BinSemaphore]") { + // perform set-up here + SemaphoreIF* binSemaph = SemaphoreFactory::instance()->createBinarySemaphore(); + REQUIRE(binSemaph != nullptr); + SECTION("Simple Test") { + // set-up is run for each section + REQUIRE(binSemaph->getSemaphoreCounter() == 1); + REQUIRE(binSemaph->release() == static_cast(SemaphoreIF::SEMAPHORE_NOT_OWNED)); + REQUIRE(binSemaph->acquire(SemaphoreIF::POLLING) == returnvalue::OK); + { + // not precise enough on linux.. should use clock instead.. + // Stopwatch stopwatch(false); + // REQUIRE(binSemaph->acquire(SemaphoreIF::TimeoutType::WAITING, 5) == + // SemaphoreIF::SEMAPHORE_TIMEOUT); + // dur_millis_t time = stopwatch.stop(); + // CHECK(time == 5); + } + REQUIRE(binSemaph->getSemaphoreCounter() == 0); + REQUIRE(binSemaph->release() == returnvalue::OK); + } + SemaphoreFactory::instance()->deleteSemaphore(binSemaph); + // perform tear-down here } - -TEST_CASE("Counting Semaphore Test" , "[CountingSemaph]") { - SECTION("Simple Test") { - - } +TEST_CASE("Counting Semaphore Test", "[CountingSemaph]") { + SECTION("Simple Test") {} } -*/ -#endif +#endif \ No newline at end of file From bf12f284faa2938254794f00d18883be38d3645b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 10:53:04 +0100 Subject: [PATCH 470/532] add size and crc check for contained TC --- src/fsfw/pus/Service11TelecommandScheduling.h | 2 ++ src/fsfw/pus/Service11TelecommandScheduling.tpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.h b/src/fsfw/pus/Service11TelecommandScheduling.h index aa958193..83b2b4c0 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.h +++ b/src/fsfw/pus/Service11TelecommandScheduling.h @@ -41,6 +41,8 @@ class Service11TelecommandScheduling final : public PusServiceBase { static constexpr ReturnValue_t INVALID_TIME_WINDOW = returnvalue::makeCode(CLASS_ID, 2); static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = returnvalue::makeCode(CLASS_ID, 3); static constexpr ReturnValue_t INVALID_RELATIVE_TIME = returnvalue::makeCode(CLASS_ID, 4); + static constexpr ReturnValue_t CONTAINED_TC_TOO_SMALL = returnvalue::makeCode(CLASS_ID, 5); + static constexpr ReturnValue_t CONTAINED_TC_CRC_MISSMATCH = returnvalue::makeCode(CLASS_ID, 6); static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_11; diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 9016af80..8bf92460 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -6,6 +6,8 @@ #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" +#include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" +#include "fsfw/globalfunctions/CRC.h": static constexpr auto DEF_END = SerializeIF::Endianness::BIG; @@ -171,6 +173,14 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi return returnvalue::FAILED; } + if (size < PusTcIF::MIN_SIZE) { + return CONTAINED_TC_TOO_SMALL; + } + + if (CRC::crc16ccitt(data, size) != 0) { + return CONTAINED_TC_CRC_MISSMATCH; + } + // store currentPacket and receive the store address store_address_t addr{}; if (tcStore->addData(&addr, data, size) != returnvalue::OK || From 97c629ad8446ff9525dd29f3211e0041cb469532 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 10:53:36 +0100 Subject: [PATCH 471/532] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80338446..f738032f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- TC Scheduler Service 11: Add size and CRC check for contained TC. - 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 From a4531e4ced145832e271f846da533d75fc4ae5c2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 10:59:39 +0100 Subject: [PATCH 472/532] typo --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 8bf92460..cbfa3103 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -7,7 +7,7 @@ #include "fsfw/serviceinterface.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" -#include "fsfw/globalfunctions/CRC.h": +#include "fsfw/globalfunctions/CRC.h" static constexpr auto DEF_END = SerializeIF::Endianness::BIG; From d16c5024dc7ece711afe88b156fe16aae6f4bd80 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 11:15:36 +0100 Subject: [PATCH 473/532] small include improvement --- src/fsfw/pus/Service11TelecommandScheduling.tpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index cbfa3103..540f6c68 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -6,7 +6,7 @@ #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" -#include "fsfw/tmtcpacket/pus/tc/PusTcReader.h" +#include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" #include "fsfw/globalfunctions/CRC.h" static constexpr auto DEF_END = SerializeIF::Endianness::BIG; From 99d8c845f2690a55a6436e31fb0f50a21a285ff0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 30 Jan 2023 14:05:39 +0100 Subject: [PATCH 474/532] allow using SO_REUSEADDR and SO_REUSEPORT on TCP server --- src/fsfw/osal/common/TcpTmTcServer.cpp | 15 ++++++++++++--- src/fsfw/osal/common/TcpTmTcServer.h | 26 ++++++++++++++++++++------ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/fsfw/osal/common/TcpTmTcServer.cpp b/src/fsfw/osal/common/TcpTmTcServer.cpp index dff959ba..903d8752 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.cpp +++ b/src/fsfw/osal/common/TcpTmTcServer.cpp @@ -26,12 +26,12 @@ const std::string TcpTmTcServer::DEFAULT_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT; TcpTmTcServer::TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge, - size_t receptionBufferSize, size_t ringBufferSize, - std::string customTcpServerPort, ReceptionModes receptionMode) + TcpTmTcServer::TcpConfig cfg, size_t receptionBufferSize, + size_t ringBufferSize, ReceptionModes receptionMode) : SystemObject(objectId), tmtcBridgeId(tmtcTcpBridge), receptionMode(receptionMode), - tcpConfig(std::move(customTcpServerPort)), + tcpConfig(cfg), receptionBuffer(receptionBufferSize), ringBuffer(ringBufferSize, true) {} @@ -91,6 +91,15 @@ ReturnValue_t TcpTmTcServer::initialize() { return returnvalue::FAILED; } + if (tcpConfig.reuseAddr) { + unsigned int enable = 1; + setsockopt(listenerTcpSocket, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)); + } + if (tcpConfig.reusePort) { + unsigned int enable = 1; + setsockopt(listenerTcpSocket, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(enable)); + } + // Bind to the address found by getaddrinfo retval = bind(listenerTcpSocket, addrResult->ai_addr, static_cast(addrResult->ai_addrlen)); if (retval == SOCKET_ERROR) { diff --git a/src/fsfw/osal/common/TcpTmTcServer.h b/src/fsfw/osal/common/TcpTmTcServer.h index 0e2182a5..8668d845 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.h +++ b/src/fsfw/osal/common/TcpTmTcServer.h @@ -41,11 +41,11 @@ class SpacePacketParser; */ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableObjectIF { public: - enum class ReceptionModes { SPACE_PACKETS }; - struct TcpConfig { public: - explicit TcpConfig(std::string tcpPort) : tcpPort(std::move(tcpPort)) {} + TcpConfig(bool reuseAddr, bool reusePort) : reuseAddr(reuseAddr), reusePort(reusePort) {} + TcpConfig(std::string tcpPort, bool reuseAddr, bool reusePort) + : tcpPort(std::move(tcpPort)), reuseAddr(reuseAddr), reusePort(reusePort) {} /** * Passed to the recv call @@ -63,8 +63,23 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb */ int tcpTmFlags = 0; - const std::string tcpPort; + /** + * Sets the SO_REUSEADDR option on the socket. See + * https://man7.org/linux/man-pages/man7/socket.7.html for more details. This option is + * especially useful in a debugging and development environment where an OBSW image might be + * re-flashed oftentimes and where all incoming telecommands are received on a dedicated TCP + * port. + */ + bool reuseAddr = false; + /** + * Sets the SO_REUSEPORT option on the socket. See + * https://man7.org/linux/man-pages/man7/socket.7.html for more details. + */ + bool reusePort = false; + + std::string tcpPort = DEFAULT_SERVER_PORT; }; + enum class ReceptionModes { SPACE_PACKETS }; static const std::string DEFAULT_SERVER_PORT; @@ -80,10 +95,9 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb * size will be the Ethernet MTU size * @param customTcpServerPort The user can specify another port than the default (7301) here. */ - TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge, + TcpTmTcServer(object_id_t objectId, object_id_t tmtcTcpBridge, TcpTmTcServer::TcpConfig cfg, size_t receptionBufferSize = RING_BUFFER_SIZE, size_t ringBufferSize = RING_BUFFER_SIZE, - std::string customTcpServerPort = DEFAULT_SERVER_PORT, ReceptionModes receptionMode = ReceptionModes::SPACE_PACKETS); ~TcpTmTcServer() override; From b646717a7610d430f999e4582a439a17eafaadc9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 30 Jan 2023 14:11:00 +0100 Subject: [PATCH 475/532] bump changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f738032f..bc0fa937 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Added +- `TcpTmTcServer`: Allow setting the `SO_REUSEADDR` and `SO_REUSEPORT` + option on the TCP server. CTOR prototype has changed and expects an explicit + TCP configuration struct to be passed. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/722 - `DleParser` helper class to parse DLE encoded packets from a byte stream. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/711 - `UioMapper` is able to resolve symlinks now. From fe7197846748040bbe4ab4c3cdd15d6cbf58cc43 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 28 Jan 2023 14:31:32 +0100 Subject: [PATCH 476/532] improve srv20 error messages --- src/fsfw/pus/Service20ParameterManagement.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index e12d47bc..87bd5a13 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -69,14 +69,14 @@ ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service20ParameterManagement::checkInterfaceAndAcquire" << "MessageQueue: Can't access object" << std::endl; - sif::error << "Object ID: " << std::hex << objectId << std::dec << std::endl; - sif::error << "Make sure it implements ReceivesParameterMessagesIF!" << std::endl; + sif::error << "Object ID: 0x" << std::hex << *objectId << std::dec << std::endl; + sif::error << "Make sure it implements ReceivesParameterMessagesIF" << std::endl; #else sif::printError( "Service20ParameterManagement::checkInterfaceAndAcquire" "MessageQueue: Can't access object\n"); sif::printError("Object ID: 0x%08x\n", *objectId); - sif::printError("Make sure it implements ReceivesParameterMessagesIF!\n"); + sif::printError("Make sure it implements ReceivesParameterMessagesIF\n"); #endif return CommandingServiceBase::INVALID_OBJECT; From 3656662d8881bb8b8e200a412dad4a1867ce759c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 20 Jan 2023 11:10:05 +0100 Subject: [PATCH 477/532] small tweak, gain factory was always them same --- src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index a32153eb..ce215a64 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -329,8 +329,8 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) { // Now scale to physical value in microtesla float fieldStrengthX = fieldStrengthRawX * scaleFactorX; - float fieldStrengthY = fieldStrengthRawY * scaleFactorX; - float fieldStrengthZ = fieldStrengthRawZ * scaleFactorX; + float fieldStrengthY = fieldStrengthRawY * scaleFactorY; + float fieldStrengthZ = fieldStrengthRawZ * scaleFactorZ; if (periodicPrintout) { if (debugDivider.checkAndIncrement()) { From eb223dae880266fdbff7f26e700e14c819ad8f8b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 30 Jan 2023 14:20:28 +0100 Subject: [PATCH 478/532] bump changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f738032f..e379a6f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- HAL MGM3100 Handler: Use axis specific gain/scaling factors. Previously, + only the X scaling factor was used. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/724 - TC Scheduler Service 11: Add size and CRC check for contained TC. - Only delete health table entry in `HealthHelper` destructor if health table was set. From 9b05e8f27406e0bc1df4db6dde6ff85fbc9ea8e8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 30 Jan 2023 14:24:28 +0100 Subject: [PATCH 479/532] re-order fields in TcpConfig --- src/fsfw/osal/common/TcpTmTcServer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fsfw/osal/common/TcpTmTcServer.h b/src/fsfw/osal/common/TcpTmTcServer.h index 8668d845..3d182827 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.h +++ b/src/fsfw/osal/common/TcpTmTcServer.h @@ -63,6 +63,8 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb */ int tcpTmFlags = 0; + std::string tcpPort = DEFAULT_SERVER_PORT; + /** * Sets the SO_REUSEADDR option on the socket. See * https://man7.org/linux/man-pages/man7/socket.7.html for more details. This option is @@ -77,7 +79,6 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb */ bool reusePort = false; - std::string tcpPort = DEFAULT_SERVER_PORT; }; enum class ReceptionModes { SPACE_PACKETS }; From e487f5be871bcdadda49d2536944d6b2a3bb12eb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Feb 2023 17:07:38 +0100 Subject: [PATCH 480/532] proper announce all impl --- src/fsfw/health/HealthTable.h | 2 + src/fsfw/pus/CService201HealthCommanding.cpp | 44 ++++++++++++++++---- src/fsfw/pus/CService201HealthCommanding.h | 7 +++- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/fsfw/health/HealthTable.h b/src/fsfw/health/HealthTable.h index 076228c1..9b0722df 100644 --- a/src/fsfw/health/HealthTable.h +++ b/src/fsfw/health/HealthTable.h @@ -8,6 +8,8 @@ #include "HealthTableIF.h" class HealthTable : public HealthTableIF, public SystemObject { + friend class CService201HealthCommanding; + public: explicit HealthTable(object_id_t objectid); ~HealthTable() override; diff --git a/src/fsfw/pus/CService201HealthCommanding.cpp b/src/fsfw/pus/CService201HealthCommanding.cpp index bf21c5bd..af261caf 100644 --- a/src/fsfw/pus/CService201HealthCommanding.cpp +++ b/src/fsfw/pus/CService201HealthCommanding.cpp @@ -1,5 +1,7 @@ #include "fsfw/pus/CService201HealthCommanding.h" +#include + #include "fsfw/health/HasHealthIF.h" #include "fsfw/health/HealthMessage.h" #include "fsfw/objectmanager/ObjectManager.h" @@ -7,11 +9,12 @@ #include "fsfw/serviceinterface/ServiceInterface.h" CService201HealthCommanding::CService201HealthCommanding(object_id_t objectId, uint16_t apid, - uint8_t serviceId, + uint8_t serviceId, HealthTable &table, uint8_t numParallelCommands, uint16_t commandTimeoutSeconds) : CommandingServiceBase(objectId, apid, "PUS 201 Health MGMT", serviceId, numParallelCommands, - commandTimeoutSeconds) {} + commandTimeoutSeconds), + healthTable(table) {} ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) { switch (subservice) { @@ -32,12 +35,16 @@ ReturnValue_t CService201HealthCommanding::getMessageQueueAndObject(uint8_t subs size_t tcDataLen, MessageQueueId_t *id, object_id_t *objectId) { - if (tcDataLen < sizeof(object_id_t)) { - return CommandingServiceBase::INVALID_TC; - } - SerializeAdapter::deSerialize(objectId, &tcData, &tcDataLen, SerializeIF::Endianness::BIG); + if (subservice == Subservice::COMMAND_SET_HEALTH and + subservice == Subservice::COMMAND_ANNOUNCE_HEALTH) { + if (tcDataLen < sizeof(object_id_t)) { + return CommandingServiceBase::INVALID_TC; + } + SerializeAdapter::deSerialize(objectId, &tcData, &tcDataLen, SerializeIF::Endianness::BIG); - return checkInterfaceAndAcquireMessageQueue(id, objectId); + return checkInterfaceAndAcquireMessageQueue(id, objectId); + } + return returnvalue::OK; } ReturnValue_t CService201HealthCommanding::checkInterfaceAndAcquireMessageQueue( @@ -72,8 +79,15 @@ ReturnValue_t CService201HealthCommanding::prepareCommand(CommandMessage *messag break; } case (Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): { - HealthMessage::setHealthMessage(message, HealthMessage::HEALTH_ANNOUNCE_ALL); - break; + ReturnValue_t result = iterateHealthTable(true); + while (true) { + ReturnValue_t result = iterateHealthTable(false); + if (result != returnvalue::OK) { + break; + } + } + + return returnvalue::OK; } default: { // Should never happen, subservice was already checked @@ -104,3 +118,15 @@ ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *rep HealthSetReply healthSetReply(health, oldHealth); return sendTmPacket(Subservice::REPLY_HEALTH_SET, healthSetReply); } + +ReturnValue_t CService201HealthCommanding::iterateHealthTable(bool reset) { + std::pair pair; + + ReturnValue_t result = healthTable.iterate(&pair, reset); + if (result != returnvalue::OK) { + return result; + } else { + EventManagerIF::triggerEvent(pair.first, HasHealthIF::HEALTH_INFO, pair.second, pair.second); + return returnvalue::OK; + } +} diff --git a/src/fsfw/pus/CService201HealthCommanding.h b/src/fsfw/pus/CService201HealthCommanding.h index 71b7caa0..8cef5599 100644 --- a/src/fsfw/pus/CService201HealthCommanding.h +++ b/src/fsfw/pus/CService201HealthCommanding.h @@ -1,6 +1,8 @@ #ifndef FSFW_PUS_CSERVICE201HEALTHCOMMANDING_H_ #define FSFW_PUS_CSERVICE201HEALTHCOMMANDING_H_ +#include + #include "fsfw/tmtcservices/CommandingServiceBase.h" /** @@ -20,7 +22,8 @@ class CService201HealthCommanding : public CommandingServiceBase { public: CService201HealthCommanding(object_id_t objectId, uint16_t apid, uint8_t serviceId, - uint8_t numParallelCommands = 4, uint16_t commandTimeoutSeconds = 60); + HealthTable &table, uint8_t numParallelCommands = 4, + uint16_t commandTimeoutSeconds = 60); ~CService201HealthCommanding() override = default; protected: @@ -38,6 +41,8 @@ class CService201HealthCommanding : public CommandingServiceBase { bool *isStep) override; private: + HealthTable &healthTable; + ReturnValue_t iterateHealthTable(bool reset); static ReturnValue_t checkInterfaceAndAcquireMessageQueue(MessageQueueId_t *MessageQueueToSet, const object_id_t *objectId); From 29ea89044e4a45ff207cb58175b3d1941740bfa3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Feb 2023 17:33:24 +0100 Subject: [PATCH 481/532] beatufil --- src/fsfw/health/HealthTable.h | 2 +- src/fsfw/pus/CMakeLists.txt | 2 +- ...nding.cpp => CServiceHealthCommanding.cpp} | 88 ++++++++++++------- ...ommanding.h => CServiceHealthCommanding.h} | 28 ++++-- 4 files changed, 79 insertions(+), 41 deletions(-) rename src/fsfw/pus/{CService201HealthCommanding.cpp => CServiceHealthCommanding.cpp} (56%) rename src/fsfw/pus/{CService201HealthCommanding.h => CServiceHealthCommanding.h} (75%) diff --git a/src/fsfw/health/HealthTable.h b/src/fsfw/health/HealthTable.h index 9b0722df..7b42dfba 100644 --- a/src/fsfw/health/HealthTable.h +++ b/src/fsfw/health/HealthTable.h @@ -8,7 +8,7 @@ #include "HealthTableIF.h" class HealthTable : public HealthTableIF, public SystemObject { - friend class CService201HealthCommanding; + friend class CServiceHealthCommanding; public: explicit HealthTable(object_id_t objectid); diff --git a/src/fsfw/pus/CMakeLists.txt b/src/fsfw/pus/CMakeLists.txt index 35b35bea..7c5b340c 100644 --- a/src/fsfw/pus/CMakeLists.txt +++ b/src/fsfw/pus/CMakeLists.txt @@ -9,4 +9,4 @@ target_sources( Service17Test.cpp Service20ParameterManagement.cpp CService200ModeCommanding.cpp - CService201HealthCommanding.cpp) + CServiceHealthCommanding.cpp) diff --git a/src/fsfw/pus/CService201HealthCommanding.cpp b/src/fsfw/pus/CServiceHealthCommanding.cpp similarity index 56% rename from src/fsfw/pus/CService201HealthCommanding.cpp rename to src/fsfw/pus/CServiceHealthCommanding.cpp index af261caf..9a2af7bc 100644 --- a/src/fsfw/pus/CService201HealthCommanding.cpp +++ b/src/fsfw/pus/CServiceHealthCommanding.cpp @@ -1,6 +1,5 @@ -#include "fsfw/pus/CService201HealthCommanding.h" - #include +#include #include "fsfw/health/HasHealthIF.h" #include "fsfw/health/HealthMessage.h" @@ -8,15 +7,13 @@ #include "fsfw/pus/servicepackets/Service201Packets.h" #include "fsfw/serviceinterface/ServiceInterface.h" -CService201HealthCommanding::CService201HealthCommanding(object_id_t objectId, uint16_t apid, - uint8_t serviceId, HealthTable &table, - uint8_t numParallelCommands, - uint16_t commandTimeoutSeconds) - : CommandingServiceBase(objectId, apid, "PUS 201 Health MGMT", serviceId, numParallelCommands, - commandTimeoutSeconds), - healthTable(table) {} +CServiceHealthCommanding::CServiceHealthCommanding(HealthServiceCfg args) + : CommandingServiceBase(args.objectId, args.apid, "PUS 201 Health MGMT", args.service, + args.numParallelCommands, args.commandTimeoutSeconds), + healthTable(args.table), + maxNumHealthInfoPerCycle(args.maxNumHealthInfoPerCycle) {} -ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) { +ReturnValue_t CServiceHealthCommanding::isValidSubservice(uint8_t subservice) { switch (subservice) { case (Subservice::COMMAND_SET_HEALTH): case (Subservice::COMMAND_ANNOUNCE_HEALTH): @@ -30,24 +27,31 @@ ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) } } -ReturnValue_t CService201HealthCommanding::getMessageQueueAndObject(uint8_t subservice, - const uint8_t *tcData, - size_t tcDataLen, - MessageQueueId_t *id, - object_id_t *objectId) { - if (subservice == Subservice::COMMAND_SET_HEALTH and - subservice == Subservice::COMMAND_ANNOUNCE_HEALTH) { - if (tcDataLen < sizeof(object_id_t)) { - return CommandingServiceBase::INVALID_TC; - } - SerializeAdapter::deSerialize(objectId, &tcData, &tcDataLen, SerializeIF::Endianness::BIG); +ReturnValue_t CServiceHealthCommanding::getMessageQueueAndObject(uint8_t subservice, + const uint8_t *tcData, + size_t tcDataLen, + MessageQueueId_t *id, + object_id_t *objectId) { + switch (subservice) { + case (Subservice::COMMAND_SET_HEALTH): + case (Subservice::COMMAND_ANNOUNCE_HEALTH): { + if (tcDataLen < sizeof(object_id_t)) { + return CommandingServiceBase::INVALID_TC; + } + SerializeAdapter::deSerialize(objectId, &tcData, &tcDataLen, SerializeIF::Endianness::BIG); - return checkInterfaceAndAcquireMessageQueue(id, objectId); + return checkInterfaceAndAcquireMessageQueue(id, objectId); + } + case (Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): { + return returnvalue::OK; + } + default: { + return returnvalue::FAILED; + } } - return returnvalue::OK; } -ReturnValue_t CService201HealthCommanding::checkInterfaceAndAcquireMessageQueue( +ReturnValue_t CServiceHealthCommanding::checkInterfaceAndAcquireMessageQueue( MessageQueueId_t *messageQueueToSet, const object_id_t *objectId) { auto *destination = ObjectManager::instance()->get(*objectId); if (destination == nullptr) { @@ -58,10 +62,9 @@ ReturnValue_t CService201HealthCommanding::checkInterfaceAndAcquireMessageQueue( return returnvalue::OK; } -ReturnValue_t CService201HealthCommanding::prepareCommand(CommandMessage *message, - uint8_t subservice, const uint8_t *tcData, - size_t tcDataLen, uint32_t *state, - object_id_t objectId) { +ReturnValue_t CServiceHealthCommanding::prepareCommand(CommandMessage *message, uint8_t subservice, + const uint8_t *tcData, size_t tcDataLen, + uint32_t *state, object_id_t objectId) { ReturnValue_t result = returnvalue::OK; switch (subservice) { case (Subservice::COMMAND_SET_HEALTH): { @@ -80,6 +83,11 @@ ReturnValue_t CService201HealthCommanding::prepareCommand(CommandMessage *messag } case (Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): { ReturnValue_t result = iterateHealthTable(true); + if (result == returnvalue::OK) { + reportAllHealth = true; + return EXECUTION_COMPLETE; + } + return result; while (true) { ReturnValue_t result = iterateHealthTable(false); if (result != returnvalue::OK) { @@ -97,10 +105,10 @@ ReturnValue_t CService201HealthCommanding::prepareCommand(CommandMessage *messag return result; } -ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *reply, - Command_t previousCommand, uint32_t *state, - CommandMessage *optionalNextCommand, - object_id_t objectId, bool *isStep) { +ReturnValue_t CServiceHealthCommanding::handleReply(const CommandMessage *reply, + Command_t previousCommand, uint32_t *state, + CommandMessage *optionalNextCommand, + object_id_t objectId, bool *isStep) { Command_t replyId = reply->getCommand(); if (replyId == HealthMessage::REPLY_HEALTH_SET) { return EXECUTION_COMPLETE; @@ -110,8 +118,20 @@ ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *rep return CommandingServiceBase::INVALID_REPLY; } +void CServiceHealthCommanding::doPeriodicOperation() { + if (reportAllHealth) { + for (uint8_t i = 0; i < maxNumHealthInfoPerCycle; i++) { + ReturnValue_t result = iterateHealthTable(true); + if (result != returnvalue::OK) { + reportAllHealth = false; + break; + } + } + } +} + // Not used for now, health state already reported by event -[[maybe_unused]] ReturnValue_t CService201HealthCommanding::prepareHealthSetReply( +[[maybe_unused]] ReturnValue_t CServiceHealthCommanding::prepareHealthSetReply( const CommandMessage *reply) { auto health = static_cast(HealthMessage::getHealth(reply)); auto oldHealth = static_cast(HealthMessage::getOldHealth(reply)); @@ -119,7 +139,7 @@ ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *rep return sendTmPacket(Subservice::REPLY_HEALTH_SET, healthSetReply); } -ReturnValue_t CService201HealthCommanding::iterateHealthTable(bool reset) { +ReturnValue_t CServiceHealthCommanding::iterateHealthTable(bool reset) { std::pair pair; ReturnValue_t result = healthTable.iterate(&pair, reset); diff --git a/src/fsfw/pus/CService201HealthCommanding.h b/src/fsfw/pus/CServiceHealthCommanding.h similarity index 75% rename from src/fsfw/pus/CService201HealthCommanding.h rename to src/fsfw/pus/CServiceHealthCommanding.h index 8cef5599..18f6c140 100644 --- a/src/fsfw/pus/CService201HealthCommanding.h +++ b/src/fsfw/pus/CServiceHealthCommanding.h @@ -5,6 +5,22 @@ #include "fsfw/tmtcservices/CommandingServiceBase.h" +struct HealthServiceCfg { + HealthServiceCfg(object_id_t objectId, uint16_t apid, HealthTable &healthTable, + uint16_t maxNumHealthInfoPerCycle) + : objectId(objectId), + apid(apid), + table(healthTable), + maxNumHealthInfoPerCycle(maxNumHealthInfoPerCycle) {} + object_id_t objectId; + uint16_t apid; + HealthTable &table; + uint16_t maxNumHealthInfoPerCycle; + uint8_t service = 201; + uint8_t numParallelCommands = 4; + uint16_t commandTimeoutSeconds = 60; +}; + /** * @brief Custom PUS service to set health of all objects * implementing hasHealthIF. @@ -19,12 +35,10 @@ * child class like this service * */ -class CService201HealthCommanding : public CommandingServiceBase { +class CServiceHealthCommanding : public CommandingServiceBase { public: - CService201HealthCommanding(object_id_t objectId, uint16_t apid, uint8_t serviceId, - HealthTable &table, uint8_t numParallelCommands = 4, - uint16_t commandTimeoutSeconds = 60); - ~CService201HealthCommanding() override = default; + CServiceHealthCommanding(HealthServiceCfg args); + ~CServiceHealthCommanding() override = default; protected: /* CSB abstract function implementations */ @@ -40,8 +54,12 @@ class CService201HealthCommanding : public CommandingServiceBase { CommandMessage *optionalNextCommand, object_id_t objectId, bool *isStep) override; + void doPeriodicOperation() override; + private: HealthTable &healthTable; + uint16_t maxNumHealthInfoPerCycle = 0; + bool reportAllHealth = false; ReturnValue_t iterateHealthTable(bool reset); static ReturnValue_t checkInterfaceAndAcquireMessageQueue(MessageQueueId_t *MessageQueueToSet, const object_id_t *objectId); From 61df451dd8844bc1310595712fd492b0b017cddc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Feb 2023 17:41:47 +0100 Subject: [PATCH 482/532] update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f738032f..8c8260b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `TcpTmTcServer.cpp`: The server was actually not able to handle CCSDS packets which were clumped together. This has been fixed now. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/673 +- `CServiceHealthCommanding`: Add announce all health info implementation + PR: https://egit.irs.uni-stuttgart.de/eive/fsfw/pulls/122 ## Added @@ -37,6 +39,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changes +- `CService201HealthCommanding` renamed to `CServiceHealthCommanding`, + service ID customizable now. `CServiceHealthCommanding` expects configuration struct + `HealthServiceCfg` now + PR: https://egit.irs.uni-stuttgart.de/eive/fsfw/pulls/122 - `AcceptsTelemetryIF`: `getReportReceptionQueue` is const now PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/712 - Moved some container returnvalues to dedicated header and namespace From 7e94baceef7ae88e82fed6b1c6fb788672a77af3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Feb 2023 18:10:07 +0100 Subject: [PATCH 483/532] service 9 update - fix time info event - add time dump subservice --- CHANGELOG.md | 2 ++ src/fsfw/pus/Service9TimeManagement.cpp | 22 ++++++++++++++++------ src/fsfw/pus/Service9TimeManagement.h | 16 ++++++++++------ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f738032f..0646cf5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes + - TC Scheduler Service 11: Add size and CRC check for contained TC. - Only delete health table entry in `HealthHelper` destructor if health table was set. @@ -28,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Added +- `Service9TimeManagement`: Add `DUMP_TIME` (129) subservice. - `DleParser` helper class to parse DLE encoded packets from a byte stream. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/711 - `UioMapper` is able to resolve symlinks now. diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index d19cb518..fb32f60e 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -1,5 +1,7 @@ #include "fsfw/pus/Service9TimeManagement.h" +#include + #include "fsfw/events/EventManagerIF.h" #include "fsfw/pus/servicepackets/Service9Packets.h" #include "fsfw/serviceinterface/ServiceInterface.h" @@ -15,9 +17,17 @@ ReturnValue_t Service9TimeManagement::performService() { return returnvalue::OK; ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { switch (subservice) { - case SUBSERVICE::SET_TIME: { + case Subservice::SET_TIME: { return setTime(); } + case Subservice::DUMP_TIME: { + timeval newTime; + Clock::getClock_timeval(&newTime); + uint32_t subsecondMs = + static_cast(std::floor(static_cast(newTime.tv_usec) / 1000.0)); + triggerEvent(CLOCK_DUMP, newTime.tv_sec, subsecondMs); + return returnvalue::OK; + } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } @@ -33,14 +43,14 @@ ReturnValue_t Service9TimeManagement::setTime() { return result; } - uint32_t formerUptime; - Clock::getUptime(&formerUptime); + timeval time; + Clock::getClock_timeval(&time); result = Clock::setClock(&timeToSet); if (result == returnvalue::OK) { - uint32_t newUptime; - Clock::getUptime(&newUptime); - triggerEvent(CLOCK_SET, newUptime, formerUptime); + timeval newTime; + Clock::getClock_timeval(&newTime); + triggerEvent(CLOCK_SET, time.tv_sec, newTime.tv_sec); return returnvalue::OK; } else { triggerEvent(CLOCK_SET_FAILURE, result, 0); diff --git a/src/fsfw/pus/Service9TimeManagement.h b/src/fsfw/pus/Service9TimeManagement.h index b4886bb0..556f3df3 100644 --- a/src/fsfw/pus/Service9TimeManagement.h +++ b/src/fsfw/pus/Service9TimeManagement.h @@ -6,10 +6,13 @@ class Service9TimeManagement : public PusServiceBase { public: static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_9; - static constexpr Event CLOCK_SET = - MAKE_EVENT(0, severity::INFO); //!< Clock has been set. P1: New Uptime. P2: Old Uptime - static constexpr Event CLOCK_SET_FAILURE = - MAKE_EVENT(1, severity::LOW); //!< Clock could not be set. P1: Returncode. + + //!< Clock has been set. P1: old timeval seconds. P2: new timeval seconds. + static constexpr Event CLOCK_SET = MAKE_EVENT(0, severity::INFO); + //!< Clock dump event. P1: timeval seconds P2: timeval milliseconds. + static constexpr Event CLOCK_DUMP = MAKE_EVENT(1, severity::INFO); + //!< Clock could not be set. P1: Returncode. + static constexpr Event CLOCK_SET_FAILURE = MAKE_EVENT(2, severity::LOW); static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_9; @@ -30,8 +33,9 @@ class Service9TimeManagement : public PusServiceBase { virtual ReturnValue_t setTime(); private: - enum SUBSERVICE { - SET_TIME = 128 //!< [EXPORT] : [COMMAND] Time command in ASCII, CUC or CDS format + enum Subservice { + SET_TIME = 128, //!< [EXPORT] : [COMMAND] Time command in ASCII, CUC or CDS format + DUMP_TIME = 129, }; }; From 1f88c006d99738a5ab124e0db078e08de967fc4d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Feb 2023 18:42:09 +0100 Subject: [PATCH 484/532] update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0646cf5e..04969f87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes - +- `Service9TimeManagement`: Fix the time dump at the `SET_TIME` subservice: Include clock timeval + seconds instead of uptime. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/726 - TC Scheduler Service 11: Add size and CRC check for contained TC. - Only delete health table entry in `HealthHelper` destructor if health table was set. From c1f42618dbb8cd541297205a37f27bef7c993aa1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Feb 2023 19:58:27 +0100 Subject: [PATCH 485/532] small but important bugfix for health service --- src/fsfw/pus/CServiceHealthCommanding.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/pus/CServiceHealthCommanding.cpp b/src/fsfw/pus/CServiceHealthCommanding.cpp index 9a2af7bc..57b704fd 100644 --- a/src/fsfw/pus/CServiceHealthCommanding.cpp +++ b/src/fsfw/pus/CServiceHealthCommanding.cpp @@ -121,7 +121,7 @@ ReturnValue_t CServiceHealthCommanding::handleReply(const CommandMessage *reply, void CServiceHealthCommanding::doPeriodicOperation() { if (reportAllHealth) { for (uint8_t i = 0; i < maxNumHealthInfoPerCycle; i++) { - ReturnValue_t result = iterateHealthTable(true); + ReturnValue_t result = iterateHealthTable(false); if (result != returnvalue::OK) { reportAllHealth = false; break; From e93137939eb42c5cdc72b50b22191e38fd99425b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Feb 2023 20:46:48 +0100 Subject: [PATCH 486/532] set sequence flags for PUS TMTC to unsegmented --- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 1 + src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 2c818c7b..82dd1c41 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -100,5 +100,6 @@ ReturnValue_t PusTcCreator::setSerializableUserData(const SerializeIF &serializa void PusTcCreator::setup() { spCreator.setPacketType(ccsds::PacketType::TC); spCreator.setSecHeaderFlag(); + spCreator.setSeqFlags(ccsds::SequenceFlags::UNSEGMENTED); updateSpLengthField(); } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index d95a18ea..c9b3290a 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -119,6 +119,7 @@ void PusTmCreator::setup() { updateSpLengthField(); spCreator.setPacketType(ccsds::PacketType::TM); spCreator.setSecHeaderFlag(); + spCreator.setSeqFlags(ccsds::SequenceFlags::UNSEGMENTED); } void PusTmCreator::setMessageTypeCounter(uint16_t messageTypeCounter) { From 0f811777a7447254da65ceb6077ff73a06cdf545 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Feb 2023 20:49:53 +0100 Subject: [PATCH 487/532] changelog update --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f738032f..316ebbf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- PUS TMTC creator module: Sequence flags were set to continuation segment (0b00) instead + of the correct unsegmented flags (0b11) as specified in the standard. - TC Scheduler Service 11: Add size and CRC check for contained TC. - Only delete health table entry in `HealthHelper` destructor if health table was set. From 5343844be54329763d7d76caf552eaf6adb8a32d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 3 Feb 2023 15:58:26 +0100 Subject: [PATCH 488/532] bugfix in setNormalDataPoolEntriesInvalid Do not forget to call read and write to actually update the validity state --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 7 ++++++- unittests/testcfg/devices/logicalAddresses.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 60966501..26c9a1bb 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1,5 +1,7 @@ #include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include + #include "fsfw/datapoollocal/LocalPoolVariable.h" #include "fsfw/devicehandlers/AcceptsDeviceResponsesIF.h" #include "fsfw/devicehandlers/DeviceTmReportingWrapper.h" @@ -1508,7 +1510,10 @@ DeviceCommandId_t DeviceHandlerBase::getPendingCommand() const { void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() { for (const auto& reply : deviceReplyMap) { if (reply.second.dataSet != nullptr) { - reply.second.dataSet->setValidity(false, true); + PoolReadGuard pg(reply.second.dataSet); + if (pg.getReadResult() == returnvalue::OK) { + reply.second.dataSet->setValidity(false, true); + } } } } diff --git a/unittests/testcfg/devices/logicalAddresses.h b/unittests/testcfg/devices/logicalAddresses.h index 788c124f..a7e34cce 100644 --- a/unittests/testcfg/devices/logicalAddresses.h +++ b/unittests/testcfg/devices/logicalAddresses.h @@ -7,7 +7,7 @@ namespace addresses { /* Logical addresses have uint32_t datatype */ -enum logicalAddresses : address_t {}; +enum LogicAddress : address_t {}; } // namespace addresses #endif /* CONFIG_DEVICES_LOGICALADDRESSES_H_ */ From 4374c7c4f4fc075e7ec1d4b18b819d36622c64b3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 3 Feb 2023 16:01:56 +0100 Subject: [PATCH 489/532] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 316ebbf5..969af78e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- DHB `setNormalDatapoolEntriesInvalid`: The default implementation did not set the validity + to false correctly because the `read` and `write` calls were missing. - PUS TMTC creator module: Sequence flags were set to continuation segment (0b00) instead of the correct unsegmented flags (0b11) as specified in the standard. - TC Scheduler Service 11: Add size and CRC check for contained TC. From 034eb34c2e86cb47cedb1d8e773ada9aae3ee8a0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 3 Feb 2023 16:05:50 +0100 Subject: [PATCH 490/532] small tweak --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 26c9a1bb..bc528128 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1,7 +1,6 @@ #include "fsfw/devicehandlers/DeviceHandlerBase.h" -#include - +#include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/datapoollocal/LocalPoolVariable.h" #include "fsfw/devicehandlers/AcceptsDeviceResponsesIF.h" #include "fsfw/devicehandlers/DeviceTmReportingWrapper.h" From 066f7a6f9bb69e8f4356ebb7098207322ae9095f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 6 Feb 2023 14:41:14 +0100 Subject: [PATCH 491/532] remove unreachable code --- src/fsfw/pus/CServiceHealthCommanding.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/fsfw/pus/CServiceHealthCommanding.cpp b/src/fsfw/pus/CServiceHealthCommanding.cpp index 57b704fd..4a2339d9 100644 --- a/src/fsfw/pus/CServiceHealthCommanding.cpp +++ b/src/fsfw/pus/CServiceHealthCommanding.cpp @@ -88,14 +88,6 @@ ReturnValue_t CServiceHealthCommanding::prepareCommand(CommandMessage *message, return EXECUTION_COMPLETE; } return result; - while (true) { - ReturnValue_t result = iterateHealthTable(false); - if (result != returnvalue::OK) { - break; - } - } - - return returnvalue::OK; } default: { // Should never happen, subservice was already checked From 7e7b3bbbc9eccfb8610e712116c1398ce877b23e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:06:34 +0100 Subject: [PATCH 492/532] time stamper empty ctor --- src/fsfw/timemanager/CdsShortTimeStamper.cpp | 2 ++ src/fsfw/timemanager/CdsShortTimeStamper.h | 1 + 2 files changed, 3 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. From b22d4393002f6d5a72bfc24c7ca6be98a1cccfe1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:10:11 +0100 Subject: [PATCH 493/532] bump changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c5cf023..0c70147e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Added +- Empty constructor for `CdsShortTimeStamper` which does not do an object manager registration. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/730 - `TcpTmTcServer`: Allow setting the `SO_REUSEADDR` and `SO_REUSEPORT` option on the TCP server. CTOR prototype has changed and expects an explicit TCP configuration struct to be passed. From 0a23f2c85a712c01e884b0d5e00cc17db26f21a4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:15:44 +0100 Subject: [PATCH 494/532] correction for printout, add prefix --- src/fsfw/osal/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fsfw/osal/CMakeLists.txt b/src/fsfw/osal/CMakeLists.txt index a4097649..6ccea974 100644 --- a/src/fsfw/osal/CMakeLists.txt +++ b/src/fsfw/osal/CMakeLists.txt @@ -18,7 +18,10 @@ elseif(FSFW_OSAL MATCHES "host") endif() set(FSFW_OSAL_HOST 1) else() - message(WARNING "The OS_FSFW variable was not set. Assuming host OS..") + message( + WARNING + "${MSG_PREFIX} The FSFW_OSAL variable was not set. Assuming host OS..") + # Not set. Assumuing this is a host build, try to determine host OS if(WIN32) add_subdirectory(host) From 539d7aac9ebbe0ed68db7a338e4e18360de7299f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:17:03 +0100 Subject: [PATCH 495/532] suppress error if ETL is not found --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8308f523..9025537a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,7 +196,7 @@ message( ) # Check whether the user has already installed ETL first -find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET) +find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET) # Not installed, so use FetchContent to download and provide etl if(NOT ${FSFW_ETL_LIB_NAME}_FOUND) message( From c8e065a713fcb7d10efa1a13a770af4ce76e9404 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:36:42 +0100 Subject: [PATCH 496/532] comment tweak to event parser can read everything --- src/fsfw/health/HasHealthIF.h | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/fsfw/health/HasHealthIF.h b/src/fsfw/health/HasHealthIF.h index 77a1c12f..16666bbc 100644 --- a/src/fsfw/health/HasHealthIF.h +++ b/src/fsfw/health/HasHealthIF.h @@ -16,26 +16,24 @@ class HasHealthIF { }; static const uint8_t INTERFACE_ID = CLASS_ID::HAS_HEALTH_IF; - static const ReturnValue_t OBJECT_NOT_HEALTHY = MAKE_RETURN_CODE(1); - static const ReturnValue_t INVALID_HEALTH_STATE = MAKE_RETURN_CODE(2); + static constexpr ReturnValue_t OBJECT_NOT_HEALTHY = returnvalue::makeCode(INTERFACE_ID, 1); + static constexpr ReturnValue_t INVALID_HEALTH_STATE = returnvalue::makeCode(INTERFACE_ID, 2); + static constexpr ReturnValue_t IS_EXTERNALLY_CONTROLLED = returnvalue::makeCode(INTERFACE_ID, 3); static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_MANAGER_1; + //! P1: New Health, P2: Old Health static const Event HEALTH_INFO = MAKE_EVENT(6, severity::INFO); static const Event CHILD_CHANGED_HEALTH = MAKE_EVENT(7, severity::INFO); static const Event CHILD_PROBLEMS = MAKE_EVENT(8, severity::LOW); - static const Event OVERWRITING_HEALTH = - MAKE_EVENT(9, severity::LOW); //!< Assembly overwrites health information of children to keep - //!< satellite alive. - static const Event TRYING_RECOVERY = - MAKE_EVENT(10, severity::MEDIUM); //!< Someone starts a recovery of a component (typically - //!< power-cycle). No parameters. - static const Event RECOVERY_STEP = - MAKE_EVENT(11, severity::MEDIUM); //!< Recovery is ongoing. Comes twice during recovery. P1: - //!< 0 for the first, 1 for the second event. P2: 0 - static const Event RECOVERY_DONE = MAKE_EVENT( - 12, - severity::MEDIUM); //!< Recovery was completed. Not necessarily successful. No parameters. - + //! Assembly overwrites health information of children to keep satellite alive. + static const Event OVERWRITING_HEALTH = MAKE_EVENT(9, severity::LOW); + //! Someone starts a recovery of a component (typically power-cycle). No parameters. + static const Event TRYING_RECOVERY = MAKE_EVENT(10, severity::MEDIUM); + //! Recovery is ongoing. Comes twice during recovery. + //! P1: 0 for the first, 1 for the second event. P2: 0 + static const Event RECOVERY_STEP = MAKE_EVENT(11, severity::MEDIUM); + //! Recovery was completed. Not necessarily successful. No parameters. + static const Event RECOVERY_DONE = MAKE_EVENT(12, severity::MEDIUM); virtual ~HasHealthIF() {} virtual MessageQueueId_t getCommandQueue() const = 0; From c2e6a22deca2033ed79276f4dceb515aa87f4bd4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:39:43 +0100 Subject: [PATCH 497/532] important bugfix for RM3100 --- src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index ce215a64..4becd420 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -169,7 +169,7 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const case (RM3100::CONFIGURE_CYCLE_COUNT): case (RM3100::CONFIGURE_TMRC): { // We can only check whether write was successful with read operation - if (mode == _MODE_START_UP) { + if (getMode() == _MODE_START_UP) { commandExecuted = true; } break; @@ -192,7 +192,7 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const if (packet[1] == tmrcRegValue) { commandExecuted = true; // Reading TMRC was commanded. Trigger event to inform ground - if (mode != _MODE_START_UP) { + if (getMode() != _MODE_START_UP) { triggerEvent(tmrcSet, tmrcRegValue, 0); } } else { @@ -211,7 +211,7 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const return DeviceHandlerIF::DEVICE_REPLY_INVALID; } // Reading TMRC was commanded. Trigger event to inform ground - if (mode != _MODE_START_UP) { + if (getMode() != _MODE_START_UP) { uint32_t eventParam1 = (cycleCountX << 16) | cycleCountY; triggerEvent(cycleCountersSet, eventParam1, cycleCountZ); } @@ -325,7 +325,7 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) { // trickery here to calculate the raw values first int32_t fieldStrengthRawX = ((packet[1] << 24) | (packet[2] << 16) | (packet[3] << 8)) >> 8; int32_t fieldStrengthRawY = ((packet[4] << 24) | (packet[5] << 16) | (packet[6] << 8)) >> 8; - int32_t fieldStrengthRawZ = ((packet[7] << 24) | (packet[8] << 16) | (packet[3] << 8)) >> 8; + int32_t fieldStrengthRawZ = ((packet[7] << 24) | (packet[8] << 16) | (packet[9] << 8)) >> 8; // Now scale to physical value in microtesla float fieldStrengthX = fieldStrengthRawX * scaleFactorX; From 5adf89b9110fac3367735419a2aa82fb434f0297 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:41:42 +0100 Subject: [PATCH 498/532] changelog update --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecc585d6..96b2df80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - HAL MGM3100 Handler: Use axis specific gain/scaling factors. Previously, only the X scaling factor was used. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/724 +- Bugfix for RM3100 MGM sensors. Z value was previously calculated + with bytes of the X value. - DHB `setNormalDatapoolEntriesInvalid`: The default implementation did not set the validity to false correctly because the `read` and `write` calls were missing. - PUS TMTC creator module: Sequence flags were set to continuation segment (0b00) instead From f39054edd4a90833903190af7d9400ec5a2335b1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:45:29 +0100 Subject: [PATCH 499/532] introduce warning switch --- src/fsfw/tmtcservices/TmTcBridge.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index f22d70d6..9ff58766 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -16,7 +16,9 @@ TmTcBridge::TmTcBridge(const char* name, object_id_t objectId, object_id_t tcDes tcDestination(tcDestination) { - tmTcReceptionQueue = QueueFactory::instance()->createMessageQueue(TMTC_RECEPTION_QUEUE_DEPTH); + auto mqArgs = MqArgs(objectId, static_cast(this)); + tmTcReceptionQueue = QueueFactory::instance()->createMessageQueue( + TMTC_RECEPTION_QUEUE_DEPTH, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } TmTcBridge::~TmTcBridge() { QueueFactory::instance()->deleteMessageQueue(tmTcReceptionQueue); } @@ -35,7 +37,7 @@ ReturnValue_t TmTcBridge::setNumberOfSentPacketsPerCycle(uint8_t sentPacketsPerC } } -ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored) { +ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(unsigned int maxNumberOfPacketsStored) { if (maxNumberOfPacketsStored <= LIMIT_DOWNLINK_PACKETS_STORED) { this->maxNumberOfPacketsStored = maxNumberOfPacketsStored; return returnvalue::OK; @@ -171,15 +173,18 @@ ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage* message) { } if (tmFifo->full()) { + if (warningSwitch) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "TmTcBridge::storeDownlinkData: TM downlink max. number " - "of stored packet IDs reached!" - << std::endl; + sif::warning << "TmTcBridge::storeDownlinkData: TM downlink max. number " + "of stored packet IDs reached!" + << std::endl; #else - sif::printWarning( - "TmTcBridge::storeDownlinkData: TM downlink max. number " - "of stored packet IDs reached!\n"); + sif::printWarning( + "TmTcBridge::storeDownlinkData: TM downlink max. number " + "of stored packet IDs reached!\n"); #endif + warningSwitch = false; + } if (overwriteOld) { tmFifo->retrieve(&storeId); tmStore->deleteData(storeId); @@ -221,6 +226,7 @@ ReturnValue_t TmTcBridge::handleStoredTm() { packetSentCounter++; if (tmFifo->empty()) { + warningSwitch = true; tmStored = false; } tmStore->deleteData(storeId); From 40a9e12416ce0d174e8402d97f155dd603fc670b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:47:40 +0100 Subject: [PATCH 500/532] 1000 is a bit much --- src/fsfw/tmtcservices/TmTcBridge.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fsfw/tmtcservices/TmTcBridge.h b/src/fsfw/tmtcservices/TmTcBridge.h index ed4d254e..3df3419c 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.h +++ b/src/fsfw/tmtcservices/TmTcBridge.h @@ -17,7 +17,7 @@ class TmTcBridge : public AcceptsTelemetryIF, public: static constexpr uint8_t TMTC_RECEPTION_QUEUE_DEPTH = 20; static constexpr uint8_t LIMIT_STORED_DATA_SENT_PER_CYCLE = 15; - static constexpr uint8_t LIMIT_DOWNLINK_PACKETS_STORED = 200; + static constexpr unsigned int LIMIT_DOWNLINK_PACKETS_STORED = 500; static constexpr uint8_t DEFAULT_STORED_DATA_SENT_PER_CYCLE = 5; static constexpr uint8_t DEFAULT_DOWNLINK_PACKETS_STORED = 10; @@ -42,7 +42,7 @@ class TmTcBridge : public AcceptsTelemetryIF, * @return -@c returnvalue::OK if value was set successfully * -@c returnvalue::FAILED otherwise, stored value stays the same */ - ReturnValue_t setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored); + ReturnValue_t setMaxNumberOfPacketsStored(unsigned int maxNumberOfPacketsStored); /** * This will set up the bridge to overwrite old data in the FIFO. @@ -91,6 +91,7 @@ class TmTcBridge : public AcceptsTelemetryIF, //! by default, so telemetry will be handled immediately. bool communicationLinkUp = true; bool tmStored = false; + bool warningSwitch = true; bool overwriteOld = true; uint8_t packetSentCounter = 0; @@ -152,7 +153,7 @@ class TmTcBridge : public AcceptsTelemetryIF, */ DynamicFIFO* tmFifo = nullptr; uint8_t sentPacketsPerCycle = DEFAULT_STORED_DATA_SENT_PER_CYCLE; - uint8_t maxNumberOfPacketsStored = DEFAULT_DOWNLINK_PACKETS_STORED; + unsigned int maxNumberOfPacketsStored = DEFAULT_DOWNLINK_PACKETS_STORED; }; #endif /* FSFW_TMTCSERVICES_TMTCBRIDGE_H_ */ From 134d908f2651648c9f9f3d053f6a1961ebb5d0e5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:52:18 +0100 Subject: [PATCH 501/532] that stuff is not in upstream yet.. --- src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index 4becd420..307d0a55 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -169,7 +169,7 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const case (RM3100::CONFIGURE_CYCLE_COUNT): case (RM3100::CONFIGURE_TMRC): { // We can only check whether write was successful with read operation - if (getMode() == _MODE_START_UP) { + if (mode == _MODE_START_UP) { commandExecuted = true; } break; @@ -192,7 +192,7 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const if (packet[1] == tmrcRegValue) { commandExecuted = true; // Reading TMRC was commanded. Trigger event to inform ground - if (getMode() != _MODE_START_UP) { + if (mode != _MODE_START_UP) { triggerEvent(tmrcSet, tmrcRegValue, 0); } } else { @@ -211,7 +211,7 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const return DeviceHandlerIF::DEVICE_REPLY_INVALID; } // Reading TMRC was commanded. Trigger event to inform ground - if (getMode() != _MODE_START_UP) { + if (mode != _MODE_START_UP) { uint32_t eventParam1 = (cycleCountX << 16) | cycleCountY; triggerEvent(cycleCountersSet, eventParam1, cycleCountZ); } From 8014e4adf90bfcece6267294436af804d657a094 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 01:20:28 +0100 Subject: [PATCH 502/532] mode service fixes --- src/fsfw/modes/ModeMessage.cpp | 16 ++++++++ src/fsfw/modes/ModeMessage.h | 3 ++ src/fsfw/pus/CService200ModeCommanding.cpp | 44 ++++++++++++++++------ 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/fsfw/modes/ModeMessage.cpp b/src/fsfw/modes/ModeMessage.cpp index ecc52c94..fbfb71aa 100644 --- a/src/fsfw/modes/ModeMessage.cpp +++ b/src/fsfw/modes/ModeMessage.cpp @@ -24,3 +24,19 @@ void ModeMessage::setCantReachMode(CommandMessage* message, ReturnValue_t reason message->setParameter(reason); message->setParameter2(0); } + +void ModeMessage::setModeAnnounceMessage(CommandMessage& message, bool recursive) { + Command_t cmd; + if (recursive) { + cmd = CMD_MODE_ANNOUNCE_RECURSIVELY; + } else { + cmd = CMD_MODE_ANNOUNCE; + } + message.setCommand(cmd); +} + +void ModeMessage::setCmdModeMessage(CommandMessage& message, Mode_t mode, Submode_t submode) { + setModeMessage(&message, CMD_MODE_COMMAND, mode, submode); +} + +void ModeMessage::setModeReadMessage(CommandMessage& message) { message.setCommand(CMD_MODE_READ); } diff --git a/src/fsfw/modes/ModeMessage.h b/src/fsfw/modes/ModeMessage.h index 84429e84..c00e6c9e 100644 --- a/src/fsfw/modes/ModeMessage.h +++ b/src/fsfw/modes/ModeMessage.h @@ -45,6 +45,9 @@ class ModeMessage { static void setModeMessage(CommandMessage* message, Command_t command, Mode_t mode, Submode_t submode); + static void setCmdModeMessage(CommandMessage& message, Mode_t mode, Submode_t submode); + static void setModeAnnounceMessage(CommandMessage& message, bool recursive); + static void setModeReadMessage(CommandMessage& message); static void setCantReachMode(CommandMessage* message, ReturnValue_t reason); static void clear(CommandMessage* message); }; diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index d28df59b..a82e7f5c 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -53,16 +53,36 @@ ReturnValue_t CService200ModeCommanding::checkInterfaceAndAcquireMessageQueue( ReturnValue_t CService200ModeCommanding::prepareCommand(CommandMessage *message, uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, uint32_t *state, object_id_t objectId) { - ModePacket modeCommandPacket; - ReturnValue_t result = - modeCommandPacket.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); - if (result != returnvalue::OK) { - return result; - } + switch (subservice) { + case (Subservice::COMMAND_MODE_COMMAND): { + ModePacket modeCommandPacket; + ReturnValue_t result = + modeCommandPacket.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); + if (result != returnvalue::OK) { + return result; + } - ModeMessage::setModeMessage(message, ModeMessage::CMD_MODE_COMMAND, modeCommandPacket.getMode(), - modeCommandPacket.getSubmode()); - return result; + ModeMessage::setModeMessage(message, ModeMessage::CMD_MODE_COMMAND, + modeCommandPacket.getMode(), modeCommandPacket.getSubmode()); + return returnvalue::OK; + } + case (Subservice::COMMAND_MODE_ANNCOUNCE): + case (Subservice::COMMAND_MODE_ANNOUNCE_RECURSIVELY): { + bool recursive = true; + if (subservice == Subservice::COMMAND_MODE_ANNCOUNCE) { + recursive = false; + } + ModeMessage::setModeAnnounceMessage(*message, recursive); + return EXECUTION_COMPLETE; + } + case (Subservice::COMMAND_MODE_READ): { + ModeMessage::setModeReadMessage(*message); + return returnvalue::OK; + } + default: { + return CommandingServiceBase::INVALID_SUBSERVICE; + } + } } ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply, @@ -73,8 +93,10 @@ ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply ReturnValue_t result = returnvalue::FAILED; switch (replyId) { case (ModeMessage::REPLY_MODE_REPLY): { - result = prepareModeReply(reply, objectId); - break; + if (previousCommand != ModeMessage::CMD_MODE_COMMAND) { + return prepareModeReply(reply, objectId); + } + return returnvalue::OK; } case (ModeMessage::REPLY_WRONG_MODE_REPLY): { result = prepareWrongModeReply(reply, objectId); From 6445debfa182475baefa77ce95c8489f3e0cd7f5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 01:31:32 +0100 Subject: [PATCH 503/532] bump changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 969af78e..18f3dedb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- `CService200ModeManagement`: Various bugfixes which lead to now execution complete being generated + on mode announcements, duplicate mode reply generated on announce commands, and the mode read + subservice not working properly. - DHB `setNormalDatapoolEntriesInvalid`: The default implementation did not set the validity to false correctly because the `read` and `write` calls were missing. - PUS TMTC creator module: Sequence flags were set to continuation segment (0b00) instead From 1fffcc2229c3cc2fea52c9c3e6829ed99a70e7f1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 20:38:32 +0100 Subject: [PATCH 504/532] possiible leak fixes --- src/fsfw/tmtcservices/TmTcBridge.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index f22d70d6..bed2c911 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -143,13 +143,17 @@ ReturnValue_t TmTcBridge::handleTmQueue() { #endif /* FSFW_VERBOSE_LEVEL >= 3 */ if (communicationLinkUp == false or packetSentCounter >= sentPacketsPerCycle) { - storeDownlinkData(&message); + ReturnValue_t result = storeDownlinkData(&message); + if (result != returnvalue::OK) { + tmStore->deleteData(message.getStorageId()); + } continue; } result = tmStore->getData(message.getStorageId(), &data, &size); if (result != returnvalue::OK) { status = result; + tmStore->deleteData(message.getStorageId()); continue; } @@ -157,9 +161,9 @@ ReturnValue_t TmTcBridge::handleTmQueue() { if (result != returnvalue::OK) { status = result; } else { - tmStore->deleteData(message.getStorageId()); packetSentCounter++; } + tmStore->deleteData(message.getStorageId()); } return status; } From 000df85556bb2bfc4e648f1e0324f71e240afd90 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 21:24:00 +0100 Subject: [PATCH 505/532] bump changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecc585d6..add39a3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- Memory leak fixes for the TCP/IP TMTC bridge. - `Service9TimeManagement`: Fix the time dump at the `SET_TIME` subservice: Include clock timeval seconds instead of uptime. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/726 From f1b0ca7cffd53ef86ec94ebc6db084ffcee8c8fd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 21:26:37 +0100 Subject: [PATCH 506/532] add PR link --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index add39a3f..c7f0ce52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes - Memory leak fixes for the TCP/IP TMTC bridge. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/737 - `Service9TimeManagement`: Fix the time dump at the `SET_TIME` subservice: Include clock timeval seconds instead of uptime. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/726 From 8c712441ab659d33663908e694216d437e5921d6 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 9 Feb 2023 11:34:58 +0100 Subject: [PATCH 507/532] Making fetch Catch2 quiet as well. --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9025537a..33d55351 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,12 +153,12 @@ if(FSFW_BUILD_TESTS) "${MSG_PREFIX} Building the FSFW unittests in addition to the static library" ) # Check whether the user has already installed Catch2 first - find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION}) + find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION} QUIET) # Not installed, so use FetchContent to download and provide Catch2 if(NOT Catch2_FOUND) message( STATUS - "${MSG_PREFIX} Catch2 installation not found. Downloading Catch2 library with FetchContent" + "${MSG_PREFIX} Catch2 installation not found. Downloading Catch2 library with FetchContent." ) include(FetchContent) @@ -201,8 +201,8 @@ find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET) if(NOT ${FSFW_ETL_LIB_NAME}_FOUND) message( STATUS - "${MSG_PREFIX} No ETL installation was found with find_package. Installing and providing " - "etl with FindPackage") + "${MSG_PREFIX} ETL installation not found. Downloading ETL with FetchContent." + ) include(FetchContent) FetchContent_Declare( From 010509efb442bf0d075b280afb5a74d8c84d1cb3 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 9 Feb 2023 13:50:16 +0100 Subject: [PATCH 508/532] removed unneeded find_package parameter for etl --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33d55351..56601aaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,7 +196,7 @@ message( ) # Check whether the user has already installed ETL first -find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET) +find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET) # Not installed, so use FetchContent to download and provide etl if(NOT ${FSFW_ETL_LIB_NAME}_FOUND) message( From 3a2393885f6228502737adb50923e73d99756a42 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 9 Feb 2023 15:44:39 +0100 Subject: [PATCH 509/532] more style --- src/fsfw/pus/CService200ModeCommanding.cpp | 20 ++++++++------------ src/fsfw/pus/CService200ModeCommanding.h | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index a82e7f5c..15745a37 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -19,7 +19,7 @@ ReturnValue_t CService200ModeCommanding::isValidSubservice(uint8_t subservice) { switch (subservice) { case (Subservice::COMMAND_MODE_COMMAND): case (Subservice::COMMAND_MODE_READ): - case (Subservice::COMMAND_MODE_ANNCOUNCE): + case (Subservice::COMMAND_MODE_ANNOUNCE): return returnvalue::OK; default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; @@ -53,6 +53,7 @@ ReturnValue_t CService200ModeCommanding::checkInterfaceAndAcquireMessageQueue( ReturnValue_t CService200ModeCommanding::prepareCommand(CommandMessage *message, uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, uint32_t *state, object_id_t objectId) { + bool recursive = false; switch (subservice) { case (Subservice::COMMAND_MODE_COMMAND): { ModePacket modeCommandPacket; @@ -66,22 +67,17 @@ ReturnValue_t CService200ModeCommanding::prepareCommand(CommandMessage *message, modeCommandPacket.getMode(), modeCommandPacket.getSubmode()); return returnvalue::OK; } - case (Subservice::COMMAND_MODE_ANNCOUNCE): - case (Subservice::COMMAND_MODE_ANNOUNCE_RECURSIVELY): { - bool recursive = true; - if (subservice == Subservice::COMMAND_MODE_ANNCOUNCE) { - recursive = false; - } + case (Subservice::COMMAND_MODE_ANNOUNCE_RECURSIVELY): + recursive = true; + [[fallthrough]]; + case (Subservice::COMMAND_MODE_ANNOUNCE): ModeMessage::setModeAnnounceMessage(*message, recursive); return EXECUTION_COMPLETE; - } - case (Subservice::COMMAND_MODE_READ): { + case (Subservice::COMMAND_MODE_READ): ModeMessage::setModeReadMessage(*message); return returnvalue::OK; - } - default: { + default: return CommandingServiceBase::INVALID_SUBSERVICE; - } } } diff --git a/src/fsfw/pus/CService200ModeCommanding.h b/src/fsfw/pus/CService200ModeCommanding.h index 830e5950..cf2baf7e 100644 --- a/src/fsfw/pus/CService200ModeCommanding.h +++ b/src/fsfw/pus/CService200ModeCommanding.h @@ -52,7 +52,7 @@ class CService200ModeCommanding : public CommandingServiceBase { COMMAND_MODE_READ = 3, //!< [EXPORT] : [COMMAND] Trigger an ModeInfo Event. //! This command does NOT have a reply - COMMAND_MODE_ANNCOUNCE = 4, + COMMAND_MODE_ANNOUNCE = 4, //!< [EXPORT] : [COMMAND] Trigger a ModeInfo Event and to send this //! command to every child. This command does NOT have a reply. COMMAND_MODE_ANNOUNCE_RECURSIVELY = 5, From 0a9c563bbc24ce7b8ea0f33231dcd29ce68e8d20 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 9 Feb 2023 15:58:48 +0100 Subject: [PATCH 510/532] format --- src/fsfw/osal/common/TcpTmTcServer.h | 1 - src/fsfw/osal/rtems/SemaphoreFactory.cpp | 2 +- .../pus/Service11TelecommandScheduling.tpp | 6 ++--- src/fsfw/rmap/rmapStructs.h | 24 +++++++++---------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/fsfw/osal/common/TcpTmTcServer.h b/src/fsfw/osal/common/TcpTmTcServer.h index 3d182827..009a1680 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.h +++ b/src/fsfw/osal/common/TcpTmTcServer.h @@ -78,7 +78,6 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb * https://man7.org/linux/man-pages/man7/socket.7.html for more details. */ bool reusePort = false; - }; enum class ReceptionModes { SPACE_PACKETS }; diff --git a/src/fsfw/osal/rtems/SemaphoreFactory.cpp b/src/fsfw/osal/rtems/SemaphoreFactory.cpp index 35099ddc..1e470f40 100644 --- a/src/fsfw/osal/rtems/SemaphoreFactory.cpp +++ b/src/fsfw/osal/rtems/SemaphoreFactory.cpp @@ -1,5 +1,5 @@ #include "fsfw/osal/rtems/BinarySemaphore.h" -//#include "fsfw/osal/rtems/CountingSemaphore.h" +// #include "fsfw/osal/rtems/CountingSemaphore.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tasks/SemaphoreFactory.h" diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 540f6c68..ac08f02c 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -2,12 +2,12 @@ #include +#include "fsfw/globalfunctions/CRC.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface.h" -#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcpacket/pus/tc/PusTcIF.h" -#include "fsfw/globalfunctions/CRC.h" +#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" static constexpr auto DEF_END = SerializeIF::Endianness::BIG; @@ -180,7 +180,7 @@ inline ReturnValue_t Service11TelecommandScheduling::doInsertActivi if (CRC::crc16ccitt(data, size) != 0) { return CONTAINED_TC_CRC_MISSMATCH; } - + // store currentPacket and receive the store address store_address_t addr{}; if (tcStore->addData(&addr, data, size) != returnvalue::OK || diff --git a/src/fsfw/rmap/rmapStructs.h b/src/fsfw/rmap/rmapStructs.h index 55e32606..1e86734b 100644 --- a/src/fsfw/rmap/rmapStructs.h +++ b/src/fsfw/rmap/rmapStructs.h @@ -10,11 +10,11 @@ ////////////////////////////////////////////////////////////////////////////////// // RMAP command bits -//#define RMAP_COMMAND_BIT_INCREMENT 2 -//#define RMAP_COMMAND_BIT_REPLY 3 -//#define RMAP_COMMAND_BIT_WRITE 5 -//#define RMAP_COMMAND_BIT_VERIFY 4 -//#define RMAP_COMMAND_BIT 6 +// #define RMAP_COMMAND_BIT_INCREMENT 2 +// #define RMAP_COMMAND_BIT_REPLY 3 +// #define RMAP_COMMAND_BIT_WRITE 5 +// #define RMAP_COMMAND_BIT_VERIFY 4 +// #define RMAP_COMMAND_BIT 6 namespace RMAPIds { @@ -32,14 +32,14 @@ static const uint8_t RMAP_COMMAND_READ = ((1 << RMAP_COMMAND_BIT) | (1 << RMAP_C static const uint8_t RMAP_REPLY_WRITE = ((1 << RMAP_COMMAND_BIT_WRITE) | (1 << RMAP_COMMAND_BIT_REPLY)); static const uint8_t RMAP_REPLY_READ = ((1 << RMAP_COMMAND_BIT_REPLY)); -//#define RMAP_COMMAND_WRITE ((1< Date: Thu, 9 Feb 2023 18:30:08 +0100 Subject: [PATCH 511/532] add allowed subservice --- src/fsfw/pus/CService200ModeCommanding.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index 15745a37..0dbdedfe 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -20,6 +20,7 @@ ReturnValue_t CService200ModeCommanding::isValidSubservice(uint8_t subservice) { case (Subservice::COMMAND_MODE_COMMAND): case (Subservice::COMMAND_MODE_READ): case (Subservice::COMMAND_MODE_ANNOUNCE): + case (Subservice::COMMAND_MODE_ANNOUNCE_RECURSIVELY): return returnvalue::OK; default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; From fffb2b61e5e65dbffc561dc2ae7372483b760a13 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 9 Feb 2023 17:00:44 +0100 Subject: [PATCH 512/532] release check helper --- CHANGELOG.md | 17 +++--- scripts/check_release.py | 110 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 6 deletions(-) create mode 100755 scripts/check_release.py diff --git a/CHANGELOG.md b/CHANGELOG.md index b7788808..17a77692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] -# [v6.0.0] +# [v6.0.0] 2023-02-10 ## Fixes - `CService200ModeManagement`: Various bugfixes which lead to now execution complete being generated on mode announcements, duplicate mode reply generated on announce commands, and the mode read subservice not working properly. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/736 - Memory leak fixes for the TCP/IP TMTC bridge. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/737 - `Service9TimeManagement`: Fix the time dump at the `SET_TIME` subservice: Include clock timeval @@ -23,16 +24,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - HAL MGM3100 Handler: Use axis specific gain/scaling factors. Previously, only the X scaling factor was used. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/724 -- Bugfix for RM3100 MGM sensors. Z value was previously calculated - with bytes of the X value. +- HAL MGM3100 Handler: Z value was previously calculated with bytes of the X value. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/733 - DHB `setNormalDatapoolEntriesInvalid`: The default implementation did not set the validity to false correctly because the `read` and `write` calls were missing. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/728 - PUS TMTC creator module: Sequence flags were set to continuation segment (0b00) instead of the correct unsegmented flags (0b11) as specified in the standard. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/727 - TC Scheduler Service 11: Add size and CRC check for contained TC. + Bug: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/issues/719 + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/720 - 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 + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/710 - 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 @@ -64,7 +69,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `AcceptsTelemetryIF`: `getReportReceptionQueue` is const now PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/712 - Moved some container returnvalues to dedicated header and namespace - to they can be used without template specification. + so they can be used without template specification. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/707 - Remove default secondary header argument for `uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag)` and @@ -125,7 +130,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). implementation without an extra component PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/682 -# [v5.0.0] 25.07.2022 +# [v5.0.0] 2022-07-25 ## Changes diff --git a/scripts/check_release.py b/scripts/check_release.py new file mode 100755 index 00000000..eb5c89f9 --- /dev/null +++ b/scripts/check_release.py @@ -0,0 +1,110 @@ +#! /bin/python + + +import argparse +import json +import urllib.request +import re +from pathlib import Path + +def main() -> None: + parser = argparse.ArgumentParser( + description="List undocumented PRs" + ) + parser.add_argument("-v", "--version", type=str, required=True) + args = parser.parse_args() + + match = re.search("([0-9]+\.[0-9]+\.[0-9]+)", args.version) + + if not match: + print("invalid version") + exit(1) + + version = "v" + match.group(1) + + print("looking for milestone for " + version + " ...") + + + with urllib.request.urlopen("https://egit.irs.uni-stuttgart.de/api/v1/repos/fsfw/fsfw/milestones?name=" + version) as milestone_json: + milestones = json.load(milestone_json) + if (len(milestones) == 0): + print("did not find any milestone") + exit(1) + if (len(milestones) > 1): + print("found multiple milestons") + milestone_title = milestones[0]['title'] + milestone = str(milestones[0]['id']) + print("Using Milestone \""+ milestone_title + "\" with id " + milestone) + + milestone_prs = [] + + page = 1 + last_count = 1; + while last_count != 0: + with urllib.request.urlopen("https://egit.irs.uni-stuttgart.de/api/v1/repos/fsfw/fsfw/pulls?state=closed&milestone=" + str(milestone) + "&limit=100&page=" + str(page)) as pull_requests_json: + pull_requests = json.load(pull_requests_json) + for pr in pull_requests: + milestone_prs.append({'number': str(pr['number']), 'title' : pr['title']}) + page += 1 + last_count = len(pull_requests) + + print("Found " + str(len(milestone_prs)) + " closed PRs in Milestone") + + print("looking for CHANGELOG.md ...") + + path = Path(".") + + files = list(path.glob("CHANGELOG.md")) + + if (len(files) != 1): + files = list(path.glob("../CHANGELOG.md")) + + if (len(files) != 1): + print("did not find CHANGELOG.md. Run script in either root directory or scripts subfolder.") + exit(1) + + print("Scanning CHANGELOG.md ...") + + changelog_prs = [] + + with open(files[0]) as changelog: + line = changelog.readline() + while (line): + #print("line: " + line) + match = re.search("\#.+(v[0-9]+\.[0-9]+\.[0-9]+)", line) + if (match): + if match.group(1) == version: + #print("found version") + line = changelog.readline() + continue + else: + #print("done with " + match.group(1)) + break + + match = re.search("PR: https://egit\.irs\.uni-stuttgart\.de/fsfw/fsfw/pulls/([0-9]+)", line) + if match: + changelog_prs.append(match.group(1)) + + line = changelog.readline() + + print("Found " + str(len(changelog_prs)) + " PRs in CHANGELOG.md") + + print("") + + copy_array = changelog_prs.copy() + print("PRs in CHANGELOG.md that are not in Milestone:") + for pr in milestone_prs: + if pr['number'] in copy_array: + copy_array.remove(pr['number']) + for pr in copy_array: + print("https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/" + pr) + + print("") + + print("PRs in milestone that are not in CHANGELOG.md:") + + for pr in milestone_prs: + if pr['number'] not in changelog_prs: + print("- " + pr['title'] + "\n PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/" + pr['number']) + +main() From 3562bf11b9d5ea75478f927c1061ba0bfacb3e16 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 10 Feb 2023 11:06:46 +0100 Subject: [PATCH 513/532] CHANGELOG update --- CHANGELOG.md | 106 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 98 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17a77692..6ae6f59f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] # [v6.0.0] 2023-02-10 + + + + + + + + + + + + + + + + + + + + ## Fixes @@ -47,6 +67,34 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `TcpTmTcServer.cpp`: The server was actually not able to handle CCSDS packets which were clumped together. This has been fixed now. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/673 +- various fixes related to linux Unittests and memory leaks + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/715 +- small fix to allow teardown handling + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/713 +- fix compiler warning for fixed array list copy ctor + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/704 +- missing include + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/703 +- defaultconfig did not build anymore + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/702 +- hotfix + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/699 +- small fix for helper + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/698 +- missing retval conv + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/697 +- DHB Countdown Bug + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/693 +- doc corrections + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/687 +- better error printout + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/686 +- include correction + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/683 +- better warning for missing include paths + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/676 +- Service 11 regression + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/670 ## Added @@ -63,6 +111,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/). 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 +- publish documentation for development and master branch + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/681 +- Add Linux HAL options + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/663 +- Expand SerializeIF + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/656 +- PUS Service 11: Additional Safety Check + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/666 +- improvements for auto-formatter script + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/665 +- provide a weak print char impl + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/674 + +## Removed + +- now that doc server is up, remove markdown files + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/688 +- remove bsp specific code + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/679 ## Changes @@ -99,18 +166,41 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `DeviceHandlerBase`: New signature of `handleDeviceTm` which expects a `const SerializeIF&` and additional helper variant which expects `const uint8_t*` PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/671 -- Move some generic `StorageManagerIF` implementations from `LocalPool` to - interface itself so it can be re-used more easily. Also add new - abstract function `bool hasDataAtId(store_address_t storeId) const`. - PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/685 - Improvements for `AcceptsTelemetryIF` and `AcceptsTelecommandsIF`: - Make functions `const` where it makes sense - Add `const char* getName const` abstract function PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/684 -- Move some generic `StorageManagerIF` implementations from `LocalPool` to - interface itself so it can be re-used more easily. Also add new - abstract function `bool hasDataAtId(store_address_t storeId) const`. - PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/685 +- Generic TMTC Bridge Update + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/734 +- comment tweak to event parser can read everything + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/732 +- CMakeLists file updates + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/731 +- improve srv20 error messages + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/723 +- I2C Linux: remove duplicate printout + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/718 +- printout handling improvements + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/717 +- vec getter, reset for content + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/716 +- updates for source sequence counter + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/714 +- SP reader getPacketData is const now + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/708 +- refactoring of serial drivers for linux + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/705 +- Local Pool Update Remove Add Data Ignore Fault Argument + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/701 +- Switch to new documentation server + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/694 +- Windows Tweaks + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/691 +- Refactor Local Pool API + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/667 +- group MGM data in local pool vectors + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/664 + ## CFDP From d76d97a36b74f67b8248a152d2001eb0ff267459 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 23 Feb 2023 12:44:42 +0100 Subject: [PATCH 514/532] changed health table parameter to objectId --- src/fsfw/pus/CServiceHealthCommanding.cpp | 18 ++++++++++++++++-- src/fsfw/pus/CServiceHealthCommanding.h | 9 ++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/fsfw/pus/CServiceHealthCommanding.cpp b/src/fsfw/pus/CServiceHealthCommanding.cpp index 4a2339d9..8efa3287 100644 --- a/src/fsfw/pus/CServiceHealthCommanding.cpp +++ b/src/fsfw/pus/CServiceHealthCommanding.cpp @@ -10,9 +10,23 @@ CServiceHealthCommanding::CServiceHealthCommanding(HealthServiceCfg args) : CommandingServiceBase(args.objectId, args.apid, "PUS 201 Health MGMT", args.service, args.numParallelCommands, args.commandTimeoutSeconds), - healthTable(args.table), + healthTableId(args.table), maxNumHealthInfoPerCycle(args.maxNumHealthInfoPerCycle) {} +ReturnValue_t CServiceHealthCommanding::initialize() { + ReturnValue_t result = CommandingServiceBase::initialize(); + if (result != returnvalue::OK) { + return result; + } + + healthTable = ObjectManager::instance()->get(healthTableId); + if(healthTable == nullptr) { + return returnvalue::FAILED; + } + + return returnvalue::OK; +} + ReturnValue_t CServiceHealthCommanding::isValidSubservice(uint8_t subservice) { switch (subservice) { case (Subservice::COMMAND_SET_HEALTH): @@ -134,7 +148,7 @@ void CServiceHealthCommanding::doPeriodicOperation() { ReturnValue_t CServiceHealthCommanding::iterateHealthTable(bool reset) { std::pair pair; - ReturnValue_t result = healthTable.iterate(&pair, reset); + ReturnValue_t result = healthTable->iterate(&pair, reset); if (result != returnvalue::OK) { return result; } else { diff --git a/src/fsfw/pus/CServiceHealthCommanding.h b/src/fsfw/pus/CServiceHealthCommanding.h index 18f6c140..2cc16589 100644 --- a/src/fsfw/pus/CServiceHealthCommanding.h +++ b/src/fsfw/pus/CServiceHealthCommanding.h @@ -6,7 +6,7 @@ #include "fsfw/tmtcservices/CommandingServiceBase.h" struct HealthServiceCfg { - HealthServiceCfg(object_id_t objectId, uint16_t apid, HealthTable &healthTable, + HealthServiceCfg(object_id_t objectId, uint16_t apid, object_id_t healthTable, uint16_t maxNumHealthInfoPerCycle) : objectId(objectId), apid(apid), @@ -14,7 +14,7 @@ struct HealthServiceCfg { maxNumHealthInfoPerCycle(maxNumHealthInfoPerCycle) {} object_id_t objectId; uint16_t apid; - HealthTable &table; + object_id_t table; uint16_t maxNumHealthInfoPerCycle; uint8_t service = 201; uint8_t numParallelCommands = 4; @@ -40,6 +40,8 @@ class CServiceHealthCommanding : public CommandingServiceBase { CServiceHealthCommanding(HealthServiceCfg args); ~CServiceHealthCommanding() override = default; + ReturnValue_t initialize() override; + protected: /* CSB abstract function implementations */ ReturnValue_t isValidSubservice(uint8_t subservice) override; @@ -57,7 +59,8 @@ class CServiceHealthCommanding : public CommandingServiceBase { void doPeriodicOperation() override; private: - HealthTable &healthTable; + const object_id_t healthTableId; + HealthTable *healthTable; uint16_t maxNumHealthInfoPerCycle = 0; bool reportAllHealth = false; ReturnValue_t iterateHealthTable(bool reset); From dc7afc5415abc712774b4d9036524f92eccf654e Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 23 Feb 2023 13:38:24 +0100 Subject: [PATCH 515/532] Version bump, CHANGELOG update, format --- CHANGELOG.md | 6 ++++-- CMakeLists.txt | 2 +- src/fsfw/pus/CServiceHealthCommanding.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acd56f3a..0cc07f78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- Mode Service: Add allowed subservice + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/739 - `CService200ModeManagement`: Various bugfixes which lead to now execution complete being generated on mode announcements, duplicate mode reply generated on announce commands, and the mode read subservice not working properly. @@ -48,7 +50,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). CCSDS packets which were clumped together. This has been fixed now. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/673 - `CServiceHealthCommanding`: Add announce all health info implementation - PR: https://egit.irs.uni-stuttgart.de/eive/fsfw/pulls/122 + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/725 - various fixes related to linux Unittests and memory leaks PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/715 - small fix to allow teardown handling @@ -118,7 +120,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `CService201HealthCommanding` renamed to `CServiceHealthCommanding`, service ID customizable now. `CServiceHealthCommanding` expects configuration struct `HealthServiceCfg` now - PR: https://egit.irs.uni-stuttgart.de/eive/fsfw/pulls/122 + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/725 - `AcceptsTelemetryIF`: `getReportReceptionQueue` is const now PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/712 - Moved some container returnvalues to dedicated header and namespace diff --git a/CMakeLists.txt b/CMakeLists.txt index 56601aaa..5eddde7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ list(APPEND CMAKE_MODULE_PATH # Version file handling # # ############################################################################## -set(FSFW_VERSION_IF_GIT_FAILS 5) +set(FSFW_VERSION_IF_GIT_FAILS 6) set(FSFW_SUBVERSION_IF_GIT_FAILS 0) set(FSFW_REVISION_IF_GIT_FAILS 0) diff --git a/src/fsfw/pus/CServiceHealthCommanding.cpp b/src/fsfw/pus/CServiceHealthCommanding.cpp index 8efa3287..7faf8174 100644 --- a/src/fsfw/pus/CServiceHealthCommanding.cpp +++ b/src/fsfw/pus/CServiceHealthCommanding.cpp @@ -20,7 +20,7 @@ ReturnValue_t CServiceHealthCommanding::initialize() { } healthTable = ObjectManager::instance()->get(healthTableId); - if(healthTable == nullptr) { + if (healthTable == nullptr) { return returnvalue::FAILED; } From f735c2e9d4f9d0c2f9803332f4b63b7e435b01eb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 11:51:51 +0100 Subject: [PATCH 516/532] assert size larger than 0 --- src/fsfw/container/FixedArrayList.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/container/FixedArrayList.h b/src/fsfw/container/FixedArrayList.h index 97ade7e8..dde8eb16 100644 --- a/src/fsfw/container/FixedArrayList.h +++ b/src/fsfw/container/FixedArrayList.h @@ -12,6 +12,7 @@ template class FixedArrayList : public ArrayList { static_assert(MAX_SIZE <= std::numeric_limits::max(), "count_t is not large enough to hold MAX_SIZE"); + static_assert(MAX_SIZE > 0, "MAX_SIZE is 0"); private: T data[MAX_SIZE]; From 066dd0d397a4ff0d94f3d193e1ecb8e64f2e7541 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 11:52:20 +0100 Subject: [PATCH 517/532] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc07f78..3a1ce06e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +## Changed + +- Assert than `FixedArrayList` is larger than 0 at compile time. + # [v6.0.0] 2023-02-10 ## Fixes From b057250bfb3bb87943797c4b32eb17f22558907a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 11:53:12 +0100 Subject: [PATCH 518/532] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a1ce06e..c56885d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changed -- Assert than `FixedArrayList` is larger than 0 at compile time. +- Assert that `FixedArrayList` is larger than 0 at compile time. # [v6.0.0] 2023-02-10 From d98ed40e3d429c60f837e8d0763edb32b44c6f07 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 12:09:30 +0100 Subject: [PATCH 519/532] add CFDP subsystem ID --- src/fsfw/events/fwSubsystemIdRanges.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/events/fwSubsystemIdRanges.h b/src/fsfw/events/fwSubsystemIdRanges.h index d8e4ade6..574ea070 100644 --- a/src/fsfw/events/fwSubsystemIdRanges.h +++ b/src/fsfw/events/fwSubsystemIdRanges.h @@ -33,6 +33,7 @@ enum : uint8_t { PUS_SERVICE_23 = 103, MGM_LIS3MDL = 106, MGM_RM3100 = 107, + CFDP = 108, FW_SUBSYSTEM_ID_RANGE }; From 6fc8f756a733e7887f5a101cfce0fe30c35834ec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 12:13:55 +0100 Subject: [PATCH 520/532] update power switch IF --- src/fsfw/events/fwSubsystemIdRanges.h | 2 +- src/fsfw/power/PowerSwitchIF.h | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/fsfw/events/fwSubsystemIdRanges.h b/src/fsfw/events/fwSubsystemIdRanges.h index d8e4ade6..88958758 100644 --- a/src/fsfw/events/fwSubsystemIdRanges.h +++ b/src/fsfw/events/fwSubsystemIdRanges.h @@ -10,7 +10,7 @@ enum : uint8_t { CDH = 28, TCS_1 = 59, PCDU_1 = 42, - PCDU_2 = 43, + POWER_SWITCH_IF = 43, HEATER = 50, T_SENSORS = 52, FDIR = 70, diff --git a/src/fsfw/power/PowerSwitchIF.h b/src/fsfw/power/PowerSwitchIF.h index e8c9aff4..0b331e11 100644 --- a/src/fsfw/power/PowerSwitchIF.h +++ b/src/fsfw/power/PowerSwitchIF.h @@ -28,10 +28,12 @@ class PowerSwitchIF { static const ReturnValue_t SWITCH_TIMEOUT = MAKE_RETURN_CODE(2); static const ReturnValue_t FUSE_ON = MAKE_RETURN_CODE(3); static const ReturnValue_t FUSE_OFF = MAKE_RETURN_CODE(4); - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PCDU_2; - static const Event SWITCH_WENT_OFF = MAKE_EVENT( - 0, severity::LOW); //!< Someone detected that a switch went off which shouldn't. Severity: - //!< Low, Parameter1: switchId1, Parameter2: switchId2 + static const ReturnValue_t SWITCH_UNKNOWN = MAKE_RETURN_CODE(5); + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::POWER_SWITCH_IF; + //!< Someone detected that a switch went off which shouldn't. Severity: + //!< Low, Parameter1: switchId1, Parameter2: switchId2 + static const Event SWITCH_WENT_OFF = MAKE_EVENT(0, severity::LOW); /** * send a direct command to the Power Unit to enable/disable the specified switch. * @@ -50,6 +52,7 @@ class PowerSwitchIF { * @return * - @c SWITCH_ON if the specified switch is on. * - @c SWITCH_OFF if the specified switch is off. + * - @c SWITCH_UNKNOWN if the state of the specified switch is unknown. * - @c returnvalue::FAILED if an error occured */ virtual ReturnValue_t getSwitchState(power::Switch_t switchNr) const = 0; From 8f63a0e747e3ab44d5a43c1e4d690d516f0e75a7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 12:15:21 +0100 Subject: [PATCH 521/532] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc07f78..05a8743e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +## Changed + +- Renamed `PCDU_2` subsystem ID to `POWER_SWITCH_IF`. +- Add new `PowerSwitchIF::SWITCH_UNKNOWN` returnvalue. + # [v6.0.0] 2023-02-10 ## Fixes From aa84e93603f32ce5aaa7c308e80ae084c3d2d004 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 12:17:36 +0100 Subject: [PATCH 522/532] small tweak for version getter --- src/fsfw/version.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fsfw/version.cpp b/src/fsfw/version.cpp index 050187a9..27d44c03 100644 --- a/src/fsfw/version.cpp +++ b/src/fsfw/version.cpp @@ -1,6 +1,7 @@ #include "version.h" #include +#include #include "fsfw/FSFWVersion.h" @@ -20,7 +21,7 @@ fsfw::Version::Version(int major, int minor, int revision, const char* addInfo) void fsfw::Version::getVersion(char* str, size_t maxLen) const { size_t len = snprintf(str, maxLen, "%d.%d.%d", major, minor, revision); - if (addInfo != nullptr) { + if (addInfo != nullptr and std::strcmp(addInfo, "") != 0) { snprintf(str + len, maxLen - len, "-%s", addInfo); } } @@ -30,7 +31,7 @@ namespace fsfw { #if FSFW_CPP_OSTREAM_ENABLED == 1 std::ostream& operator<<(std::ostream& os, const Version& v) { os << v.major << "." << v.minor << "." << v.revision; - if (v.addInfo != nullptr) { + if (v.addInfo != nullptr and std::strcmp(v.addInfo, "") != 0) { os << "-" << v.addInfo; } return os; From 1f36c082ef83a6c8a30992d319221c5b3bb5c70e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 12:21:50 +0100 Subject: [PATCH 523/532] bugfix and changelog for Linux getUptime --- CHANGELOG.md | 4 ++++ src/fsfw/osal/linux/Clock.cpp | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc07f78..4a6f185b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +## Fixes + +- Linux OSAL `getUptime` fix: Check validity of `/proc/uptime` file before reading uptime. + # [v6.0.0] 2023-02-10 ## Fixes diff --git a/src/fsfw/osal/linux/Clock.cpp b/src/fsfw/osal/linux/Clock.cpp index bfdcf4e2..7dd960e5 100644 --- a/src/fsfw/osal/linux/Clock.cpp +++ b/src/fsfw/osal/linux/Clock.cpp @@ -76,14 +76,17 @@ timeval Clock::getUptime() { } ReturnValue_t Clock::getUptime(timeval* uptime) { - // TODO This is not posix compatible and delivers only seconds precision - // Linux specific file read but more precise. double uptimeSeconds; - if (std::ifstream("/proc/uptime", std::ios::in) >> uptimeSeconds) { + std::ifstream ifile("/proc/uptime"); + if (ifile.bad()) { + return returnvalue::FAILED; + } + if (ifile >> uptimeSeconds) { uptime->tv_sec = uptimeSeconds; uptime->tv_usec = uptimeSeconds * (double)1e6 - (uptime->tv_sec * 1e6); + return returnvalue::OK; } - return returnvalue::OK; + return returnvalue::FAILED; } // Wait for new FSFW Clock function delivering seconds uptime. From 5e3f5c4121317ab62a89a028301251ca59edbe33 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 12:25:39 +0100 Subject: [PATCH 524/532] fuse update --- src/fsfw/power/Fuse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/power/Fuse.h b/src/fsfw/power/Fuse.h index e8b86cfd..c1b35899 100644 --- a/src/fsfw/power/Fuse.h +++ b/src/fsfw/power/Fuse.h @@ -32,7 +32,7 @@ class Fuse : public SystemObject, gp_id_t poolIdPower; }; - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PCDU_1; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::POWER_SWITCH_IF; //! PSS detected that current on a fuse is totally out of bounds. static const Event FUSE_CURRENT_HIGH = MAKE_EVENT(1, severity::LOW); //! PSS detected a fuse that went off. From 47503824d7ca4cf656b9f603c8e10daac85b3393 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Mar 2023 12:27:39 +0100 Subject: [PATCH 525/532] health service fixes and changelog --- CHANGELOG.md | 5 +++++ src/fsfw/pus/CServiceHealthCommanding.cpp | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc07f78..f12aa90e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +## Fixes + +- PUS Health Service: Size check for set health command. +- PUS Health Service: Perform operation completion for announce health command. + # [v6.0.0] 2023-02-10 ## Fixes diff --git a/src/fsfw/pus/CServiceHealthCommanding.cpp b/src/fsfw/pus/CServiceHealthCommanding.cpp index 7faf8174..3ced4ffb 100644 --- a/src/fsfw/pus/CServiceHealthCommanding.cpp +++ b/src/fsfw/pus/CServiceHealthCommanding.cpp @@ -82,6 +82,9 @@ ReturnValue_t CServiceHealthCommanding::prepareCommand(CommandMessage *message, ReturnValue_t result = returnvalue::OK; switch (subservice) { case (Subservice::COMMAND_SET_HEALTH): { + if (tcDataLen != sizeof(object_id_t) + sizeof(HasHealthIF::HealthState)) { + return CommandingServiceBase::INVALID_TC; + } HealthSetCommand healthCommand; result = healthCommand.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); if (result != returnvalue::OK) { @@ -93,7 +96,7 @@ ReturnValue_t CServiceHealthCommanding::prepareCommand(CommandMessage *message, } case (Subservice::COMMAND_ANNOUNCE_HEALTH): { HealthMessage::setHealthMessage(message, HealthMessage::HEALTH_ANNOUNCE); - break; + return CommandingServiceBase::EXECUTION_COMPLETE; } case (Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): { ReturnValue_t result = iterateHealthTable(true); From 52c32464160cf5e1bfde526c2fa78dde3c16dce9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 4 May 2023 14:01:18 +0200 Subject: [PATCH 526/532] update ETL version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5eddde7f..5d35e6ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,7 @@ set(FSFW_ETL_LIB_MAJOR_VERSION 20 CACHE STRING "ETL library major version requirement") set(FSFW_ETL_LIB_VERSION - ${FSFW_ETL_LIB_MAJOR_VERSION}.28.0 + ${FSFW_ETL_LIB_MAJOR_VERSION}.35.14 CACHE STRING "ETL library exact version requirement") set(FSFW_ETL_LINK_TARGET etl::etl) From 025b379e8bc053c7daa9267e3fa77c33749ef3c9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 4 May 2023 14:04:55 +0200 Subject: [PATCH 527/532] bump ETL version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5eddde7f..5d35e6ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,7 @@ set(FSFW_ETL_LIB_MAJOR_VERSION 20 CACHE STRING "ETL library major version requirement") set(FSFW_ETL_LIB_VERSION - ${FSFW_ETL_LIB_MAJOR_VERSION}.28.0 + ${FSFW_ETL_LIB_MAJOR_VERSION}.35.14 CACHE STRING "ETL library exact version requirement") set(FSFW_ETL_LINK_TARGET etl::etl) From 4518fec65ce92c0cc0f569036da8cbcf1b1a3d1e Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Mon, 8 May 2023 15:25:47 +0200 Subject: [PATCH 528/532] CHANGELOG --- CHANGELOG.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01420436..693e59e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,15 +10,28 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes -- Linux OSAL `getUptime` fix: Check validity of `/proc/uptime` file before reading uptime. - PUS Health Service: Size check for set health command. -- PUS Health Service: Perform operation completion for announce health command. + Perform operation completion for announce health command. + https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/746 +- Linux OSAL `getUptime` fix: Check validity of `/proc/uptime` file before reading uptime. + https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/745 +- Small tweak for version getter + https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/744 + +## Added + +- add CFDP subsystem ID + https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/742 ## Changed - +- Bump ETL version to 20.35.14 + https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/748 - Renamed `PCDU_2` subsystem ID to `POWER_SWITCH_IF`. + https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/743 - Add new `PowerSwitchIF::SWITCH_UNKNOWN` returnvalue. + https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/743 - Assert that `FixedArrayList` is larger than 0 at compile time. + https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/740 # [v6.0.0] 2023-02-10 From 82eaf4412f8eecb2a02bc07d95cf84af840754bb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 May 2023 15:43:31 +0200 Subject: [PATCH 529/532] get rid of obsolete serializer --- .../tmtcpacket/pus/tc/TcPacketSerializer.cpp | 42 ------------------ .../tmtcpacket/pus/tc/TcPacketSerializer.h | 43 ------------------- 2 files changed, 85 deletions(-) delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.cpp delete mode 100644 src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.h diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.cpp deleted file mode 100644 index cc280d2b..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "TcPacketSerializer.h" - -#include - -TcPacketSerializer::TcPacketSerializer(uint8_t* store, size_t maxSize, PusConfig& cfg) - : TcPacketPus(nullptr), store(store), maxSize(maxSize), cfg(cfg) {} - -ReturnValue_t TcPacketSerializer::serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const { - if (*size + getSerializedSize() > maxSize) { - return BUFFER_TOO_SHORT; - } - std::memcpy(*buffer, store, getSerializedSize()); - *buffer += getSerializedSize(); - *size += getSerializedSize(); - return RETURN_OK; -} - -size_t TcPacketSerializer::getSerializedSize() const { return TC_PACKET_MIN_SIZE + cfg.appDataLen; } - -ReturnValue_t TcPacketSerializer::initialize() { - if (getSerializedSize() > maxSize) { - return SerializeIF::BUFFER_TOO_SHORT; - } - ReturnValue_t result = setData(store, maxSize); - if (result != RETURN_OK) { - return result; - } - initializeTcPacket(cfg.apid, cfg.sequenceCount, cfg.ack, cfg.service, cfg.subservice, - PusConfig::PUS_VERSION, cfg.sourceId); - if (cfg.appData != nullptr and cfg.appDataLen > 0) { - std::memcpy(&tcData->appData, cfg.appData, cfg.appDataLen); - } - setPacketDataLength(calculateFullPacketLength(cfg.appDataLen) - sizeof(CCSDSPrimaryHeader) - 1); - setErrorControl(); - return RETURN_OK; -} - -ReturnValue_t TcPacketSerializer::deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) { - return RETURN_FAILED; -} diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.h deleted file mode 100644 index 9abb37b1..00000000 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketSerializer.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef FSFW_SRC_FSFW_TMTCPACKET_PUS_TC_TCPACKETPUSINTOBUF_H_ -#define FSFW_SRC_FSFW_TMTCPACKET_PUS_TC_TCPACKETPUSINTOBUF_H_ - -#include - -#include "TcPacketPus.h" -#include "fsfw/serialize/SerializeIF.h" - -struct PusConfig { - uint16_t apid = 0; - uint8_t service = 0; - uint8_t subservice = 0; - uint16_t sequenceCount = 0; - uint16_t sourceId = 0; - uint8_t* appData = nullptr; - size_t appDataLen = 0; -#if FSFW_USE_PUS_C_TELECOMMANDS == 1 - static constexpr pus::PusVersion PUS_VERSION = pus::PusVersion::PUS_C_VERSION; -#else - static constexpr pus::PusVersion PUS_VERSION = pus::PusVersion::PUS_A_VERSION; -#endif - uint8_t ack = TcPacketPus::ACK_ALL; -}; - -class TcPacketSerializer : public TcPacketPus, public SerializeIF, public HasReturnvaluesIF { - public: - TcPacketSerializer(uint8_t* store, size_t maxSize, PusConfig& cfg); - - ReturnValue_t initialize(); - - ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const override; - size_t getSerializedSize() const override; - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) override; - - private: - uint8_t* store; - size_t maxSize; - PusConfig& cfg; -}; - -#endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TC_TCPACKETPUSINTOBUF_H_ */ From 0b39ab383fa21acffc1a9fd6fd43b84595ae1e60 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 25 May 2023 13:22:38 +0200 Subject: [PATCH 530/532] comment --- src/fsfw/tmtcservices/CommandingServiceBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 1ec5c0d8..728c8d77 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -223,7 +223,7 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, Comma // In case a new command is to be sent immediately, this is performed here. // If no new command is sent, only analyse reply result by initializing - // sendResult as RETURN_OK + // sendResult as returnvalue::OK ReturnValue_t sendResult = returnvalue::OK; if (nextCommand->getCommand() != CommandMessage::CMD_NONE) { sendResult = commandQueue->sendMessage(reply->getSender(), nextCommand); From f42a16748d502fda0ff4c40b29224ed5d6f977dd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 25 May 2023 15:06:04 +0200 Subject: [PATCH 531/532] fix shadowing issue --- src/fsfw/tmtcservices/TmTcBridge.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index ba851a85..25b183f2 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -145,7 +145,7 @@ ReturnValue_t TmTcBridge::handleTmQueue() { #endif /* FSFW_VERBOSE_LEVEL >= 3 */ if (communicationLinkUp == false or packetSentCounter >= sentPacketsPerCycle) { - ReturnValue_t result = storeDownlinkData(&message); + result = storeDownlinkData(&message); if (result != returnvalue::OK) { tmStore->deleteData(message.getStorageId()); } From cb6eed134bc5088cad4d010ca8a415655632af65 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 26 May 2023 17:03:27 +0200 Subject: [PATCH 532/532] add printf support --- src/fsfw/objectmanager/ObjectManager.cpp | 6 +++++- src/fsfw/tcdistribution/CcsdsDistributor.cpp | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/fsfw/objectmanager/ObjectManager.cpp b/src/fsfw/objectmanager/ObjectManager.cpp index 29c1b2fc..5d345a3c 100644 --- a/src/fsfw/objectmanager/ObjectManager.cpp +++ b/src/fsfw/objectmanager/ObjectManager.cpp @@ -109,13 +109,15 @@ void ObjectManager::initialize() { for (auto const& it : objectList) { result = it.second->initialize(); if (result != returnvalue::OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 object_id_t var = it.first; +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::initialize: Object 0x" << std::hex << std::setw(8) << std::setfill('0') << var << " failed to " "initialize with code 0x" << result << std::dec << std::setfill(' ') << std::endl; +#else + sif::printError("ObjectManager::initialize: Object 0x%08x failed to initialize with code 0x%04x\n", var, result); #endif errorCount++; } @@ -124,6 +126,8 @@ void ObjectManager::initialize() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::ObjectManager: Counted " << errorCount << " failed initializations." << std::endl; +#else + sif::printError("ObjectManager: Counted %d\n", errorCount); #endif } // Init was successful. Now check successful interconnections. diff --git a/src/fsfw/tcdistribution/CcsdsDistributor.cpp b/src/fsfw/tcdistribution/CcsdsDistributor.cpp index 4668a3bc..9c674674 100644 --- a/src/fsfw/tcdistribution/CcsdsDistributor.cpp +++ b/src/fsfw/tcdistribution/CcsdsDistributor.cpp @@ -6,7 +6,7 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" -#define CCSDS_DISTRIBUTOR_DEBUGGING 0 +#define CCSDS_DISTRIBUTOR_DEBUGGING 1 CcsdsDistributor::CcsdsDistributor(uint16_t setDefaultApid, object_id_t setObjectId, StorageManagerIF* tcStore, MessageQueueIF* queue, @@ -68,9 +68,13 @@ ReturnValue_t CcsdsDistributor::selectDestination(MessageQueueId_t& destId) { handlePacketCheckFailure(result); return result; } -#if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1 +#if CCSDS_DISTRIBUTOR_DEBUGGING == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "CCSDSDistributor::selectDestination has packet with APID 0x" << std::hex << currentPacket.getApid() << std::dec << std::endl; +#else + sif::printDebug("CCSDS Distributor: Packet with APID 0x%04x detected\n", currentPacket.getApid()); +#endif #endif auto iter = receiverMap.find(currentPacket.getApid()); if (iter != receiverMap.end()) {